tor-browser

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

basetest.html (1629B)


      1 <!DOCTYPE html>
      2 <head>
      3 <title>Performance Paint Timing Test</title>
      4 </head>
      5 <body>
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <div id="main"></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    t.step(function() {
     15        const bufferedEntries = performance.getEntriesByType('paint');
     16        assert_equals(bufferedEntries.length, 0, "No paint entries yet");
     17    });
     18    const div = document.createElement("div");
     19    div.style.width = "100px";
     20    div.style.height = "100px";
     21    div.style.backgroundColor = "red";
     22    div.style.color = "blue";
     23    div.innerHTML = "test"
     24    document.getElementById("main").appendChild(div);
     25    function testPaintEntries() {
     26        const bufferedEntries = performance.getEntriesByType('paint');
     27        if (bufferedEntries.length < 2) {
     28            t.step_timeout(function() {
     29                testPaintEntries();
     30            }, 20);
     31            return;
     32        }
     33        t.step(function() {
     34            assert_equals(bufferedEntries.length, 2, "FP and FCP.");
     35            assert_equals(bufferedEntries[0].entryType, "paint");
     36            assert_equals(bufferedEntries[0].name, "first-paint");
     37            assert_equals(bufferedEntries[1].entryType, "paint");
     38            assert_equals(bufferedEntries[1].name, "first-contentful-paint");
     39            t.done();
     40        });
     41    }
     42    t.step(function() {
     43        testPaintEntries();
     44    });
     45 }, "Basic test to check existence of FP and FCP.");
     46 </script>
     47 </body>
     48 </html>