summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/shared/test/browser_styleinspector_transform-highlighter-04.js
blob: cc5bbd270d286fdc4bd47316ef54ad00ac9f921f (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
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test that the css transform highlighter is shown only when hovering over a
// transform declaration that isn't overriden or disabled

// Note that unlike the other browser_styleinspector_transform-highlighter-N.js
// tests, this one only tests the rule-view as only this view features disabled
// and overriden properties

const TEST_URI = `
  <style type="text/css">
    div {
      background: purple;
      width:300px;height:300px;
      transform: rotate(16deg);
    }
    .test {
      transform: skew(25deg);
    }
  </style>
  <div class="test"></div>
`;

const TYPE = "CssTransformHighlighter";

add_task(function* () {
  yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
  let {inspector, view} = yield openRuleView();
  yield selectNode(".test", inspector);

  let hs = view.highlighters;

  info("Faking a mousemove on the overriden property");
  let {valueSpan} = getRuleViewProperty(view, "div", "transform");
  hs._onMouseMove({target: valueSpan});
  ok(!hs.highlighters[TYPE],
    "No highlighter was created for the overriden property");

  info("Disabling the applied property");
  let classRuleEditor = getRuleViewRuleEditor(view, 1);
  let propEditor = classRuleEditor.rule.textProps[0].editor;
  propEditor.enable.click();
  yield classRuleEditor.rule._applyingModifications;

  info("Faking a mousemove on the disabled property");
  ({valueSpan} = getRuleViewProperty(view, ".test", "transform"));
  hs._onMouseMove({target: valueSpan});
  ok(!hs.highlighters[TYPE],
    "No highlighter was created for the disabled property");

  info("Faking a mousemove on the now unoverriden property");
  ({valueSpan} = getRuleViewProperty(view, "div", "transform"));
  let onHighlighterShown = hs.once("highlighter-shown");
  hs._onMouseMove({target: valueSpan});
  yield onHighlighterShown;
});