test-partitioned-access-in-same-origin-iframes.https.sub.html (3062B)
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="write-frame-window"></iframe> 13 <iframe id="write-frame-worker"></iframe> 14 <iframe id="read-frame-window"></iframe> 15 <iframe id="read-frame-worker"></iframe> 16 <script> 17 const messageHub = createMotherListener(); 18 19 async function runTests() { 20 const params = new URL(window.location.href).searchParams; 21 const api = params.get("api"); 22 assert_true(!!api); 23 console.log("Tested API " + api); 24 25 const testIdWindow = "SameOriginIFramesWith" + api; 26 const testIdWorker = "Worker" + testIdWindow; 27 28 const writeWindows = new Map(); 29 30 const writeFrameWindow = document.getElementById("write-frame-window"); 31 writeWindows.set(testIdWindow, writeFrameWindow.contentWindow); 32 33 const writeFrameWorker = document.getElementById("write-frame-worker"); 34 writeWindows.set(testIdWorker, writeFrameWorker.contentWindow); 35 36 const readWindows = new Map(); 37 38 messageHub.registerReadWindow(testIdWindow); 39 const readFrameWindow = document.getElementById("read-frame-window"); 40 readFrameWindow.src = 41 "https://{{hosts[alt][www2]}}:{{ports[https][0]}}/_mozilla/dom/quota/support/test-read-and-notify.https.html?id=" + 42 testIdWindow; 43 readWindows.set(testIdWindow, readFrameWindow.contentWindow); 44 45 messageHub.registerReadWindow(testIdWorker); 46 const readFrameWorker = document.getElementById("read-frame-worker"); 47 readFrameWorker.src = 48 "https://{{hosts[alt][www2]}}:{{ports[https][0]}}/_mozilla/dom/quota/support/test-read-and-notify-worker.https.html?id=" + 49 testIdWorker; 50 readWindows.set(testIdWorker, readFrameWorker.contentWindow); 51 52 const setup = { readWindows, writeWindows }; 53 54 await messageHub.getReadWindow(testIdWindow); 55 async_test(t => { 56 messageHub.registerWindow(t, testIdWindow, api, "allow", setup); 57 58 writeFrameWindow.src = 59 "https://{{hosts[alt][www2]}}:{{ports[https][0]}}/_mozilla/dom/quota/support/test-write-and-notify.https.html?id=" + 60 testIdWindow; 61 }, "Access allowed for two iframes with the same origin " + api); 62 63 await messageHub.getReadWindow(testIdWorker); 64 async_test(t => { 65 messageHub.registerWorker(t, testIdWorker, api, "allow", setup); 66 67 writeFrameWorker.src = 68 "https://{{hosts[alt][www2]}}:{{ports[https][0]}}/_mozilla/dom/quota/support/test-write-and-notify.https.html?id=" + 69 testIdWorker; 70 }, "Worker access allowed from two iframes with the same origin " + api); 71 } 72 </script> 73 </head> 74 <body onload="runTests();"></body> 75 </html>