Bug 657136 - Rename top-level Context menu to something less confusing in Scratchpad; r=mihai.sucan
authorRob Campbell <rcampbell@mozilla.com>
Thu, 19 May 2011 18:10:41 -0300
changeset 69846 ac4c8689e717739894b00f188fe72fdf56c524f0
parent 69845 b00797b2e0b9913adf87d2d45a7a88d7e10143a3
child 69847 2a10e886f3d7a4f43511ba88179bd440cf65b078
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmihai.sucan
bugs657136
milestone6.0a1
Bug 657136 - Rename top-level Context menu to something less confusing in Scratchpad; r=mihai.sucan
browser/base/content/scratchpad.js
browser/base/content/scratchpad.xul
browser/base/content/test/browser_scratchpad_bug_646070_chrome_context_pref.js
browser/base/content/test/browser_scratchpad_contexts.js
browser/base/content/test/browser_scratchpad_initialization.js
browser/base/content/test/browser_scratchpad_ui.js
browser/locales/en-US/chrome/browser/scratchpad.dtd
--- a/browser/base/content/scratchpad.js
+++ b/browser/base/content/scratchpad.js
@@ -53,34 +53,34 @@ const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/NetUtil.jsm");
 Cu.import("resource:///modules/PropertyPanel.jsm");
 
 const SCRATCHPAD_CONTEXT_CONTENT = 1;
