Skip to content

Commit

Permalink
Bug 1890362 [wpt PR 45611] - Fix <meta> referrer post-insertion ste…
Browse files Browse the repository at this point in the history
…ps expectations, a=testonly

Automatic update from web-platform-tests
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}

--

wpt-commits: 499f941b0fa6ed59e4a29c98a603813c358f17a9
wpt-pr: 45611
  • Loading branch information
domfarolino authored and moz-wptsync-bot committed Apr 15, 2024
1 parent 61a0b92 commit 6d8a589
Showing 1 changed file with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,37 @@
<script src=/resources/testharnessreport.js></script>
<script>
promise_test(async t => {
const script = document.createElement("script");
const meta = document.createElement("meta");
meta.name = "referrer";
meta.content = "no-referrer";
const fragment = new DocumentFragment();
const done = new Promise(resolve => {
window.didFetch = resolve;
});
script.textContent = `
(async function() {
const response = await fetch("/html/infrastructure/urls/terminology-0/resources/echo-referrer-text.py")
const text = await response.text();
window.didFetch(text);
})();
`;
fragment.append(script, meta);
document.head.append(fragment);
const result = await done;
assert_equals(result, "");
}, "<meta name=referrer> should apply before script, as it is an insertion step " +
"and not a post-insertion step");
const preMetaScript = document.createElement("script");
preMetaScript.textContent = `
window.preMetaScriptPromise = fetch('/html/infrastructure/urls/terminology-0/resources/echo-referrer-text.py')
.then(response => response.text());
`;

const meta = document.createElement("meta");
meta.name = "referrer";
meta.content = "no-referrer";

const postMetaScript = document.createElement("script");
postMetaScript.textContent = `
window.postMetaScriptPromise = fetch('/html/infrastructure/urls/terminology-0/resources/echo-referrer-text.py')
.then(response => response.text());
`;

const fragment = new DocumentFragment();
fragment.append(preMetaScript, meta, postMetaScript);
document.head.append(fragment);

const preMetaReferrer = await window.preMetaScriptPromise;
assert_equals(preMetaReferrer, location.href,
"preMetaReferrer is the full URL; by the time the first script runs in " +
"its post-insertion steps, the later-inserted meta tag has not run its " +
"post-insertion steps, which is where meta tags are processed");

const postMetaReferrer = await window.postMetaScriptPromise;
assert_equals(postMetaReferrer, "",
"postMetaReferrer is empty; by the time the second script runs in " +
"its post-insertion steps, the later-inserted meta tag has run its " +
"post-insertion steps, and observes the meta tag's effect");
}, "<meta name=referrer> gets processed and applied in the post-insertion " +
"steps");
</script>

0 comments on commit 6d8a589

Please sign in to comment.