commit-queue@webkit.org | 16a9cba | 2022-01-24 16:05:24 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- webkit-test-runner [ jscOptions=--useShadowRealm=true ] --> |
| 2 | <html> |
| 3 | <head> |
| 4 | <script src="../resources/js-test-pre.js"></script> |
| 5 | </head> |
| 6 | <body> |
| 7 | <script src =../resources/testharness.js></script> |
| 8 | <script src =../resources/testharnessreport.js></script> |
| 9 | <iframe src="resources/shadow-realm-iframe.html" sandbox="allow-scripts"></iframe> |
| 10 | <script> |
| 11 | description("Test to ensure ShadowRealms running in a sandboxed iframe do not access the parent window object"); |
| 12 | window.jsTestIsAsync = true; |
| 13 | |
| 14 | function wrappedLog(prefix) { |
| 15 | return function (msg) { |
| 16 | debug(prefix + ": " + msg); |
| 17 | }; |
| 18 | } |
| 19 | |
| 20 | debug("attached frames: " + window.frames.length); |
| 21 | let frame = window.frames[0]; |
| 22 | window.addEventListener("message", async () => { |
| 23 | let realm = frame.realm; |
| 24 | debug("detaching iframe"); |
| 25 | document.getElementsByTagName("iframe")[0].remove() |
| 26 | $vm.gc(); |
| 27 | frame = null; |
| 28 | const checkFn2 = await realm.importValue("./resources/example-module.js", "check"); |
| 29 | debug("dropping realm value") |
| 30 | realm = null; |
| 31 | $vm.gc(); |
| 32 | shouldBe(() => checkFn2(wrappedLog("shadowRealm")), |
| 33 | "true"); |
| 34 | finishJSTest(); |
| 35 | }); |
| 36 | </script> |
| 37 | <script src="../resources/js-test-post.js"></script> |
| 38 | </body> |
| 39 | </html> |