Bug 653093 - Rename Workspace to Scratchpad; r=l10n

--HG--
rename : browser/base/content/workspace.js => browser/base/content/scratchpad.js
rename : browser/base/content/workspace.xul => browser/base/content/scratchpad.xul
rename : browser/base/content/test/browser_workspace_bug_646070_chrome_context_pref.js => browser/base/content/test/browser_scratchpad_bug_646070_chrome_context_pref.js
rename : browser/base/content/test/browser_workspace_contexts.js => browser/base/content/test/browser_scratchpad_contexts.js
rename : browser/base/content/test/browser_workspace_execute_print.js => browser/base/content/test/browser_scratchpad_execute_print.js
rename : browser/base/content/test/browser_workspace_files.js => browser/base/content/test/browser_scratchpad_files.js
rename : browser/base/content/test/browser_workspace_initialization.js => browser/base/content/test/browser_scratchpad_initialization.js
rename : browser/base/content/test/browser_workspace_inspect.js => browser/base/content/test/browser_scratchpad_inspect.js
rename : browser/base/content/test/browser_workspace_ui.js => browser/base/content/test/browser_scratchpad_ui.js
rename : browser/locales/en-US/chrome/browser/workspace.dtd => browser/locales/en-US/chrome/browser/scratchpad.dtd
rename : browser/locales/en-US/chrome/browser/workspace.properties => browser/locales/en-US/chrome/browser/scratchpad.properties
This commit is contained in:
Rob Campbell 2011-05-09 11:51:52 -03:00
parent ca7b9a63e0
commit b895140c3c
23 changed files with 602 additions and 583 deletions

View File

@ -992,8 +992,8 @@ pref("services.sync.prefs.sync.xpinstall.whitelist.required", true);
pref("devtools.errorconsole.enabled", false); pref("devtools.errorconsole.enabled", false);
pref("devtools.inspector.enabled", false); pref("devtools.inspector.enabled", false);
// Enable the Workspace tool. // Enable the Scratchpad tool.
pref("devtools.workspace.enabled", true); pref("devtools.scratchpad.enabled", true);
// Enable tools for Chrome development. // Enable tools for Chrome development.
pref("devtools.chrome.enabled", false); pref("devtools.chrome.enabled", false);

View File

@ -187,11 +187,11 @@
type="checkbox" type="checkbox"
command="Tools:Inspect" command="Tools:Inspect"
key="key_inspect"/> key="key_inspect"/>
<menuitem id="appmenu_workspace" <menuitem id="appmenu_scratchpad"
hidden="true" hidden="true"
label="&workspace.label;" label="&scratchpad.label;"
key="key_workspace" key="key_scratchpad"
command="Tools:Workspace"/> command="Tools:Scratchpad"/>
<menuitem id="appmenu_pageSource" <menuitem id="appmenu_pageSource"
label="&viewPageSourceCmd.label;" label="&viewPageSourceCmd.label;"
command="View:PageSource" command="View:PageSource"

View File

@ -557,12 +557,12 @@
accesskey="&webConsoleCmd.accesskey;" accesskey="&webConsoleCmd.accesskey;"
key="key_webConsole" key="key_webConsole"
oncommand="HUDConsoleUI.toggleHUD();"/> oncommand="HUDConsoleUI.toggleHUD();"/>
<menuitem id="menu_workspace" <menuitem id="menu_scratchpad"
hidden="true" hidden="true"
label="&workspace.label;" label="&scratchpad.label;"
accesskey="&workspace.accesskey;" accesskey="&scratchpad.accesskey;"
key="key_workspace" key="key_scratchpad"
command="Tools:Workspace"/> command="Tools:Scratchpad"/>
<menuitem id="menu_pageInfo" <menuitem id="menu_pageInfo"
accesskey="&pageInfoCmd.accesskey;" accesskey="&pageInfoCmd.accesskey;"
label="&pageInfoCmd.label;" label="&pageInfoCmd.label;"

View File

@ -125,7 +125,7 @@
<command id="Tools:Search" oncommand="BrowserSearch.webSearch();"/> <command id="Tools:Search" oncommand="BrowserSearch.webSearch();"/>
<command id="Tools:Downloads" oncommand="BrowserDownloadsUI();"/> <command id="Tools:Downloads" oncommand="BrowserDownloadsUI();"/>
<command id="Tools:Inspect" oncommand="InspectorUI.toggleInspectorUI();" disabled="true"/> <command id="Tools:Inspect" oncommand="InspectorUI.toggleInspectorUI();" disabled="true"/>
<command id="Tools:Workspace" oncommand="Workspace.openWorkspace();" disabled="true"/> <command id="Tools:Scratchpad" oncommand="Scratchpad.openScratchpad();" disabled="true"/>
<command id="Tools:Addons" oncommand="BrowserOpenAddonsMgr();"/> <command id="Tools:Addons" oncommand="BrowserOpenAddonsMgr();"/>
<command id="Tools:Sanitize" <command id="Tools:Sanitize"
oncommand="Cc['@mozilla.org/browser/browserglue;1'].getService(Ci.nsIBrowserGlue).sanitize(window);"/> oncommand="Cc['@mozilla.org/browser/browserglue;1'].getService(Ci.nsIBrowserGlue).sanitize(window);"/>
@ -242,8 +242,8 @@
<key id="key_errorConsole" key="&errorConsoleCmd.commandkey;" oncommand="toJavaScriptConsole();" modifiers="accel,shift" disabled="true"/> <key id="key_errorConsole" key="&errorConsoleCmd.commandkey;" oncommand="toJavaScriptConsole();" modifiers="accel,shift" disabled="true"/>
<key id="key_webConsole" key="&webConsoleCmd.commandkey;" oncommand="HUDConsoleUI.toggleHUD();" modifiers="accel,shift"/> <key id="key_webConsole" key="&webConsoleCmd.commandkey;" oncommand="HUDConsoleUI.toggleHUD();" modifiers="accel,shift"/>
<key id="key_inspect" key="&inspectMenu.commandkey;" command="Tools:Inspect" modifiers="accel,shift"/> <key id="key_inspect" key="&inspectMenu.commandkey;" command="Tools:Inspect" modifiers="accel,shift"/>
<key id="key_workspace" keycode="&workspace.keycode;" <key id="key_scratchpad" keycode="&scratchpad.keycode;"
keytext="&workspace.keytext;" command="Tools:Workspace"/> keytext="&scratchpad.keytext;" command="Tools:Scratchpad"/>
<key id="openFileKb" key="&openFileCmd.commandkey;" command="Browser:OpenFile" modifiers="accel"/> <key id="openFileKb" key="&openFileCmd.commandkey;" command="Browser:OpenFile" modifiers="accel"/>
<key id="key_savePage" key="&savePageCmd.commandkey;" command="Browser:SavePage" modifiers="accel"/> <key id="key_savePage" key="&savePageCmd.commandkey;" command="Browser:SavePage" modifiers="accel"/>
<key id="printKb" key="&printCmd.commandkey;" command="cmd_print" modifiers="accel"/> <key id="printKb" key="&printCmd.commandkey;" command="cmd_print" modifiers="accel"/>

View File

@ -1654,13 +1654,13 @@ function delayedStartup(isLoadingBlank, mustLoadSidebar) {
#endif #endif
} }
// Enable Workspace in the UI, if the preference allows this. // Enable Scratchpad in the UI, if the preference allows this.
let workspaceEnabled = gPrefService.getBoolPref(Workspace.prefEnabledName); let scratchpadEnabled = gPrefService.getBoolPref(Scratchpad.prefEnabledName);
if (workspaceEnabled) { if (scratchpadEnabled) {
document.getElementById("menu_workspace").hidden = false; document.getElementById("menu_scratchpad").hidden = false;
document.getElementById("Tools:Workspace").removeAttribute("disabled"); document.getElementById("Tools:Scratchpad").removeAttribute("disabled");
#ifdef MENUBAR_CAN_AUTOHIDE #ifdef MENUBAR_CAN_AUTOHIDE
document.getElementById("appmenu_workspace").hidden = false; document.getElementById("appmenu_scratchpad").hidden = false;
#endif #endif
} }
@ -8642,15 +8642,15 @@ function toggleAddonBar() {
setToolbarVisibility(addonBar, addonBar.collapsed); setToolbarVisibility(addonBar, addonBar.collapsed);
} }
var Workspace = { var Scratchpad = {
prefEnabledName: "devtools.workspace.enabled", prefEnabledName: "devtools.scratchpad.enabled",
openWorkspace: function WS_openWorkspace() { openScratchpad: function SP_openScratchpad() {
const WORKSPACE_WINDOW_URL = "chrome://browser/content/workspace.xul"; const SCRATCHPAD_WINDOW_URL = "chrome://browser/content/scratchpad.xul";
const WORKSPACE_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no"; const SCRATCHPAD_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
return Services.ww.openWindow(null, WORKSPACE_WINDOW_URL, "_blank", return Services.ww.openWindow(null, SCRATCHPAD_WINDOW_URL, "_blank",
WORKSPACE_WINDOW_FEATURES, null); SCRATCHPAD_WINDOW_FEATURES, null);
}, },
}; };

View File

