test-partitioned-parent-reader-and-different-origin-window-writer-iframe.https.sub.html (2931B)
1 <!-- 2 Any copyright is dedicated to the Public Domain. 3 http://creativecommons.org/publicdomain/zero/1.0/ 4 --> 5 <html> 6 <head> 7 <meta charset="utf-8" /> 8 <meta name="timeout" content="long" /> 9 <script src="/resources/testharness.js"></script> 10 <script src="/resources/testharnessreport.js"></script> 11 <script src="testHelpers.js"></script> 12 <iframe id="read-frame-window"></iframe> 13 <iframe id="read-frame-worker"></iframe> 14 <script> 15 const messageHub = createMotherListener(); 16 17 async function runTests() { 18 const params = new URL(window.location.href).searchParams; 19 const api = params.get("api"); 20 assert_true(!!api); 21 console.log("Tested API " + api); 22 23 const testIdWindow = "ReadIFrameWriteDifferentOriginWindowWith" + api; 24 const testIdWorker = "Worker" + testIdWindow; 25 26 const writeWindows = new Map(); 27 28 const readWindows = new Map(); 29 30 messageHub.registerReadWindow(testIdWindow); 31 const readFrameWindow = document.getElementById("read-frame-window"); 32 readFrameWindow.src = 33 "https://{{hosts[][www2]}}:{{ports[https][0]}}/_mozilla/dom/quota/support/test-read-and-notify.https.html?id=" + 34 testIdWindow; 35 readWindows.set(testIdWindow, readFrameWindow.contentWindow); 36 37 messageHub.registerReadWindow(testIdWorker); 38 const readFrameWorker = document.getElementById("read-frame-worker"); 39 readFrameWorker.src = 40 "https://{{hosts[][www2]}}:{{ports[https][0]}}/_mozilla/dom/quota/support/test-read-and-notify.https.html?id=" + 41 testIdWorker; 42 readWindows.set(testIdWorker, readFrameWorker.contentWindow); 43 44 const setup = { readWindows, writeWindows }; 45 46 await messageHub.getReadWindow(testIdWindow); 47 async_test(t => { 48 messageHub.registerWindow(t, testIdWindow, api, "deny", setup); 49 50 writeWindows.set( 51 testIdWindow, 52 window.open( 53 "https://{{hosts[alt][www1]}}:{{ports[https][0]}}/_mozilla/dom/quota/support/test-write-and-notify-wrapper.https.sub.html?id=" + 54 testIdWindow 55 ) 56 ); 57 }, "Read for iframe not allowed when write was done by an iframe in a window of different origin " + api); 58 59 await messageHub.getReadWindow(testIdWorker); 60 async_test(t => { 61 messageHub.registerWorker(t, testIdWorker, api, "deny", setup); 62 63 writeWindows.set( 64 testIdWorker, 65 window.open( 66 "https://{{hosts[alt][www1]}}:{{ports[https][0]}}/_mozilla/dom/quota/support/test-write-and-notify-wrapper.https.sub.html?id=" + 67 testIdWorker 68 ) 69 ); 70 }, "Read by worker in iframe not allowed when write was done by an iframe in a window of different origin " + api); 71 } 72 </script> 73 </head> 74 <body onload="runTests();"></body> 75 </html>