Bug 1320994 - Remove chrome-test hacks that accomodated the misaligned MediaManager model. r?florian draft
authorAndreas Pehrson <pehrsons@gmail.com>
Fri, 07 Apr 2017 15:30:43 +0200
changeset 572750 aaee13c926fe82ca010168557624912571292a8f
parent 572749 ca7ef5d9e197e7c0cc07d9e76f9e16f336914771
child 572751 f15c16b361171603783ce0b5f1defd128a89144c
push id57178
push userbmo:pehrson@telenordigital.com
push dateThu, 04 May 2017 17:44:26 +0000
reviewersflorian
bugs1320994
milestone55.0a1
Bug 1320994 - Remove chrome-test hacks that accomodated the misaligned MediaManager model. r?florian MozReview-Commit-ID: BS693gGyVhm
browser/base/content/test/webrtc/browser_devices_get_user_media_screen.js
browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access.js
browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_in_frame.js
browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_tear_off_tab.js
browser/base/content/test/webrtc/head.js
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media_screen.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_screen.js
@@ -405,30 +405,30 @@ var gTests = [
     yield share(false, true);
     yield check({video: true, audio: true, screen: "Screen"});
 
     info("Stop the screen share, mic+cam should continue");
     yield stopSharing("screen", true);
     yield check({video: true, audio: true});
 
     info("Stop the camera, everything should stop.");
-    yield stopSharing("camera", false, true);
+    yield stopSharing("camera");
 
     info("Now, share only the screen...");
     indicator = promiseIndicatorWindow();
     yield share(false, false, true);
     yield indicator;
     yield check({screen: "Screen"});
 
     info("... and add camera and microphone in a second request.");
     yield share(true, true);
     yield check({video: true, audio: true, screen: "Screen"});
 
     info("Stop the camera, this should stop everything.");
-    yield stopSharing("camera", false, true);
+    yield stopSharing("camera");
   }
 },
 
 {
   desc: "getUserMedia screen: reloading the page removes all gUM UI",
   run: function* checkReloading() {
     let promise = promisePopupNotificationShown("webRTC-shareDevices");
     yield promiseRequestDevice(false, true, null, "screen");
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access.js
@@ -57,17 +57,17 @@ var gTests = [
     });
 
     yield expectObserverCalled("getUserMedia:response:deny");
     SitePermissions.remove(null, "screen", gBrowser.selectedBrowser);
     SitePermissions.remove(null, "camera", gBrowser.selectedBrowser);
     SitePermissions.remove(null, "microphone", gBrowser.selectedBrowser);
 
     // After closing all streams, gUM(audio+camera) causes a prompt.
-    yield closeStream(false, 0, 2);
+    yield closeStream();
     promise = promisePopupNotificationShown("webRTC-shareDevices");
     yield promiseRequestDevice(true, true);
     yield promise;
     yield expectObserverCalled("getUserMedia:request");
     checkDeviceSelectors(true, true);
 
     yield promiseMessage(permissionError, () => {
       activateSecondaryAction(kActionDeny);
@@ -164,17 +164,17 @@ var gTests = [
     yield expectObserverCalled("recording-device-events");
 
     Assert.deepEqual((yield getMediaCaptureState()), {video: true},
                      "expected camera to be shared");
 
     yield checkSharingUI({audio: false, video: true});
 
     // close all streams
-    yield closeStream(false, 0, 2);
+    yield closeStream();
   }
 },
 
 {
   desc: "getUserMedia audio",
   run: function* checkAudioVideoWhileLiveTracksExist_audio() {
     let promise = promisePopupNotificationShown("webRTC-shareDevices");
     yield promiseRequestDevice(true, false);
@@ -236,17 +236,17 @@ var gTests = [
     yield expectObserverCalled("recording-device-events");
 
     Assert.deepEqual((yield getMediaCaptureState()), {audio: true},
                      "expected microphone to be shared");
 
     yield checkSharingUI({audio: true, video: false});
 
     // close all streams
-    yield closeStream(false, 0, 2);
+    yield closeStream();
   }
 }
 
 ];
 
 add_task(async function test() {
   await runTests(gTests);
 });
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_in_frame.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_in_frame.js
@@ -52,17 +52,17 @@ var gTests = [
     yield promiseRequestDevice(true, true, "frame1");
     yield promise;
     yield expectObserverCalled("getUserMedia:request");
     yield promiseNoPopupNotification("webRTC-shareDevices");
     yield expectObserverCalled("getUserMedia:response:allow");
     yield expectObserverCalled("recording-device-events");
 
     // close the stream
-    yield closeStream(false, "frame1", 2);
+    yield closeStream(false, "frame1");
   }
 },
 
 {
   desc: "getUserMedia audio+camera in frame 1 - part II",
   run: function* checkAudioVideoWhileLiveTracksExist_frame_partII() {
     let promise = promisePopupNotificationShown("webRTC-shareDevices");
     yield promiseRequestDevice(true, true, "frame1");
@@ -192,17 +192,17 @@ var gTests = [
     yield promiseMessage(permissionError, () => {
       activateSecondaryAction(kActionDeny);
     });
 
     yield expectObserverCalled("getUserMedia:response:deny");
     yield expectObserverCalled("recording-window-ended");
 
     // close the stream
-    yield closeStream(false);
+    yield closeStream();
     SitePermissions.remove(null, "screen", gBrowser.selectedBrowser);
     SitePermissions.remove(null, "camera", gBrowser.selectedBrowser);
     SitePermissions.remove(null, "microphone", gBrowser.selectedBrowser);
   }
 }
 
 ];
 
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_tear_off_tab.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_tear_off_tab.js
@@ -36,17 +36,16 @@ var gTests = [
     yield promiseRequestDevice(true, true, null, null, win.gBrowser.selectedBrowser);
     yield promiseObserverCalled("getUserMedia:request");
     let promises = [promiseNoPopupNotification("webRTC-shareDevices"),
                     promiseObserverCalled("getUserMedia:response:allow"),
                     promiseObserverCalled("recording-device-events")];
     yield Promise.all(promises);
 
     promises = [promiseObserverCalled("recording-device-events"),
-                promiseObserverCalled("recording-device-events"),
                 promiseObserverCalled("recording-window-ended")];
     yield BrowserTestUtils.closeWindow(win);
     yield Promise.all(promises);
 
     yield checkNotSharing();
   }
 }
 
