summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/whatwg/postMessage_idn_helper.html
blob: c66932280c04a3d0d4db0df282a72adb4377b5d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html>
<head>
  <title>postMessage IDN test page</title>
  <script type="application/javascript">
    function receiveMessage(evt)
    {
      var response = "idn-response";

      if (!(evt instanceof MessageEvent))
        response += " not-a-MessageEvent";
      if (evt.origin !== "http://mochi.test:8888")
        response += " wrong-sender-origin(" + evt.origin + ")";
      if (evt.data !== "idn-message")
        response += " wrong-data(" + evt.data + ")";
      if (evt.lastEventId !== "")
        response += " wrong-lastEventId(" + evt.lastEventId + ")";
      if (evt.source !== window.parent)
        response += " wrong-source";
      if (evt.target !== window)
        response += " wrong-target";
      if (evt.type !== "message")
        response += " wrong-type(" + evt.type + ")";

      evt.source.postMessage(response, evt.origin);
    }
    window.addEventListener("message", receiveMessage, false);

    function setup()
    {
      var target = document.getElementById("location");
      target.textContent = location.hostname + ":" + (location.port || 80);
    }

    window.addEventListener("load", setup, false);
  </script>
</head>
<body>
<h1 id="location">No location!</h1>
</body>
</html>