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
124
125
126
127
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const {
COMPATIBILITY_ISSUE_TYPE,
} = require("resource://devtools/shared/constants.js");
const {
COMPATIBILITY_UPDATE_NODE_COMPLETE,
} = require("resource://devtools/client/inspector/compatibility/actions/index.js");
// Test the behavior rules are dynamically added
const ISSUE_OUTLINE_RADIUS = {
type: COMPATIBILITY_ISSUE_TYPE.CSS_PROPERTY,
property: "-moz-user-input",
url: "https://developer.mozilla.org/docs/Web/CSS/-moz-user-input",
deprecated: true,
experimental: false,
};
const ISSUE_HYPHENS = {
type: COMPATIBILITY_ISSUE_TYPE.CSS_PROPERTY_ALIASES,
aliases: ["hyphens"],
property: "hyphens",
url: "https://developer.mozilla.org/docs/Web/CSS/hyphens",
deprecated: false,
experimental: false,
};
const TEST_URI = `
<style>
.issue {
-moz-user-input: none;
}
</style>
<body>
<div class="test"></div>
</body>
`;
add_task(async function () {
info("Testing dynamic style change using JavaScript");
const tab = await addTab(
"data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)
);
const { allElementsPane, inspector, selectedElementPane } =
await openCompatibilityView();
info("Testing inline style change due to JavaScript execution");
const onPanelUpdate = waitForUpdateSelectedNodeAction(inspector.store);
info("Select the div to undergo mutation");
await selectNode(".test", inspector);
await onPanelUpdate;
info("Check initial issues");
await assertIssueList(selectedElementPane, []);
await assertIssueList(allElementsPane, []);
info("Adding inline style with compatibility issue");
await testAttributeMutation(
tab,
inspector,
selectedElementPane,
allElementsPane,
[ISSUE_HYPHENS],
[ISSUE_HYPHENS],
async function () {
content.document.querySelector(".test").style.hyphens = "none";
}
);
info("Adding a class with declarations having compatibility issue");
await testAttributeMutation(
tab,
inspector,
selectedElementPane,
allElementsPane,
[ISSUE_HYPHENS, ISSUE_OUTLINE_RADIUS],
[ISSUE_HYPHENS, ISSUE_OUTLINE_RADIUS],
async function () {
content.document.querySelector(".test").classList.add("issue");
}
);
info("Removing a class with declarations having compatibility issue");
await testAttributeMutation(
tab,
inspector,
selectedElementPane,
allElementsPane,
[ISSUE_HYPHENS],
[ISSUE_HYPHENS],
async function () {
content.document.querySelector(".test").classList.remove("issue");
}
);
await removeTab(tab);
});
async function testAttributeMutation(
tab,
inspector,
selectedElementPane,
allElementsPane,
expectedSelectedElementIssues,
expectedAllElementsIssues,
contentTaskFunction
) {
const onPanelUpdate = Promise.all([
inspector.once("markupmutation"),
waitForDispatch(inspector.store, COMPATIBILITY_UPDATE_NODE_COMPLETE),
]);
info("Run the task in webpage context");
await ContentTask.spawn(tab.linkedBrowser, {}, contentTaskFunction);
info("Wait for changes to reflect");
await onPanelUpdate;
info("Check issues listed in selected element pane");
await assertIssueList(selectedElementPane, expectedSelectedElementIssues);
info("Check issues listed in all issues pane");
await assertIssueList(allElementsPane, expectedAllElementsIssues);
}
|