Bug 1374640 - always prompt for screen sharing. r=florian,jib a=jcristau
authorMunro Mengjue Chiang <mchiang@mozilla.com>
Thu, 29 Jun 2017 15:50:30 -0700
changeset 414266 2f1f99506678fe2d72500e1b68866bef34ebd510
parent 414265 5d0c516a2b0d56487899e47899933b3cbf86e589
child 414267 6fb3245ab49779cc7ed82e0354a125f32ab30600
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian, jib, jcristau
bugs1374640
milestone55.0
Bug 1374640 - always prompt for screen sharing. r=florian,jib a=jcristau MozReview-Commit-ID: FJvuf2XVZXJ
browser/base/content/test/webrtc/browser_devices_get_user_media_screen.js
browser/modules/webrtcUI.jsm
--- 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
@@ -77,16 +77,33 @@ var gTests = [
     });
     await expectObserverCalled("getUserMedia:response:allow");
     await expectObserverCalled("recording-device-events");
     Assert.deepEqual((await getMediaCaptureState()), {screen: "Screen"},
                      "expected screen to be shared");
 
     await indicator;
     await checkSharingUI({screen: "Screen"});
+
+    // we always show prompt for screen sharing.
+    promise = promisePopupNotificationShown("webRTC-shareDevices");
+    await promiseRequestDevice(false, true, null, "screen");
+    await promise;
+    await expectObserverCalled("getUserMedia:request");
+
+    is(PopupNotifications.getNotification("webRTC-shareDevices").anchorID,
+       "webRTC-shareScreen-notification-icon", "anchored to device icon");
+    checkDeviceSelectors(false, false, true);
+
+    await promiseMessage(permissionError, () => {
+      PopupNotifications.panel.firstChild.button.click();
+    });
+
+    await expectObserverCalled("getUserMedia:response:deny");
+    SitePermissions.remove(null, "screen", gBrowser.selectedBrowser);
     await closeStream();
   }
 },
 
 {
   desc: "getUserMedia window only",
   run: async function checkWindowOnly() {
     let promise = promisePopupNotificationShown("webRTC-shareDevices");
--- a/browser/modules/webrtcUI.jsm
+++ b/browser/modules/webrtcUI.jsm
@@ -474,29 +474,32 @@ function prompt(aBrowser, aRequest) {
 
         // Screen sharing shouldn't follow the camera permissions.
         if (videoDevices.length && sharingScreen)
           camAllowed = false;
 
         let activeCamera;
         let activeMic;
 
-        for (let device of videoDevices) {
-          let set = webrtcUI.activePerms.get(aBrowser.outerWindowID);
-          if (set && set.has(aRequest.windowID + device.mediaSource + device.id)) {
-            activeCamera = device;
-            break;
+        // Always prompt for screen sharing
+        if (!sharingScreen) {
+          for (let device of videoDevices) {
+            let set = webrtcUI.activePerms.get(aBrowser.outerWindowID);
+            if (set && set.has(aRequest.windowID + device.mediaSource + device.id)) {
+              activeCamera = device;
+              break;
+            }
           }
-        }
 
-        for (let device of audioDevices) {
-          let set = webrtcUI.activePerms.get(aBrowser.outerWindowID);
-          if (set && set.has(aRequest.windowID + device.mediaSource + device.id)) {
-            activeMic = device;
-            break;
+          for (let device of audioDevices) {
+            let set = webrtcUI.activePerms.get(aBrowser.outerWindowID);
+            if (set && set.has(aRequest.windowID + device.mediaSource + device.id)) {
+              activeMic = device;
+              break;
+            }
           }
         }
 
         if ((!audioDevices.length || micAllowed || activeMic) &&
             (!videoDevices.length || camAllowed || activeCamera)) {
           let allowedDevices = [];
           if (videoDevices.length) {
             allowedDevices.push((activeCamera || videoDevices[0]).deviceIndex);