tor-browser

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

loaf-toJSON.html (1431B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 </head>
      7 <body>
      8 <script>
      9  promise_test(async t => {
     10    window.onload = () => {
     11        // Trigger a long task.
     12        const begin = window.performance.now();
     13        while (window.performance.now() < begin + 60);
     14    };
     15 
     16    assert_implements(window.PerformanceLongAnimationFrameTiming, 'Lon are not supported.');
     17    const entry = await new Promise(resolve => new PerformanceObserver(
     18      t.step_func(entryList => {
     19        const entries = entryList.getEntries();
     20        assert_greater_than_equal(entries.length, 1);
     21        resolve(entries[0]);
     22      })).observe({entryTypes: ["long-animation-frame"]}));
     23 
     24    assert_equals(typeof(entry.toJSON), 'function');
     25    const entryJSON = entry.toJSON();
     26    assert_equals(typeof(entryJSON), 'object');
     27    // Check attributes inheritted from PerformanceEntry.
     28    const performanceEntryKeys = [
     29        'name',
     30        'entryType',
     31        'startTime',
     32        'duration',
     33        'renderStart',
     34        'styleAndLayoutStart',
     35        'blockingTime',
     36        'firstUIEventTimestamp'
     37    ];
     38    for (const key of performanceEntryKeys) {
     39        assert_equals(entryJSON[key], entry[key],
     40            `entry.toJSON().${key} should match entry.${key}`);
     41    }
     42 
     43  }, 'Test toJSON() in PerformanceLongAnimationFrameTiming');
     44 </script>
     45 </body>
     46 </html>