Bug 1125661 - Intermittent browser_devices_get_user_media.js | expected notification recording-device-events - Got 0, expected 1. r=felipc
authorFlorian Quèze <florian@queze.net>
Mon, 26 Jan 2015 12:29:08 +0100
changeset 225689 ab970e5d511895634335d80aea12d30ce6ef04b7
parent 225688 b792e9c41c662b3091e2964c3bd81f42aa580143
child 225690 d79a930a61f1639b84b66df81b04ca05a6227264
push id10997
push userryanvm@gmail.com
push dateMon, 26 Jan 2015 20:13:50 +0000
treeherderfx-team@ab970e5d5118 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipc
bugs1125661
milestone38.0a1
Bug 1125661 - Intermittent browser_devices_get_user_media.js | expected notification recording-device-events - Got 0, expected 1. r=felipc
browser/base/content/test/general/browser_devices_get_user_media.js
browser/base/content/test/general/browser_devices_get_user_media_in_frame.js
--- a/browser/base/content/test/general/browser_devices_get_user_media.js
+++ b/browser/base/content/test/general/browser_devices_get_user_media.js
@@ -477,31 +477,24 @@ let gTests = [
     is(getMediaCaptureState(), "CameraAndMicrophone",
        "expected camera and microphone to be shared");
 
     yield checkSharingUI({video: true, audio: true});
 
     yield promiseNotificationShown(PopupNotifications.getNotification("webRTC-sharingDevices"));
 
     info("reloading the web page");
-    let deferred = Promise.defer();
-    let browser = gBrowser.selectedBrowser;
-    browser.addEventListener("load", function onload() {
-      browser.removeEventListener("load", onload, true);
-      deferred.resolve();
-    }, true);
-    content.location.reload();
-    yield deferred.promise;
+    yield promiseObserverCalled("recording-device-events",
+                                () => { content.location.reload(); });
 
     yield promiseNoPopupNotification("webRTC-sharingDevices");
-    if (gObservedTopics["recording-device-events"] == 2) {
+    if (gObservedTopics["recording-device-events"] == 1) {
       todo(false, "Got the 'recording-device-events' notification twice, likely because of bug 962719");
-      --gObservedTopics["recording-device-events"];
+      gObservedTopics["recording-device-events"] = 0;
     }
-    expectObserverCalled("recording-device-events");
     expectObserverCalled("recording-window-ended");
     expectNoObserverCalled();
     yield checkNotSharing();
   }
 },
 
 {
   desc: "getUserMedia prompt: Always/Never Share",
--- a/browser/base/content/test/general/browser_devices_get_user_media_in_frame.js
+++ b/browser/base/content/test/general/browser_devices_get_user_media_in_frame.js
@@ -314,31 +314,24 @@ let gTests = [
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "CameraAndMicrophone",
        "expected camera and microphone to be shared");
 
     yield checkSharingUI({video: true, audio: true});
 
     info("reloading the frame");
-    let deferred = Promise.defer();
-    let browser = gBrowser.selectedBrowser;
-    browser.addEventListener("load", function onload() {
-      browser.removeEventListener("load", onload, true);
-      deferred.resolve();
-    }, true);
-    global.location.reload();
-    yield deferred.promise;
+    yield promiseObserverCalled("recording-device-events",
+                                () => { global.location.reload(); });
 
     yield promiseNoPopupNotification("webRTC-sharingDevices");
-    if (gObservedTopics["recording-device-events"] == 2) {
+    if (gObservedTopics["recording-device-events"] == 1) {
       todo(false, "Got the 'recording-device-events' notification twice, likely because of bug 962719");
-      --gObservedTopics["recording-device-events"];
+      gObservedTopics["recording-device-events"] = 0;
     }
-    expectObserverCalled("recording-device-events");
     expectObserverCalled("recording-window-ended");
     expectNoObserverCalled();
     yield checkNotSharing();
   }
 },
 
 {
   desc: "getUserMedia audio+video: reloading the frame removes prompts",
@@ -347,28 +340,21 @@ let gTests = [
     yield promisePopupNotificationShown("webRTC-shareDevices", () => {
       info("requesting devices");
       global.requestDevice(true, true);
     });
     expectObserverCalled("getUserMedia:request");
     checkDeviceSelectors(true, true);
 
     info("reloading the frame");
-    let deferred = Promise.defer();
-    let browser = gBrowser.selectedBrowser;
-    browser.addEventListener("load", function onload() {
-      browser.removeEventListener("load", onload, true);
-      deferred.resolve();
-    }, true);
-    global.location.reload();
-    yield deferred.promise;
+    yield promiseObserverCalled("recording-window-ended",
+                                () => { global.location.reload(); });
 
     yield promiseNoPopupNotification("webRTC-shareDevices");
 
-    expectObserverCalled("recording-window-ended");
     expectNoObserverCalled();
     yield checkNotSharing();
   }
 },
 
 {
   desc: "getUserMedia audio+video: reloading a frame updates the sharing UI",
   run: function checkUpdateWhenReloading() {
@@ -408,32 +394,25 @@ let gTests = [
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "CameraAndMicrophone",
        "expected camera and microphone to be shared");
 
     yield checkSharingUI({video: true, audio: true});
     expectNoObserverCalled();
 
     info("reloading the second frame");
-    let deferred = Promise.defer();
-    let browser = gBrowser.selectedBrowser;
-    browser.addEventListener("load", function onload() {
-      browser.removeEventListener("load", onload, true);
-      deferred.resolve();
-    }, true);
-    g2.location.reload();
-    yield deferred.promise;
+    yield promiseObserverCalled("recording-device-events",
+                                () => { g2.location.reload(); });
 
     yield checkSharingUI({video: false, audio: true});
     expectObserverCalled("recording-window-ended");
-    if (gObservedTopics["recording-device-events"] == 2) {
+    if (gObservedTopics["recording-device-events"] == 1) {
       todo(false, "Got the 'recording-device-events' notification twice, likely because of bug 962719");
-      --gObservedTopics["recording-device-events"];
+      gObservedTopics["recording-device-events"] = 0;
     }
-    expectObserverCalled("recording-device-events");
     expectNoObserverCalled();
 
     yield closeStream(g1);
     yield promiseNoPopupNotification("webRTC-sharingDevices");
     expectNoObserverCalled();
     yield checkNotSharing();
   }
 }