dom/tests/mochitest/whatwg/test_postMessage_idn.xhtml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/whatwg/test_postMessage_idn.xhtml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<!DOCTYPE html>
     1.6 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.7 +<!--
     1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage
     1.9 +-->
    1.10 +<head>
    1.11 +  <title>postMessage uri/domain values and IDN encoding</title>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
    1.13 +  <script type="text/javascript" src="browserFu.js"></script>
    1.14 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.15 +</head>
    1.16 +<body>
    1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage">Mozilla Bug 387706</a>
    1.18 +<p id="display"></p>
    1.19 +<div id="content" style="display: none"></div>
    1.20 +
    1.21 +<iframe src="http://sub1.ält.example.org:8000/tests/dom/tests/mochitest/whatwg/postMessage_idn_helper.html"></iframe>
    1.22 +
    1.23 +<pre id="test">
    1.24 +<script class="testbody" type="application/javascript">
    1.25 +/** Test for Bug 387706 **/
    1.26 +
    1.27 +SimpleTest.waitForExplicitFinish();
    1.28 +
    1.29 +var responseReceived = false;
    1.30 +var idnWindow = null;
    1.31 +
    1.32 +function receiveMessage(evt)
    1.33 +{
    1.34 +  ok(evt instanceof MessageEvent, "umm, how did we get this?");
    1.35 +  is(evt.type, "message", "expected events of type 'message'");
    1.36 +
    1.37 +  if (isMozilla)
    1.38 +  {
    1.39 +    ok(evt.isTrusted === false, "shouldn't have been a trusted event");
    1.40 +  }
    1.41 +
    1.42 +  is(evt.origin, "http://sub1.ält.example.org:8000",
    1.43 +     "wrong origin -- IDN issue, perhaps?");
    1.44 +
    1.45 +  is(evt.data, "idn-response", "unexpected test result");
    1.46 +  is(evt.lastEventId, "", "postMessage creates events with empty lastEventId");
    1.47 +  ok(evt.source === idnWindow, "wrong source");
    1.48 +
    1.49 +  SimpleTest.finish();
    1.50 +}
    1.51 +window.addEventListener("message", receiveMessage, false);
    1.52 +
    1.53 +var xhtmlns = "http://www.w3.org/1999/xhtml";
    1.54 +
    1.55 +function setup()
    1.56 +{
    1.57 +  var idnFrame = document.getElementsByTagNameNS(xhtmlns, "iframe")[0];
    1.58 +  idnWindow = idnFrame.contentWindow;
    1.59 +  try
    1.60 +  {
    1.61 +    idnWindow.postMessage("idn-message", "http://sub1.ält.example.org:8000");
    1.62 +  }
    1.63 +  catch (e)
    1.64 +  {
    1.65 +    ok(false, "failed to post message: " + e);
    1.66 +    SimpleTest.finish();
    1.67 +  }
    1.68 +}
    1.69 +
    1.70 +addLoadEvent(setup);
    1.71 +</script>
    1.72 +</pre>
    1.73 +</body>
    1.74 +</html>

mercurial