tor-browser

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

longtask-in-new-window.html (1903B)


      1 <!DOCTYPE HTML>
      2 <meta charset=utf-8>
      3 <title>LongTask Timing: long task in another window</title>
      4 <body>
      5 
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 
      9 <script>
     10 /* This test should pass even when windows share a single renderer process.
     11  This window opens a new window which contains a longtask. We test that the
     12  longtask from the new window is not observed by the observer of this window. */
     13 async_test(t => {
     14  assert_implements(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
     15  const observer = new PerformanceObserver(
     16      t.step_func(function (entryList) {
     17          const entries = entryList.getEntries();
     18          let markFound = false;
     19          for (let i = 0; i < entries.length; ++i) {
     20            const entry = entries[i];
     21            // We do not expect to observe longtasks but the work being made in this window may produce a longtask.
     22            assert_true(entry.entryType === 'longtask' ||
     23              entry.entryType === 'mark');
     24            if (entry.entryType === 'mark') {
     25              markFound = true;
     26              continue;
     27            }
     28            // If a longtask is observed, it must come from this window.
     29            assert_equals(entry.name, 'self');
     30          }
     31          // If we found the mark, then the other window longtask is done.
     32          if (markFound)
     33            t.done();
     34      })
     35  );
     36  observer.observe({entryTypes: ['mark', 'longtask']});
     37 
     38  window.onload = () => {
     39    // Open a window with a longtask.
     40    const other_window = window.open('resources/frame-with-longtask.html');
     41    window.addEventListener('message', t.step_func(e => {
     42      // Do a mark (after the other window's longtask) to fire the callback.
     43      self.performance.mark('mark1');
     44    }));
     45  };
     46 }, 'A longtask in a frame from window.open is not reported in original frame');
     47 </script>
     48 </body>