tor-browser

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

Node-appendChild-script-and-source-from-fragment.tentative.html (1275B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Node.appendChild: inserting script and source from a fragment</title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <video id="media"></video>
      7 <script>
      8 const happened = [];
      9 const media = document.getElementById("media");
     10 test(() => {
     11  const source = document.createElement("source");
     12  const script = document.createElement("script");
     13  script.textContent = `
     14    happened.push(media.networkState);
     15  `;
     16 
     17  const df = document.createDocumentFragment();
     18  df.appendChild(script);
     19  df.appendChild(source);
     20 
     21  assert_array_equals(happened, []);
     22  media.appendChild(df);
     23  // This is because immediately during DOM insertion, before the
     24  // post-insertion steps invoke script, `<source>` insertion invokes the
     25  // resource selection algorithm [1] which does this assignment. This
     26  // assignment takes place before earlier-inserted script elements run
     27  // post-insertion.
     28  //
     29  // [1]: https://html.spec.whatwg.org/#concept-media-load-algorithm
     30  assert_array_equals(happened, [HTMLMediaElement.NETWORK_NO_SOURCE]);
     31 }, "Empty <source> immediately sets media.networkState during DOM insertion, " +
     32   "so that an earlier-running script can observe networkState");
     33 </script>