tor-browser

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

disconnect-image.html (1703B)


      1 <!DOCTYPE HTML>
      2 <meta charset=utf-8>
      3 <title>Element Timing: element attribute returns null when element is disconnected</title>
      4 <body>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="resources/element-timing-helpers.js"></script>
      8 <script>
      9  let beforeRender;
     10  let img;
     11  async_test(function (t) {
     12    assert_implements(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
     13    const observer = new PerformanceObserver(
     14      t.step_func_done(function(entryList) {
     15        assert_equals(entryList.getEntries().length, 1);
     16        const entry = entryList.getEntries()[0];
     17        const pathname = window.location.origin + '/element-timing/resources/square100.png';
     18        // This method will check that entry.element is |img|.
     19        checkElement(entry, pathname, 'my_image', 'my_id', beforeRender, img);
     20 
     21        img.parentNode.removeChild(img);
     22        // After removing image, entry.element should return null.
     23        assert_equals(entry.element, null);
     24      })
     25    );
     26    observer.observe({entryTypes: ['element']});
     27    // We add the image during onload to be sure that the observer is registered
     28    // in time for it to observe the element timing.
     29    window.onload = () => {
     30      // Add image of width equal to 100 and height equal to 100.
     31      img = document.createElement('img');
     32      img.src = 'resources/square100.png';
     33      img.setAttribute('elementtiming', 'my_image');
     34      img.setAttribute('id', 'my_id');
     35      document.body.appendChild(img);
     36      beforeRender = performance.now();
     37    };
     38  }, 'Disconnected elements have null as their |element| attribute.');
     39 </script>
     40 
     41 </body>