summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/insertion-removing-steps/Node-append-meta-referrer-and-script-from-fragment.tentative.html
blob: e80e3b45b61d993f6ae1a5e7e916c2decb663a59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and meta-referrer from a div</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
promise_test(async t => {
  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>