tor-browser

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

Node-appendChild-text-and-script-in-style.tentative.html (974B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Node.appendChild: inserting text and script nodes in a style element</title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <style id="style"></style>
      7 <body>
      8 <script>
      9 const happened = []
     10 const style = document.getElementById("style");
     11 test(() => {
     12  const r1 = new Text("body {}");
     13  const r2 = new Text("body {}");
     14  const script = document.createElement("script");
     15  script.textContent = `
     16    happened.push(style.sheet.cssRules.length);
     17  `;
     18 
     19  const df = document.createDocumentFragment();
     20  df.appendChild(r1);
     21  df.appendChild(script);
     22  df.appendChild(r2);
     23 
     24  assert_array_equals(happened, []);
     25  style.appendChild(df);
     26  assert_array_equals(happened, [2]);
     27 }, "All style rules appended to a <style> element are inserted and " +
     28   "script-observable to scripts inserted in the `<style>` element, by the " +
     29   "time scripts execute after DOM insertions.");
     30 </script>