Backout 7c5e399e8bfb, Bug 679753 - Remove status bar in Scratchpad, a=testfailures
authorRob Campbell <rcampbell@mozilla.com>
Fri, 26 Aug 2011 14:07:29 -0300
changeset 76025 20c17cdc5cb300a721da2d8c25b224f4883be011
parent 76024 062173689eb3e91600008d5ae28e5c3b38f0a4c1
child 76026 61586623c897f4689c0e3c251608a23f1a14cb38
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewerstestfailures
bugs679753
milestone9.0a1
backs out7c5e399e8bfbd892ecbda0b48c87caa8f3d63886
Backout 7c5e399e8bfb, Bug 679753 - Remove status bar in Scratchpad, a=testfailures
browser/devtools/scratchpad/scratchpad.js
browser/devtools/scratchpad/scratchpad.xul
browser/devtools/scratchpad/test/browser_scratchpad_contexts.js
browser/devtools/scratchpad/test/browser_scratchpad_tab_switch.js
browser/locales/en-US/chrome/browser/scratchpad.dtd
browser/locales/en-US/chrome/browser/scratchpad.properties
--- a/browser/devtools/scratchpad/scratchpad.js
+++ b/browser/devtools/scratchpad/scratchpad.js
@@ -79,20 +79,20 @@ var Scratchpad = {
    *   - SCRATCHPAD_CONTEXT_CONTENT to execute code in the context of the current
    *   tab content window object.
    *   - SCRATCHPAD_CONTEXT_BROWSER to execute code in the context of the
    *   currently active chrome window object.
    */
   executionContext: SCRATCHPAD_CONTEXT_CONTENT,
 
   /**
-   * Retrieve the xul:notificationbox DOM element. It notifies the user when
-   * the current code execution context is SCRATCHPAD_CONTEXT_BROWSER.
+   * Retrieve the xul:statusbarpanel DOM element. The status bar tells the
+   * current code execution context.
    */
-  get notificationBox() document.getElementById("scratchpad-notificationbox"),
+  get statusbarStatus() document.getElementById("scratchpad-status"),
 
   /**
    * Get the selected text from the editor.
    *
    * @return string
    *         The selected text.
    */
   get selectedText() this.editor.getSelectedText(),
@@ -594,47 +594,34 @@ var Scratchpad = {
     this.browserWindow.focus();
   },
 
   /**
    * Set the current execution context to be the active tab content window.
    */
   setContentContext: function SP_setContentContext()
   {
-    if (this.executionContext == SCRATCHPAD_CONTEXT_CONTENT) {
-      return;
-    }
-
     let content = document.getElementById("sp-menu-content");
     document.getElementById("sp-menu-browser").removeAttribute("checked");
     content.setAttribute("checked", true);
     this.executionContext = SCRATCHPAD_CONTEXT_CONTENT;
-    this.notificationBox.removeAllNotifications(false);
+    this.statusbarStatus.label = content.getAttribute("label");
     this.resetContext();
   },
 
   /**
    * Set the current execution context to be the most recent chrome window.
    */
   setBrowserContext: function SP_setBrowserContext()
   {
-    if (this.executionContext == SCRATCHPAD_CONTEXT_BROWSER) {
-      return;
-    }
-
     let browser = document.getElementById("sp-menu-browser");
     document.getElementById("sp-menu-content").removeAttribute("checked");
     browser.setAttribute("checked", true);
     this.executionContext = SCRATCHPAD_CONTEXT_BROWSER;
-    this.notificationBox.appendNotification(
-      this.strings.GetStringFromName("browserContext.notification"),
-      SCRATCHPAD_CONTEXT_BROWSER,
-      null,
-      this.notificationBox.PRIORITY_WARNING_HIGH,
-      null);
+    this.statusbarStatus.label = browser.getAttribute("label");
     this.resetContext();
   },
 
   /**
    * Reset the cached Cu.Sandbox object for the current context.
    */
   resetContext: function SP_resetContext()
   {
@@ -672,19 +659,18 @@ var Scratchpad = {
 
     let chromeContextMenu = document.getElementById("sp-menu-browser");
     let errorConsoleMenu = document.getElementById("sp-menu-errorConsole");
     let errorConsoleCommand = document.getElementById("sp-cmd-errorConsole");
     let chromeContextCommand = document.getElementById("sp-cmd-browserContext");
 
     let chrome = Services.prefs.getBoolPref(DEVTOOLS_CHROME_ENABLED);
     if (chrome) {
-      chromeContextMenu.removeAttribute("disabled");
-      chromeContextMenu.removeAttribute("tooltiptext");
-      errorConsoleMenu.removeAttribute("disabled");
+      chromeContextMenu.removeAttribute("hidden");
+      errorConsoleMenu.removeAttribute("hidden");
       errorConsoleCommand.removeAttribute("disabled");
       chromeContextCommand.removeAttribute("disabled");
     }
 
     this.editor = new SourceEditor();
 
     let config = {
       mode: SourceEditor.MODES.JAVASCRIPT,
--- a/browser/devtools/scratchpad/scratchpad.xul
+++ b/browser/devtools/scratchpad/scratchpad.xul
@@ -269,35 +269,34 @@
         accesskey="&environmentMenu.accesskey;">
     <menupopup id="sp-menu-environment">
       <menuitem id="sp-menu-content"
                 label="&contentContext.label;"
                 accesskey="&contentContext.accesskey;"
                 command="sp-cmd-contentContext"
                 checked="true"
                 type="radio"/>
-      <menuitem id="sp-menu-browser" disabled="true"
+      <menuitem id="sp-menu-browser" hidden="true"
                 command="sp-cmd-browserContext"
                 label="&browserContext.label;"
-                tooltiptext="&browserContext.tooltiptext;"
                 accesskey="&browserContext.accesskey;"
                 type="radio"/>
       <menuseparator/>
       <menuitem id="sp-menu-resetContext"
                 command="sp-cmd-resetContext"
                 label="&resetContext.label;"
                 accesskey="&resetContext.accesskey;"/>
     </menupopup>
   </menu>
 
   <menu id="sp-tools-menu"
         label="&toolsMenu.label;"
         accesskey="&toolsMenu.accesskey;">
     <menupopup id="sp-menu-tools">
-      <menuitem id="sp-menu-errorConsole" disabled="true"
+      <menuitem id="sp-menu-errorConsole" hidden="true"
                 label="&errorConsoleCmd.label;"
                 accesskey="&errorConsoleCmd.accesskey;"
                 key="sp-key-errorConsole"
                 command="sp-cmd-errorConsole"/>
       <menuitem id="sp-menu-webConsole"
                 label="&webConsoleCmd.label;"
                 accesskey="&webConsoleCmd.accesskey;"
                 key="sp-key-webConsole"
@@ -328,13 +327,17 @@
     <menuitem id="sp-text-display"
               label="&display.label;"
               accesskey="&display.accesskey;"
               key="sp-key-display"
               command="sp-cmd-display"/>
   </menupopup>
 </popupset>
 
-<notificationbox id="scratchpad-notificationbox" flex="1">
-  <hbox id="scratchpad-editor" flex="1" context="scratchpad-text-popup" />
-</notificationbox>
+<hbox id="scratchpad-editor" flex="1" context="scratchpad-text-popup" />
 
+<statusbar id="scratchpad-statusbar" align="end">
+  <statusbarpanel id="scratchpad-status"
+                  label="&contentContext.label;"
+                  class="statusbarpanel-iconic-text"/>
+  <spacer flex="1"/>
+</statusbar>
 </window>
--- a/browser/devtools/scratchpad/test/browser_scratchpad_contexts.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_contexts.js
@@ -23,35 +23,35 @@ function test()
 function runTests()
 {
   gScratchpadWindow.removeEventListener("load", arguments.callee, false);
 
   let sp = gScratchpadWindow.Scratchpad;
 
   let contentMenu = gScratchpadWindow.document.getElementById("sp-menu-content");
   let chromeMenu = gScratchpadWindow.document.getElementById("sp-menu-browser");
-  let notificationBox = sp.notificationBox;
+  let statusbar = sp.statusbarStatus;
 
   ok(contentMenu, "found #sp-menu-content");
   ok(chromeMenu, "found #sp-menu-browser");
-  ok(notificationBox, "found Scratchpad.notificationBox");
+  ok(statusbar, "found Scratchpad.statusbarStatus");
 
   sp.setContentContext();
 
   is(sp.executionContext, gScratchpadWindow.SCRATCHPAD_CONTEXT_CONTENT,
      "executionContext is content");
 
   is(contentMenu.getAttribute("checked"), "true",
      "content menuitem is checked");
 
   ok(!chromeMenu.hasAttribute("checked"),
      "chrome menuitem is not checked");
 
-  ok(!notificationBox.currentNotification,
-     "there is no notification in content context");
+  is(statusbar.getAttribute("label"), contentMenu.getAttribute("label"),
+     "statusbar label is correct");
 
   sp.setText("window.foobarBug636725 = 'aloha';");
 
   ok(!content.wrappedJSObject.foobarBug636725,
      "no content.foobarBug636725");
 
   sp.run();
 
@@ -64,18 +64,18 @@ function runTests()
      "executionContext is chrome");
 
   is(chromeMenu.getAttribute("checked"), "true",
      "chrome menuitem is checked");
 
   ok(!contentMenu.hasAttribute("checked"),
      "content menuitem is not checked");
 
-  ok(notificationBox.currentNotification,
-     "there is a notification in browser context");
+  is(statusbar.getAttribute("label"), chromeMenu.getAttribute("label"),
+     "statusbar label is correct");
 
   sp.setText("2'", 31, 33);
 
   ok(sp.getText(), "window.foobarBug636725 = 'aloha2';",
      "setText() worked");
 
   ok(!window.foobarBug636725, "no window.foobarBug636725");
 
--- a/browser/devtools/scratchpad/test/browser_scratchpad_tab_switch.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_tab_switch.js
@@ -33,35 +33,35 @@ function test()
 function runTests()
 {
   gScratchpadWindow.removeEventListener("load", runTests, true);
 
   sp = gScratchpadWindow.Scratchpad;
 
   let contentMenu = gScratchpadWindow.document.getElementById("sp-menu-content");
   let browserMenu = gScratchpadWindow.document.getElementById("sp-menu-browser");
-  let notificationBox = sp.notificationBox;
+  let statusbar = sp.statusbarStatus;
 
   ok(contentMenu, "found #sp-menu-content");
   ok(browserMenu, "found #sp-menu-browser");
-  ok(notificationBox, "found Scratchpad.notificationBox");
+  ok(statusbar, "found Scratchpad.statusbarStatus");
 
   sp.setContentContext();
 
   is(sp.executionContext, gScratchpadWindow.SCRATCHPAD_CONTEXT_CONTENT,
      "executionContext is content");
 
   is(contentMenu.getAttribute("checked"), "true",
      "content menuitem is checked");
 
   ok(!browserMenu.hasAttribute("checked"),
      "chrome menuitem is not checked");
 
-  ok(!notificationBox,
-     "there is no notification in content context");
+  is(statusbar.getAttribute("label"), contentMenu.getAttribute("label"),
+     "statusbar label is correct");
 
   sp.setText("window.foosbug653108 = 'aloha';");
 
   ok(!content.wrappedJSObject.foosbug653108,
      "no content.foosbug653108");
 
   sp.run();
 
--- a/browser/locales/en-US/chrome/browser/scratchpad.dtd
+++ b/browser/locales/en-US/chrome/browser/scratchpad.dtd
@@ -88,17 +88,16 @@
 
 <!-- LOCALIZATION NOTE (browserContext.label, accesskey): This menu item is used
   -  to select an execution environment for the browser window itself as opposed
   -  to content. This is a feature for browser and addon developers and only
   -  enabled via the devtools.chrome.enabled preference. Formerly, this label
   -  was called "Chrome".
   -->
 <!ENTITY browserContext.label         "Browser">
-<!ENTITY browserContext.tooltiptext   "To enable this, set devtools.chrome.enabled preference to true in about:config">
 <!ENTITY browserContext.accesskey     "B">
 
 <!-- LOCALIZATION NOTE (resetContext.label): This command allows the developer
   -  to reset/clear the global object of the environment where the code executes.
   -->
 <!ENTITY resetContext.label           "Reset">
 <!ENTITY resetContext.accesskey       "R">
 
--- a/browser/locales/en-US/chrome/browser/scratchpad.properties
+++ b/browser/locales/en-US/chrome/browser/scratchpad.properties
@@ -28,12 +28,8 @@ saveFileAs=Save File As
 # LOCALIZATION NOTE  (saveFile.failed): This is the message displayed when file
 # save fails.
 saveFile.failed=The file save operation failed.
 
 # LOCALIZATION NOTE  (scratchpadIntro): This is a multi-line comment explaining
 # how to use the Scratchpad. Note that this should be a valid JavaScript
 # comment inside /* and */.
 scratchpadIntro=/*\n * This is a JavaScript Scratchpad.\n *\n * Enter some JavaScript, then Right Click or choose from the Execute Menu:\n * 1. Run to evaluate the selected text,\n * 2. Inspect to bring up an Object Inspector on the result, or,\n * 3. Display to insert the result in a comment after the selection.\n */\n\n
-
-# LOCALIZATION NOTE  (notification.browserContext): This is the message displayed
-# over the top of the editor when the user has switched to browser context.
-browserContext.notification=This scratchpad executes in the Browser context.