Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>postMessage chrome message receiver</title>
5 <script type="application/javascript">
6 var gPrePath = "";
8 function receiveMessage(evt)
9 {
10 if (evt.data.substring(0,9) == "chrome://") {
11 gPrePath = evt.data;
12 respond("path-is-set");
13 } else {
14 // Content cannot post to chrome without privileges
15 try {
16 window.parent.postMessage("SHOULD NOT GET THIS!", "*");
17 }
18 catch (ex) {
19 }
21 var msg = "post-to-content-response";
23 if (evt.source !== null)
24 msg += " wrong-source(" + evt.source + ")";
25 if (!evt.isTrusted)
26 msg += " unexpected-untrusted-event";
27 if (evt.type !== "message")
28 msg += " wrong-type(" + evt.type + ")";
29 if (evt.origin !== gPrePath)
30 msg += " wrong-origin(" + evt.origin + ")";
31 if (evt.data !== "post-to-content")
32 msg += " wrong-message(" + evt.data + ")";
34 respond(msg);
35 }
36 }
38 function respond(msg)
39 {
40 SpecialPowers.wrap(window).parent.postMessage(msg, "*");
41 }
43 window.addEventListener("message", receiveMessage, false);
44 </script>
45 </head>
46 <body>
47 <h1 id="domain">example.org</h1>
48 </body>
49 </html>