Skip to content

Commit

Permalink
Fix <meta> referrer post-insertion steps expectations
Browse files Browse the repository at this point in the history
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
  • Loading branch information
domfarolino authored and chromium-wpt-export-bot committed Apr 8, 2024
1 parent 9600b67 commit f503087
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 f503087

Please sign in to comment.