Bug 1311358 - Add error notification for RDM with container tabs. r=ntim draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 19 Oct 2016 08:53:10 -0500
changeset 427106 5329239ef212afd3f641f86c5be1e1bd0242be82
parent 426004 7c8216f48c38a8498f251fe044509b930af44de6
child 534381 658c16a6305e9374c8dcb878b36893ccc2a58756
push id32923
push userbmo:jryans@gmail.com
push dateWed, 19 Oct 2016 19:14:00 +0000
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