file_xorigin_frames.html (730B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Page that embeds two cross-origin frames</title> 4 <body> 5 <script> 6 async function addFrame(id, filename) { 7 let url = new URL(filename, document.URL); 8 url.hostname = url.hostname === "example.com" ? "example.org" : "example.com"; 9 10 let f = document.createElement("iframe"); 11 f.id = id; 12 f.src = url.href; 13 await new Promise(resolve => { 14 f.onload = resolve; 15 document.body.append(f); 16 }); 17 } 18 19 if (window === top) { 20 window.loadedPromise = Promise.all([ 21 addFrame("frame1", "?this_is_child_frame_1"), 22 addFrame("frame2", "?this_is_child_frame_2"), 23 ]).then(() => "frames_all_loaded"); 24 } else { 25 document.body.append("This is child frame: " + location); 26 } 27 </script>