tor-browser

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

containertiming-observe-after-paint-with-buffering.html (1607B)


      1 <!DOCTYPE HTML>
      2 <meta charset=utf-8>
      3 <title>Container Timing: starting observation after image paint, with buffering, reports paint.</title>
      4 <body>
      5 <style>
      6 body {
      7  margin: 0;
      8 }
      9 </style>
     10 <script src="/resources/testharness.js"></script>
     11 <script src="/resources/testharnessreport.js"></script>
     12 <script src="/container-timing/resources/container-timing-helpers.js"></script>
     13 <script src="/element-timing/resources/element-timing-helpers.js"></script>
     14 <script>
     15  let beforeRender;
     16  async_test(function (t) {
     17    assert_implements(window.PerformanceContainerTiming, "PerformanceContainerTiming is not implemented");
     18    onElementTimingEvent(() => {
     19      const observer = new PerformanceObserver(
     20        t.step_func_done((entryList) => {
     21          assert_equals(entryList.getEntries().length, 1);
     22          const entry = entryList.getEntries()[0];
     23          checkContainerEntry(entry, 'image_ct', 'my_id', beforeRender);
     24          checkRect(entry, [0, 100, 0, 100])
     25          checkContainerSize(entry, 10000);
     26        })
     27      );
     28      observer.observe({type: 'container', buffered: true });
     29    });
     30 
     31    // Add image of width equal to 100 and height equal to 100.
     32    const img = document.createElement('img');
     33    img.src = '/container-timing/resources/square100.png';
     34    img.setAttribute('containertiming', 'image_ct');
     35    img.setAttribute('id', 'my_id');
     36    document.body.appendChild(img);
     37 
     38    beforeRender = performance.now();
     39 
     40    addPaintingElementTimingAfterDoubleRAF(document.body);
     41  }, 'Paint is reported when observation starts after image paint if buffering is enabled.');
     42 </script>
     43 
     44 </body>