Bug 1125661 - Intermittent browser_devices_get_user_media.js | expected notification recording-device-events - Got 0, expected 1. r=felipc, a=test-only
authorFlorian Quèze <florian@queze.net>
Mon, 26 Jan 2015 12:29:08 +0100
changeset 249443 aaaa3b3b7bf84925f142a0c4ca74e1b6a67adb80
parent 249442 87a0f1b690400040355898c03e8324f121f42d57
child 249444 5b21e1bf0ee7b3aa6b8554e4c7d9a3a22ee11591
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipc, test-only
bugs1125661
milestone37.0a2
Bug 1125661 - Intermittent browser_devices_get_user_media.js | expected notification recording-device-events - Got 0, expected 1. r=felipc, a=test-only
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();
   }
 }