Bug 1311358 - Add error notification for RDM with container tabs. r=ntim
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 19 Oct 2016 08:53:10 -0500
changeset 318621 455c709178a6a84c81c8fa963a956ac1dcb1673b
parent 318620 c30204f93da8fb0a4fd29f3d1276593bbe1d7cff
child 318622 babb18c5b2a7af9f9fe5c1c8e88d580f48d3a001
push id20725
push userphilringnalda@gmail.com
push dateThu, 20 Oct 2016 01:36:01 +0000
treeherderfx-team@998ad5a74da8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersntim
bugs1311358
milestone52.0a1
Bug 1311358 - Add error notification for RDM with container tabs. r=ntim MozReview-Commit-ID: DPDGaHQzuYq
devtools/client/locales/en-US/responsive.properties
devtools/client/responsive.html/manager.js
--- a/devtools/client/locales/en-US/responsive.properties
+++ b/devtools/client/locales/en-US/responsive.properties
@@ -54,13 +54,18 @@ responsive.screenshot=Take a screenshot 
 # second argument (%2$S) is the time string in HH.MM.SS format.
 responsive.screenshotGeneratedFilename=Screen Shot %1$S at %2$S
 
 # LOCALIZATION NOTE (responsive.remoteOnly): Message displayed in the tab's
 # notification box if a user tries to open Responsive Design Mode in a
 # non-remote tab.
 responsive.remoteOnly=Responsive Design Mode is only available for remote browser tabs, such as those used for web content in multi-process Firefox.
 
+# LOCALIZATION NOTE (responsive.noContainerTabs): Message displayed in the tab's
+# notification box if a user tries to open Responsive Design Mode in a
+# container tab.
+responsive.noContainerTabs=Responsive Design Mode is currently unavailable in container tabs.
+
 # LOCALIZATION NOTE (responsive.noThrottling): UI option in a menu to configure
 # network throttling.  This option is the default and disables throttling so you
 # just have normal network conditions.  There is not very much room in the UI
 # so a short string would be best if possible.
 responsive.noThrottling=No throttling
--- a/devtools/client/responsive.html/manager.js
+++ b/devtools/client/responsive.html/manager.js
@@ -71,16 +71,21 @@ const ResponsiveUIManager = exports.Resp
    *         Resolved to the ResponsiveUI instance for this tab when opening is
    *         complete.
    */
   openIfNeeded: Task.async(function* (window, tab, options) {
     if (!tab.linkedBrowser.isRemoteBrowser) {
       this.showRemoteOnlyNotification(window, tab, options);
       return promise.reject(new Error("RDM only available for remote tabs."));
     }
+    // Remove this once we support this case in bug 1306975.
+    if (tab.linkedBrowser.hasAttribute("usercontextid")) {
+      this.showNoContainerTabsNotification(window, tab, options);
+      return promise.reject(new Error("RDM not available for container tabs."));
+    }
     if (!this.isActiveForTab(tab)) {
       this.initMenuCheckListenerFor(window);
 
       let ui = new ResponsiveUI(window, tab);
       this.activeTabs.set(tab, ui);
       yield this.setMenuCheckFor(tab, window);
       yield ui.inited;
       this.emit("on", { tab });
@@ -208,39 +213,48 @@ const ResponsiveUIManager = exports.Resp
     yield startup(window);
 
     let menu = window.document.getElementById("menu_responsiveUI");
     if (menu) {
       menu.setAttribute("checked", this.isActiveForTab(tab));
     }
   }),
 
-  showRemoteOnlyNotification(window, tab, { command } = {}) {
+  showRemoteOnlyNotification(window, tab, options) {
+    this.showErrorNotification(window, tab, options, getStr("responsive.remoteOnly"));
+  },
+
+  showNoContainerTabsNotification(window, tab, options) {
+    this.showErrorNotification(window, tab, options,
+                               getStr("responsive.noContainerTabs"));
+  },
+
+  showErrorNotification(window, tab, { command } = {}, msg) {
     // Default to using the browser's per-tab notification box
     let nbox = window.gBrowser.getNotificationBox(tab.linkedBrowser);
 
     // If opening was initiated by GCLI command bar or toolbox button, check for an open
     // toolbox for the tab.  If one exists, use the toolbox's notification box so that the
     // message is placed closer to the action taken by the user.
     if (command) {
       let target = TargetFactory.forTab(tab);
       let toolbox = gDevTools.getToolbox(target);
       if (toolbox) {
         nbox = toolbox.notificationBox;
       }
     }
 
-    let value = "devtools-responsive-remote-only";
+    let value = "devtools-responsive-error";
     if (nbox.getNotificationWithValue(value)) {
       // Notification already displayed
       return;
     }
 
     nbox.appendNotification(
-       getStr("responsive.remoteOnly"),
+       msg,
        value,
        null,
        nbox.PRIORITY_CRITICAL_MEDIUM,
        []);
   },
 };
 
 // GCLI commands in ../responsivedesign/resize-commands.js listen for events