tor-browser

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

sibling-painting-first-image.html (2280B)


      1 <!DOCTYPE html>
      2 <body>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <!-- This iframe will have a sibling that paints, we want to ensure it does not detect that paint. -->
      6 <iframe id="listening-iframe" src="../resources/subframe-sending-paint.html"></iframe>
      7 <script>
      8 setup({"hide_test_state": true});
      9 var entriesExpectToReceive = [
     10    {
     11        'entryType': 'paint',
     12        'name': 'first-paint'
     13    },
     14    {
     15        'entryType': 'paint',
     16        'name': 'first-contentful-paint'
     17    }
     18 ];
     19 async_test(function (t) {
     20    assert_implements(window.PerformancePaintTiming, "Paint Timing isn't supported.");
     21    let paintingIframeHasDispatchedEntries = false;
     22    window.addEventListener('message', t.step_func(e => {
     23        if (!paintingIframeHasDispatchedEntries) {
     24            // Check paint-timing entries from the painting iframe.
     25            for (let i = 0; i < entriesExpectToReceive.length; i++) {
     26                if (entriesExpectToReceive[i].entryType == e.data.entryType &&
     27                    entriesExpectToReceive[i].name == e.data.name) {
     28                    entriesExpectToReceive.splice(i, 1);
     29                    break;
     30                }
     31            }
     32            if (entriesExpectToReceive.length == 0) {
     33                paintingIframeHasDispatchedEntries = true;
     34                // Ask the listening iframe to send its paint-timing entries.
     35                document.getElementById('listening-iframe').
     36                    contentWindow.postMessage('', '*');
     37            }
     38            return;
     39        }
     40        // Check the paint-timing entries from the listening iframe.
     41        assert_equals(e.data, '0');
     42        // Check that current frame receives first-paint but not first-contentful-paint.
     43        const bufferedEntries = performance.getEntriesByType('paint');
     44        assert_equals(bufferedEntries.length, 1);
     45        assert_equals(bufferedEntries[0].entryType, 'paint');
     46        assert_equals(bufferedEntries[0].name, 'first-paint');
     47        t.done();
     48    }));
     49 }, 'Frame ignores paint-timing events fired from sibling frame.');
     50 </script>
     51 <!-- This iframe is where all of the painting occurs. -->
     52 <iframe id="painting-iframe" src="../resources/subframe-painting.html"></iframe>
     53 </body>
     54 </html>