Skip to content

Commit fc085a1

Browse files
annevkmoz-wptsync-bot
authored andcommitted
Bug 1537760 [wpt PR 15871] - HTML: mutating the style element, a=testonly
Automatic update from web-platform-tests HTML: mutating the style element For whatwg/dom#800. -- wpt-commits: 7b63b60158ca7d636aafc099079b2b1b77cdc76a wpt-pr: 15871
1 parent a5d5a23 commit fc085a1

File tree

1 file changed

+39
-0
lines changed
  • testing/web-platform/tests/html/semantics/document-metadata/the-style-element

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
test(t => {
2+
const style = document.body.appendChild(document.createElement("style"));
3+
const sheet = style.sheet;
4+
t.add_cleanup(() => style.remove());
5+
assert_not_equals(sheet, null);
6+
style.appendChild(new Comment());
7+
assert_not_equals(sheet, style.sheet);
8+
}, "Mutating the style element: inserting a Comment node");
9+
10+
test(t => {
11+
const style = document.body.appendChild(document.createElement("style"));
12+
t.add_cleanup(() => style.remove());
13+
const comment = style.appendChild(new Comment());
14+
const sheet = style.sheet;
15+
comment.appendData("x");
16+
assert_not_equals(sheet, style.sheet);
17+
}, "Mutating the style element: mutating a Comment node");
18+
19+
test(t => {
20+
const style = document.body.appendChild(document.createElement("style"));
21+
t.add_cleanup(() => style.remove());
22+
const text1 = style.appendChild(new Text("1"));
23+
const text2 = style.appendChild(new Text("2"));
24+
assert_equals(style.textContent, "12");
25+
assert_equals(style.childNodes.length, 2);
26+
const sheet = style.sheet;
27+
style.normalize();
28+
assert_equals(style.childNodes.length, 1);
29+
assert_not_equals(sheet, style.sheet);
30+
}, "Mutating the style element: using normalize()");
31+
32+
test(t => {
33+
const style = document.body.appendChild(document.createElement("style"));
34+
t.add_cleanup(() => style.remove());
35+
const comment = style.appendChild(new Comment());
36+
const sheet = style.sheet;
37+
comment.remove();
38+
assert_not_equals(sheet, style.sheet);
39+
}, "Mutating the style element: removing a Comment node");

0 commit comments

Comments
 (0)