3 <title>LongTask Timing: long task in another window
</title>
6 <script src=
"/resources/testharness.js"></script>
7 <script src=
"/resources/testharnessreport.js"></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. */
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') {
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.
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');
46 }, 'A longtask in a frame from window.open is not reported in original frame');