tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Node-append-meta-referrer-and-script-from-fragment.tentative.html (1767B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Node.appendChild: inserting script and meta-referrer from a div</title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <script>
      7 promise_test(async t => {
      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");
     41 </script>