Skip to content

Commit 6a1f0ed

Browse files
domfarolinomoz-wptsync-bot
authored andcommitted
Bug 1888988 [wpt PR 45457] - Fix <meta> post-insertion steps expectations, a=testonly
Automatic update from web-platform-tests Fix `<meta>` post-insertion steps expectations See whatwg/html#10241 for the recommendation to change these test expectations to align with Chromium and WebKit's behavior. FWIW, I did try and change the processing of these kinds of meta tags in Chromium to use the insertion steps [1], and without any extra work at least, this caused a bunch of crashes [2]. So this change (changing the test expectations) is easier, and aligns with more browsers. [1]: https://crrev.com/c/5399060 [2]: https://crbug.com/330694762 [email protected] Bug: 40150299, 330694762 Change-Id: I60f8ba556984bc1e8df4ba6e1dc375b1dfb7823d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5410497 Reviewed-by: Noam Rosenthal <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1281241} -- wpt-commits: 38c6d6793e349f48b44950428bccd0f96d113b4e wpt-pr: 45457
1 parent 3747c6a commit 6a1f0ed

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

testing/web-platform/tests/dom/nodes/insertion-removing-steps/Node-appendChild-script-and-default-style-meta-from-fragment.tentative.html

+35-11
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,53 @@
77
<div id="div">hello</div>
88
<script>
99
let scriptRan = false;
10-
let computedStyleDuringInsertion = null;
10+
let computedStyleInPreScript = null;
11+
let computedStyleInPostScript = null;
1112
test(() => {
1213
const div = document.getElementById("div");
14+
15+
// 1. Gets inserted *before* the `<meta>` tag. Cannot observe the meta tag's
16+
// effect, because this script runs before the meta tag's post-insertion steps
17+
// run, and the meta tag's post-insertion steps is where the default style
18+
// sheet actually changes.
19+
const preScript = document.createElement("script");
20+
preScript.textContent = `
21+
computedStyleInPreScript = getComputedStyle(div).display;
22+
scriptRan = true;
23+
`;
24+
25+
// 2. The `<meta>` tag itself.
1326
const meta = document.createElement("meta");
1427
meta.httpEquiv = "default-style";
1528
meta.content = "alternative";
16-
const script = document.createElement("script");
17-
script.textContent = `
18-
computedStyleDuringInsertion = getComputedStyle(div).display;
29+
30+
// 3. Gets inserted *after* the `<meta>` tag. Observes the meta tag's effect,
31+
// because this script runs after the meta tag's post-insertion steps, which
32+
// has the script-observable change to the default style sheet.
33+
const postScript = document.createElement("script");
34+
postScript.textContent = `
35+
computedStyleInPostScript = getComputedStyle(div).display;
1936
scriptRan = true;
2037
`;
38+
2139
const df = document.createDocumentFragment();
22-
df.appendChild(script);
23-
df.appendChild(meta);
24-
assert_equals(getComputedStyle(div).display, "block", "div has block display");
40+
df.append(preScript, meta, postScript);
41+
42+
assert_equals(getComputedStyle(div).display, "block",
43+
"div still has block display before meta insertion");
2544
assert_false(scriptRan, "script has not run before insertion");
45+
2646
document.head.appendChild(df);
2747
assert_true(scriptRan, "script has run after insertion");
28-
assert_equals(computedStyleDuringInsertion, "none",
29-
"display: none; style was applied during DOM insertion, before " +
30-
"later-inserted script runs");
48+
assert_equals(computedStyleInPreScript, "block",
49+
"display: none; style was NOT applied during DOM insertion steps, " +
50+
"before earlier-inserted script post-insertion steps run");
51+
assert_equals(computedStyleInPostScript, "none",
52+
"display: none; style WAS applied during DOM post-insertion steps, " +
53+
"before later-inserted script runs");
3154
assert_equals(getComputedStyle(div).display, "none",
3255
"style remains display: none; after insertion");
56+
3357
}, "Inserting <meta> that uses alternate stylesheets, applies the style " +
34-
"during DOM insertion, and before script runs as a result of any atomic insertions");
58+
"during DOM post-insertion steps");
3559
</script>

0 commit comments

Comments
 (0)