loaf-script-window-attribution.html (2295B)
1 <!DOCTYPE HTML> 2 <meta charset=utf-8> 3 <title>Long Animation Frame Timing: window attribution</title> 4 <meta name="timeout" content="long"> 5 <body> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/common/get-host-info.sub.js"></script> 9 <script src="/common/utils.js"></script> 10 <script src="/common/dispatcher/dispatcher.js"></script> 11 <script src="resources/utils.js"></script> 12 <div id="log"></div> 13 <script> 14 15 const host_info = get_host_info(); 16 const {ORIGIN, REMOTE_ORIGIN, HTTP_NOTSAMESITE_ORIGIN} = host_info; 17 18 promise_test (async t => { 19 const [entry, script] = await expect_long_frame_with_script((t, busy_wait) => { 20 requestAnimationFrame(() => busy_wait()); 21 }, () => true, t); 22 assert_equals(script.windowAttribution, "self"); 23 assert_equals(script.window, window); 24 }, 'Scripts in this window should be self-attributed'); 25 26 promise_test (async t => { 27 let found = false; 28 for (let i = 0; i < 10 && !found; ++i) { 29 const [executor, iframe] = await prepare_exec_iframe(t, ORIGIN); 30 const [entry, script] = await expect_long_frame_with_script(() => 31 executor.execute_script(async (duration) => { 32 await new Promise(resolve => window.requestAnimationFrame(resolve)); 33 parent.generate_loaf_now(); 34 }, [very_long_frame_duration]), () => true, t); 35 36 if (script.windowAttribution === "descendant" && script.window === iframe.contentWindow) { 37 found = true; 38 } 39 } 40 41 assert_true(found); 42 }, 'Scripts in subframes should be descendant-attributed'); 43 44 promise_test(async t => { 45 const iframe = document.createElement("iframe"); 46 iframe.src = "/resource-timing/resources/green.html"; 47 document.body.append(iframe); 48 t.add_cleanup(() => iframe.remove()); 49 const [entry, script] = await expect_long_frame_with_script( 50 (t, busy_wait) => requestAnimationFrame(busy_wait), () => true, t); 51 const in_iframe = iframe.contentWindow.performance.getEntriesByType("long-animation-frame").some( 52 e => e.scripts.some(script_in_iframe => script_in_iframe.invoker === script.invoker) 53 ); 54 55 assert_false(in_iframe, "IFrame should not receive the LoAF entry"); 56 }, 'A long busy wait in a requestAnimationFrame should not be observable by same-origin iframes'); 57 58 </script> 59 </body>