Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: dom/tests/mochitest/chrome/chrome.toml
<!DOCTYPE HTML>
<html>
<head>
<title>Testing postMessage from sandbox</title>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
function doTest() {
var win = window.frames.sameDomain;
sandbox.win = win;
sandbox.is = is;
sandbox.done = SimpleTest.finish;
result = Cu.evalInSandbox('var data = {some:"data"};'
+'win.addEventListener("message", receiveMessage, false);'
+'function receiveMessage(event)'
+'{'
+' is(JSON.stringify(event.data), JSON.stringify(data), "Received the expected message data");'
+' done();'
+'}'
+'win.postMessage(data, "*")'
, sandbox);
}
addLoadEvent(doTest);
</script>
</head>
<body>
id="sameDomain" name="sameDomain">
</iframe>
</body>
</html>