Bug 1274265 - browser_broadcastchannel.js should not expose content promises to the rest of the test. r=jhao, a=test-only
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 15 Jun 2016 11:51:44 +0100
changeset 342120 6ec9fc7f1edd7bee384f6ec8614a41c61d306a52
parent 342119 babac065acd357ccd1408d13f8401f4eea9f1189
child 342121 7d30a0449e626b23dbd45dc2837aef386c2de0dc
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhao, test-only
bugs1274265
milestone49.0a2
Bug 1274265 - browser_broadcastchannel.js should not expose content promises to the rest of the test. r=jhao, a=test-only
browser/components/contextualidentity/test/browser/browser_broadcastchannel.js
--- a/browser/components/contextualidentity/test/browser/browser_broadcastchannel.js
+++ b/browser/components/contextualidentity/test/browser/browser_broadcastchannel.js
@@ -29,26 +29,27 @@ add_task(function* setup() {
 });
 
 add_task(function* test() {
   let receiver = yield* openTabInUserContext(URI, 2);
 
   let channelName = "contextualidentity-broadcastchannel";
 
   // reflect the received message on title
-  let receiveMsg = ContentTask.spawn(receiver.browser, channelName,
-      function (name) {
-        return new content.window.wrappedJSObject.Promise(resolve => {
-          content.window.bc = new content.window.BroadcastChannel(name);
-          content.window.bc.onmessage = function (e) {
-            content.document.title += e.data;
-            resolve();
-          }
-        });
+  yield ContentTask.spawn(receiver.browser, channelName,
+    function (name) {
+      content.window.testPromise = new content.window.Promise(resolve => {
+        content.window.bc = new content.window.BroadcastChannel(name);
+        content.window.bc.onmessage = function (e) {
+          content.document.title += e.data;
+          resolve();
+        }
       });
+    }
+  );
 
   let sender1 = yield* openTabInUserContext(URI, 1);
   let sender2 = yield* openTabInUserContext(URI, 2);
   sender1.message = "Message from user context #1";
   sender2.message = "Message from user context #2";
 
   // send a message from a tab in different user context first
   // then send a message from a tab in the same user context
@@ -58,17 +59,21 @@ add_task(function* test() {
         { name: channelName, message: sender.message },
         function (opts) {
           let bc = new content.window.BroadcastChannel(opts.name);
           bc.postMessage(opts.message);
         });
   }
 
   // make sure we have received a message
-  yield receiveMsg;
+  yield ContentTask.spawn(receiver.browser, channelName,
+    function* (name) {
+      yield content.window.testPromise.then(function() {});
+    }
+  );
 
   // Since sender1 sends before sender2, if the title is exactly
   // sender2's message, sender1's message must've been blocked
   is(receiver.browser.contentDocument.title, sender2.message,
       "should only receive messages from the same user context");
 
   gBrowser.removeTab(sender1.tab);
   gBrowser.removeTab(sender2.tab);