Fix up recently-landed test for async and target changes to postMessage. r=orange
authorjwalden@mit.edu
Fri, 02 May 2008 14:39:06 -0700
changeset 14902 da3a8e06916f8c2ecdf7c50892d6a7eab75326c2
parent 14901 decc3f920091cd60d7d6179a3731c894f0f2ba96
child 14903 f56885e0520df229c8d56adf23f987c8e19b08e3
push idunknown
push userunknown
push dateunknown
reviewersorange
milestone1.9pre
Fix up recently-landed test for async and target changes to postMessage. r=orange
content/xbl/test/file_bug379959_cross.html
content/xbl/test/file_bug379959_data.html
content/xbl/test/test_bug379959.html
--- a/content/xbl/test/file_bug379959_cross.html
+++ b/content/xbl/test/file_bug379959_cross.html
@@ -1,25 +1,25 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-<style>
-#div1 {
-  color: green;
-  -moz-binding: url(file_bug379959_xbl.xml#xbltest);
-}
-#div2 {
-  color: green;
-  -moz-binding: url(http://example.com/tests/content/xbl/test/file_bug379959_xbl.xml#xbltest);
-}
-</style>
-<body>
-<div id="div1"></div>
-<div id="div2"></div>
-<script>
-onload = function() {
-  nodes = document.getAnonymousNodes(document.getElementById('div1'));
-  parent.postMessage(nodes ? nodes.length : 0);
-  nodes = document.getAnonymousNodes(document.getElementById('div2'));
-  parent.postMessage(nodes ? nodes.length : 0);
-}
-</script>
-</html>
+<!DOCTYPE HTML>
+<html>
+<head>
+<style>
+#div1 {
+  color: green;
+  -moz-binding: url(file_bug379959_xbl.xml#xbltest);
+}
+#div2 {
+  color: green;
+  -moz-binding: url(http://example.com/tests/content/xbl/test/file_bug379959_xbl.xml#xbltest);
+}
+</style>
+<body>
+<div id="div1"></div>
+<div id="div2"></div>
+<script>
+onload = function() {
+  nodes = document.getAnonymousNodes(document.getElementById('div1'));
+  parent.postMessage(nodes ? nodes.length : 0, "http://localhost:8888");
+  nodes = document.getAnonymousNodes(document.getElementById('div2'));
+  parent.postMessage(nodes ? nodes.length : 0, "http://localhost:8888");
+}
+</script>
+</html>
--- a/content/xbl/test/file_bug379959_data.html
+++ b/content/xbl/test/file_bug379959_data.html
@@ -1,18 +1,18 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-<style>
-#d {
-  color: green;
-  -moz-binding: url(data:text/xml;charset=utf-8,%3C%3Fxml%20version%3D%221.0%22%3F%3E%0A%3Cbindings%20id%3D%22xbltestBindings%22%20xmlns%3D%22http%3A//www.mozilla.org/xbl%22%3E%0A%20%20%3Cbinding%20id%3D%22xbltest%22%3E%3Ccontent%3EPASS%3C/content%3E%3C/binding%3E%0A%3C/bindings%3E%0A);
-}
-</style>
-<body>
-<div id="d"></div>
-<script>
-onload = function() {
-  nodes = document.getAnonymousNodes(document.getElementById('d'));
-  parent.postMessage(nodes ? nodes.length : 0);
-}
-</script>
-</html>
+<!DOCTYPE HTML>
+<html>
+<head>
+<style>
+#d {
+  color: green;
+  -moz-binding: url(data:text/xml;charset=utf-8,%3C%3Fxml%20version%3D%221.0%22%3F%3E%0A%3Cbindings%20id%3D%22xbltestBindings%22%20xmlns%3D%22http%3A//www.mozilla.org/xbl%22%3E%0A%20%20%3Cbinding%20id%3D%22xbltest%22%3E%3Ccontent%3EPASS%3C/content%3E%3C/binding%3E%0A%3C/bindings%3E%0A);
+}
+</style>
+<body>
+<div id="d"></div>
+<script>
+onload = function() {
+  nodes = document.getAnonymousNodes(document.getElementById('d'));
+  parent.postMessage(nodes ? nodes.length : 0, "http://localhost:8888");
+}
+</script>
+</html>
--- a/content/xbl/test/test_bug379959.html
+++ b/content/xbl/test/test_bug379959.html
@@ -22,19 +22,24 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   <pre id="test">
     <script class="testbody" type="application/javascript;version=1.7">
 SimpleTest.waitForExplicitFinish();
 
 gen = runTest();
 var messages = 0;
 
-document.addEventListener("message",
-                          function(e) { messages++; gen.send(e.data); },
-                          false);
+function receiveMessage(e)
+{
+  is(e.origin, "http://localhost:8888", "wrong sender!");
+  messages++;
+  gen.send(e.data);
+}
+
+window.addEventListener("message", receiveMessage, false);
 
 const prefName = "layout.debug.enable_data_xbl";
 
 function runTest() {
   iframe = document.getElementById('f');
 
   // Turn on loads of data-urls
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");