Bug 1134224 - test_bug1132395.html must wait until the port is actually available before sending messages. r=ehsan, a=test-only
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 08 Apr 2015 17:59:08 +0100
changeset 258396 982dba6be01c
parent 258395 51c5166a338b
child 258397 8bb13d7a5d2a
push id4659
push userryanvm@gmail.com
push date2015-04-09 15:23 +0000
treeherdermozilla-beta@58dca3f7560a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, test-only
bugs1134224, 1132395
milestone38.0
Bug 1134224 - test_bug1132395.html must wait until the port is actually available before sending messages. r=ehsan, a=test-only
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>