Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Testing postMessage from sandbox</title> |
michael@0 | 5 | <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> |
michael@0 | 7 | <script type="application/javascript"> |
michael@0 | 8 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 9 | function doTest() { |
michael@0 | 10 | var sandbox = Components.utils.Sandbox("http://mochi.test:8888/", { wantXrays: true }); |
michael@0 | 11 | var win = window.frames["sameDomain"]; |
michael@0 | 12 | sandbox.win = win; |
michael@0 | 13 | sandbox.is = is; |
michael@0 | 14 | sandbox.done = SimpleTest.finish; |
michael@0 | 15 | |
michael@0 | 16 | result = Components.utils.evalInSandbox('var data = {some:"data"};' |
michael@0 | 17 | +'win.addEventListener("message", receiveMessage, false);' |
michael@0 | 18 | +'function receiveMessage(event)' |
michael@0 | 19 | +'{' |
michael@0 | 20 | +' is(JSON.stringify(event.data), JSON.stringify(data), "Received the expected message data");' |
michael@0 | 21 | +' done();' |
michael@0 | 22 | +'}' |
michael@0 | 23 | +'win.postMessage(data, "*")' |
michael@0 | 24 | , sandbox); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | addLoadEvent(doTest); |
michael@0 | 28 | </script> |
michael@0 | 29 | </head> |
michael@0 | 30 | <body> |
michael@0 | 31 | <iframe src="http://mochi.test:8888/" |
michael@0 | 32 | id="sameDomain" name="sameDomain"> |
michael@0 | 33 | </iframe> |
michael@0 | 34 | </body> |
michael@0 | 35 | </html> |
michael@0 | 36 |