tor-browser

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

current-request-microtask-002.html (1089B)


      1 <!doctype html>
      2 <title>Current request microtask handling with multiple tasks.</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <body>
      6 <script>
      7 async_test(function(t) {
      8  let img;
      9  function testSrcOnMicrotask(expectedCurrentSrc, done) {
     10    window.queueMicrotask(t.step_func(() => {
     11      assert_equals(img.currentSrc, expectedCurrentSrc, `currentSrc should be ${expectedCurrentSrc}`);
     12      if (done) {
     13        t.done();
     14      }
     15    }));
     16  }
     17  testSrcOnMicrotask("");
     18  img = new Image();
     19  let png = "/images/green.png?" + Math.random();
     20  let resolved_png = new URL(png, document.documentURI).href;
     21  testSrcOnMicrotask("");
     22  // Both .src and .srcset assignments are relevant mutations. So the first task should be "canceled" (return early).
     23  // appendChild is not a relevant mutation unless in a <picture> element.
     24  img.src = png;
     25  testSrcOnMicrotask("");
     26  img.srcset = png;
     27  testSrcOnMicrotask(resolved_png);
     28  document.body.appendChild(img);
     29  testSrcOnMicrotask(resolved_png, /* done = */ true);
     30 });
     31 </script>