@ -12,7 +12,7 @@
* for the specific language governing rights and limitations under the * for the specific language governing rights and limitations under the
* License. * License.
* *
* The Original Code is Workspace. * The Original Code is Scratchpad.
* *
* The Initial Developer of the Original Code is * The Initial Developer of the Original Code is
* The Mozilla Foundation. * The Mozilla Foundation.
@ -48,40 +48,40 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource:///modules/PropertyPanel.jsm"); Cu.import("resource:///modules/PropertyPanel.jsm");
const WORKSPACE_CONTEXT_CONTENT = 1; const SCRATCHPAD_CONTEXT_CONTENT = 1;
const WORKSPACE_CONTEXT_CHROME = 2; const SCRATCHPAD_CONTEXT_CHROME = 2;
const WORKSPACE_WINDOW_URL = "chrome://browser/content/workspace.xul"; const SCRATCHPAD_WINDOW_URL = "chrome://browser/content/scratchpad.xul";
const WORKSPACE_L10N = "chrome://browser/locale/workspace.properties"; const SCRATCHPAD_L10N = "chrome://browser/locale/scratchpad.properties";
const WORKSPACE_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no"; const SCRATCHPAD_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
const DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled"; const DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled";
/** /**
* The workspace object handles the Workspace window functionality. * The scratchpad object handles the Scratchpad window functionality.
*/ */
var Workspace = { var Scratchpad = {
/** /**
* The script execution context. This tells Workspace in which context the * The script execution context. This tells Scratchpad in which context the
* script shall execute. * script shall execute.
* *
* Possible values: * Possible values:
* - WORKSPACE_CONTEXT_CONTENT to execute code in the context of the current * - SCRATCHPAD_CONTEXT_CONTENT to execute code in the context of the current
* tab content window object. * tab content window object.
* - WORKSPACE_CONTEXT_CHROME to execute code in the context of the * - SCRATCHPAD_CONTEXT_CHROME to execute code in the context of the
* currently active chrome window object. * currently active chrome window object.
*/ */
executionContext: WORKSPACE_CONTEXT_CONTENT, executionContext: SCRATCHPAD_CONTEXT_CONTENT,
/** /**
* Retrieve the xul:textbox DOM element. This element holds the source code * Retrieve the xul:textbox DOM element. This element holds the source code
* the user writes and executes. * the user writes and executes.
*/ */
get textbox() document.getElementById("workspace-textbox"), get textbox() document.getElementById("scratchpad-textbox"),
/** /**
* Retrieve the xul:statusbarpanel DOM element. The status bar tells the * Retrieve the xul:statusbarpanel DOM element. The status bar tells the
* current code execution context. * current code execution context.
*/ */
get statusbarStatus() document.getElementById("workspace-status"), get statusbarStatus() document.getElementById("scratchpad-status"),
/** /**
* Get the selected text from the textbox. * Get the selected text from the textbox.
@ -177,20 +177,20 @@ var Workspace = {
/** /**
* Drop the textbox selection. * Drop the textbox selection.
*/ */
deselect: function WS_deselect() deselect: function SP_deselect()
{ {
this.textbox.selectionEnd = this.textbox.selectionStart; this.textbox.selectionEnd = this.textbox.selectionStart;
}, },
/** /**
* Select a specific range in the Workspace xul:textbox. * Select a specific range in the Scratchpad xul:textbox.
* *
* @param number aStart * @param number aStart
* Selection range start. * Selection range start.
* @param number aEnd * @param number aEnd
* Selection range end. * Selection range end.
*/ */
selectRange: function WS_selectRange(aStart, aEnd) selectRange: function SP_selectRange(aStart, aEnd)
{ {
this.textbox.selectionStart = aStart; this.textbox.selectionStart = aStart;
this.textbox.selectionEnd = aEnd; this.textbox.selectionEnd = aEnd;
@ -204,12 +204,12 @@ var Workspace = {
* @return mixed * @return mixed
* The script evaluation result. * The script evaluation result.
*/ */
evalInContentSandbox: function WS_evalInContentSandbox(aString) evalInContentSandbox: function SP_evalInContentSandbox(aString)
{ {
let result; let result;
try { try {
result = Cu.evalInSandbox(aString, this.contentSandbox, "1.8", result = Cu.evalInSandbox(aString, this.contentSandbox, "1.8",
"Workspace", 1); "Scratchpad", 1);
} }
catch (ex) { catch (ex) {
this.openWebConsole(); this.openWebConsole();
@ -238,12 +238,12 @@ var Workspace = {
* @return mixed * @return mixed
* The script evaluation result. * The script evaluation result.
*/ */
evalInChromeSandbox: function WS_evalInChromeSandbox(aString) evalInChromeSandbox: function SP_evalInChromeSandbox(aString)
{ {
let result; let result;
try { try {
result = Cu.evalInSandbox(aString, this.chromeSandbox, "1.8", result = Cu.evalInSandbox(aString, this.chromeSandbox, "1.8",
"Workspace", 1); "Scratchpad", 1);
} }
catch (ex) { catch (ex) {
Cu.reportError(ex); Cu.reportError(ex);
@ -263,9 +263,9 @@ var Workspace = {
* @return mixed * @return mixed
* The script evaluation result. * The script evaluation result.
*/ */
evalForContext: function WS_evaluateForContext(aString) evalForContext: function SP_evaluateForContext(aString)
{ {
return this.executionContext == WORKSPACE_CONTEXT_CONTENT ? return this.executionContext == SCRATCHPAD_CONTEXT_CONTENT ?
this.evalInContentSandbox(aString) : this.evalInContentSandbox(aString) :
this.evalInChromeSandbox(aString); this.evalInChromeSandbox(aString);
}, },
@ -274,7 +274,7 @@ var Workspace = {
* Execute the selected text (if any) or the entire textbox content in the * Execute the selected text (if any) or the entire textbox content in the
* current context. * current context.
*/ */
execute: function WS_execute() execute: function SP_execute()
{ {
let selection = this.selectedText || this.textbox.value; let selection = this.selectedText || this.textbox.value;
let result = this.evalForContext(selection); let result = this.evalForContext(selection);
@ -287,7 +287,7 @@ var Workspace = {
* current context. The resulting object is opened up in the Property Panel * current context. The resulting object is opened up in the Property Panel
* for inspection. * for inspection.
*/ */
inspect: function WS_inspect() inspect: function SP_inspect()
{ {
let [selection, result] = this.execute(); let [selection, result] = this.execute();
@ -302,7 +302,7 @@ var Workspace = {
* the selected text, or at the end of the textbox value if there is no * the selected text, or at the end of the textbox value if there is no
* selected text. * selected text.
*/ */
print: function WS_print() print: function SP_print()
{ {
let selectionStart = this.textbox.selectionStart; let selectionStart = this.textbox.selectionStart;
let selectionEnd = this.textbox.selectionEnd; let selectionEnd = this.textbox.selectionEnd;
@ -338,7 +338,7 @@ var Workspace = {
* @return object * @return object
* The PropertyPanel object instance. * The PropertyPanel object instance.
*/ */
openPropertyPanel: function WS_openPropertyPanel(aEvalString, aOutputObject) openPropertyPanel: function SP_openPropertyPanel(aEvalString, aOutputObject)
{ {
let self = this; let self = this;
let propPanel; let propPanel;
@ -375,7 +375,7 @@ var Workspace = {
propPanel = new PropertyPanel(parent, doc, title, aOutputObject, buttons); propPanel = new PropertyPanel(parent, doc, title, aOutputObject, buttons);
let panel = propPanel.panel; let panel = propPanel.panel;
panel.setAttribute("class", "workspace_propertyPanel"); panel.setAttribute("class", "scratchpad_propertyPanel");
panel.openPopup(null, "after_pointer", 0, 0, false, false); panel.openPopup(null, "after_pointer", 0, 0, false, false);
panel.sizeTo(200, 400); panel.sizeTo(200, 400);
@ -385,12 +385,12 @@ var Workspace = {
// Menu Operations // Menu Operations
/** /**
* Open a new Workspace window. * Open a new Scratchpad window.
*/ */
openWorkspace: function WS_openWorkspace() openScratchpad: function SP_openScratchpad()
{ {
Services.ww.openWindow(null, WORKSPACE_WINDOW_URL, "_blank", Services.ww.openWindow(null, SCRATCHPAD_WINDOW_URL, "_blank",
WORKSPACE_WINDOW_FEATURES, null); SCRATCHPAD_WINDOW_FEATURES, null);
}, },
/** /**
@ -408,7 +408,7 @@ var Workspace = {
* get the following arguments: * get the following arguments:
* 1) the nsresult status code for the export operation. * 1) the nsresult status code for the export operation.
*/ */
exportToFile: function WS_exportToFile(aFile, aNoConfirmation, aSilentError, exportToFile: function SP_exportToFile(aFile, aNoConfirmation, aSilentError,
aCallback) aCallback)
{ {
if (!aNoConfirmation && aFile.exists() && if (!aNoConfirmation && aFile.exists() &&
@ -453,7 +453,7 @@ var Workspace = {
* 1) the nsresult status code for the import operation. * 1) the nsresult status code for the import operation.
* 2) the data that was read from the file, if any. * 2) the data that was read from the file, if any.
*/ */
importFromFile: function WS_importFromFile(aFile, aSilentError, aCallback) importFromFile: function SP_importFromFile(aFile, aSilentError, aCallback)
{ {
// Prevent file type detection. // Prevent file type detection.
let channel = NetUtil.newChannel(aFile); let channel = NetUtil.newChannel(aFile);
@ -479,9 +479,9 @@ var Workspace = {
}, },
/** /**
* Open a file to edit in the Workspace. * Open a file to edit in the Scratchpad.
*/ */
openFile: function WS_openFile() openFile: function SP_openFile()
{ {
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.init(window, this.strings.GetStringFromName("openFile.title"), fp.init(window, this.strings.GetStringFromName("openFile.title"),
@ -496,7 +496,7 @@ var Workspace = {
/** /**
* Save the textbox content to the currently open file. * Save the textbox content to the currently open file.
*/ */
saveFile: function WS_saveFile() saveFile: function SP_saveFile()
{ {
if (!this.filename) { if (!this.filename) {
return this.saveFileAs(); return this.saveFileAs();
@ -510,12 +510,12 @@ var Workspace = {
/** /**
* Save the textbox content to a new file. * Save the textbox content to a new file.
*/ */
saveFileAs: function WS_saveFileAs() saveFileAs: function SP_saveFileAs()
{ {
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.init(window, this.strings.GetStringFromName("saveFileAs"), fp.init(window, this.strings.GetStringFromName("saveFileAs"),
Ci.nsIFilePicker.modeSave); Ci.nsIFilePicker.modeSave);
fp.defaultString = "workspace.js"; fp.defaultString = "scratchpad.js";
if (fp.show() != Ci.nsIFilePicker.returnCancel) { if (fp.show() != Ci.nsIFilePicker.returnCancel) {
document.title = this.filename = fp.file.path; document.title = this.filename = fp.file.path;
this.exportToFile(fp.file); this.exportToFile(fp.file);
@ -525,7 +525,7 @@ var Workspace = {
/** /**
* Open the Error Console. * Open the Error Console.
*/ */
openErrorConsole: function WS_openErrorConsole() openErrorConsole: function SP_openErrorConsole()
{ {
this.browserWindow.toJavaScriptConsole(); this.browserWindow.toJavaScriptConsole();
}, },
@ -533,7 +533,7 @@ var Workspace = {
/** /**
* Open the Web Console. * Open the Web Console.
*/ */
openWebConsole: function WS_openWebConsole() openWebConsole: function SP_openWebConsole()
{ {
if (!this.browserWindow.HUDConsoleUI.getOpenHUD()) { if (!this.browserWindow.HUDConsoleUI.getOpenHUD()) {
this.browserWindow.HUDConsoleUI.toggleHUD(); this.browserWindow.HUDConsoleUI.toggleHUD();
@ -544,33 +544,33 @@ var Workspace = {
/** /**
* Set the current execution context to be the active tab content window. * Set the current execution context to be the active tab content window.
*/ */
setContentContext: function WS_setContentContext() setContentContext: function SP_setContentContext()
{ {
let content = document.getElementById("ws-menu-content"); let content = document.getElementById("sp-menu-content");
document.getElementById("ws-menu-chrome").removeAttribute("checked"); document.getElementById("sp-menu-chrome").removeAttribute("checked");
content.setAttribute("checked", true); content.setAttribute("checked", true);
this.statusbarStatus.label = content.getAttribute("label"); this.statusbarStatus.label = content.getAttribute("label");
this.executionContext = WORKSPACE_CONTEXT_CONTENT; this.executionContext = SCRATCHPAD_CONTEXT_CONTENT;
this.resetContext(); this.resetContext();
}, },
/** /**
* Set the current execution context to be the most recent chrome window. * Set the current execution context to be the most recent chrome window.
*/ */
setChromeContext: function WS_setChromeContext() setChromeContext: function SP_setChromeContext()
{ {
let chrome = document.getElementById("ws-menu-chrome"); let chrome = document.getElementById("sp-menu-chrome");
document.getElementById("ws-menu-content").removeAttribute("checked"); document.getElementById("sp-menu-content").removeAttribute("checked");
chrome.setAttribute("checked", true); chrome.setAttribute("checked", true);
this.statusbarStatus.label = chrome.getAttribute("label"); this.statusbarStatus.label = chrome.getAttribute("label");
this.executionContext = WORKSPACE_CONTEXT_CHROME; this.executionContext = SCRATCHPAD_CONTEXT_CHROME;
this.resetContext(); this.resetContext();
}, },
/** /**
* Reset the cached Cu.Sandbox object for the current context. * Reset the cached Cu.Sandbox object for the current context.
*/ */
resetContext: function WS_resetContext() resetContext: function SP_resetContext()
{ {
this._chromeSandbox = null; this._chromeSandbox = null;
this._contentSandbox = null; this._contentSandbox = null;
@ -584,21 +584,21 @@ var Workspace = {
* @return integer * @return integer
* the outer window ID * the outer window ID
*/ */
getWindowId: function HS_getWindowId(aWindow) getWindowId: function SP_getWindowId(aWindow)
{ {
return aWindow.QueryInterface(Ci.nsIInterfaceRequestor). return aWindow.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils).outerWindowID; getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
}, },
/** /**
* The Workspace window DOMContentLoaded event handler. * The Scratchpad window DOMContentLoaded event handler.
*/ */
onLoad: function HS_onLoad() onLoad: function SP_onLoad()
{ {
let chromeContextMenu = document.getElementById("ws-menu-chrome"); let chromeContextMenu = document.getElementById("sp-menu-chrome");
let errorConsoleMenu = document.getElementById("ws-menu-errorConsole"); let errorConsoleMenu = document.getElementById("sp-menu-errorConsole");
let errorConsoleCommand = document.getElementById("ws-cmd-errorConsole"); let errorConsoleCommand = document.getElementById("sp-cmd-errorConsole");
let chromeContextCommand = document.getElementById("ws-cmd-chromeContext"); let chromeContextCommand = document.getElementById("sp-cmd-chromeContext");
let chrome = Services.prefs.getBoolPref(DEVTOOLS_CHROME_ENABLED); let chrome = Services.prefs.getBoolPref(DEVTOOLS_CHROME_ENABLED);
if (chrome) { if (chrome) {
@ -610,9 +610,9 @@ var Workspace = {
}, },
}; };
XPCOMUtils.defineLazyGetter(Workspace, "strings", function () { XPCOMUtils.defineLazyGetter(Scratchpad, "strings", function () {
return Services.strings.createBundle(WORKSPACE_L10N); return Services.strings.createBundle(SCRATCHPAD_L10N);
}); });
addEventListener("DOMContentLoaded", Workspace.onLoad.bind(Workspace), false); addEventListener("DOMContentLoaded", Scratchpad.onLoad.bind(Scratchpad), false);

View File

@ -13,7 +13,7 @@
- for the specific language governing rights and limitations under the - for the specific language governing rights and limitations under the
- License. - License.
- -
- The Original Code is Workspace. - The Original Code is Scratchpad.
- -
- The Initial Developer of the Original Code is - The Initial Developer of the Original Code is
- The Mozilla Foundation. - The Mozilla Foundation.
@ -40,8 +40,8 @@
- ***** END LICENSE BLOCK ***** --> - ***** END LICENSE BLOCK ***** -->
#endif #endif
<!DOCTYPE window [ <!DOCTYPE window [
<!ENTITY % workspaceDTD SYSTEM "chrome://browser/locale/workspace.dtd" > <!ENTITY % scratchpadDTD SYSTEM "chrome://browser/locale/scratchpad.dtd" >
%workspaceDTD; %scratchpadDTD;
]> ]>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?> <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?> <?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
@ -49,59 +49,59 @@
<window id="main-window" <window id="main-window"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&window.title;" title="&window.title;"
windowtype="devtools:workspace" windowtype="devtools:scratchpad"
screenX="4" screenY="4" screenX="4" screenY="4"
width="640" height="480" width="640" height="480"
persist="screenX screenY width height sizemode"> persist="screenX screenY width height sizemode">
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/> <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://browser/content/workspace.js"/> <script type="application/javascript" src="chrome://browser/content/scratchpad.js"/>
<commandset id="editMenuCommands"/> <commandset id="editMenuCommands"/>
<commandset id="ws-commandset"> <commandset id="sp-commandset">
<command id="ws-cmd-newWindow" oncommand="Workspace.openWorkspace();"/> <command id="sp-cmd-newWindow" oncommand="Scratchpad.openScratchpad();"/>
<command id="ws-cmd-openFile" oncommand="Workspace.openFile();"/> <command id="sp-cmd-openFile" oncommand="Scratchpad.openFile();"/>
<command id="ws-cmd-save" oncommand="Workspace.saveFile();"/> <command id="sp-cmd-save" oncommand="Scratchpad.saveFile();"/>
<command id="ws-cmd-saveas" oncommand="Workspace.saveFileAs();"/> <command id="sp-cmd-saveas" oncommand="Scratchpad.saveFileAs();"/>
<!-- TODO: bug 650340 - implement printFile() <!-- TODO: bug 650340 - implement printFile()
<command id="ws-cmd-printFile" oncommand="Workspace.printFile();" disabled="true"/> <command id="sp-cmd-printFile" oncommand="Scratchpad.printFile();" disabled="true"/>
--> -->
<command id="ws-cmd-close" oncommand="window.close();"/> <command id="sp-cmd-close" oncommand="window.close();"/>
<command id="ws-cmd-execute" oncommand="Workspace.execute();"/> <command id="sp-cmd-execute" oncommand="Scratchpad.execute();"/>
<command id="ws-cmd-inspect" oncommand="Workspace.inspect();"/> <command id="sp-cmd-inspect" oncommand="Scratchpad.inspect();"/>
<command id="ws-cmd-print" oncommand="Workspace.print();"/> <command id="sp-cmd-print" oncommand="Scratchpad.print();"/>
<command id="ws-cmd-contentContext" oncommand="Workspace.setContentContext();"/> <command id="sp-cmd-contentContext" oncommand="Scratchpad.setContentContext();"/>
<command id="ws-cmd-chromeContext" oncommand="Workspace.setChromeContext();" disabled="true"/> <command id="sp-cmd-chromeContext" oncommand="Scratchpad.setChromeContext();" disabled="true"/>
<command id="ws-cmd-resetContext" oncommand="Workspace.resetContext();"/> <command id="sp-cmd-resetContext" oncommand="Scratchpad.resetContext();"/>
<command id="ws-cmd-errorConsole" oncommand="Workspace.openErrorConsole();" disabled="true"/> <command id="sp-cmd-errorConsole" oncommand="Scratchpad.openErrorConsole();" disabled="true"/>
<command id="ws-cmd-webConsole" oncommand="Workspace.openWebConsole();"/> <command id="sp-cmd-webConsole" oncommand="Scratchpad.openWebConsole();"/>
</commandset> </commandset>
<keyset id="ws-keyset"> <keyset id="sp-keyset">
<key id="ws-key-window" <key id="sp-key-window"
key="&newWindowCmd.commandkey;" key="&newWindowCmd.commandkey;"
command="ws-cmd-newWindow" command="sp-cmd-newWindow"
modifiers="accel"/> modifiers="accel"/>
<key id="ws-key-open" <key id="sp-key-open"
key="&openFileCmd.commandkey;" key="&openFileCmd.commandkey;"
command="ws-cmd-openFile" command="sp-cmd-openFile"
modifiers="accel"/> modifiers="accel"/>
<key id="ws-key-save" <key id="sp-key-save"
key="&saveFileCmd.commandkey;" key="&saveFileCmd.commandkey;"
command="ws-cmd-save" command="sp-cmd-save"
modifiers="accel"/> modifiers="accel"/>
<key id="ws-key-close" <key id="sp-key-close"
key="&closeCmd.key;" key="&closeCmd.key;"
command="ws-cmd-close" command="sp-cmd-close"
modifiers="accel"/> modifiers="accel"/>
<!-- TODO: bug 650340 - implement printFile <!-- TODO: bug 650340 - implement printFile
<key id="ws-key-printFile" <key id="sp-key-printFile"
key="&printCmd.commandkey;" key="&printCmd.commandkey;"
command="ws-cmd-printFile" command="sp-cmd-printFile"
modifiers="accel"/> modifiers="accel"/>
--> -->
@ -118,104 +118,104 @@
<key id="key_selectAll" key="&selectAllCmd.key;" modifiers="accel"/> <key id="key_selectAll" key="&selectAllCmd.key;" modifiers="accel"/>
<key id="key_undo" key="&undoCmd.key;" modifiers="accel"/> <key id="key_undo" key="&undoCmd.key;" modifiers="accel"/>
<key id="key_redo" key="&undoCmd.key;" modifiers="accel,shift"/> <key id="key_redo" key="&undoCmd.key;" modifiers="accel,shift"/>
<key id="ws-key-execute" <key id="sp-key-execute"
key="&execute.key;" key="&execute.key;"
command="ws-cmd-execute" command="sp-cmd-execute"
modifiers="accel"/> modifiers="accel"/>
<key id="ws-key-inspect" <key id="sp-key-inspect"
key="&inspect.key;" key="&inspect.key;"
command="ws-cmd-inspect" command="sp-cmd-inspect"
modifiers="accel"/> modifiers="accel"/>
<key id="ws-key-print" <key id="sp-key-print"
key="&print.key;" key="&print.key;"
command="ws-cmd-print" command="sp-cmd-print"
modifiers="accel"/> modifiers="accel"/>
<key id="ws-key-errorConsole" <key id="sp-key-errorConsole"
key="&errorConsoleCmd.commandkey;" key="&errorConsoleCmd.commandkey;"
command="ws-cmd-errorConsole" command="sp-cmd-errorConsole"
modifiers="accel,shift"/> modifiers="accel,shift"/>
<key id="ws-key-webConsole" <key id="sp-key-webConsole"
key="&webConsoleCmd.commandkey;" key="&webConsoleCmd.commandkey;"
command="ws-cmd-webConsole" command="sp-cmd-webConsole"
modifiers="accel,shift"/> modifiers="accel,shift"/>
</keyset> </keyset>
<menubar id="ws-menubar"> <menubar id="sp-menubar">
<menu id="ws-file-menu" label="&fileMenu.label;" <menu id="sp-file-menu" label="&fileMenu.label;"
accesskey="&fileMenu.accesskey;"> accesskey="&fileMenu.accesskey;">
<menupopup id="ws-menu-filepopup"> <menupopup id="sp-menu-filepopup">
<menuitem id="ws-menu-newworkspace" <menuitem id="sp-menu-newscratchpad"
label="&newWindowCmd.label;" label="&newWindowCmd.label;"
accesskey="&newWindowCmd.accesskey;" accesskey="&newWindowCmd.accesskey;"
key="ws-key-window" key="sp-key-window"
command="ws-cmd-newWindow"/> command="sp-cmd-newWindow"/>
<menuseparator/> <menuseparator/>
<menuitem id="ws-menu-open" <menuitem id="sp-menu-open"
label="&openFileCmd.label;" label="&openFileCmd.label;"
command="ws-cmd-openFile" command="sp-cmd-openFile"
key="ws-key-open" key="sp-key-open"
accesskey="&openFileCmd.accesskey;"/> accesskey="&openFileCmd.accesskey;"/>
<menuitem id="ws-menu-save" <menuitem id="sp-menu-save"
label="&saveFileCmd.label;" label="&saveFileCmd.label;"
accesskey="&saveFileCmd.accesskey;" accesskey="&saveFileCmd.accesskey;"
key="ws-key-save" key="sp-key-save"
command="ws-cmd-save"/> command="sp-cmd-save"/>
<menuitem id="ws-menu-saveas" <menuitem id="sp-menu-saveas"
label="&saveFileAsCmd.label;" label="&saveFileAsCmd.label;"
accesskey="&saveFileAsCmd.accesskey;" accesskey="&saveFileAsCmd.accesskey;"
command="ws-cmd-saveas"/> command="sp-cmd-saveas"/>
<menuseparator/> <menuseparator/>
<!-- TODO: bug 650340 - implement printFile <!-- TODO: bug 650340 - implement printFile
<menuitem id="ws-menu-print" <menuitem id="sp-menu-print"
label="&printCmd.label;" label="&printCmd.label;"
accesskey="&printCmd.accesskey;" accesskey="&printCmd.accesskey;"
command="ws-cmd-printFile"/> command="sp-cmd-printFile"/>
<menuseparator/> <menuseparator/>
--> -->
<menuitem id="ws-menu-close" <menuitem id="sp-menu-close"
label="&closeCmd.label;" label="&closeCmd.label;"
key="ws-key-close" key="sp-key-close"
accesskey="&closeCmd.accesskey;" accesskey="&closeCmd.accesskey;"
command="ws-cmd-close"/> command="sp-cmd-close"/>
</menupopup> </menupopup>
</menu> </menu>
<menu id="ws-edit-menu" label="&editMenu.label;" <menu id="sp-edit-menu" label="&editMenu.label;"
accesskey="&editMenu.accesskey;"> accesskey="&editMenu.accesskey;">
<menupopup id="ws-menu_editpopup"> <menupopup id="sp-menu_editpopup">
<menuitem id="ws-menu_undo" <menuitem id="sp-menu_undo"
label="&undoCmd.label;" label="&undoCmd.label;"
key="key_undo" key="key_undo"
accesskey="&undoCmd.accesskey;" accesskey="&undoCmd.accesskey;"
disabled="true" disabled="true"
oncommand="cmd_undo"/> oncommand="cmd_undo"/>
<menuitem id="ws-menu-redo" <menuitem id="sp-menu-redo"
label="&redoCmd.label;" label="&redoCmd.label;"
key="key_redo" key="key_redo"
disabled="true" disabled="true"
accesskey="&redoCmd.accesskey;" accesskey="&redoCmd.accesskey;"
command="cmd_redo"/> command="cmd_redo"/>
<menuseparator/> <menuseparator/>
<menuitem id="ws-menu-cut" <menuitem id="sp-menu-cut"
label="&cutCmd.label;" label="&cutCmd.label;"
key="key_cut" key="key_cut"
accesskey="&cutCmd.accesskey;" accesskey="&cutCmd.accesskey;"
command="cmd_cut"/> command="cmd_cut"/>
<menuitem id="ws-menu-copy" <menuitem id="sp-menu-copy"
label="&copyCmd.label;" label="&copyCmd.label;"
key="key_copy" key="key_copy"
accesskey="&copyCmd.accesskey;" accesskey="&copyCmd.accesskey;"
command="cmd_copy"/> command="cmd_copy"/>
<menuitem id="ws-menu-paste" <menuitem id="sp-menu-paste"
label="&pasteCmd.label;" label="&pasteCmd.label;"
key="key_paste" key="key_paste"
accesskey="&pasteCmd.accesskey;" accesskey="&pasteCmd.accesskey;"
command="cmd_paste"/> command="cmd_paste"/>
<menuseparator/> <menuseparator/>
<menuitem id="ws-menu-selectAll" <menuitem id="sp-menu-selectAll"
label="&selectAllCmd.label;" label="&selectAllCmd.label;"
key="key_selectAll" key="key_selectAll"
accesskey="&selectAllCmd.accesskey;" accesskey="&selectAllCmd.accesskey;"
@ -223,82 +223,82 @@
<menuseparator/> <menuseparator/>
<!-- TODO: bug 650345 - implement search and replace <!-- TODO: bug 650345 - implement search and replace
<menuitem id="ws-menu-find" <menuitem id="sp-menu-find"
label="&findOnCmd.label;" label="&findOnCmd.label;"
accesskey="&findOnCmd.accesskey;" accesskey="&findOnCmd.accesskey;"
key="key_find" key="key_find"
disabled="true" disabled="true"
command="cmd_find"/> command="cmd_find"/>
<menuitem id="ws-menu-findAgain" <menuitem id="sp-menu-findAgain"
label="&findAgainCmd.label;" label="&findAgainCmd.label;"
accesskey="&findAgainCmd.accesskey;" accesskey="&findAgainCmd.accesskey;"
key="key_findAgain" key="key_findAgain"
disabled="true" disabled="true"
command="cmd_findAgain"/> command="cmd_findAgain"/>
<menuseparator id="ws-execute-separator"/> <menuseparator id="sp-execute-separator"/>
--> -->
<menuitem id="ws-text-execute" <menuitem id="sp-text-execute"
label="&execute.label;" label="&execute.label;"
accesskey="&execute.accesskey;" accesskey="&execute.accesskey;"
key="ws-key-execute" key="sp-key-execute"
command="ws-cmd-execute"/> command="sp-cmd-execute"/>
<menuitem id="ws-text-inspect" <menuitem id="sp-text-inspect"
label="&inspect.label;" label="&inspect.label;"
accesskey="&inspect.accesskey;" accesskey="&inspect.accesskey;"
key="ws-key-inspect" key="sp-key-inspect"
command="ws-cmd-inspect"/> command="sp-cmd-inspect"/>
<menuitem id="ws-text-print" <menuitem id="sp-text-print"
label="&print.label;" label="&print.label;"
accesskey="&print.accesskey;" accesskey="&print.accesskey;"
key="ws-key-print" key="sp-key-print"
command="ws-cmd-print"/> command="sp-cmd-print"/>
</menupopup> </menupopup>
</menu> </menu>
<menu id="ws-context-menu" <menu id="sp-context-menu"
label="&contextMenu.label;" label="&contextMenu.label;"
accesskey="&contextMenu.accesskey;"> accesskey="&contextMenu.accesskey;">
<menupopup id="ws-menu-context"> <menupopup id="sp-menu-context">
<menuitem id="ws-menu-content" <menuitem id="sp-menu-content"
label="&contentContext.label;" label="&contentContext.label;"
accesskey="&contentContext.accesskey;" accesskey="&contentContext.accesskey;"
command="ws-cmd-contentContext" command="sp-cmd-contentContext"
checked="true" checked="true"
type="radio"/> type="radio"/>
<menuitem id="ws-menu-chrome" hidden="true" <menuitem id="sp-menu-chrome" hidden="true"
command="ws-cmd-chromeContext" command="sp-cmd-chromeContext"
label="&chromeContext.label;" label="&chromeContext.label;"
accesskey="&chromeContext.accesskey;" accesskey="&chromeContext.accesskey;"
type="radio"/> type="radio"/>
<menuseparator/> <menuseparator/>
<menuitem id="ws-menu-resetContext" <menuitem id="sp-menu-resetContext"
command="ws-cmd-resetContext" command="sp-cmd-resetContext"
label="&resetContext.label;" label="&resetContext.label;"
accesskey="&resetContext.accesskey;"/> accesskey="&resetContext.accesskey;"/>
</menupopup> </menupopup>
</menu> </menu>
<menu id="ws-tools-menu" <menu id="sp-tools-menu"
label="&toolsMenu.label;" label="&toolsMenu.label;"
accesskey="&toolsMenu.accesskey;"> accesskey="&toolsMenu.accesskey;">
<menupopup id="ws-menu-tools"> <menupopup id="sp-menu-tools">
<menuitem id="ws-menu-errorConsole" hidden="true" <menuitem id="sp-menu-errorConsole" hidden="true"
label="&errorConsoleCmd.label;" label="&errorConsoleCmd.label;"
accesskey="&errorConsoleCmd.accesskey;" accesskey="&errorConsoleCmd.accesskey;"
key="ws-key-errorConsole" key="sp-key-errorConsole"
command="ws-cmd-errorConsole"/> command="sp-cmd-errorConsole"/>
<menuitem id="ws-menu-webConsole" <menuitem id="sp-menu-webConsole"
label="&webConsoleCmd.label;" label="&webConsoleCmd.label;"
accesskey="&webConsoleCmd.accesskey;" accesskey="&webConsoleCmd.accesskey;"
key="ws-key-webConsole" key="sp-key-webConsole"
command="ws-cmd-webConsole"/> command="sp-cmd-webConsole"/>
</menupopup> </menupopup>
</menu> </menu>
</menubar> </menubar>
<popupset id="workspace-popups"> <popupset id="scratchpad-popups">
<menupopup id="workspace-text-popup"> <menupopup id="scratchpad-text-popup">
<menuitem id="menu_cut"/> <menuitem id="menu_cut"/>
<menuitem id="menu_copy"/> <menuitem id="menu_copy"/>
<menuitem id="menu_paste"/> <menuitem id="menu_paste"/>
@ -306,31 +306,31 @@
<menuseparator/> <menuseparator/>
<menuitem id="menu_selectAll"/> <menuitem id="menu_selectAll"/>
<menuseparator/> <menuseparator/>
<menuitem id="ws-text-execute" <menuitem id="sp-text-execute"
label="&execute.label;" label="&execute.label;"
accesskey="&execute.accesskey;" accesskey="&execute.accesskey;"
key="ws-key-execute" key="sp-key-execute"
command="ws-cmd-execute"/> command="sp-cmd-execute"/>
<menuitem id="ws-text-inspect" <menuitem id="sp-text-inspect"
label="&inspect.label;" label="&inspect.label;"
accesskey="&inspect.accesskey;" accesskey="&inspect.accesskey;"
key="ws-key-inspect" key="sp-key-inspect"
command="ws-cmd-inspect"/> command="sp-cmd-inspect"/>
<menuitem id="ws-text-print" <menuitem id="sp-text-print"
label="&print.label;" label="&print.label;"
accesskey="&print.accesskey;" accesskey="&print.accesskey;"
key="ws-key-print" key="sp-key-print"
command="ws-cmd-print"/> command="sp-cmd-print"/>
</menupopup> </menupopup>
</popupset> </popupset>
<textbox id="workspace-textbox" <textbox id="scratchpad-textbox"
multiline="true" multiline="true"
flex="1" flex="1"
context="workspace-text-popup" context="scratchpad-text-popup"
placeholder="&textbox.placeholder;" /> placeholder="&textbox.placeholder;" />
<statusbar id="workspace-statusbar" align="end"> <statusbar id="scratchpad-statusbar" align="end">
<statusbarpanel id="workspace-status" <statusbarpanel id="scratchpad-status"
label="&contentContext.label;" label="&contentContext.label;"
class="statusbarpanel-iconic-text"/> class="statusbarpanel-iconic-text"/>
<spacer flex="1"/> <spacer flex="1"/>

View File

@ -192,13 +192,13 @@ _BROWSER_FILES = \
browser_inspector_treePanel_output.js \ browser_inspector_treePanel_output.js \
browser_inspector_treePanel_input.html \ browser_inspector_treePanel_input.html \
browser_inspector_treePanel_result.html \ browser_inspector_treePanel_result.html \
browser_workspace_initialization.js \ browser_scratchpad_initialization.js \
browser_workspace_contexts.js \ browser_scratchpad_contexts.js \
browser_workspace_execute_print.js \ browser_scratchpad_execute_print.js \
browser_workspace_inspect.js \ browser_scratchpad_inspect.js \
browser_workspace_files.js \ browser_scratchpad_files.js \
browser_workspace_ui.js \ browser_scratchpad_ui.js \
browser_workspace_bug_646070_chrome_context_pref.js \ browser_scratchpad_bug_646070_chrome_context_pref.js \
browser_overflowScroll.js \ browser_overflowScroll.js \
browser_pageInfo.js \ browser_pageInfo.js \
browser_page_style_menu.js \ browser_page_style_menu.js \

View File

@ -2,8 +2,8 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
// Reference to the Workspace chrome window object. // Reference to the Scratchpad chrome window object.
let gWorkspaceWindow; let gScratchpadWindow;
let gOldPref; let gOldPref;
let DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled"; let DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled";
@ -19,50 +19,50 @@ function test()
gBrowser.selectedBrowser.addEventListener("load", function() { gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
ok(Workspace, "Workspace variable exists"); ok(Scratchpad, "Scratchpad variable exists");
gWorkspaceWindow = Workspace.openWorkspace(); gScratchpadWindow = Scratchpad.openScratchpad();
gWorkspaceWindow.addEventListener("load", runTests, false); gScratchpadWindow.addEventListener("load", runTests, false);
}, true); }, true);
content.location = "data:text/html,Workspace test for bug 646070 - chrome context preference"; content.location = "data:text/html,Scratchpad test for bug 646070 - chrome context preference";
} }
function runTests() function runTests()
{ {
gWorkspaceWindow.removeEventListener("load", arguments.callee, false); gScratchpadWindow.removeEventListener("load", arguments.callee, false);
let ws = gWorkspaceWindow.Workspace; let sp = gScratchpadWindow.Scratchpad;
ok(ws, "Workspace object exists in new window"); ok(sp, "Scratchpad object exists in new window");
let chromeContextMenu = gWorkspaceWindow.document. let chromeContextMenu = gScratchpadWindow.document.
getElementById("ws-menu-chrome"); getElementById("sp-menu-chrome");
ok(chromeContextMenu, "Chrome context menuitem element exists"); ok(chromeContextMenu, "Chrome context menuitem element exists");
ok(!chromeContextMenu.hasAttribute("hidden"), ok(!chromeContextMenu.hasAttribute("hidden"),
"Chrome context menuitem is visible"); "Chrome context menuitem is visible");
let errorConsoleCommand = gWorkspaceWindow.document. let errorConsoleCommand = gScratchpadWindow.document.
getElementById("ws-cmd-errorConsole"); getElementById("sp-cmd-errorConsole");
ok(errorConsoleCommand, "Error console command element exists"); ok(errorConsoleCommand, "Error console command element exists");
ok(!errorConsoleCommand.hasAttribute("disabled"), ok(!errorConsoleCommand.hasAttribute("disabled"),
"Error console command is enabled"); "Error console command is enabled");
let errorConsoleMenu = gWorkspaceWindow.document. let errorConsoleMenu = gScratchpadWindow.document.
getElementById("ws-menu-errorConsole"); getElementById("sp-menu-errorConsole");
ok(errorConsoleMenu, "Error console menu element exists"); ok(errorConsoleMenu, "Error console menu element exists");
ok(!errorConsoleMenu.hasAttribute("hidden"), ok(!errorConsoleMenu.hasAttribute("hidden"),
"Error console menuitem is visible"); "Error console menuitem is visible");
let chromeContextCommand = gWorkspaceWindow.document. let chromeContextCommand = gScratchpadWindow.document.
getElementById("ws-cmd-chromeContext"); getElementById("sp-cmd-chromeContext");
ok(chromeContextCommand, "Chrome context command element exists"); ok(chromeContextCommand, "Chrome context command element exists");
ok(!chromeContextCommand.hasAttribute("disabled"), ok(!chromeContextCommand.hasAttribute("disabled"),
"Chrome context command is disabled"); "Chrome context command is disabled");
Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, gOldPref); Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, gOldPref);
gWorkspaceWindow.close(); gScratchpadWindow.close();
gWorkspaceWindow = null; gScratchpadWindow = null;
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
finish(); finish();
} }

View File

@ -0,0 +1,125 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Reference to the Scratchpad chrome window object.
let gScratchpadWindow;
function test()
{
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
gScratchpadWindow = Scratchpad.openScratchpad();
gScratchpadWindow.addEventListener("load", runTests, false);
}, true);
content.location = "data:text/html,test context switch in Scratchpad";
}
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 statusbar = sp.statusbarStatus;
ok(contentMenu, "found #sp-menu-content");
ok(chromeMenu, "found #sp-menu-chrome");
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");
is(statusbar.getAttribute("label"), contentMenu.getAttribute("label"),
"statusbar label is correct");
ok(sp.textbox, "textbox exists");
sp.textbox.value = "window.foobarBug636725 = 'aloha';";
ok(!content.wrappedJSObject.foobarBug636725,
"no content.foobarBug636725");
sp.execute();
is(content.wrappedJSObject.foobarBug636725, "aloha",
"content.foobarBug636725 has been set");
sp.setChromeContext();
is(sp.executionContext, gScratchpadWindow.SCRATCHPAD_CONTEXT_CHROME,
"executionContext is chrome");
is(chromeMenu.getAttribute("checked"), "true",
"chrome menuitem is checked");
ok(!contentMenu.hasAttribute("checked"),
"content menuitem is not checked");
is(statusbar.getAttribute("label"), chromeMenu.getAttribute("label"),
"statusbar label is correct");
sp.textbox.value = "window.foobarBug636725 = 'aloha2';";
ok(!window.foobarBug636725, "no window.foobarBug636725");
sp.execute();
is(window.foobarBug636725, "aloha2", "window.foobarBug636725 has been set");
sp.textbox.value = "window.gBrowser";
is(typeof sp.execute()[1].addTab, "function",
"chrome context has access to chrome objects");
// Check that the sandbox is cached.
sp.textbox.value = "typeof foobarBug636725cache;";
is(sp.execute()[1], "undefined", "global variable does not exist");
sp.textbox.value = "var foobarBug636725cache = 'foo';";
sp.execute();
sp.textbox.value = "typeof foobarBug636725cache;";
is(sp.execute()[1], "string",
"global variable exists across two different executions");
sp.resetContext();
is(sp.execute()[1], "undefined",
"global variable no longer exists after calling resetContext()");
sp.textbox.value = "var foobarBug636725cache2 = 'foo';";
sp.execute();
sp.textbox.value = "typeof foobarBug636725cache2;";
is(sp.execute()[1], "string",
"global variable exists across two different executions");
sp.setContentContext();
is(sp.executionContext, gScratchpadWindow.SCRATCHPAD_CONTEXT_CONTENT,
"executionContext is content");
is(sp.execute()[1], "undefined",
"global variable no longer exists after changing the context");
gScratchpadWindow.close();
gScratchpadWindow = null;
gBrowser.removeCurrentTab();
finish();
}

View File

@ -2,8 +2,8 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
// Reference to the Workspace chrome window object. // Reference to the Scratchpad chrome window object.
let gWorkspaceWindow; let gScratchpadWindow;
function test() function test()
{ {
@ -13,103 +13,103 @@ function test()
gBrowser.selectedBrowser.addEventListener("load", function() { gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
gWorkspaceWindow = Workspace.openWorkspace(); gScratchpadWindow = Scratchpad.openScratchpad();
gWorkspaceWindow.addEventListener("load", runTests, false); gScratchpadWindow.addEventListener("load", runTests, false);
}, true); }, true);
content.location = "data:text/html,<p>test execute() and print() in Workspace"; content.location = "data:text/html,<p>test execute() and print() in Scratchpad";
} }
function runTests() function runTests()
{ {
gWorkspaceWindow.removeEventListener("load", arguments.callee, false); gScratchpadWindow.removeEventListener("load", arguments.callee, false);
let ws = gWorkspaceWindow.Workspace; let sp = gScratchpadWindow.Scratchpad;
content.wrappedJSObject.foobarBug636725 = 1; content.wrappedJSObject.foobarBug636725 = 1;
ok(ws.textbox, "textbox exists"); ok(sp.textbox, "textbox exists");
ws.textbox.value = "++window.foobarBug636725"; sp.textbox.value = "++window.foobarBug636725";
let exec = ws.execute(); let exec = sp.execute();
is(exec[0], ws.textbox.value, "execute()[0] is correct"); is(exec[0], sp.textbox.value, "execute()[0] is correct");
is(exec[1], content.wrappedJSObject.foobarBug636725, is(exec[1], content.wrappedJSObject.foobarBug636725,
"execute()[1] is correct"); "execute()[1] is correct");
is(ws.textbox.value, "++window.foobarBug636725", is(sp.textbox.value, "++window.foobarBug636725",
"execute() does not change the textbox value"); "execute() does not change the textbox value");
is(content.wrappedJSObject.foobarBug636725, 2, is(content.wrappedJSObject.foobarBug636725, 2,
"execute() updated window.foobarBug636725"); "execute() updated window.foobarBug636725");
ws.print(); sp.print();
is(content.wrappedJSObject.foobarBug636725, 3, is(content.wrappedJSObject.foobarBug636725, 3,
"print() updated window.foobarBug636725"); "print() updated window.foobarBug636725");
is(ws.textbox.value, "++window.foobarBug636725/*\n3\n*/", is(sp.textbox.value, "++window.foobarBug636725/*\n3\n*/",
"print() shows evaluation result in the textbox"); "print() shows evaluation result in the textbox");
is(ws.selectedText, "/*\n3\n*/", "selectedText is correct"); is(sp.selectedText, "/*\n3\n*/", "selectedText is correct");
is(ws.textbox.selectionStart, 24, "selectionStart is correct"); is(sp.textbox.selectionStart, 24, "selectionStart is correct");
is(ws.textbox.selectionEnd, 31, "selectionEnd is correct"); is(sp.textbox.selectionEnd, 31, "selectionEnd is correct");
// Test selection execute() and print(). // Test selection execute() and print().
ws.textbox.value = "window.foobarBug636725 = 'a';\n" + sp.textbox.value = "window.foobarBug636725 = 'a';\n" +
"window.foobarBug636725 = 'b';"; "window.foobarBug636725 = 'b';";
ws.selectRange(1, 2); sp.selectRange(1, 2);
is(ws.textbox.selectionStart, 1, "selectionStart is 1"); is(sp.textbox.selectionStart, 1, "selectionStart is 1");
is(ws.textbox.selectionEnd, 2, "selectionEnd is 2"); is(sp.textbox.selectionEnd, 2, "selectionEnd is 2");
ws.selectRange(0, 29); sp.selectRange(0, 29);
is(ws.textbox.selectionStart, 0, "selectionStart is 0"); is(sp.textbox.selectionStart, 0, "selectionStart is 0");
is(ws.textbox.selectionEnd, 29, "selectionEnd is 29"); is(sp.textbox.selectionEnd, 29, "selectionEnd is 29");
exec = ws.execute(); exec = sp.execute();
is(exec[0], "window.foobarBug636725 = 'a';", is(exec[0], "window.foobarBug636725 = 'a';",
"execute()[0] is correct"); "execute()[0] is correct");
is(exec[1], "a", is(exec[1], "a",
"execute()[1] is correct"); "execute()[1] is correct");
is(ws.textbox.value, "window.foobarBug636725 = 'a';\n" + is(sp.textbox.value, "window.foobarBug636725 = 'a';\n" +
"window.foobarBug636725 = 'b';", "window.foobarBug636725 = 'b';",
"execute() does not change the textbox value"); "execute() does not change the textbox value");
is(content.wrappedJSObject.foobarBug636725, "a", is(content.wrappedJSObject.foobarBug636725, "a",
"execute() worked for the selected range"); "execute() worked for the selected range");
ws.textbox.value = "window.foobarBug636725 = 'c';\n" + sp.textbox.value = "window.foobarBug636725 = 'c';\n" +
"window.foobarBug636725 = 'b';"; "window.foobarBug636725 = 'b';";
ws.selectRange(0, 22); sp.selectRange(0, 22);
ws.print(); sp.print();
is(content.wrappedJSObject.foobarBug636725, "a", is(content.wrappedJSObject.foobarBug636725, "a",
"print() worked for the selected range"); "print() worked for the selected range");
is(ws.textbox.value, "window.foobarBug636725" + is(sp.textbox.value, "window.foobarBug636725" +
"/*\na\n*/" + "/*\na\n*/" +
" = 'c';\n" + " = 'c';\n" +
"window.foobarBug636725 = 'b';", "window.foobarBug636725 = 'b';",
"print() shows evaluation result in the textbox"); "print() shows evaluation result in the textbox");
is(ws.selectedText, "/*\na\n*/", "selectedText is correct"); is(sp.selectedText, "/*\na\n*/", "selectedText is correct");
is(ws.textbox.selectionStart, 22, "selectionStart is correct"); is(sp.textbox.selectionStart, 22, "selectionStart is correct");
is(ws.textbox.selectionEnd, 29, "selectionEnd is correct"); is(sp.textbox.selectionEnd, 29, "selectionEnd is correct");
ws.deselect(); sp.deselect();
ok(!ws.selectedText, "selectedText is empty"); ok(!sp.selectedText, "selectedText is empty");
is(ws.textbox.selectionStart, ws.textbox.selectionEnd, "deselect() works"); is(sp.textbox.selectionStart, sp.textbox.selectionEnd, "deselect() works");
gWorkspaceWindow.close(); gScratchpadWindow.close();
gWorkspaceWindow = null; gScratchpadWindow = null;
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
finish(); finish();
} }

View File

@ -9,11 +9,11 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm");
// Reference to the Workspace chrome window object. // Reference to the Scratchpad chrome window object.
let gWorkspaceWindow; let gScratchpadWindow;
// Reference to the Workspace object. // Reference to the Scratchpad object.
let gWorkspace; let gScratchpad;
// Reference to the temporary nsIFile we will work with. // Reference to the temporary nsIFile we will work with.
let gFile; let gFile;
@ -29,18 +29,18 @@ function test()
gBrowser.selectedBrowser.addEventListener("load", function() { gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
gWorkspaceWindow = Workspace.openWorkspace(); gScratchpadWindow = Scratchpad.openScratchpad();
gWorkspaceWindow.addEventListener("load", runTests, false); gScratchpadWindow.addEventListener("load", runTests, false);
}, true); }, true);
content.location = "data:text/html,<p>test file open and save in Workspace"; content.location = "data:text/html,<p>test file open and save in Scratchpad";
} }
function runTests() function runTests()
{ {
gWorkspaceWindow.removeEventListener("load", arguments.callee, false); gScratchpadWindow.removeEventListener("load", arguments.callee, false);
gWorkspace = gWorkspaceWindow.Workspace; gScratchpad = gScratchpadWindow.Scratchpad;
// Create a temporary file. // Create a temporary file.
gFile = FileUtils.getFile("TmpD", ["fileForBug636725.tmp"]); gFile = FileUtils.getFile("TmpD", ["fileForBug636725.tmp"]);
@ -65,52 +65,52 @@ function tempFileSaved(aStatus)
ok(Components.isSuccessCode(aStatus), ok(Components.isSuccessCode(aStatus),
"the temporary file was saved successfully"); "the temporary file was saved successfully");
// Import the file into Workspace. // Import the file into Scratchpad.
gWorkspace.importFromFile(gFile.QueryInterface(Ci.nsILocalFile), true, gScratchpad.importFromFile(gFile.QueryInterface(Ci.nsILocalFile), true,
fileImported); fileImported);
} }
function fileImported(aStatus, aFileContent) function fileImported(aStatus, aFileContent)
{ {
ok(Components.isSuccessCode(aStatus), ok(Components.isSuccessCode(aStatus),
"the temporary file was imported successfully with Workspace"); "the temporary file was imported successfully with Scratchpad");
is(aFileContent, gFileContent, is(aFileContent, gFileContent,
"received data is correct"); "received data is correct");
is(gWorkspace.textbox.value, gFileContent, is(gScratchpad.textbox.value, gFileContent,
"the textbox.value is correct"); "the textbox.value is correct");
// Save the file after changes. // Save the file after changes.
gFileContent += "// omg, saved!"; gFileContent += "// omg, saved!";
gWorkspace.textbox.value = gFileContent; gScratchpad.textbox.value = gFileContent;
gWorkspace.exportToFile(gFile.QueryInterface(Ci.nsILocalFile), true, true, gScratchpad.exportToFile(gFile.QueryInterface(Ci.nsILocalFile), true, true,
fileExported); fileExported);
} }
function fileExported(aStatus) function fileExported(aStatus)
{ {
ok(Components.isSuccessCode(aStatus), ok(Components.isSuccessCode(aStatus),
"the temporary file was exported successfully with Workspace"); "the temporary file was exported successfully with Scratchpad");
let oldContent = gFileContent; let oldContent = gFileContent;
// Attempt another file save, with confirmation which returns false. // Attempt another file save, with confirmation which returns false.
gFileContent += "// omg, saved twice!"; gFileContent += "// omg, saved twice!";
gWorkspace.textbox.value = gFileContent; gScratchpad.textbox.value = gFileContent;
let oldConfirm = gWorkspaceWindow.confirm; let oldConfirm = gScratchpadWindow.confirm;
let askedConfirmation = false; let askedConfirmation = false;
gWorkspaceWindow.confirm = function() { gScratchpadWindow.confirm = function() {
askedConfirmation = true; askedConfirmation = true;
return false; return false;
}; };
gWorkspace.exportToFile(gFile.QueryInterface(Ci.nsILocalFile), false, true, gScratchpad.exportToFile(gFile.QueryInterface(Ci.nsILocalFile), false, true,
fileExported2); fileExported2);
gWorkspaceWindow.confirm = oldConfirm; gScratchpadWindow.confirm = oldConfirm;
ok(askedConfirmation, "exportToFile() asked for overwrite confirmation"); ok(askedConfirmation, "exportToFile() asked for overwrite confirmation");
@ -141,9 +141,9 @@ function fileRead(aInputStream, aStatus)
// Done! // Done!
gFile.remove(false); gFile.remove(false);
gFile = null; gFile = null;
gWorkspace = null; gScratchpad = null;
gWorkspaceWindow.close(); gScratchpadWindow.close();
gWorkspaceWindow = null; gScratchpadWindow = null;
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
finish(); finish();
} }

View File

@ -0,0 +1,63 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Reference to the Scratchpad chrome window object.
let gScratchpadWindow;
function test()
{
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
ok(Scratchpad, "Scratchpad variable exists");
gScratchpadWindow = Scratchpad.openScratchpad();
gScratchpadWindow.addEventListener("load", runTests, false);
}, true);
content.location = "data:text/html,initialization test for Scratchpad";
}
function runTests()
{
gScratchpadWindow.removeEventListener("load", arguments.callee, false);
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");
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-chromeContext");
ok(chromeContextCommand, "Chrome context command element exists");
is(chromeContextCommand.getAttribute("disabled"), "true",
"Chrome context command is disabled");
gScratchpadWindow.close();
gScratchpadWindow = null;
gBrowser.removeCurrentTab();
finish();
}

View File

@ -2,8 +2,8 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
// Reference to the Workspace chrome window object. // Reference to the Scratchpad chrome window object.
let gWorkspaceWindow; let gScratchpadWindow;
function test() function test()
{ {
@ -13,26 +13,26 @@ function test()
gBrowser.selectedBrowser.addEventListener("load", function() { gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
gWorkspaceWindow = Workspace.openWorkspace(); gScratchpadWindow = Scratchpad.openScratchpad();
gWorkspaceWindow.addEventListener("load", runTests, false); gScratchpadWindow.addEventListener("load", runTests, false);
}, true); }, true);
content.location = "data:text/html,<title>foobarBug636725</title>" + content.location = "data:text/html,<title>foobarBug636725</title>" +
"<p>test inspect() in Workspace"; "<p>test inspect() in Scratchpad";
} }
function runTests() function runTests()
{ {
gWorkspaceWindow.removeEventListener("load", arguments.callee, false); gScratchpadWindow.removeEventListener("load", arguments.callee, false);
let ws = gWorkspaceWindow.Workspace; let sp = gScratchpadWindow.Scratchpad;
ok(ws.textbox, "textbox exists"); ok(sp.textbox, "textbox exists");
ws.textbox.value = "document"; sp.textbox.value = "document";
ws.inspect(); sp.inspect();
let propPanel = document.querySelector(".workspace_propertyPanel"); let propPanel = document.querySelector(".scratchpad_propertyPanel");
ok(propPanel, "property panel is open"); ok(propPanel, "property panel is open");
propPanel.addEventListener("popupshown", function() { propPanel.addEventListener("popupshown", function() {
@ -56,8 +56,8 @@ function runTests()
executeSoon(function() { executeSoon(function() {
propPanel.hidePopup(); propPanel.hidePopup();
gWorkspaceWindow.close(); gScratchpadWindow.close();
gWorkspaceWindow = null; gScratchpadWindow = null;
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
finish(); finish();
}); });

View File

@ -0,0 +1,81 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Reference to the Scratchpad chrome window object.
let gScratchpadWindow;
function test()
{
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
gScratchpadWindow = Scratchpad.openScratchpad();
gScratchpadWindow.addEventListener("load", runTests, false);
}, true);
content.location = "data:text/html,<title>foobarBug636725</title>" +
"<p>test inspect() in Scratchpad";
}
function runTests()
{
gScratchpadWindow.removeEventListener("load", arguments.callee, false);
let sp = gScratchpadWindow.Scratchpad;
let doc = gScratchpadWindow.document;
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-resetContext": "resetContext",
"sp-menu-errorConsole": "openErrorConsole",
"sp-menu-webConsole": "openWebConsole",
};
let lastMethodCalled = null;
sp.__noSuchMethod__ = function(aMethodName) {
lastMethodCalled = aMethodName;
};
for (let id in methodsAndItems) {
lastMethodCalled = null;
let methodName = methodsAndItems[id];
let oldMethod = sp[methodName];
ok(oldMethod, "found method " + methodName + " in Scratchpad object");
delete sp[methodName];
let menu = doc.getElementById(id);
ok(menu, "found menuitem #" + id);
try {
menu.doCommand();
}
catch (ex) {
ok(false, "exception thrown while executing the command of menuitem #" + id);
}
ok(lastMethodCalled == methodName,
"method " + methodName + " invoked by the associated menuitem");
sp[methodName] = oldMethod;
}
delete sp.__noSuchMethod__;
gScratchpadWindow.close();
gScratchpadWindow = null;
gBrowser.removeCurrentTab();
finish();
}

View File

@ -1,125 +0,0 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Reference to the Workspace chrome window object.
let gWorkspaceWindow;
function test()
{
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
gWorkspaceWindow = Workspace.openWorkspace();
gWorkspaceWindow.addEventListener("load", runTests, false);
}, true);
content.location = "data:text/html,test context switch in Workspace";
}
function runTests()
{
gWorkspaceWindow.removeEventListener("load", arguments.callee, false);
let ws = gWorkspaceWindow.Workspace;
let contentMenu = gWorkspaceWindow.document.getElementById("ws-menu-content");
let chromeMenu = gWorkspaceWindow.document.getElementById("ws-menu-chrome");
let statusbar = ws.statusbarStatus;
ok(contentMenu, "found #ws-menu-content");
ok(chromeMenu, "found #ws-menu-chrome");
ok(statusbar, "found Workspace.statusbarStatus");
ws.setContentContext();
is(ws.executionContext, gWorkspaceWindow.WORKSPACE_CONTEXT_CONTENT,
"executionContext is content");
is(contentMenu.getAttribute("checked"), "true",
"content menuitem is checked");
ok(!chromeMenu.hasAttribute("checked"),
"chrome menuitem is not checked");
is(statusbar.getAttribute("label"), contentMenu.getAttribute("label"),
"statusbar label is correct");
ok(ws.textbox, "textbox exists");
ws.textbox.value = "window.foobarBug636725 = 'aloha';";
ok(!content.wrappedJSObject.foobarBug636725,
"no content.foobarBug636725");
ws.execute();
is(content.wrappedJSObject.foobarBug636725, "aloha",
"content.foobarBug636725 has been set");
ws.setChromeContext();
is(ws.executionContext, gWorkspaceWindow.WORKSPACE_CONTEXT_CHROME,
"executionContext is chrome");
is(chromeMenu.getAttribute("checked"), "true",
"chrome menuitem is checked");
ok(!contentMenu.hasAttribute("checked"),
"content menuitem is not checked");
is(statusbar.getAttribute("label"), chromeMenu.getAttribute("label"),
"statusbar label is correct");
ws.textbox.value = "window.foobarBug636725 = 'aloha2';";
ok(!window.foobarBug636725, "no window.foobarBug636725");
ws.execute();
is(window.foobarBug636725, "aloha2", "window.foobarBug636725 has been set");
ws.textbox.value = "window.gBrowser";
is(typeof ws.execute()[1].addTab, "function",
"chrome context has access to chrome objects");
// Check that the sandbox is cached.
ws.textbox.value = "typeof foobarBug636725cache;";
is(ws.execute()[1], "undefined", "global variable does not exist");
ws.textbox.value = "var foobarBug636725cache = 'foo';";
ws.execute();
ws.textbox.value = "typeof foobarBug636725cache;";
is(ws.execute()[1], "string",
"global variable exists across two different executions");
ws.resetContext();
is(ws.execute()[1], "undefined",
"global variable no longer exists after calling resetContext()");
ws.textbox.value = "var foobarBug636725cache2 = 'foo';";
ws.execute();
ws.textbox.value = "typeof foobarBug636725cache2;";
is(ws.execute()[1], "string",
"global variable exists across two different executions");
ws.setContentContext();
is(ws.executionContext, gWorkspaceWindow.WORKSPACE_CONTEXT_CONTENT,
"executionContext is content");
is(ws.execute()[1], "undefined",
"global variable no longer exists after changing the context");
gWorkspaceWindow.close();
gWorkspaceWindow = null;
gBrowser.removeCurrentTab();
finish();
}

View File

@ -1,63 +0,0 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Reference to the Workspace chrome window object.
let gWorkspaceWindow;
function test()
{
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
ok(Workspace, "Workspace variable exists");
gWorkspaceWindow = Workspace.openWorkspace();
gWorkspaceWindow.addEventListener("load", runTests, false);
}, true);
content.location = "data:text/html,initialization test for Workspace";
}
function runTests()
{
gWorkspaceWindow.removeEventListener("load", arguments.callee, false);
let ws = gWorkspaceWindow.Workspace;
ok(ws, "Workspace object exists in new window");
is(typeof ws.execute, "function", "Workspace.execute() exists");
is(typeof ws.inspect, "function", "Workspace.inspect() exists");
is(typeof ws.print, "function", "Workspace.print() exists");
let chromeContextMenu = gWorkspaceWindow.document.
getElementById("ws-menu-chrome");
ok(chromeContextMenu, "Chrome context menuitem element exists");
is(chromeContextMenu.getAttribute("hidden"), "true",
"Chrome context menuitem is hidden");
let errorConsoleCommand = gWorkspaceWindow.document.
getElementById("ws-cmd-errorConsole");
ok(errorConsoleCommand, "Error console command element exists");
is(errorConsoleCommand.getAttribute("disabled"), "true",
"Error console command is disabled");
let errorConsoleMenu = gWorkspaceWindow.document.
getElementById("ws-menu-errorConsole");
ok(errorConsoleMenu, "Error console menu element exists");
is(errorConsoleMenu.getAttribute("hidden"), "true",
"Error console menu item is hidden");
let chromeContextCommand = gWorkspaceWindow.document.
getElementById("ws-cmd-chromeContext");
ok(chromeContextCommand, "Chrome context command element exists");
is(chromeContextCommand.getAttribute("disabled"), "true",
"Chrome context command is disabled");
gWorkspaceWindow.close();
gWorkspaceWindow = null;
gBrowser.removeCurrentTab();
finish();
}

View File

@ -1,81 +0,0 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Reference to the Workspace chrome window object.
let gWorkspaceWindow;
function test()
{
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
gWorkspaceWindow = Workspace.openWorkspace();
gWorkspaceWindow.addEventListener("load", runTests, false);
}, true);
content.location = "data:text/html,<title>foobarBug636725</title>" +
"<p>test inspect() in Workspace";
}
function runTests()
{
gWorkspaceWindow.removeEventListener("load", arguments.callee, false);
let ws = gWorkspaceWindow.Workspace;
let doc = gWorkspaceWindow.document;
let methodsAndItems = {
"ws-menu-newworkspace": "openWorkspace",
"ws-menu-open": "openFile",
"ws-menu-save": "saveFile",
"ws-menu-saveas": "saveFileAs",
"ws-text-execute": "execute",
"ws-text-inspect": "inspect",
"ws-menu-content": "setContentContext",
"ws-menu-chrome": "setChromeContext",
"ws-menu-resetContext": "resetContext",
"ws-menu-errorConsole": "openErrorConsole",
"ws-menu-webConsole": "openWebConsole",
};
let lastMethodCalled = null;
ws.__noSuchMethod__ = function(aMethodName) {
lastMethodCalled = aMethodName;
};
for (let id in methodsAndItems) {
lastMethodCalled = null;
let methodName = methodsAndItems[id];
let oldMethod = ws[methodName];
ok(oldMethod, "found method " + methodName + " in Workspace object");
delete ws[methodName];
let menu = doc.getElementById(id);
ok(menu, "found menuitem #" + id);
try {
menu.doCommand();
}
catch (ex) {
ok(false, "exception thrown while executing the command of menuitem #" + id);
}
ok(lastMethodCalled == methodName,
"method " + methodName + " invoked by the associated menuitem");
ws[methodName] = oldMethod;
}
delete ws.__noSuchMethod__;
gWorkspaceWindow.close();
gWorkspaceWindow = null;
gBrowser.removeCurrentTab();
finish();
}

View File

@ -29,8 +29,8 @@ browser.jar:
* content/browser/browser-tabPreviews.xml (content/browser-tabPreviews.xml) * content/browser/browser-tabPreviews.xml (content/browser-tabPreviews.xml)
* content/browser/fullscreen-video.xhtml (content/fullscreen-video.xhtml) * content/browser/fullscreen-video.xhtml (content/fullscreen-video.xhtml)
* content/browser/inspector.html (content/inspector.html) * content/browser/inspector.html (content/inspector.html)
* content/browser/workspace.xul (content/workspace.xul) * content/browser/scratchpad.xul (content/scratchpad.xul)
* content/browser/workspace.js (content/workspace.js) * content/browser/scratchpad.js (content/scratchpad.js)
* content/browser/pageinfo/pageInfo.xul (content/pageinfo/pageInfo.xul) * content/browser/pageinfo/pageInfo.xul (content/pageinfo/pageInfo.xul)
* content/browser/pageinfo/pageInfo.js (content/pageinfo/pageInfo.js) * content/browser/pageinfo/pageInfo.js (content/pageinfo/pageInfo.js)
* content/browser/pageinfo/pageInfo.css (content/pageinfo/pageInfo.css) * content/browser/pageinfo/pageInfo.css (content/pageinfo/pageInfo.css)

View File

@ -191,10 +191,20 @@ can reach it easily. -->
<!ENTITY inspectMenu.accesskey "T"> <!ENTITY inspectMenu.accesskey "T">
<!ENTITY inspectMenu.commandkey "I"> <!ENTITY inspectMenu.commandkey "I">
<!ENTITY workspace.label "Workspace"> <!-- LOCALIZATION NOTE (scratchpad.label): This menu item label appears
<!ENTITY workspace.accesskey "O"> - in the Tools menu. See bug 653093.
<!ENTITY workspace.keycode "VK_F4"> - The Scratchpad is intended to provide a simple text editor for creating
<!ENTITY workspace.keytext "F4"> - and evaluating bits of JavaScript code for the purposes of function
- prototyping, experimentation and convenient scripting.
-
- It's quite possible that you won't have a good analogue for the word
- "Scratchpad" in your locale. You should feel free to find a close
- approximation to it or choose a word (or words) that means
- "simple discardable text editor". -->
<!ENTITY scratchpad.label "Scratchpad">
<!ENTITY scratchpad.accesskey "r">
<!ENTITY scratchpad.keycode "VK_F4">
<!ENTITY scratchpad.keytext "F4">
<!ENTITY inspectPanelTitle.label "HTML"> <!ENTITY inspectPanelTitle.label "HTML">
<!ENTITY inspectButton.label "Inspect"> <!ENTITY inspectButton.label "Inspect">

View File

@ -1,7 +1,16 @@
<!-- LOCALIZATION NOTE : FILE This file contains the Workspace window strings --> <!-- LOCALIZATION NOTE : FILE This file contains the Scratchpad window strings -->
<!-- LOCALIZATION NOTE : FILE Do not translate commandkeys --> <!-- LOCALIZATION NOTE : FILE Do not translate commandkeys -->
<!ENTITY window.title "Workspace"> <!-- LOCALIZATION NOTE (scratchpad.title):
- The Scratchpad is intended to provide a simple text editor for creating
- and evaluating bits of JavaScript code for the purposes of function
- prototyping, experimentation and convenient scripting.
-
- It's quite possible that you won't have a good analogue for the word
- "Scratchpad" in your locale. You should feel free to find a close
- approximation to it or choose a word (or words) that means
- "simple discardable text editor". -->
<!ENTITY window.title "Scratchpad">
<!ENTITY fileMenu.label "File"> <!ENTITY fileMenu.label "File">
<!ENTITY fileMenu.accesskey "F"> <!ENTITY fileMenu.accesskey "F">

View File

@ -1,5 +1,5 @@
# LOCALIZATION NOTE (propertyPanel.updateButton.label): Used in the Property # LOCALIZATION NOTE (propertyPanel.updateButton.label): Used in the Property
# Panel that is opened by the Workspace window when inspecting an object. This # Panel that is opened by the Scratchpad window when inspecting an object. This
# is the Update button label. # is the Update button label.
propertyPanel.updateButton.label=Update propertyPanel.updateButton.label=Update
propertyPanel.updateButton.accesskey=U propertyPanel.updateButton.accesskey=U
@ -9,12 +9,12 @@ propertyPanel.updateButton.accesskey=U
export.fileOverwriteConfirmation=File exists. Overwrite? export.fileOverwriteConfirmation=File exists. Overwrite?
# LOCALIZATION NOTE (browserWindow.unavailable): This error message is shown # LOCALIZATION NOTE (browserWindow.unavailable): This error message is shown
# when Workspace does not find any recently active window of navigator:browser # when Scratchpad does not find any recently active window of navigator:browser
# type. # type.
browserWindow.unavailable=Workspace cannot find any browser window where to execute the code. browserWindow.unavailable=Scratchpad cannot find any browser window to execute the code in.
# LOCALIZATION NOTE (openFile.title): This is the file picker title, when you # LOCALIZATION NOTE (openFile.title): This is the file picker title, when you
# open a file from Workspace. # open a file from Scratchpad.
openFile.title=Open File openFile.title=Open File
# LOCALIZATION NOTE (openFile.failed): This is the message displayed when file # LOCALIZATION NOTE (openFile.failed): This is the message displayed when file
@ -22,7 +22,7 @@ openFile.title=Open File
openFile.failed=Failed to read the file. openFile.failed=Failed to read the file.
# LOCALIZATION NOTE (saveFileAs): This is the file picker title, when you save # LOCALIZATION NOTE (saveFileAs): This is the file picker title, when you save
# a file in Workspace. # a file in Scratchpad.
saveFileAs=Save File As saveFileAs=Save File As
# LOCALIZATION NOTE (saveFile.failed): This is the message displayed when file # LOCALIZATION NOTE (saveFile.failed): This is the message displayed when file

View File

@ -15,8 +15,8 @@
locale/browser/baseMenuOverlay.dtd (%chrome/browser/baseMenuOverlay.dtd) locale/browser/baseMenuOverlay.dtd (%chrome/browser/baseMenuOverlay.dtd)
locale/browser/browser.properties (%chrome/browser/browser.properties) locale/browser/browser.properties (%chrome/browser/browser.properties)
locale/browser/inspector.properties (%chrome/browser/inspector.properties) locale/browser/inspector.properties (%chrome/browser/inspector.properties)
locale/browser/workspace.properties (%chrome/browser/workspace.properties) locale/browser/scratchpad.properties (%chrome/browser/scratchpad.properties)
locale/browser/workspace.dtd (%chrome/browser/workspace.dtd) locale/browser/scratchpad.dtd (%chrome/browser/scratchpad.dtd)
locale/browser/openLocation.dtd (%chrome/browser/openLocation.dtd) locale/browser/openLocation.dtd (%chrome/browser/openLocation.dtd)
locale/browser/openLocation.properties (%chrome/browser/openLocation.properties) locale/browser/openLocation.properties (%chrome/browser/openLocation.properties)
* locale/browser/pageInfo.dtd (%chrome/browser/pageInfo.dtd) * locale/browser/pageInfo.dtd (%chrome/browser/pageInfo.dtd)