summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/shared/test/browser_styleinspector_transform-highlighter-02.js
blob: f1ddc68892137adccdaa452c8c872e28915aed01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test that the css transform highlighter is created when hovering over a
// transform property

const TEST_URI = `
  <style type="text/css">
    body {
      transform: skew(16deg);
      color: yellow;
    }
  </style>
  Test the css transform highlighter
`;

var TYPE = "CssTransformHighlighter";

add_task(async function () {
  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
  const { inspector, view } = await openRuleView();
  let hs = view.highlighters;

  ok(!hs.highlighters[TYPE], "No highlighter exists in the rule-view (1)");

  info("Faking a mousemove on a non-transform property");
  let { valueSpan } = getRuleViewProperty(view, "body", "color");
  hs.onMouseMove({ target: valueSpan });
  ok(!hs.highlighters[TYPE], "No highlighter exists in the rule-view (2)");

  info("Faking a mousemove on a transform property");
  ({ valueSpan } = getRuleViewProperty(view, "body", "transform"));
  let onHighlighterShown = hs.once("css-transform-highlighter-shown");
  hs.onMouseMove({ target: valueSpan });
  await onHighlighterShown;

  const onComputedViewReady = inspector.once("computed-view-refreshed");
  const cView = selectComputedView(inspector);
  await onComputedViewReady;
  hs = cView.highlighters;

  info("Remove the created transform highlighter");
  hs.highlighters[TYPE].finalize();
  hs.highlighters[TYPE] = null;

  info("Faking a mousemove on a non-transform property");
  ({ valueSpan } = getComputedViewProperty(cView, "color"));
  hs.onMouseMove({ target: valueSpan });
  ok(!hs.highlighters[TYPE], "No highlighter exists in the computed-view (3)");

  info("Faking a mousemove on a transform property");
  ({ valueSpan } = getComputedViewProperty(cView, "transform"));
  onHighlighterShown = hs.once("css-transform-highlighter-shown");
  hs.onMouseMove({ target: valueSpan });
  await onHighlighterShown;

  ok(
    hs.highlighters[TYPE],
    "The highlighter has been created in the computed-view"
  );
});