Best JavaScript code snippet using wpt
fenced-frame-bypass.tentative.https.window.js
Source:fenced-frame-bypass.tentative.https.window.js
1// META: script=/common/get-host-info.sub.js2// META: script=/common/utils.js3// META: script=/common/dispatcher/dispatcher.js4// META: script=/html/cross-origin-embedder-policy/credentialless/resources/common.js5// META: script=./resources/common.js6// META: timeout=long7setup(() => {8 assert_implements(window.HTMLFencedFrameElement,9 "HTMLFencedFrameElement is not supported.");10})11// 4 actors:12// A (this document)13// âââââââââââââââââââââââ´âââ14// âââ¼ââââââââââââââââââââ D (anonymous-iframe)15// â B (fenced-frame) â16// â â â17// â C (anonymous-iframe)â18// âââââââââââââââââââââââ19//20// This test whether the two anonymous iframe can communicate and bypass the21// fencedframe boundary. This shouldn't happen.22promise_test(async test => {23 const cross_origin = get_host_info().HTTPS_REMOTE_ORIGIN;24 const msg_queue = token();25 // Create the the 3 actors.26 const anonymous_iframe_1 = newAnonymousIframe(cross_origin);27 const fenced_frame = newFencedFrame(cross_origin);28 send(fenced_frame, `29 const importScript = ${importScript};30 await importScript("/common/utils.js");31 await importScript("/html/cross-origin-embedder-policy/credentialless" +32 "/resources/common.js");33 await importScript("/html/anonymous-iframe/resources/common.js");34 const support_loading_mode_fenced_frame =35 "|header(Supports-Loading-Mode,fenced-frame)";36 const anonymous_iframe_2 =37 newAnonymousIframe("${cross_origin}", support_loading_mode_fenced_frame);38 send("${msg_queue}", anonymous_iframe_2);39 `);40 const anonymous_iframe_2 = await receive(msg_queue);41 // Try to communicate using BroadCastChannel, in between the two42 // AnonymousIframe.43 const bc_key = token();44 send(anonymous_iframe_1, `45 const bc = new BroadcastChannel("${bc_key}");46 bc.onmessage = event => send("${msg_queue}", event.data);47 send("${msg_queue}", "BroadcastChannel registered");48 `);49 assert_equals(await receive(msg_queue), "BroadcastChannel registered");50 await send(anonymous_iframe_2, `51 const bc = new BroadcastChannel("${bc_key}");52 bc.postMessage("Can communicate");53 `);54 test.step_timeout(() => {55 send(msg_queue, "Cannot communicate");56 }, 4000);57 assert_equals(await receive(msg_queue), "Cannot communicate");...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!