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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that keyframe rules and gutters are displayed correctly in the
// rule view.
const TEST_URI = URL_ROOT + "doc_keyframeanimation.html";
add_task(async function () {
await addTab(TEST_URI);
const { inspector, view } = await openRuleView();
await testPacman(inspector, view);
await testBoxy(inspector, view);
await testMoxy(inspector, view);
});
async function testPacman(inspector, view) {
info("Test content and gutter in the keyframes rule of #pacman");
await assertKeyframeRules("#pacman", inspector, view, {
elementRulesNb: 2,
keyframeRulesNb: 2,
keyframesRules: ["pacman", "pacman"],
keyframeRules: ["100%", "100%"],
});
assertGutters(view, {
guttersNbs: 2,
gutterHeading: ["Keyframes pacman", "Keyframes pacman"],
});
}
async function testBoxy(inspector, view) {
info("Test content and gutter in the keyframes rule of #boxy");
await assertKeyframeRules("#boxy", inspector, view, {
elementRulesNb: 3,
keyframeRulesNb: 3,
keyframesRules: ["boxy", "boxy", "boxy"],
keyframeRules: ["10%", "20%", "100%"],
});
assertGutters(view, {
guttersNbs: 1,
gutterHeading: ["Keyframes boxy"],
});
}
async function testMoxy(inspector, view) {
info("Test content and gutter in the keyframes rule of #moxy");
await assertKeyframeRules("#moxy", inspector, view, {
elementRulesNb: 3,
keyframeRulesNb: 4,
keyframesRules: ["boxy", "boxy", "boxy", "moxy"],
keyframeRules: ["10%", "20%", "100%", "100%"],
});
assertGutters(view, {
guttersNbs: 2,
gutterHeading: ["Keyframes boxy", "Keyframes moxy"],
});
}
async function assertKeyframeRules(selector, inspector, view, expected) {
await selectNode(selector, inspector);
const elementStyle = view._elementStyle;
const rules = {
elementRules: elementStyle.rules.filter(rule => !rule.keyframes),
keyframeRules: elementStyle.rules.filter(rule => rule.keyframes),
};
is(
rules.elementRules.length,
expected.elementRulesNb,
selector + " has the correct number of non keyframe element rules"
);
is(
rules.keyframeRules.length,
expected.keyframeRulesNb,
selector + " has the correct number of keyframe rules"
);
let i = 0;
for (const keyframeRule of rules.keyframeRules) {
Assert.equal(
keyframeRule.keyframes.name,
expected.keyframesRules[i],
keyframeRule.keyframes.name + " has the correct keyframes name"
);
Assert.equal(
keyframeRule.domRule.keyText,
expected.keyframeRules[i],
keyframeRule.domRule.keyText + " selector heading is correct"
);
i++;
}
}
function assertGutters(view, expected) {
const gutters = view.element.querySelectorAll(".ruleview-header");
is(
gutters.length,
expected.guttersNbs,
"There are " + gutters.length + " gutter headings"
);
let i = 0;
for (const gutter of gutters) {
is(
gutter.textContent,
expected.gutterHeading[i],
"Correct " + gutter.textContent + " gutter headings"
);
i++;
}
return gutters;
}
|