-const SCRATCHPAD_CONTEXT_CHROME = 2;
+const SCRATCHPAD_CONTEXT_BROWSER = 2;
 const SCRATCHPAD_WINDOW_URL = "chrome://browser/content/scratchpad.xul";
 const SCRATCHPAD_L10N = "chrome://browser/locale/scratchpad.properties";
 const SCRATCHPAD_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
 const DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled";
 
 /**
  * The scratchpad object handles the Scratchpad window functionality.
  */
 var Scratchpad = {
   /**
    * The script execution context. This tells Scratchpad in which context the
    * script shall execute.
    *
    * Possible values:
    *   - SCRATCHPAD_CONTEXT_CONTENT to execute code in the context of the current
    *   tab content window object.
-   *   - SCRATCHPAD_CONTEXT_CHROME to execute code in the context of the
+   *   - SCRATCHPAD_CONTEXT_BROWSER to execute code in the context of the
    *   currently active chrome window object.
    */
   executionContext: SCRATCHPAD_CONTEXT_CONTENT,
 
   /**
    * Retrieve the xul:textbox DOM element. This element holds the source code
    * the user writes and executes.
    */
@@ -551,33 +551,33 @@ var Scratchpad = {
   },
 
   /**
    * Set the current execution context to be the active tab content window.
    */
   setContentContext: function SP_setContentContext()
   {
     let content = document.getElementById("sp-menu-content");
-    document.getElementById("sp-menu-chrome").removeAttribute("checked");
+    document.getElementById("sp-menu-browser").removeAttribute("checked");
     content.setAttribute("checked", true);
     this.statusbarStatus.label = content.getAttribute("label");
     this.executionContext = SCRATCHPAD_CONTEXT_CONTENT;
     this.resetContext();
   },
 
   /**
    * Set the current execution context to be the most recent chrome window.
    */
-  setChromeContext: function SP_setChromeContext()
+  setBrowserContext: function SP_setBrowserContext()
   {
-    let chrome = document.getElementById("sp-menu-chrome");
+    let chrome = document.getElementById("sp-menu-browser");
     document.getElementById("sp-menu-content").removeAttribute("checked");
     chrome.setAttribute("checked", true);
     this.statusbarStatus.label = chrome.getAttribute("label");
-    this.executionContext = SCRATCHPAD_CONTEXT_CHROME;
+    this.executionContext = SCRATCHPAD_CONTEXT_BROWSER;
     this.resetContext();
   },
 
   /**
    * Reset the cached Cu.Sandbox object for the current context.
    */
   resetContext: function SP_resetContext()
   {
@@ -599,20 +599,20 @@ var Scratchpad = {
            getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
   },
 
   /**
    * The Scratchpad window DOMContentLoaded event handler.
    */
   onLoad: function SP_onLoad()
   {
-    let chromeContextMenu = document.getElementById("sp-menu-chrome");
+    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-chromeContext");
+    let chromeContextCommand = document.getElementById("sp-cmd-browserContext");
 
     let chrome = Services.prefs.getBoolPref(DEVTOOLS_CHROME_ENABLED);
     if (chrome) {
       chromeContextMenu.removeAttribute("hidden");
       errorConsoleMenu.removeAttribute("hidden");
       errorConsoleCommand.removeAttribute("disabled");
       chromeContextCommand.removeAttribute("disabled");
     }
--- a/browser/base/content/scratchpad.xul
+++ b/browser/base/content/scratchpad.xul
@@ -69,17 +69,17 @@
   <command id="sp-cmd-printFile" oncommand="Scratchpad.printFile();" disabled="true"/>
  -->
 
   <command id="sp-cmd-close" oncommand="window.close();"/>
   <command id="sp-cmd-execute" oncommand="Scratchpad.execute();"/>
   <command id="sp-cmd-inspect" oncommand="Scratchpad.inspect();"/>
   <command id="sp-cmd-print" oncommand="Scratchpad.print();"/>
   <command id="sp-cmd-contentContext" oncommand="Scratchpad.setContentContext();"/>
-  <command id="sp-cmd-chromeContext" oncommand="Scratchpad.setChromeContext();" disabled="true"/>
+  <command id="sp-cmd-browserContext" oncommand="Scratchpad.setBrowserContext();" disabled="true"/>
   <command id="sp-cmd-resetContext" oncommand="Scratchpad.resetContext();"/>
   <command id="sp-cmd-errorConsole" oncommand="Scratchpad.openErrorConsole();" disabled="true"/>
   <command id="sp-cmd-webConsole" oncommand="Scratchpad.openWebConsole();"/>
 </commandset>
 
 <keyset id="sp-keyset">
   <key id="sp-key-window"
        key="&newWindowCmd.commandkey;"
@@ -251,30 +251,30 @@
       <menuitem id="sp-text-print"
                 label="&print.label;"
                 accesskey="&print.accesskey;"
                 key="sp-key-print"
                 command="sp-cmd-print"/>
     </menupopup>
   </menu>
 
-  <menu id="sp-context-menu"
-        label="&contextMenu.label;"
-        accesskey="&contextMenu.accesskey;">
-    <menupopup id="sp-menu-context">
+  <menu id="sp-environment-menu"
+        label="&environmentMenu.label;"
+        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-chrome" hidden="true"
-                command="sp-cmd-chromeContext"
-                label="&chromeContext.label;"
-                accesskey="&chromeContext.accesskey;"
+      <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>
--- a/browser/base/content/test/browser_scratchpad_bug_646070_chrome_context_pref.js
+++ b/browser/base/content/test/browser_scratchpad_bug_646070_chrome_context_pref.js
@@ -31,17 +31,17 @@ function test()
 function runTests()
 {
   gScratchpadWindow.removeEventListener("load", arguments.callee, false);
 
   let sp = gScratchpadWindow.Scratchpad;
   ok(sp, "Scratchpad object exists in new window");
 
   let chromeContextMenu = gScratchpadWindow.document.
-                          getElementById("sp-menu-chrome");
+                          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"),
@@ -49,17 +49,17 @@ function runTests()
 
   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-chromeContext");
+                            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);
 
   gScratchpadWindow.close();
   gScratchpadWindow = null;
--- a/browser/base/content/test/browser_scratchpad_contexts.js
+++ b/browser/base/content/test/browser_scratchpad_contexts.js
@@ -22,21 +22,21 @@ 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-chrome");
+  let chromeMenu = gScratchpadWindow.document.getElementById("sp-menu-browser");
   let statusbar = sp.statusbarStatus;
 
   ok(contentMenu, "found #sp-menu-content");
-  ok(chromeMenu, "found #sp-menu-chrome");
+  ok(chromeMenu, "found #sp-menu-browser");
   ok(statusbar, "found Scratchpad.statusbarStatus");
 
   sp.setContentContext();
 
   is(sp.executionContext, gScratchpadWindow.SCRATCHPAD_CONTEXT_CONTENT,
      "executionContext is content");
 
   is(contentMenu.getAttribute("checked"), "true",
@@ -54,19 +54,19 @@ function runTests()
   ok(!content.wrappedJSObject.foobarBug636725,
      "no content.foobarBug636725");
 
   sp.execute();
 
   is(content.wrappedJSObject.foobarBug636725, "aloha",
      "content.foobarBug636725 has been set");
 
-  sp.setChromeContext();
+  sp.setBrowserContext();
 
-  is(sp.executionContext, gScratchpadWindow.SCRATCHPAD_CONTEXT_CHROME,
+  is(sp.executionContext, gScratchpadWindow.SCRATCHPAD_CONTEXT_BROWSER,
      "executionContext is chrome");
 
   is(chromeMenu.getAttribute("checked"), "true",
      "chrome menuitem is checked");
 
   ok(!contentMenu.hasAttribute("checked"),
      "content menuitem is not checked");
 
--- a/browser/base/content/test/browser_scratchpad_initialization.js
+++ b/browser/base/content/test/browser_scratchpad_initialization.js
@@ -28,17 +28,17 @@ function runTests()
 
   let sp = gScratchpadWindow.Scratchpad;
   ok(sp, "Scratchpad object exists in new window");
   is(typeof sp.execute, "function", "Scratchpad.execute() exists");
   is(typeof sp.inspect, "function", "Scratchpad.inspect() exists");
   is(typeof sp.print, "function", "Scratchpad.print() exists");
 
   let chromeContextMenu = gScratchpadWindow.document.
-                          getElementById("sp-menu-chrome");
+                          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",
@@ -46,17 +46,17 @@ function runTests()
 
   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-chromeContext");
+                            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;
   gBrowser.removeCurrentTab();
   finish();
--- a/browser/base/content/test/browser_scratchpad_ui.js
+++ b/browser/base/content/test/browser_scratchpad_ui.js
@@ -31,17 +31,17 @@ function runTests()
   let methodsAndItems = {
     "sp-menu-newscratchpad": "openScratchpad",
     "sp-menu-open": "openFile",
     "sp-menu-save": "saveFile",
     "sp-menu-saveas": "saveFileAs",
     "sp-text-execute": "execute",
     "sp-text-inspect": "inspect",
     "sp-menu-content": "setContentContext",
-    "sp-menu-chrome": "setChromeContext",
+    "sp-menu-browser": "setBrowserContext",
     "sp-menu-resetContext": "resetContext",
     "sp-menu-errorConsole": "openErrorConsole",
     "sp-menu-webConsole": "openWebConsole",
   };
 
   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
@@ -68,27 +68,49 @@
 <!ENTITY inspect.label                "Inspect">
 <!ENTITY inspect.accesskey            "I">
 <!ENTITY inspect.key                  "i">
 
 <!ENTITY print.label                  "Print">
 <!ENTITY print.accesskey              "p">
 <!ENTITY print.key                    "r">
 
+<!-- LOCALIZATION NOTE (environmentMenu.label, accesskey): This menu item was
+  -  renamed from "Context" to avoid confusion with the right-click context
+  -  menu in the text area. It refers to the JavaScript Environment (or context)
+  -  the user is evaluating against. I.e., Content (current tab) or Chrome
+  -  (browser).
+  -->
+<!ENTITY environmentMenu.label        "Environment">
+<!ENTITY environmentMenu.accesskey    "N">
+
+<!-- LOCALIZATION NOTE (contextMenu.label, accesskey): No longer used.
 <!ENTITY contextMenu.label            "Context">
 <!ENTITY contextMenu.accesskey        "C">
+  -->
 
 <!ENTITY contentContext.label         "Content">
 <!ENTITY contentContext.accesskey     "C">
 
+<!-- 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.accesskey     "B">
+
+<!-- LOCALIZATION NOTE (chromeContext.label, accesskey): No longer used.
 <!ENTITY chromeContext.label          "Chrome">
 <!ENTITY chromeContext.accesskey      "H">
+  -->
 
 <!-- LOCALIZATION NOTE (resetContext.label): This command allows the developer
-  -  to reset/clear the global object of the context where the code executes.
+  -  to reset/clear the global object of the environment where the code executes.
   -->
 <!ENTITY resetContext.label           "Reset">
 <!ENTITY resetContext.accesskey       "R">
 
 <!ENTITY toolsMenu.label              "Tools">
 <!ENTITY toolsMenu.accesskey          "T">
 
 <!ENTITY errorConsoleCmd.label        "Error Console">