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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test toggling transform mode of the shapes highlighter
const TEST_URI = `
<style type='text/css'>
#shape {
width: 800px;
height: 800px;
clip-path: circle(25%);
}
</style>
<div id="shape"></div>
`;
const HIGHLIGHTER_TYPE = "ShapesHighlighter";
add_task(async function () {
await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
const { inspector, view } = await openRuleView();
const highlighters = view.highlighters;
info("Select a node with a shape value");
await selectNode("#shape", inspector);
const container = getRuleViewProperty(view, "#shape", "clip-path").valueSpan;
const shapesToggle = container.querySelector(".ruleview-shapeswatch");
info("Toggling ON the CSS shapes highlighter with transform mode on.");
let onHighlighterShown = highlighters.once("shapes-highlighter-shown");
EventUtils.sendMouseEvent(
{ type: "click", metaKey: true, ctrlKey: true },
shapesToggle,
view.styleWindow
);
await onHighlighterShown;
info(
"Checking the CSS shapes highlighter is created and transform mode is on"
);
ok(
inspector.inspectorFront.getKnownHighlighter(HIGHLIGHTER_TYPE).actorID,
"CSS shapes highlighter created in the rule-view."
);
ok(highlighters.shapesHighlighterShown, "CSS shapes highlighter is shown.");
ok(highlighters.state.shapes.options.transformMode, "Transform mode is on.");
info("Toggling OFF the CSS shapes highlighter from the rule-view.");
const onHighlighterHidden = highlighters.once("shapes-highlighter-hidden");
EventUtils.sendMouseEvent({ type: "click" }, shapesToggle, view.styleWindow);
await onHighlighterHidden;
info("Checking the CSS shapes highlighter is not shown.");
ok(
!highlighters.shapesHighlighterShown,
"No CSS shapes highlighter is shown."
);
info("Toggling ON the CSS shapes highlighter with transform mode off.");
onHighlighterShown = highlighters.once("shapes-highlighter-shown");
EventUtils.sendMouseEvent({ type: "click" }, shapesToggle, view.styleWindow);
await onHighlighterShown;
info(
"Checking the CSS shapes highlighter is created and transform mode is off"
);
ok(
inspector.inspectorFront.getKnownHighlighter(HIGHLIGHTER_TYPE).actorID,
"CSS shapes highlighter created in the rule-view."
);
ok(highlighters.shapesHighlighterShown, "CSS shapes highlighter is shown.");
ok(
!highlighters.state.shapes.options.transformMode,
"Transform mode is off."
);
info(
"Clicking shapes toggle to turn on transform mode while highlighter is shown."
);
onHighlighterShown = highlighters.once("shapes-highlighter-shown");
EventUtils.sendMouseEvent(
{ type: "click", metaKey: true, ctrlKey: true },
shapesToggle,
view.styleWindow
);
await onHighlighterShown;
info(
"Checking the CSS shapes highlighter is created and transform mode is on"
);
ok(
inspector.inspectorFront.getKnownHighlighter(HIGHLIGHTER_TYPE).actorID,
"CSS shapes highlighter created in the rule-view."
);
ok(highlighters.shapesHighlighterShown, "CSS shapes highlighter is shown.");
ok(highlighters.state.shapes.options.transformMode, "Transform mode is on.");
});
|