Bug 1134224 - test_bug1132395.html must wait until the port is actually available before sending messages, r=ehsan
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 08 Apr 2015 17:59:08 +0100
changeset 238190 a70e27fa70b1ad17734da8f5068a62cfd58ec801
parent 238189 4ab18dfd2884b239cf6135a13d3e8786ad48a119
child 238191 cfea20361c1edb87d1fcde827f7b132dbf2b9c63
push id58140
push useramarchesini@mozilla.com
push dateWed, 08 Apr 2015 17:27:09 +0000
treeherdermozilla-inbound@a70e27fa70b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1134224, 1132395
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1134224 - test_bug1132395.html must wait until the port is actually available before sending messages, r=ehsan
dom/workers/test/bug1132395_sharedWorker.js
dom/workers/test/test_bug1132395.html
--- a/dom/workers/test/bug1132395_sharedWorker.js
+++ b/dom/workers/test/bug1132395_sharedWorker.js
@@ -1,5 +1,7 @@
 onconnect = function(evt) {
-  var blob = new Blob(['123'], { type: 'text/plain' });
-  var url = URL.createObjectURL(blob);
-  evt.ports[0].postMessage('alive \\o/');
+  evt.ports[0].onmessage = function(e) {
+    var blob = new Blob(['123'], { type: 'text/plain' });
+    var url = URL.createObjectURL(blob);
+    evt.ports[0].postMessage('alive \\o/');
+  };
 }
--- a/dom/workers/test/test_bug1132395.html
+++ b/dom/workers/test/test_bug1132395.html
@@ -11,19 +11,21 @@
 </head>
 <body>
 
 <script class="testbody" type="text/javascript">
 
 SpecialPowers.pushPrefEnv({ set: [["dom.workers.sharedWorkers.enabled", true]] }, function() {
   var sw = new SharedWorker('bug1132395_sharedWorker.js');
   sw.port.onmessage = function(event) {
-     ok(true, "We didn't crash.");
+    ok(true, "We didn't crash.");
     SimpleTest.finish();
   }
+
+  sw.port.postMessage('go');
 });
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 </body>
 </html>