Backed out changeset 77b01f2bda7f (bug 1320375)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 28 Nov 2016 15:56:41 +0100
changeset 371689 f905fe26e901bc325828d8780f2007454fbb97e3
parent 371688 d2a6721fbbde1f38a29fde87f13bbb49fed49706
child 371690 7b6efd0556202afe260177485214d727377b446e
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1320375
milestone53.0a1
backs out77b01f2bda7f4737ad3573103c05ccea895d1a39
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
Backed out changeset 77b01f2bda7f (bug 1320375)
browser/base/content/test/webrtc/browser_devices_get_user_media.js
browser/base/content/webrtcIndicator.js
browser/modules/webrtcUI.jsm
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media.js
@@ -450,17 +450,17 @@ var gTests = [
     is((yield getMediaCaptureState()), "Camera", "expected camera to be shared");
 
     yield indicator;
     yield checkSharingUI({video: true});
 
     ok(gIdentityHandler._identityPopup.hidden, "control center should be hidden");
     if ("nsISystemStatusBar" in Ci) {
       let activeStreams = webrtcUI.getActiveStreams(true, false, false);
-      webrtcUI.showSharingDoorhanger(activeStreams[0]);
+      webrtcUI.showSharingDoorhanger(activeStreams[0], "Devices");
     }
     else {
       let win =
         Services.wm.getMostRecentWindow("Browser:WebRTCGlobalIndicator");
       let elt = win.document.getElementById("audioVideoButton");
       EventUtils.synthesizeMouseAtCenter(elt, {}, win);
       yield promiseWaitForCondition(() => !gIdentityHandler._identityPopup.hidden);
     }
--- a/browser/base/content/webrtcIndicator.js
+++ b/browser/base/content/webrtcIndicator.js
@@ -83,25 +83,26 @@ function updateWindowAttr(attr, value) {
   if (value)
     docEl.setAttribute(attr, "true");
   else
     docEl.removeAttribute(attr);
 }
 
 function onPopupMenuShowing(event) {
   let popup = event.target;
+  let type = popup.getAttribute("type");
 
   let activeStreams;
-  if (popup.getAttribute("type") == "Devices")
+  if (type == "Devices")
     activeStreams = webrtcUI.getActiveStreams(true, true, false);
   else
     activeStreams = webrtcUI.getActiveStreams(false, false, true);
 
   if (activeStreams.length == 1) {
-    webrtcUI.showSharingDoorhanger(activeStreams[0]);
+    webrtcUI.showSharingDoorhanger(activeStreams[0], type);
     event.preventDefault();
     return;
   }
 
   for (let stream of activeStreams) {
     let item = document.createElement("menuitem");
     item.setAttribute("label", stream.browser.contentTitle || stream.uri);
     item.setAttribute("tooltiptext", stream.uri);
@@ -112,17 +113,19 @@ function onPopupMenuShowing(event) {
 
 function onPopupMenuHiding(event) {
   let popup = event.target;
   while (popup.firstChild)
     popup.firstChild.remove();
 }
 
 function onPopupMenuCommand(event) {
-  webrtcUI.showSharingDoorhanger(event.target.stream);
+  let item = event.target;
+  webrtcUI.showSharingDoorhanger(item.stream,
+                                 item.parentNode.getAttribute("type"));
 }
 
 function onFirefoxButtonClick(event) {
   event.target.blur();
   let activeStreams = webrtcUI.getActiveStreams(true, true, true);
   activeStreams[0].browser.ownerGlobal.focus();
 }
 
--- a/browser/modules/webrtcUI.jsm
+++ b/browser/modules/webrtcUI.jsm
@@ -131,17 +131,17 @@ this.webrtcUI = {
         stream.browser = aNewBrowser;
     }
   },
 
   forgetStreamsFromBrowser: function(aBrowser) {
     this._streams = this._streams.filter(stream => stream.browser != aBrowser);
   },
 
-  showSharingDoorhanger: function(aActiveStream) {
+  showSharingDoorhanger: function(aActiveStream, aType) {
     let browserWindow = aActiveStream.browser.ownerGlobal;
     if (aActiveStream.tab) {
       browserWindow.gBrowser.selectedTab = aActiveStream.tab;
     } else {
       aActiveStream.browser.focus();
     }
     browserWindow.focus();
     let identityBox = browserWindow.document.getElementById("identity-box");
@@ -692,17 +692,22 @@ function getGlobalIndicator() {
 
     _hiddenDoc: Cc["@mozilla.org/appshell/appShellService;1"]
                   .getService(Ci.nsIAppShellService)
                   .hiddenDOMWindow.document,
     _statusBar: Cc["@mozilla.org/widget/macsystemstatusbar;1"]
                   .getService(Ci.nsISystemStatusBar),
 
     _command: function(aEvent) {
-      webrtcUI.showSharingDoorhanger(aEvent.target.stream);
+      let type = this.getAttribute("type");
+      if (type == "Camera" || type == "Microphone")
+        type = "Devices";
+      else if (type == "Window" || type == "Application" || type == "Browser")
+        type = "Screen";
+      webrtcUI.showSharingDoorhanger(aEvent.target.stream, type);
     },
 
     _popupShowing: function(aEvent) {
       let type = this.getAttribute("type");
       let activeStreams;
       if (type == "Camera") {
         activeStreams = webrtcUI.getActiveStreams(true, false, false);
       }
@@ -725,16 +730,17 @@ function getGlobalIndicator() {
         let label = stream.browser.contentTitle || stream.uri;
         menuitem.setAttribute("label", bundle.formatStringFromName(labelId, [label], 1));
         menuitem.setAttribute("disabled", "true");
         this.appendChild(menuitem);
 
         menuitem = this.ownerDocument.createElement("menuitem");
         menuitem.setAttribute("label",
                               bundle.GetStringFromName("webrtcIndicator.controlSharing.menuitem"));
+        menuitem.setAttribute("type", type);
         menuitem.stream = stream;
         menuitem.addEventListener("command", indicator._command);
 
         this.appendChild(menuitem);
         return true;
       }
 
       // We show a different menu when there are several active streams.
@@ -746,16 +752,17 @@ function getGlobalIndicator() {
       menuitem.setAttribute("disabled", "true");
       this.appendChild(menuitem);
 
       for (let stream of activeStreams) {
         let item = this.ownerDocument.createElement("menuitem");
         labelId = "webrtcIndicator.controlSharingOn.menuitem";
         label = stream.browser.contentTitle || stream.uri;
         item.setAttribute("label", bundle.formatStringFromName(labelId, [label], 1));
+        item.setAttribute("type", type);
         item.stream = stream;
         item.addEventListener("command", indicator._command);
         this.appendChild(item);
       }
 
       return true;
     },
 
@@ -820,28 +827,40 @@ function onTabSharingMenuPopupShowing(e)
 
     let doc = e.target.ownerDocument;
     let bundle = doc.defaultView.gNavigatorBundle;
 
     let origin = getHost(null, streamInfo.uri);
     let menuitem = doc.createElement("menuitem");
     menuitem.setAttribute("label", bundle.getFormattedString(stringName, [origin]));
     menuitem.stream = streamInfo;
+
+    // We can only open 1 doorhanger at a time. Guessing that users would be
+    // most eager to control screen/window/app sharing, and only then
+    // camera/microphone sharing, in that (decreasing) order of priority.
+    let doorhangerType;
+    if ((/Screen|Window|Application/).test(stringName)) {
+      doorhangerType = "Screen";
+    } else {
+      doorhangerType = "Devices";
+    }
+    menuitem.setAttribute("doorhangertype", doorhangerType);
     menuitem.addEventListener("command", onTabSharingMenuPopupCommand);
     e.target.appendChild(menuitem);
   }
 }
 
 function onTabSharingMenuPopupHiding(e) {
   while (this.lastChild)
     this.lastChild.remove();
 }
 
 function onTabSharingMenuPopupCommand(e) {
-  webrtcUI.showSharingDoorhanger(e.target.stream);
+  let type = e.target.getAttribute("doorhangertype");
+  webrtcUI.showSharingDoorhanger(e.target.stream, type);
 }
 
 function showOrCreateMenuForWindow(aWindow) {
   let document = aWindow.document;
   let menu = document.getElementById("tabSharingMenu");
   if (!menu) {
     let stringBundle = aWindow.gNavigatorBundle;
     menu = document.createElement("menu");