tor-browser

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

test_performance_paint_timing_helper.html (1914B)


      1 <!--
      2  Any copyright is dedicated to the Public Domain.
      3  http://creativecommons.org/publicdomain/zero/1.0/
      4 -->
      5 <!DOCTYPE HTML>
      6 <html>
      7    <!--
      8      https://bugzilla.mozilla.org/show_bug.cgi?id=1518999
      9    -->
     10    <head>
     11        <title>Test for Bug 1518999</title>
     12        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
     13    </head>
     14    <body>
     15        <div id="main"></div>
     16        <div id="image"></div>
     17        <div id="test">
     18            <script class="testbody" type="text/javascript">
     19             async function runTest() {
     20                const paintEntries = performance.getEntriesByType('paint');
     21                opener.is(paintEntries.length, 0, "No paint entries yet");
     22 
     23                const img = document.createElement("img");
     24                img.src = "http://example.org/tests/dom/performance/tests/logo.png";
     25 
     26                const observer = new PerformanceObserver((entryList) => {
     27                  const entries = entryList.getEntries();
     28                  opener.is(entries.length, 1, "FCP Only returns");
     29                  opener.is(entries[0].entryType, "paint", "entryType is paint");
     30                  opener.is(entries[0].name, "first-contentful-paint",
     31                            "Returned entry should be first-contentful-paint" );
     32                  const fcpEntriesGotByName =
     33                      performance.getEntriesByName('first-contentful-paint');
     34                  opener.is(fcpEntriesGotByName.length, 1, "entries length should match");
     35                  opener.is(entries[0], fcpEntriesGotByName[0], "should be the same entry");
     36                  opener.done();
     37                });
     38 
     39                observer.observe({type: 'paint'});
     40                document.body.appendChild(img);
     41             }
     42             window.onload = function() {
     43                runTest();
     44             }
     45            </script>
     46        </div>
     47        </div>
     48    </body>
     49 </html>