|
| 1 | +<!DOCTYPE html> |
| 2 | +<meta charset="utf-8"> |
| 3 | +<title>Parent is isolated, subdomain child 1 is not isolated, different-subdomain child 2 is not isolated</title> |
| 4 | +<script src="/resources/testharness.js"></script> |
| 5 | +<script src="/resources/testharnessreport.js"></script> |
| 6 | + |
| 7 | +<div id="log"></div> |
| 8 | + |
| 9 | +<script type="module"> |
| 10 | +import { insertIframe, sendWasmModule, setBothDocumentDomains, |
| 11 | + sendWasmModuleBetween, accessDocumentBetween } from "./resources/helpers.mjs"; |
| 12 | + |
| 13 | +let frameWindow1, frameWindow2; |
| 14 | +promise_setup(async () => { |
| 15 | + // Order of loading should not matter, but we make it sequential to ensure the |
| 16 | + // tests are deterministic. |
| 17 | + frameWindow1 = await insertIframe("{{hosts[][www]}}"); |
| 18 | + frameWindow2 = await insertIframe("{{hosts[][www1]}}"); |
| 19 | + |
| 20 | + await setBothDocumentDomains(frameWindow1); |
| 21 | + await setBothDocumentDomains(frameWindow2); |
| 22 | +}); |
| 23 | + |
| 24 | + |
| 25 | +// Since everybody is different-origin, everyone's requests/non-requests get |
| 26 | +// respected. |
| 27 | +// |
| 28 | +// So, the parent ends up in its origin-keyed agent cluster, and child 1 and |
| 29 | +// child 2 both end up in the site-keyed agent cluster. |
| 30 | + |
| 31 | +promise_test(async () => { |
| 32 | + const whatHappened = await sendWasmModule(frameWindow1); |
| 33 | + |
| 34 | + assert_equals(whatHappened, "messageerror"); |
| 35 | +}, "Parent to child1: messageerror event must occur"); |
| 36 | + |
| 37 | +promise_test(async () => { |
| 38 | + assert_throws_dom("SecurityError", DOMException, () => { |
| 39 | + frameWindow1.document; |
| 40 | + }); |
| 41 | +}, "Parent to child1: setting document.domain must not give sync access"); |
| 42 | + |
| 43 | +promise_test(async () => { |
| 44 | + const whatHappened = await sendWasmModule(frameWindow2); |
| 45 | + |
| 46 | + assert_equals(whatHappened, "messageerror"); |
| 47 | +}, "Parent to child2: messageerror event must occur"); |
| 48 | + |
| 49 | +promise_test(async () => { |
| 50 | + assert_throws_dom("SecurityError", DOMException, () => { |
| 51 | + frameWindow2.document; |
| 52 | + }); |
| 53 | +}, "Parent to child2: setting document.domain must not give sync access"); |
| 54 | + |
| 55 | +promise_test(async () => { |
| 56 | + const whatHappened = await sendWasmModuleBetween(frameWindow1, 1); |
| 57 | + |
| 58 | + assert_equals(whatHappened, "WebAssembly.Module message received"); |
| 59 | +}, "child1 to child2: message event must occur"); |
| 60 | + |
| 61 | +promise_test(async () => { |
| 62 | + const whatHappened = await accessDocumentBetween(frameWindow1, 1); |
| 63 | + |
| 64 | + assert_equals(whatHappened, "accessed document successfully"); |
| 65 | +}, "child1 to child2: setting document.domain must give sync access"); |
| 66 | + |
| 67 | +promise_test(async () => { |
| 68 | + const whatHappened = await sendWasmModuleBetween(frameWindow2, 0); |
| 69 | + |
| 70 | + assert_equals(whatHappened, "WebAssembly.Module message received"); |
| 71 | +}, "child2 to child1: message event must occur"); |
| 72 | + |
| 73 | +promise_test(async () => { |
| 74 | + const whatHappened = await accessDocumentBetween(frameWindow2, 0); |
| 75 | + |
| 76 | + assert_equals(whatHappened, "accessed document successfully"); |
| 77 | +}, "child2 to child1: setting document.domain must give sync access"); |
| 78 | +</script> |
0 commit comments