Bug 1154019 - Intermittent browser_devices_get_user_media.js | Test timed out | Found a Browser:WebRTCGlobalIndicator, r=Gijs.
authorFlorian Quèze <florian@queze.net>
Wed, 10 Jun 2015 11:18:40 +0200
changeset 248120 d378f3087fcac59519e5cc874cebb1c4851ed8b1
parent 248119 027ffd03bae2e88b17e12076c9147fdf08673b4a
child 248121 9f6666bd7a9b1056d4c22b87122b4fdbc508723c
push id60888
push userkwierso@gmail.com
push dateThu, 11 Jun 2015 01:38:38 +0000
treeherdermozilla-inbound@39e638ed06bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1154019
milestone41.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 1154019 - Intermittent browser_devices_get_user_media.js | Test timed out | Found a Browser:WebRTCGlobalIndicator, r=Gijs.
browser/base/content/test/general/browser_devices_get_user_media.js
browser/base/content/test/general/browser_devices_get_user_media_in_frame.js
browser/base/content/test/general/head.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
@@ -237,24 +237,26 @@ let gTests = [
     expectObserverCalled("getUserMedia:request");
 
     is(PopupNotifications.getNotification("webRTC-shareDevices").anchorID,
        "webRTC-shareDevices-notification-icon", "anchored to device icon");
     checkDeviceSelectors(true, true);
     is(PopupNotifications.panel.firstChild.getAttribute("popupid"),
        "webRTC-shareDevices", "panel using devices icon");
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "CameraAndMicrophone",
        "expected camera and microphone to be shared");
 
+    yield indicator;
     yield checkSharingUI({audio: true, video: true});
     yield closeStream();
   }
 },
 
 {
   desc: "getUserMedia audio only",
   run: function checkAudioOnly() {
@@ -265,23 +267,25 @@ let gTests = [
     expectObserverCalled("getUserMedia:request");
 
     is(PopupNotifications.getNotification("webRTC-shareDevices").anchorID,
        "webRTC-shareMicrophone-notification-icon", "anchored to mic icon");
     checkDeviceSelectors(true);
     is(PopupNotifications.panel.firstChild.getAttribute("popupid"),
        "webRTC-shareMicrophone", "panel using microphone icon");
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "Microphone", "expected microphone to be shared");
 
+    yield indicator;
     yield checkSharingUI({audio: true});
     yield closeStream();
   }
 },
 
 {
   desc: "getUserMedia video only",
   run: function checkVideoOnly() {
@@ -292,23 +296,25 @@ let gTests = [
     expectObserverCalled("getUserMedia:request");
 
     is(PopupNotifications.getNotification("webRTC-shareDevices").anchorID,
        "webRTC-shareDevices-notification-icon", "anchored to device icon");
     checkDeviceSelectors(false, true);
     is(PopupNotifications.panel.firstChild.getAttribute("popupid"),
        "webRTC-shareDevices", "panel using devices icon");
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "Camera", "expected camera to be shared");
 
+    yield indicator;
     yield checkSharingUI({video: true});
     yield closeStream();
   }
 },
 
 {
   desc: "getUserMedia audio+video, user disables video",
   run: function checkDisableVideo() {
@@ -317,28 +323,30 @@ let gTests = [
       content.wrappedJSObject.requestDevice(true, true);
     });
     expectObserverCalled("getUserMedia:request");
     checkDeviceSelectors(true, true);
 
     // disable the camera
     enableDevice("Camera", false);
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
 
     // reset the menuitem to have no impact on the following tests.
     enableDevice("Camera", true);
 
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "Microphone",
        "expected microphone to be shared");
 
+    yield indicator;
     yield checkSharingUI({audio: true});
     yield closeStream();
   }
 },
 
 {
   desc: "getUserMedia audio+video, user disables audio",
   run: function checkDisableAudio() {
@@ -347,28 +355,30 @@ let gTests = [
       content.wrappedJSObject.requestDevice(true, true);
     });
     expectObserverCalled("getUserMedia:request");
     checkDeviceSelectors(true, true);
 
     // disable the microphone
     enableDevice("Microphone", false);
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
 
     // reset the menuitem to have no impact on the following tests.
     enableDevice("Microphone", true);
 
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "Camera",
        "expected microphone to be shared");
 
