backout ba23b2987f38, Bug 679753 - Scratchpad could probably do without the status bar; a=l10n
authorRob Campbell <rcampbell@mozilla.com>
Fri, 14 Oct 2011 09:29:45 -0300
changeset 78726 68799855e85331cf0d0112fe1b3aa8f11f6f7d9e
parent 78725 ca73f057dab701a1e5531744e3349351113ad0bd
child 78727 fef552fcd2fcab54b2598f76118e7f5869ae117b
child 78810 c625f509f7b580a182bcb3b0fd6f4552b433bb73
push id21327
push userrcampbell@mozilla.com
push dateFri, 14 Oct 2011 12:30:08 +0000
treeherdermozilla-central@68799855e853 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersl10n
bugs679753
milestone10.0a1
backs outba23b2987f3823231abdfc88636f0f511cc8ea92
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
backout ba23b2987f38, Bug 679753 - Scratchpad could probably do without the status bar; a=l10n
browser/devtools/scratchpad/scratchpad.js
browser/devtools/scratchpad/scratchpad.xul
browser/devtools/scratchpad/test/browser_scratchpad_bug_646070_chrome_context_pref.js
browser/devtools/scratchpad/test/browser_scratchpad_contexts.js
browser/devtools/scratchpad/test/browser_scratchpad_initialization.js
browser/devtools/scratchpad/test/browser_scratchpad_tab_switch.js
browser/devtools/scratchpad/test/browser_scratchpad_ui.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()
   {
@@ -665,24 +652,27 @@ var Scratchpad = {
    * @param nsIDOMEvent aEvent
    */
   onLoad: function SP_onLoad(aEvent)
   {
     if (aEvent.target != document) {
       return;
     }
 
+    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) {
-      let environmentMenu = document.getElementById("sp-environment-menu");
-      let errorConsoleCommand = document.getElementById("sp-cmd-errorConsole");
-      let chromeContextCommand = document.getElementById("sp-cmd-browserContext");
-      environmentMenu.removeAttribute("hidden");
+      chromeContextMenu.removeAttribute("hidden");
+      errorConsoleMenu.removeAttribute("hidden");
+      errorConsoleCommand.removeAttribute("disabled");
       chromeContextCommand.removeAttribute("disabled");
-      errorConsoleCommand.removeAttribute("disabled");
     }
 
     this.editor = new SourceEditor();
 
     let config = {
       mode: SourceEditor.MODES.JAVASCRIPT,
       showLineNumbers: true,
       placeholderText: this.strings.GetStringFromName("scratchpadIntro"),
--- a/browser/devtools/scratchpad/scratchpad.xul
+++ b/browser/devtools/scratchpad/scratchpad.xul
@@ -256,40 +256,56 @@
                 accesskey="&inspect.accesskey;"
                 key="sp-key-inspect"
                 command="sp-cmd-inspect"/>
       <menuitem id="sp-text-display"
                 label="&display.label;"
                 accesskey="&display.accesskey;"
                 key="sp-key-display"
                 command="sp-cmd-display"/>
-      <menuseparator/>
-      <menuitem id="sp-text-resetContext"
-                label="&resetContext.label;"
-                accesskey="&resetContext.accesskey;"
-                command="sp-cmd-resetContext"/>
     </menupopup>
   </menu>
 
   <menu id="sp-environment-menu"
         label="&environmentMenu.label;"
-        accesskey="&environmentMenu.accesskey;"
-        hidden="true">
+        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"
+      <menuitem id="sp-menu-browser" hidden="true"
                 command="sp-cmd-browserContext"
                 label="&browserContext.label;"
                 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" 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"
+                command="sp-cmd-webConsole"/>
     </menupopup>
   </menu>
 </menubar>
 
 <popupset id="scratchpad-popups">
   <menupopup id="scratchpad-text-popup">
     <menuitem id="menu_cut"/>
     <menuitem id="menu_copy"/>
@@ -308,21 +324,20 @@
               accesskey="&inspect.accesskey;"
               key="sp-key-inspect"
               command="sp-cmd-inspect"/>
     <menuitem id="sp-text-display"
               label="&display.label;"
               accesskey="&display.accesskey;"
               key="sp-key-display"
               command="sp-cmd-display"/>
-    <menuseparator/>
-    <menuitem id="sp-text-resetContext"
-              label="&resetContext.label;"
-              accesskey="&resetContext.accesskey;"
-              command="sp-cmd-resetContext"/>
   </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_bug_646070_chrome_context_pref.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_bug_646070_chrome_context_pref.js
@@ -30,28 +30,34 @@ function test()
 
 function runTests()
 {
   gScratchpadWindow.removeEventListener("load", arguments.callee, false);
 
   let sp = gScratchpadWindow.Scratchpad;
   ok(sp, "Scratchpad object exists in new window");
 
-  let environmentMenu = gScratchpadWindow.document.
-                          getElementById("sp-environment-menu");
-  ok(environmentMenu, "Environment menu element exists");
-  ok(!environmentMenu.hasAttribute("hidden"),
-     "Environment menu is visible");
+  let chromeContextMenu = gScratchpadWindow.document.
+                          getElementById("sp-menu-browser");
+  ok(chromeContextMenu, "Chrome context menuitem element exists");
+  ok(!chromeContextMenu.hasAttribute("hidden"),
+     "Chrome context menuitem is visible");
 
   let errorConsoleCommand = gScratchpadWindow.document.
                             getElementById("sp-cmd-errorConsole");
   ok(errorConsoleCommand, "Error console command element exists");
   ok(!errorConsoleCommand.hasAttribute("disabled"),
      "Error console command is enabled");
 
+  let errorConsoleMenu = gScratchpadWindow.document.
+                         getElementById("sp-menu-errorConsole");
+  ok(errorConsoleMenu, "Error console menu element exists");
+  ok(!errorConsoleMenu.hasAttribute("hidden"),
+     "Error console menuitem is visible");
+
   let chromeContextCommand = gScratchpadWindow.document.
                             getElementById("sp-cmd-browserContext");
   ok(chromeContextCommand, "Chrome context command element exists");
   ok(!chromeContextCommand.hasAttribute("disabled"),
      "Chrome context command is disabled");
 
   Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, gOldPref);
 
--- 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_initialization.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_initialization.js
@@ -27,28 +27,34 @@ function runTests()
   gScratchpadWindow.removeEventListener("load", arguments.callee, false);
 
   let sp = gScratchpadWindow.Scratchpad;
   ok(sp, "Scratchpad object exists in new window");
   is(typeof sp.run, "function", "Scratchpad.run() exists");
   is(typeof sp.inspect, "function", "Scratchpad.inspect() exists");
   is(typeof sp.display, "function", "Scratchpad.display() exists");
 
-  let environmentMenu = gScratchpadWindow.document.
-                          getElementById("sp-environment-menu");
-  ok(environmentMenu, "Environment menu element exists");
-  ok(environmentMenu.hasAttribute("hidden"),
-     "Environment menu is not visible");
+  let chromeContextMenu = gScratchpadWindow.document.
+                          getElementById("sp-menu-browser");
+  ok(chromeContextMenu, "Chrome context menuitem element exists");
+  is(chromeContextMenu.getAttribute("hidden"), "true",
+     "Chrome context menuitem is hidden");
 
   let errorConsoleCommand = gScratchpadWindow.document.
                             getElementById("sp-cmd-errorConsole");
   ok(errorConsoleCommand, "Error console command element exists");
   is(errorConsoleCommand.getAttribute("disabled"), "true",
      "Error console command is disabled");
 
+  let errorConsoleMenu = gScratchpadWindow.document.
+                         getElementById("sp-menu-errorConsole");
+  ok(errorConsoleMenu, "Error console menu element exists");
+  is(errorConsoleMenu.getAttribute("hidden"), "true",
+     "Error console menu item is hidden");
+
   let chromeContextCommand = gScratchpadWindow.document.
                             getElementById("sp-cmd-browserContext");
   ok(chromeContextCommand, "Chrome context command element exists");
   is(chromeContextCommand.getAttribute("disabled"), "true",
      "Chrome context command is disabled");
 
   gScratchpadWindow.close();
   gScratchpadWindow = null;
--- 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");
 
-  is(notificationBox.currentNotification, null,
-     "there is no notification currently shown for 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/devtools/scratchpad/test/browser_scratchpad_ui.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_ui.js
@@ -31,19 +31,21 @@ function runTests()
   let methodsAndItems = {
     "sp-menu-newscratchpad": "openScratchpad",
     "sp-menu-open": "openFile",
     "sp-menu-save": "saveFile",
     "sp-menu-saveas": "saveFileAs",
     "sp-text-run": "run",
     "sp-text-inspect": "inspect",
     "sp-text-display": "display",
-    "sp-text-resetContext": "resetContext",
     "sp-menu-content": "setContentContext",
     "sp-menu-browser": "setBrowserContext",
+    "sp-menu-resetContext": "resetContext",
+    "sp-menu-errorConsole": "openErrorConsole",
+    "sp-menu-webConsole": "openWebConsole",
     "sp-menu-undo": "undo",
     "sp-menu-redo": "redo",
   };
 
   let lastMethodCalled = null;
   sp.__noSuchMethod__ = function(aMethodName) {
     lastMethodCalled = aMethodName;
   };
--- a/browser/locales/en-US/chrome/browser/scratchpad.dtd
+++ b/browser/locales/en-US/chrome/browser/scratchpad.dtd
@@ -93,19 +93,24 @@
   -  was called "Chrome".
   -->
 <!ENTITY browserContext.label         "Browser">
 <!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 Variables">
-<!ENTITY resetContext.accesskey       "T">
+<!ENTITY resetContext.label           "Reset">
+<!ENTITY resetContext.accesskey       "R">
 
 <!ENTITY executeMenu.label            "Execute">
 <!ENTITY executeMenu.accesskey        "X">
 
+<!ENTITY toolsMenu.label              "Tools">
+<!ENTITY toolsMenu.accesskey          "T">
+
 <!ENTITY errorConsoleCmd.label        "Error Console">
+<!ENTITY errorConsoleCmd.accesskey    "C">
 <!ENTITY errorConsoleCmd.commandkey   "j">
 
 <!ENTITY webConsoleCmd.label          "Web Console">
+<!ENTITY webConsoleCmd.accesskey      "W">
 <!ENTITY webConsoleCmd.commandkey     "k">
--- 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.