tor-browser

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

mutation-observer.html (1518B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>document.write in mutation observer</title>
      4 <link rel=help href="https://html.spec.whatwg.org/#parsing-main-incdata">
      5 <link rel=help href="https://html.spec.whatwg.org/#perform-a-microtask-checkpoint">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <div id="log"></div>
      9 <script>
     10 [
     11  {name: "classic", src: "resources/mutation-observer-iframe-script.html"},
     12  {name: "module", src: "resources/mutation-observer-iframe-script-module.html"},
     13  {name: "async", src: "resources/mutation-observer-iframe-script-async.html"},
     14  {name: "defer", src: "resources/mutation-observer-iframe-script-defer.html"},
     15 ].forEach(({name, src}) => {
     16  promise_test(async t => {
     17    const iframe = document.createElement("iframe");
     18 
     19    iframe.onerror = t.unreached_func("Error loading iframe");
     20    document.addEventListener("scriptRan", t.unreached_func("script should not run"));
     21    document.addEventListener("documentWriteDone", t.step_func(() => {
     22      assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
     23    }));
     24 
     25    let loadPromise = new Promise(resolve => {
     26      iframe.onload = t.step_func(() => {
     27        assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
     28        resolve();
     29      });
     30    });
     31 
     32    iframe.src = src;
     33    document.body.appendChild(iframe);
     34 
     35    await loadPromise;
     36  }, `Mutation observer for ${name} script element`);
     37 });
     38 </script>