tor-browser

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

Node-appendChild-script-with-mutation-observer-takeRecords.html (849B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Node.appendChild: inserted script should be able to take own mutation record</title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <body>
      7 <main></main>
      8 <script>
      9 
     10 test(() => {
     11  window.mutationObserver = new MutationObserver(() => {});
     12  window.mutationObserver.observe(document.querySelector("main"), {childList: true});
     13  const script = document.createElement("script");
     14  script.textContent = `
     15    window.mutationRecords = window.mutationObserver.takeRecords();
     16  `;
     17  document.querySelector("main").appendChild(script);
     18  assert_equals(window.mutationRecords.length, 1);
     19  assert_array_equals(window.mutationRecords[0].addedNodes, [script]);
     20 }, "An inserted script should be able to observe its own mutation record with takeRecords");
     21 </script>