|
5 | 5 | <script src=/resources/testharnessreport.js></script>
|
6 | 6 | <script>
|
7 | 7 | 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"); |
29 | 41 | </script>
|
0 commit comments