diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/base/test/test_postMessage_originAttributes.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/test/test_postMessage_originAttributes.html')
-rw-r--r-- | dom/base/test/test_postMessage_originAttributes.html | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/base/test/test_postMessage_originAttributes.html b/dom/base/test/test_postMessage_originAttributes.html new file mode 100644 index 000000000..5ababc1d4 --- /dev/null +++ b/dom/base/test/test_postMessage_originAttributes.html @@ -0,0 +1,60 @@ +<!DOCTYPE html> +<html> +<head> + <title>Test window.postMessages from system principal to window with non-default originAttributes</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> + +<body> +<iframe id="target-iframe"></iframe> +<script type="application/javascript"> + +add_task(function*() { + yield SpecialPowers.pushPrefEnv( + { "set": [["network.disable.ipc.security", true]] }); +}); + +add_task(function*() { + let iframe = document.querySelector("#target-iframe"); + + let win = SpecialPowers.wrap(iframe).contentWindow; + let docShell = win.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) + .getInterface(SpecialPowers.Ci.nsIDocShell); + + // Add private browsing ID to docShell origin and load document. + docShell.setOriginAttributes({privateBrowsingId: 1}); + + yield new Promise(resolve => { + iframe.addEventListener("load", resolve, true); + + iframe.src = SimpleTest.getTestFileURL("file_receiveMessage.html"); + }); + + // Set up console monitor to wait for warning. + const expectedMessage = ( + 'Attempting to post a message to window with url ' + + '"http://mochi.test:8888/tests/dom/base/test/file_receiveMessage.html" ' + + 'and origin "http://mochi.test:8888^privateBrowsingId=1" from a system ' + + 'principal scope with mismatched origin "[System Principal]".'); + + let consolePromise = new Promise(resolve => { + SimpleTest.monitorConsole(resolve, [e => e.message == expectedMessage]); + }); + + // Post to the content window via SpecialPowers' system principal scope. + win.postMessage("Hello. o/", "http://mochi.test:8888"); + yield new Promise(resolve => setTimeout(resolve, 0)); + + SimpleTest.endMonitorConsole(); + yield consolePromise; + + // Check that the window received and handled the message. + is(win.document.body.textContent, "|Hello. o/", + "Content window received the expected message"); +}); +</script> +</body> +</html> + |