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 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=553125 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>postMessage uses structured clone</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="application/javascript;version=1.7" |
michael@0 | 10 | src="postMessage_structured_clone_helper.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=553125">Mozilla Bug 553125</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div id="content" style="display: none"></div> |
michael@0 | 17 | |
michael@0 | 18 | <iframe src="http://mochi.test:8888/tests/dom/tests/mochitest/whatwg/postMessage_structured_clone_helper.html" |
michael@0 | 19 | name="sameDomain"></iframe> |
michael@0 | 20 | <iframe src="http://example.org:8000/tests/dom/tests/mochitest/whatwg/postMessage_structured_clone_helper.html" |
michael@0 | 21 | name="crossDomain"></iframe> |
michael@0 | 22 | |
michael@0 | 23 | |
michael@0 | 24 | <pre id="test"> |
michael@0 | 25 | <script class="testbody" type="application/javascript"> |
michael@0 | 26 | /** Test for Bug 553125 **/ |
michael@0 | 27 | |
michael@0 | 28 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 29 | |
michael@0 | 30 | var lastMessage = null; |
michael@0 | 31 | var crossOrigin = false; |
michael@0 | 32 | var generator = new getTestContent(); |
michael@0 | 33 | |
michael@0 | 34 | function runNextSameOrigin() { |
michael@0 | 35 | try { |
michael@0 | 36 | lastMessage = generator.next(); |
michael@0 | 37 | } catch (e) { |
michael@0 | 38 | generator = new getTestContent(); |
michael@0 | 39 | crossOrigin = true; |
michael@0 | 40 | runNextCrossOrigin(); |
michael@0 | 41 | } |
michael@0 | 42 | window.frames.sameDomain.postMessage(lastMessage, "http://mochi.test:8888"); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function runNextCrossOrigin() { |
michael@0 | 46 | try { |
michael@0 | 47 | lastMessage = generator.next(); |
michael@0 | 48 | } catch (e) { |
michael@0 | 49 | SimpleTest.finish(); |
michael@0 | 50 | } |
michael@0 | 51 | window.frames.crossDomain.postMessage(lastMessage, "http://example.org:8000"); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | function receiveMessage(evt) { |
michael@0 | 55 | if (evt.data == "TEST-PASS") |
michael@0 | 56 | SimpleTest.ok(true, "structured clone of | " + lastMessage + " | succeeded"); |
michael@0 | 57 | else |
michael@0 | 58 | SimpleTest.ok(false, "structured clone of | " + lastMessage + " | failed"); |
michael@0 | 59 | setTimeout(crossOrigin ? runNextCrossOrigin : runNextSameOrigin, 0); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | window.addEventListener("message", receiveMessage, false); |
michael@0 | 63 | window.addEventListener("load", runNextSameOrigin, false); |
michael@0 | 64 | |
michael@0 | 65 | </script> |
michael@0 | 66 | </pre> |
michael@0 | 67 | </body> |
michael@0 | 68 | </html> |