Bug 1611320 [wpt PR 21400] - Gate Longtasks and PaintTiming tests under assert_precon...
[gecko.git] / testing / web-platform / tests / longtask-timing / shared-renderer / longtask-in-new-window.html
blob18d36b1e734bc0ef21af575892690211c420bd5b
1 <!DOCTYPE HTML>
2 <meta charset=utf-8>
3 <title>LongTask Timing: long task in another window</title>
4 <body>
6 <script src="/resources/testharness.js"></script>
7 <script src="/resources/testharnessreport.js"></script>
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_precondition(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;
28 // If a longtask is observed, it must come from this window.
29 assert_equals(entry.name, 'self');
31 // If we found the mark, then the other window longtask is done.
32 if (markFound)
33 t.done();
36 observer.observe({entryTypes: ['mark', 'longtask']});
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 }));
46 }, 'A longtask in a frame from window.open is not reported in original frame');
47 </script>
48 </body>