--- a/browser/base/content/test/webrtc/head.js
+++ b/browser/base/content/test/webrtc/head.js
@@ -210,35 +210,27 @@ function expectObserverCalled(aTopic) {
       is(data.count, 1, "expected notification " + aTopic);
       mm.removeMessageListener("Test:ExpectObserverCalled:Reply", listener);
       resolve();
     });
     mm.sendAsyncMessage("Test:ExpectObserverCalled", aTopic);
   });
 }
 
-function expectNoObserverCalled(aIgnoreDeviceEvents = false) {
+function expectNoObserverCalled() {
   return new Promise(resolve => {
     let mm = _mm();
     mm.addMessageListener("Test:ExpectNoObserverCalled:Reply",
                           function listener({data}) {
       mm.removeMessageListener("Test:ExpectNoObserverCalled:Reply", listener);
       for (let topic in data) {
         if (!data[topic])
           continue;
 
-        // If we are stopping tracks that were created from 2 different
-        // getUserMedia calls, the "recording-device-events" notification is
-        // fired twice on Windows and Mac, and intermittently twice on Linux.
-        if (topic == "recording-device-events" && aIgnoreDeviceEvents) {
-          todo(false, "Got " + data[topic] + " unexpected " + topic +
-               " notifications, see bug 1320994");
-        } else {
-          is(data[topic], 0, topic + " notification unexpected");
-        }
+        is(data[topic], 0, topic + " notification unexpected");
       }
       resolve();
     });
     mm.sendAsyncMessage("Test:ExpectNoObserverCalled");
   });
 }
 
 function ignoreObserversCalled() {
@@ -349,35 +341,34 @@ function getMediaCaptureState() {
     let mm = _mm();
     mm.addMessageListener("Test:MediaCaptureState", ({data}) => {
       resolve(data);
     });
     mm.sendAsyncMessage("Test:GetMediaCaptureState");
   });
 }
 
-function* stopSharing(aType = "camera", aShouldKeepSharing = false,
-                      aExpectDoubleRecordingEvent = false) {
+function* stopSharing(aType = "camera", aShouldKeepSharing = false) {
   let promiseRecordingEvent = promiseObserverCalled("recording-device-events");
   gIdentityHandler._identityBox.click();
   let permissions = document.getElementById("identity-popup-permission-list");
   let cancelButton =
     permissions.querySelector(".identity-popup-permission-icon." + aType + "-icon ~ " +
                               ".identity-popup-permission-remove-button");
   cancelButton.click();
   gIdentityHandler._identityPopup.hidden = true;
   yield promiseRecordingEvent;
   yield expectObserverCalled("getUserMedia:revoke");
 
   // If we are stopping screen sharing and expect to still have another stream,
   // "recording-window-ended" won't be fired.
   if (!aShouldKeepSharing)
     yield expectObserverCalled("recording-window-ended");
 
-  yield expectNoObserverCalled(aExpectDoubleRecordingEvent);
+  yield expectNoObserverCalled();
 
   if (!aShouldKeepSharing)
     yield* checkNotSharing();
 }
 
 function promiseRequestDevice(aRequestAudio, aRequestVideo, aFrameId, aType,
                               aBrowser = gBrowser.selectedBrowser) {
   info("requesting devices");
@@ -386,26 +377,23 @@ function promiseRequestDevice(aRequestAu
                            function*(args) {
     let global = content.wrappedJSObject;
     if (args.aFrameId)
       global = global.document.getElementById(args.aFrameId).contentWindow;
     global.requestDevice(args.aRequestAudio, args.aRequestVideo, args.aType);
   });
 }
 
-function* closeStream(aAlreadyClosed, aFrameId, aStreamCount = 1) {
+function* closeStream(aAlreadyClosed, aFrameId) {
   yield expectNoObserverCalled();
 
   let promises;
   if (!aAlreadyClosed) {
-    promises = [];
-    for (let i = 0; i < aStreamCount; i++) {
-      promises.push(promiseObserverCalled("recording-device-events"));
-    }
-    promises.push(promiseObserverCalled("recording-window-ended"));
+    promises = [promiseObserverCalled("recording-device-events"),
+                promiseObserverCalled("recording-window-ended")];
   }
 
   info("closing the stream");
   yield ContentTask.spawn(gBrowser.selectedBrowser, aFrameId, function*(contentFrameId) {
     let global = content.wrappedJSObject;
     if (contentFrameId)
       global = global.document.getElementById(contentFrameId).contentWindow;
     global.closeStream();