Skip to content

Commit 499f941

Browse files
Fix <meta> referrer post-insertion steps expectations
See whatwg/html#10241 for the recommendation to change these test expectations to align with Chromium and WebKit's behavior. [email protected] Bug: 40150299 Change-Id: I3cabc92c16a4cfadc6675bd156aca04c2ade64aa Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5420410 Commit-Queue: Dominic Farolino <[email protected]> Reviewed-by: Noam Rosenthal <[email protected]> Cr-Commit-Position: refs/heads/main@{#1284444}
1 parent d7b9fab commit 499f941

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

dom/nodes/insertion-removing-steps/Node-append-meta-referrer-and-script-from-fragment.tentative.html

+33-21
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,37 @@
55
<script src=/resources/testharnessreport.js></script>
66
<script>
77
promise_test(async t => {
8-
const script = document.createElement("script");
9-
const meta = document.createElement("meta");
10-
meta.name = "referrer";
11-
meta.content = "no-referrer";
12-
const fragment = new DocumentFragment();
13-
const done = new Promise(resolve => {
14-
window.didFetch = resolve;
15-
});
16-
script.textContent = `
17-
(async function() {
18-
const response = await fetch("/html/infrastructure/urls/terminology-0/resources/echo-referrer-text.py")
19-
const text = await response.text();
20-
window.didFetch(text);
21-
})();
22-
`;
23-
fragment.append(script, meta);
24-
document.head.append(fragment);
25-
const result = await done;
26-
assert_equals(result, "");
27-
}, "<meta name=referrer> should apply before script, as it is an insertion step " +
28-
"and not a post-insertion step");
8+
const preMetaScript = document.createElement("script");
9+
preMetaScript.textContent = `
10+
window.preMetaScriptPromise = fetch('/html/infrastructure/urls/terminology-0/resources/echo-referrer-text.py')
11+
.then(response => response.text());
12+
`;
13+
14+
const meta = document.createElement("meta");
15+
meta.name = "referrer";
16+
meta.content = "no-referrer";
17+
18+
const postMetaScript = document.createElement("script");
19+
postMetaScript.textContent = `
20+
window.postMetaScriptPromise = fetch('/html/infrastructure/urls/terminology-0/resources/echo-referrer-text.py')
21+
.then(response => response.text());
22+
`;
23+
24+
const fragment = new DocumentFragment();
25+
fragment.append(preMetaScript, meta, postMetaScript);
26+
document.head.append(fragment);
27+
28+
const preMetaReferrer = await window.preMetaScriptPromise;
29+
assert_equals(preMetaReferrer, location.href,
30+
"preMetaReferrer is the full URL; by the time the first script runs in " +
31+
"its post-insertion steps, the later-inserted meta tag has not run its " +
32+
"post-insertion steps, which is where meta tags are processed");
33+
34+
const postMetaReferrer = await window.postMetaScriptPromise;
35+
assert_equals(postMetaReferrer, "",
36+
"postMetaReferrer is empty; by the time the second script runs in " +
37+
"its post-insertion steps, the later-inserted meta tag has run its " +
38+
"post-insertion steps, and observes the meta tag's effect");
39+
}, "<meta name=referrer> gets processed and applied in the post-insertion " +
40+
"steps");
2941
</script>

0 commit comments

Comments
 (0)