Adding a test to ensure .uri on a postMessage-generated event contains a hash reference from the caller, if one was present. No bug or code changes.
authorjwalden@mit.edu
Mon, 11 Feb 2008 12:27:32 -0800
changeset 11552 79f974b45d8019c8534d520b50b55931247239a8
parent 11551 589def7ef4c64998eb6ff694a95a3250b964447c
child 11553 a2f4c7682f6051b4ed498fda17e05b11cb259ab8
push idunknown
push userunknown
push dateunknown
milestone1.9b4pre
Adding a test to ensure .uri on a postMessage-generated event contains a hash reference from the caller, if one was present. No bug or code changes.
dom/tests/mochitest/whatwg/Makefile.in
dom/tests/mochitest/whatwg/postMessage_hash.html
dom/tests/mochitest/whatwg/test_postMessage_hash.html
--- a/dom/tests/mochitest/whatwg/Makefile.in
+++ b/dom/tests/mochitest/whatwg/Makefile.in
@@ -60,16 +60,18 @@ include $(topsrcdir)/config/rules.mk
 		postMessage_override_helper.html \
 		test_postMessage_throw.html \
 		postMessage_throw_helper.html \
 		postMessage_chrome_helper.html \
 		test_postMessage_special.xhtml \
 		test_postMessage_idn.xhtml \
 		postMessage_idn_helper.html \
 		test_postMessage_basehref.html \
+		test_postMessage_hash.html \
+		postMessage_hash.html \
 		$(NULL)
 
 _CHROME_FILES	= \
 		test_postMessage_chrome.html \
 		$(NULL)		
 
 libs:: 	$(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/whatwg/postMessage_hash.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Hashed kid for test_postMessage_hash.html</title>
+  <script type="application/javascript">
+function receiveMessage(evt)
+{
+  var response = "response-message";
+
+  if (window.location.href !== "http://localhost:8888/tests/dom/tests/mochitest/whatwg/postMessage_hash.html#hash")
+    response += " kid-at-wrong-uri(" + window.location.href + ")";
+
+  if (evt.domain !== "localhost")
+    response += " wrong-domain(" + evt.domain + ")";
+  if (evt.uri !== "http://localhost:8888/tests/dom/tests/mochitest/whatwg/test_postMessage_hash.html")
+    response += " wrong-uri(" + evt.uri + ")";
+  if (evt.source !== window.parent)
+    response += " wrong-source";
+  if (evt.data !== "from-parent")
+    response += " wrong-data(" + evt.data + ")";
+
+  window.parent.postMessage(response);
+}
+
+document.addEventListener("message", receiveMessage, false);
+  </script>
+</head>
+<body>
+<p>Kid iframe</p>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/whatwg/test_postMessage_hash.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>postMessage's interaction with hash URIs</title>
+  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
+  <script type="text/javascript" src="browserFu.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <base href="http://example.com/" />
+</head>
+<body>
+<p>(no bug; this is a preemptive test)</p>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+
+<iframe src="http://localhost:8888/tests/dom/tests/mochitest/whatwg/postMessage_hash.html#hash"
+        name="kid"></iframe>
+
+<pre id="test">
+<script class="testbody" type="application/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+function receiveMessage(evt)
+{
+  is(evt.domain, "localhost", "wrong sender");
+  is(evt.uri, "http://localhost:8888/tests/dom/tests/mochitest/whatwg/postMessage_hash.html#hash",
+     "wrong sender");
+  ok(evt.source === window.frames.kid, "wrong source");
+
+  is(evt.data, "response-message", "wrong data");
+
+  SimpleTest.finish();
+}
+
+document.addEventListener("message", receiveMessage, false);
+
+function run()
+{
+  window.frames.kid.postMessage("from-parent");
+}
+
+window.addEventListener("load", run, false);
+</script>
+</pre>
+</body>
+</html>