fence-urn-iframes.https.html (1771B)
1 <!DOCTYPE html> 2 <title>Test window.fence availability in iframes.</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/utils.js"></script> 6 <script src="/common/dispatcher/dispatcher.js"></script> 7 <script src="resources/utils.js"></script> 8 9 <body> 10 <script> 11 12 promise_test(async(t) => { 13 const frame = await attachIFrameContext(); 14 await frame.execute(() => { 15 assert_equals(window.fence, null); 16 }); 17 }, 'window.fence is unavailable in normal (non-urn) iframes'); 18 19 promise_test(async(t) => { 20 // window.fence works in urn iframes. 21 var frame = await attachIFrameContext({generator_api: 'fledge'}); 22 await frame.execute(() => { 23 assert_not_equals(window.fence, null); 24 }); 25 // window.fence works after navigating to a new urn. 26 frame = await replaceFrameContext(frame, {generator_api: 'fledge'}); 27 await frame.execute(() => { 28 assert_not_equals(window.fence, null); 29 }); 30 // window.fence still works after embedder-initiated navigations to non-urns, 31 // because the concept of "embedder-initiated" navigations is nebulous in 32 // iframes. 33 frame = await replaceFrameContext(frame); 34 await frame.execute(() => { 35 assert_not_equals(window.fence, null); 36 }); 37 }, 'window.fence is available in urn iframes'); 38 39 promise_test(async(t) => { 40 // window.fence works in urn iframes. 41 const frame = await attachIFrameContext({generator_api: 'fledge'}); 42 await frame.execute(async () => { 43 assert_not_equals(window.fence, null); 44 const nested_frame = await attachIFrameContext(); 45 await nested_frame.execute(() => { 46 assert_not_equals(window.fence, null); 47 }); 48 }); 49 }, 'window.fence is available in same-origin subframes of urn iframes'); 50 51 </script> 52 </body>