tor-browser

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

first-contentful-svg.html (1484B)


      1 <!DOCTYPE html>
      2 <head>
      3 <title>Performance Paint Timing Test: FCP due to SVG</title>
      4 </head>
      5 <body>
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <div id="svg"></div>
      9 
     10 <script>
     11 setup({"hide_test_state": true});
     12 async_test(function (t) {
     13    assert_implements(window.PerformancePaintTiming, "Paint Timing isn't supported.");
     14    const img = document.createElement("IMG");
     15    img.src = "../resources/circle.svg";
     16    img.onload = function() {
     17        function testPaintEntries() {
     18            const bufferedEntries = performance.getEntriesByType('paint');
     19            if (bufferedEntries.length < 2) {
     20              t.step_timeout(function() {
     21                testPaintEntries();
     22              }, 20);
     23              return;
     24            }
     25            t.step(function() {
     26                assert_equals(bufferedEntries.length, 2, "There should be two paint timing instances.");
     27                assert_equals(bufferedEntries[0].entryType, "paint");
     28                assert_equals(bufferedEntries[0].name, "first-paint");
     29                assert_equals(bufferedEntries[1].entryType, "paint");
     30                assert_equals(bufferedEntries[1].name, "first-contentful-paint");
     31                t.done();
     32            });
     33        }
     34        t.step(function() {
     35            testPaintEntries();
     36        });
     37    };
     38    document.getElementById('svg').appendChild(img);
     39 }, "First contentful paint fires due to svg.");
     40 </script>
     41 </body>
     42 </html>