+    yield indicator;
     yield checkSharingUI({video: true});
     yield closeStream();
   }
 },
 
 {
   desc: "getUserMedia audio+video, user disables both audio and video",
   run: function checkDisableAudioVideo() {
@@ -422,24 +432,26 @@ let gTests = [
   run: function checkStopSharing() {
     yield promisePopupNotificationShown("webRTC-shareDevices", () => {
       info("requesting devices");
       content.wrappedJSObject.requestDevice(true, true);
     });
     expectObserverCalled("getUserMedia:request");
     checkDeviceSelectors(true, true);
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "CameraAndMicrophone",
        "expected camera and microphone to be shared");
 
+    yield indicator;
     yield checkSharingUI({video: true, audio: true});
 
     yield promiseNotificationShown(PopupNotifications.getNotification("webRTC-sharingDevices"));
     activateSecondaryAction(kActionDeny);
 
     yield promiseObserverCalled("recording-device-events");
     expectObserverCalled("getUserMedia:revoke");
 
@@ -464,24 +476,26 @@ let gTests = [
   run: function checkReloading() {
     yield promisePopupNotificationShown("webRTC-shareDevices", () => {
       info("requesting devices");
       content.wrappedJSObject.requestDevice(true, true);
     });
     expectObserverCalled("getUserMedia:request");
     checkDeviceSelectors(true, true);
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "CameraAndMicrophone",
        "expected camera and microphone to be shared");
 
+    yield indicator;
     yield checkSharingUI({video: true, audio: true});
 
     yield promiseNotificationShown(PopupNotifications.getNotification("webRTC-sharingDevices"));
 
     info("reloading the web page");
     yield promiseObserverCalled("recording-device-events",
                                 () => { content.location.reload(); });
 
@@ -725,23 +739,25 @@ let gTests = [
     function stopAndCheckPerm(aRequestAudio, aRequestVideo) {
       let Perms = Services.perms;
       let uri = content.document.documentURIObject;
 
       // Initially set both permissions to 'allow'.
       Perms.add(uri, "microphone", Perms.ALLOW_ACTION);
       Perms.add(uri, "camera", Perms.ALLOW_ACTION);
 
+      let indicator = promiseIndicatorWindow();
       // Start sharing what's been requested.
       yield promiseMessage("ok", () => {
         content.wrappedJSObject.requestDevice(aRequestAudio, aRequestVideo);
       });
       expectObserverCalled("getUserMedia:request");
       expectObserverCalled("getUserMedia:response:allow");
       expectObserverCalled("recording-device-events");
+      yield indicator;
       yield checkSharingUI({video: aRequestVideo, audio: aRequestAudio});
 
       yield promiseNotificationShown(PopupNotifications.getNotification("webRTC-sharingDevices"));
       let expectedIcon = "webRTC-sharingDevices";
       if (aRequestAudio && !aRequestVideo)
         expectedIcon = "webRTC-sharingMicrophone";
       is(PopupNotifications.getNotification("webRTC-sharingDevices").anchorID,
          expectedIcon + "-notification-icon", "anchored to correct icon");
@@ -796,23 +812,25 @@ let gTests = [
   run: function checkShowSharingDoorhanger() {
     yield promisePopupNotificationShown("webRTC-shareDevices", () => {
       info("requesting devices");
       content.wrappedJSObject.requestDevice(false, true);
     });
     expectObserverCalled("getUserMedia:request");
     checkDeviceSelectors(false, true);
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "Camera", "expected camera to be shared");
 
+    yield indicator;
     yield checkSharingUI({video: true});
 
     yield promisePopupNotificationShown("webRTC-sharingDevices", () => {
       if ("nsISystemStatusBar" in Ci) {
         let activeStreams = gWebRTCUI.getActiveStreams(true, false, false);
         gWebRTCUI.showSharingDoorhanger(activeStreams[0], "Devices");
       }
       else {
--- 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
@@ -236,48 +236,52 @@ let gTests = [
     expectObserverCalled("getUserMedia:request");
 
     is(PopupNotifications.getNotification("webRTC-shareDevices").anchorID,
        "webRTC-shareDevices-notification-icon", "anchored to device icon");
     checkDeviceSelectors(true, true);
     is(PopupNotifications.panel.firstChild.getAttribute("popupid"),
        "webRTC-shareDevices", "panel using devices icon");
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "CameraAndMicrophone",
        "expected camera and microphone to be shared");
 
+    yield indicator;
     yield checkSharingUI({audio: true, video: true});
     yield closeStream(global);
   }
 },
 
 {
   desc: "getUserMedia audio+video: stop sharing",
   run: function checkStopSharing() {
     let global = getFrameGlobal("frame1");
     yield promisePopupNotificationShown("webRTC-shareDevices", () => {
       info("requesting devices");
       global.requestDevice(true, true);
     });
     expectObserverCalled("getUserMedia:request");
     checkDeviceSelectors(true, true);
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "CameraAndMicrophone",
        "expected camera and microphone to be shared");
 
+    yield indicator;
     yield checkSharingUI({video: true, audio: true});
 
     yield promiseNotificationShown(PopupNotifications.getNotification("webRTC-sharingDevices"));
     activateSecondaryAction(kActionDeny);
 
     yield promiseObserverCalled("recording-device-events");
     expectObserverCalled("getUserMedia:revoke");
 
@@ -303,24 +307,26 @@ let gTests = [
     let global = getFrameGlobal("frame1");
     yield promisePopupNotificationShown("webRTC-shareDevices", () => {
       info("requesting devices");
       global.requestDevice(true, true);
     });
     expectObserverCalled("getUserMedia:request");
     checkDeviceSelectors(true, true);
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "CameraAndMicrophone",
        "expected camera and microphone to be shared");
 
+    yield indicator;
     yield checkSharingUI({video: true, audio: true});
 
     info("reloading the frame");
     yield promiseObserverCalled("recording-device-events",
                                 () => { global.location.reload(); });
 
     yield promiseNoPopupNotification("webRTC-sharingDevices");
     if (gObservedTopics["recording-device-events"] == 1) {
@@ -365,23 +371,25 @@ let gTests = [
 
     yield promisePopupNotificationShown("webRTC-shareDevices", () => {
       info("requesting microphone in the first frame");
       g1.requestDevice(true, false);
     });
     expectObserverCalled("getUserMedia:request");
     checkDeviceSelectors(true, false);
 
+    let indicator = promiseIndicatorWindow();
     yield promiseMessage("ok", () => {
       PopupNotifications.panel.firstChild.button.click();
     });
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "Microphone", "microphone to be shared");
 
+    yield indicator;
     yield checkSharingUI({video: false, audio: true});
     expectNoObserverCalled();
 
     yield promisePopupNotificationShown("webRTC-shareDevices", () => {
       info("requesting both devices in the second frame");
       g2.requestDevice(true, true);
     });
     expectObserverCalled("getUserMedia:request");
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -628,31 +628,43 @@ function waitForNewTabEvent(aTabBrowser)
  * Waits for a window with the given URL to exist.
  *
  * @param url
  *        The url of the window.
  * @return {Promise} resolved when the window exists.
  * @resolves to the window
  */
 function promiseWindow(url) {
-  info("waiting for a " + url + " window");
+  info("expecting a " + url + " window");
   return new Promise(resolve => {
     Services.obs.addObserver(function obs(win) {
       win.QueryInterface(Ci.nsIDOMWindow);
-      if (win.location.href !== url) {
-        info("ignoring a window with this url: " + win.location.href);
-        return;
-      }
+      win.addEventListener("load", function loadHandler() {
+        win.removeEventListener("load", loadHandler);
 
-      Services.obs.removeObserver(obs, "domwindowopened");
-      resolve(win);
+        if (win.location.href !== url) {
+          info("ignoring a window with this url: " + win.location.href);
+          return;
+        }
+
+        Services.obs.removeObserver(obs, "domwindowopened");
+        resolve(win);
+      });
     }, "domwindowopened", false);
   });
 }
 
+function promiseIndicatorWindow() {
+  // We don't show the indicator window on Mac.
+  if ("nsISystemStatusBar" in Ci)
+    return Promise.resolve();
+
+  return promiseWindow("chrome://browser/content/webrtcIndicator.xul");
+}
+
 function assertWebRTCIndicatorStatus(expected) {
   let ui = Cu.import("resource:///modules/webrtcUI.jsm", {}).webrtcUI;
   let expectedState = expected ? "visible" : "hidden";
   let msg = "WebRTC indicator " + expectedState;
   if (!expected && ui.showGlobalIndicator) {
     // It seems the global indicator is not always removed synchronously
     // in some cases.
     info("waiting for the global indicator to be hidden");
@@ -689,19 +701,16 @@ function assertWebRTCIndicatorStatus(exp
             if (e.target == win.document) {
               win.removeEventListener("unload", arguments.callee);
               resolve();
             }
           }, false);
         });
       }
     }
-    if (expected &&
-        !Services.wm.getMostRecentWindow("Browser:WebRTCGlobalIndicator"))
-      yield promiseWindow("chrome://browser/content/webrtcIndicator.xul");
     let indicator = Services.wm.getEnumerator("Browser:WebRTCGlobalIndicator");
     let hasWindow = indicator.hasMoreElements();
     is(hasWindow, !!expected, "popup " + msg);
     if (hasWindow) {
       let document = indicator.getNext().document;
       let docElt = document.documentElement;
 
       if (document.readyState != "complete") {