mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
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:
parent
ca7b9a63e0
commit
b895140c3c
@ -992,8 +992,8 @@ pref("services.sync.prefs.sync.xpinstall.whitelist.required", true);
|
||||
pref("devtools.errorconsole.enabled", false);
|
||||
pref("devtools.inspector.enabled", false);
|
||||
|
||||
// Enable the Workspace tool.
|
||||
pref("devtools.workspace.enabled", true);
|
||||
// Enable the Scratchpad tool.
|
||||
pref("devtools.scratchpad.enabled", true);
|
||||
|
||||
// Enable tools for Chrome development.
|
||||
pref("devtools.chrome.enabled", false);
|
||||
|
@ -187,11 +187,11 @@
|
||||
type="checkbox"
|
||||
command="Tools:Inspect"
|
||||
key="key_inspect"/>
|
||||
<menuitem id="appmenu_workspace"
|
||||
<menuitem id="appmenu_scratchpad"
|
||||
hidden="true"
|
||||
label="&workspace.label;"
|
||||
key="key_workspace"
|
||||
command="Tools:Workspace"/>
|
||||
label="&scratchpad.label;"
|
||||
key="key_scratchpad"
|
||||
command="Tools:Scratchpad"/>
|
||||
<menuitem id="appmenu_pageSource"
|
||||
label="&viewPageSourceCmd.label;"
|
||||
command="View:PageSource"
|
||||
|
@ -557,12 +557,12 @@
|
||||
accesskey="&webConsoleCmd.accesskey;"
|
||||
key="key_webConsole"
|
||||
oncommand="HUDConsoleUI.toggleHUD();"/>
|
||||
<menuitem id="menu_workspace"
|
||||
<menuitem id="menu_scratchpad"
|
||||
hidden="true"
|
||||
label="&workspace.label;"
|
||||
accesskey="&workspace.accesskey;"
|
||||
key="key_workspace"
|
||||
command="Tools:Workspace"/>
|
||||
label="&scratchpad.label;"
|
||||
accesskey="&scratchpad.accesskey;"
|
||||
key="key_scratchpad"
|
||||
command="Tools:Scratchpad"/>
|
||||
<menuitem id="menu_pageInfo"
|
||||
accesskey="&pageInfoCmd.accesskey;"
|
||||
label="&pageInfoCmd.label;"
|
||||
|
@ -125,7 +125,7 @@
|
||||
<command id="Tools:Search" oncommand="BrowserSearch.webSearch();"/>
|
||||
<command id="Tools:Downloads" oncommand="BrowserDownloadsUI();"/>
|
||||
<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:Sanitize"
|
||||
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_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_workspace" keycode="&workspace.keycode;"
|
||||
keytext="&workspace.keytext;" command="Tools:Workspace"/>
|
||||
<key id="key_scratchpad" keycode="&scratchpad.keycode;"
|
||||
keytext="&scratchpad.keytext;" command="Tools:Scratchpad"/>
|
||||
<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="printKb" key="&printCmd.commandkey;" command="cmd_print" modifiers="accel"/>
|
||||
|
@ -1654,13 +1654,13 @@ function delayedStartup(isLoadingBlank, mustLoadSidebar) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// Enable Workspace in the UI, if the preference allows this.
|
||||
let workspaceEnabled = gPrefService.getBoolPref(Workspace.prefEnabledName);
|
||||
if (workspaceEnabled) {
|
||||
document.getElementById("menu_workspace").hidden = false;
|
||||
document.getElementById("Tools:Workspace").removeAttribute("disabled");
|
||||
// Enable Scratchpad in the UI, if the preference allows this.
|
||||
let scratchpadEnabled = gPrefService.getBoolPref(Scratchpad.prefEnabledName);
|
||||
if (scratchpadEnabled) {
|
||||
document.getElementById("menu_scratchpad").hidden = false;
|
||||
document.getElementById("Tools:Scratchpad").removeAttribute("disabled");
|
||||
#ifdef MENUBAR_CAN_AUTOHIDE
|
||||
document.getElementById("appmenu_workspace").hidden = false;
|
||||
document.getElementById("appmenu_scratchpad").hidden = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -8642,15 +8642,15 @@ function toggleAddonBar() {
|
||||
setToolbarVisibility(addonBar, addonBar.collapsed);
|
||||
}
|
||||
|
||||
var Workspace = {
|
||||
prefEnabledName: "devtools.workspace.enabled",
|
||||
var Scratchpad = {
|
||||
prefEnabledName: "devtools.scratchpad.enabled",
|
||||
|
||||
openWorkspace: function WS_openWorkspace() {
|
||||
const WORKSPACE_WINDOW_URL = "chrome://browser/content/workspace.xul";
|
||||
const WORKSPACE_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
openScratchpad: function SP_openScratchpad() {
|
||||
const SCRATCHPAD_WINDOW_URL = "chrome://browser/content/scratchpad.xul";
|
||||
const SCRATCHPAD_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
return Services.ww.openWindow(null, WORKSPACE_WINDOW_URL, "_blank",
|
||||
WORKSPACE_WINDOW_FEATURES, null);
|
||||
return Services.ww.openWindow(null, SCRATCHPAD_WINDOW_URL, "_blank",
|
||||
SCRATCHPAD_WINDOW_FEATURES, null);
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Workspace.
|
||||
* The Original Code is Scratchpad.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
@ -48,40 +48,40 @@ Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource:///modules/PropertyPanel.jsm");
|
||||
|
||||
const WORKSPACE_CONTEXT_CONTENT = 1;
|
||||
const WORKSPACE_CONTEXT_CHROME = 2;
|
||||
const WORKSPACE_WINDOW_URL = "chrome://browser/content/workspace.xul";
|
||||
const WORKSPACE_L10N = "chrome://browser/locale/workspace.properties";
|
||||
const WORKSPACE_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
const SCRATCHPAD_CONTEXT_CONTENT = 1;
|
||||
const SCRATCHPAD_CONTEXT_CHROME = 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 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.
|
||||
*
|
||||
* 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.
|
||||
* - 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.
|
||||
*/
|
||||
executionContext: WORKSPACE_CONTEXT_CONTENT,
|
||||
executionContext: SCRATCHPAD_CONTEXT_CONTENT,
|
||||
|
||||
/**
|
||||
* Retrieve the xul:textbox DOM element. This element holds the source code
|
||||
* 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
|
||||
* current code execution context.
|
||||
*/
|
||||
get statusbarStatus() document.getElementById("workspace-status"),
|
||||
get statusbarStatus() document.getElementById("scratchpad-status"),
|
||||
|
||||
/**
|
||||
* Get the selected text from the textbox.
|
||||
@ -177,20 +177,20 @@ var Workspace = {
|
||||
/**
|
||||
* Drop the textbox selection.
|
||||
*/
|
||||
deselect: function WS_deselect()
|
||||
deselect: function SP_deselect()
|
||||
{
|
||||
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
|
||||
* Selection range start.
|
||||
* @param number aEnd
|
||||
* Selection range end.
|
||||
*/
|
||||
selectRange: function WS_selectRange(aStart, aEnd)
|
||||
selectRange: function SP_selectRange(aStart, aEnd)
|
||||
{
|
||||
this.textbox.selectionStart = aStart;
|
||||
this.textbox.selectionEnd = aEnd;
|
||||
@ -204,12 +204,12 @@ var Workspace = {
|
||||
* @return mixed
|
||||
* The script evaluation result.
|
||||
*/
|
||||
evalInContentSandbox: function WS_evalInContentSandbox(aString)
|
||||
evalInContentSandbox: function SP_evalInContentSandbox(aString)
|
||||
{
|
||||
let result;
|
||||
try {
|
||||
result = Cu.evalInSandbox(aString, this.contentSandbox, "1.8",
|
||||
"Workspace", 1);
|
||||
"Scratchpad", 1);
|
||||
}
|
||||
catch (ex) {
|
||||
this.openWebConsole();
|
||||
@ -238,12 +238,12 @@ var Workspace = {
|
||||
* @return mixed
|
||||
* The script evaluation result.
|
||||
*/
|
||||
evalInChromeSandbox: function WS_evalInChromeSandbox(aString)
|
||||
evalInChromeSandbox: function SP_evalInChromeSandbox(aString)
|
||||
{
|
||||
let result;
|
||||
try {
|
||||
result = Cu.evalInSandbox(aString, this.chromeSandbox, "1.8",
|
||||
"Workspace", 1);
|
||||
"Scratchpad", 1);
|
||||
}
|
||||
catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
@ -263,9 +263,9 @@ var Workspace = {
|
||||
* @return mixed
|
||||
* 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.evalInChromeSandbox(aString);
|
||||
},
|
||||
@ -274,7 +274,7 @@ var Workspace = {
|
||||
* Execute the selected text (if any) or the entire textbox content in the
|
||||
* current context.
|
||||
*/
|
||||
execute: function WS_execute()
|
||||
execute: function SP_execute()
|
||||
{
|
||||
let selection = this.selectedText || this.textbox.value;
|
||||
let result = this.evalForContext(selection);
|
||||
@ -287,7 +287,7 @@ var Workspace = {
|
||||
* current context. The resulting object is opened up in the Property Panel
|
||||
* for inspection.
|
||||
*/
|
||||
inspect: function WS_inspect()
|
||||
inspect: function SP_inspect()
|
||||
{
|
||||
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
|
||||
* selected text.
|
||||
*/
|
||||
print: function WS_print()
|
||||
print: function SP_print()
|
||||
{
|
||||
let selectionStart = this.textbox.selectionStart;
|
||||
let selectionEnd = this.textbox.selectionEnd;
|
||||
@ -338,7 +338,7 @@ var Workspace = {
|
||||
* @return object
|
||||
* The PropertyPanel object instance.
|
||||
*/
|
||||
openPropertyPanel: function WS_openPropertyPanel(aEvalString, aOutputObject)
|
||||
openPropertyPanel: function SP_openPropertyPanel(aEvalString, aOutputObject)
|
||||
{
|
||||
let self = this;
|
||||
let propPanel;
|
||||
@ -375,7 +375,7 @@ var Workspace = {
|
||||
propPanel = new PropertyPanel(parent, doc, title, aOutputObject, buttons);
|
||||
|
||||
let panel = propPanel.panel;
|
||||
panel.setAttribute("class", "workspace_propertyPanel");
|
||||
panel.setAttribute("class", "scratchpad_propertyPanel");
|
||||
panel.openPopup(null, "after_pointer", 0, 0, false, false);
|
||||
panel.sizeTo(200, 400);
|
||||
|
||||
@ -385,12 +385,12 @@ var Workspace = {
|
||||
// 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",
|
||||
WORKSPACE_WINDOW_FEATURES, null);
|
||||
Services.ww.openWindow(null, SCRATCHPAD_WINDOW_URL, "_blank",
|
||||
SCRATCHPAD_WINDOW_FEATURES, null);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -408,7 +408,7 @@ var Workspace = {
|
||||
* get the following arguments:
|
||||
* 1) the nsresult status code for the export operation.
|
||||
*/
|
||||
exportToFile: function WS_exportToFile(aFile, aNoConfirmation, aSilentError,
|
||||
exportToFile: function SP_exportToFile(aFile, aNoConfirmation, aSilentError,
|
||||
aCallback)
|
||||
{
|
||||
if (!aNoConfirmation && aFile.exists() &&
|
||||
@ -453,7 +453,7 @@ var Workspace = {
|
||||
* 1) the nsresult status code for the import operation.
|
||||
* 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.
|
||||
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);
|
||||
fp.init(window, this.strings.GetStringFromName("openFile.title"),
|
||||
@ -496,7 +496,7 @@ var Workspace = {
|
||||
/**
|
||||
* Save the textbox content to the currently open file.
|
||||
*/
|
||||
saveFile: function WS_saveFile()
|
||||
saveFile: function SP_saveFile()
|
||||
{
|
||||
if (!this.filename) {
|
||||
return this.saveFileAs();
|
||||
@ -510,12 +510,12 @@ var Workspace = {
|
||||
/**
|
||||
* 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);
|
||||
fp.init(window, this.strings.GetStringFromName("saveFileAs"),
|
||||
Ci.nsIFilePicker.modeSave);
|
||||
fp.defaultString = "workspace.js";
|
||||
fp.defaultString = "scratchpad.js";
|
||||
if (fp.show() != Ci.nsIFilePicker.returnCancel) {
|
||||
document.title = this.filename = fp.file.path;
|
||||
this.exportToFile(fp.file);
|
||||
@ -525,7 +525,7 @@ var Workspace = {
|
||||
/**
|
||||
* Open the Error Console.
|
||||
*/
|
||||
openErrorConsole: function WS_openErrorConsole()
|
||||
openErrorConsole: function SP_openErrorConsole()
|
||||
{
|
||||
this.browserWindow.toJavaScriptConsole();
|
||||
},
|
||||
@ -533,7 +533,7 @@ var Workspace = {
|
||||
/**
|
||||
* Open the Web Console.
|
||||
*/
|
||||
openWebConsole: function WS_openWebConsole()
|
||||
openWebConsole: function SP_openWebConsole()
|
||||
{
|
||||
if (!this.browserWindow.HUDConsoleUI.getOpenHUD()) {
|
||||
this.browserWindow.HUDConsoleUI.toggleHUD();
|
||||
@ -544,33 +544,33 @@ var Workspace = {
|
||||
/**
|
||||
* 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");
|
||||
document.getElementById("ws-menu-chrome").removeAttribute("checked");
|
||||
let content = document.getElementById("sp-menu-content");
|
||||
document.getElementById("sp-menu-chrome").removeAttribute("checked");
|
||||
content.setAttribute("checked", true);
|
||||
this.statusbarStatus.label = content.getAttribute("label");
|
||||
this.executionContext = WORKSPACE_CONTEXT_CONTENT;
|
||||
this.executionContext = SCRATCHPAD_CONTEXT_CONTENT;
|
||||
this.resetContext();
|
||||
},
|
||||
|
||||
/**
|
||||
* 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");
|
||||
document.getElementById("ws-menu-content").removeAttribute("checked");
|
||||
let chrome = document.getElementById("sp-menu-chrome");
|
||||
document.getElementById("sp-menu-content").removeAttribute("checked");
|
||||
chrome.setAttribute("checked", true);
|
||||
this.statusbarStatus.label = chrome.getAttribute("label");
|
||||
this.executionContext = WORKSPACE_CONTEXT_CHROME;
|
||||
this.executionContext = SCRATCHPAD_CONTEXT_CHROME;
|
||||
this.resetContext();
|
||||
},
|
||||
|
||||
/**
|
||||
* Reset the cached Cu.Sandbox object for the current context.
|
||||
*/
|
||||
resetContext: function WS_resetContext()
|
||||
resetContext: function SP_resetContext()
|
||||
{
|
||||
this._chromeSandbox = null;
|
||||
this._contentSandbox = null;
|
||||
@ -584,21 +584,21 @@ var Workspace = {
|
||||
* @return integer
|
||||
* the outer window ID
|
||||
*/
|
||||
getWindowId: function HS_getWindowId(aWindow)
|
||||
getWindowId: function SP_getWindowId(aWindow)
|
||||
{
|
||||
return aWindow.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
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 errorConsoleMenu = document.getElementById("ws-menu-errorConsole");
|
||||
let errorConsoleCommand = document.getElementById("ws-cmd-errorConsole");
|
||||
let chromeContextCommand = document.getElementById("ws-cmd-chromeContext");
|
||||
let chromeContextMenu = document.getElementById("sp-menu-chrome");
|
||||
let errorConsoleMenu = document.getElementById("sp-menu-errorConsole");
|
||||
let errorConsoleCommand = document.getElementById("sp-cmd-errorConsole");
|
||||
let chromeContextCommand = document.getElementById("sp-cmd-chromeContext");
|
||||
|
||||
let chrome = Services.prefs.getBoolPref(DEVTOOLS_CHROME_ENABLED);
|
||||
if (chrome) {
|
||||
@ -610,9 +610,9 @@ var Workspace = {
|
||||
},
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyGetter(Workspace, "strings", function () {
|
||||
return Services.strings.createBundle(WORKSPACE_L10N);
|
||||
XPCOMUtils.defineLazyGetter(Scratchpad, "strings", function () {
|
||||
return Services.strings.createBundle(SCRATCHPAD_L10N);
|
||||
});
|
||||
|
||||
addEventListener("DOMContentLoaded", Workspace.onLoad.bind(Workspace), false);
|
||||
addEventListener("DOMContentLoaded", Scratchpad.onLoad.bind(Scratchpad), false);
|
||||
|
@ -13,7 +13,7 @@
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Workspace.
|
||||
- The Original Code is Scratchpad.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- The Mozilla Foundation.
|
||||
@ -40,8 +40,8 @@
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
#endif
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % workspaceDTD SYSTEM "chrome://browser/locale/workspace.dtd" >
|
||||
%workspaceDTD;
|
||||
<!ENTITY % scratchpadDTD SYSTEM "chrome://browser/locale/scratchpad.dtd" >
|
||||
%scratchpadDTD;
|
||||
]>
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
|
||||
@ -49,59 +49,59 @@
|
||||
<window id="main-window"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&window.title;"
|
||||
windowtype="devtools:workspace"
|
||||
windowtype="devtools:scratchpad"
|
||||
screenX="4" screenY="4"
|
||||
width="640" height="480"
|
||||
persist="screenX screenY width height sizemode">
|
||||
|
||||
<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="ws-commandset">
|
||||
<command id="ws-cmd-newWindow" oncommand="Workspace.openWorkspace();"/>
|
||||
<command id="ws-cmd-openFile" oncommand="Workspace.openFile();"/>
|
||||
<command id="ws-cmd-save" oncommand="Workspace.saveFile();"/>
|
||||
<command id="ws-cmd-saveas" oncommand="Workspace.saveFileAs();"/>
|
||||
<commandset id="sp-commandset">
|
||||
<command id="sp-cmd-newWindow" oncommand="Scratchpad.openScratchpad();"/>
|
||||
<command id="sp-cmd-openFile" oncommand="Scratchpad.openFile();"/>
|
||||
<command id="sp-cmd-save" oncommand="Scratchpad.saveFile();"/>
|
||||
<command id="sp-cmd-saveas" oncommand="Scratchpad.saveFileAs();"/>
|
||||
|
||||
<!-- 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="ws-cmd-execute" oncommand="Workspace.execute();"/>
|
||||
<command id="ws-cmd-inspect" oncommand="Workspace.inspect();"/>
|
||||
<command id="ws-cmd-print" oncommand="Workspace.print();"/>
|
||||
<command id="ws-cmd-contentContext" oncommand="Workspace.setContentContext();"/>
|
||||
<command id="ws-cmd-chromeContext" oncommand="Workspace.setChromeContext();" disabled="true"/>
|
||||
<command id="ws-cmd-resetContext" oncommand="Workspace.resetContext();"/>
|
||||
<command id="ws-cmd-errorConsole" oncommand="Workspace.openErrorConsole();" disabled="true"/>
|
||||
<command id="ws-cmd-webConsole" oncommand="Workspace.openWebConsole();"/>
|
||||
<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-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="ws-keyset">
|
||||
<key id="ws-key-window"
|
||||
<keyset id="sp-keyset">
|
||||
<key id="sp-key-window"
|
||||
key="&newWindowCmd.commandkey;"
|
||||
command="ws-cmd-newWindow"
|
||||
command="sp-cmd-newWindow"
|
||||
modifiers="accel"/>
|
||||
<key id="ws-key-open"
|
||||
<key id="sp-key-open"
|
||||
key="&openFileCmd.commandkey;"
|
||||
command="ws-cmd-openFile"
|
||||
command="sp-cmd-openFile"
|
||||
modifiers="accel"/>
|
||||
<key id="ws-key-save"
|
||||
<key id="sp-key-save"
|
||||
key="&saveFileCmd.commandkey;"
|
||||
command="ws-cmd-save"
|
||||
command="sp-cmd-save"
|
||||
modifiers="accel"/>
|
||||
<key id="ws-key-close"
|
||||
<key id="sp-key-close"
|
||||
key="&closeCmd.key;"
|
||||
command="ws-cmd-close"
|
||||
command="sp-cmd-close"
|
||||
modifiers="accel"/>
|
||||
|
||||
<!-- TODO: bug 650340 - implement printFile
|
||||
<key id="ws-key-printFile"
|
||||
<key id="sp-key-printFile"
|
||||
key="&printCmd.commandkey;"
|
||||
command="ws-cmd-printFile"
|
||||
command="sp-cmd-printFile"
|
||||
modifiers="accel"/>
|
||||
-->
|
||||
|
||||
@ -118,104 +118,104 @@
|
||||
<key id="key_selectAll" key="&selectAllCmd.key;" modifiers="accel"/>
|
||||
<key id="key_undo" key="&undoCmd.key;" modifiers="accel"/>
|
||||
<key id="key_redo" key="&undoCmd.key;" modifiers="accel,shift"/>
|
||||
<key id="ws-key-execute"
|
||||
<key id="sp-key-execute"
|
||||
key="&execute.key;"
|
||||
command="ws-cmd-execute"
|
||||
command="sp-cmd-execute"
|
||||
modifiers="accel"/>
|
||||
<key id="ws-key-inspect"
|
||||
<key id="sp-key-inspect"
|
||||
key="&inspect.key;"
|
||||
command="ws-cmd-inspect"
|
||||
command="sp-cmd-inspect"
|
||||
modifiers="accel"/>
|
||||
<key id="ws-key-print"
|
||||
<key id="sp-key-print"
|
||||
key="&print.key;"
|
||||
command="ws-cmd-print"
|
||||
command="sp-cmd-print"
|
||||
modifiers="accel"/>
|
||||
<key id="ws-key-errorConsole"
|
||||
<key id="sp-key-errorConsole"
|
||||
key="&errorConsoleCmd.commandkey;"
|
||||
command="ws-cmd-errorConsole"
|
||||
command="sp-cmd-errorConsole"
|
||||
modifiers="accel,shift"/>
|
||||
<key id="ws-key-webConsole"
|
||||
<key id="sp-key-webConsole"
|
||||
key="&webConsoleCmd.commandkey;"
|
||||
command="ws-cmd-webConsole"
|
||||
command="sp-cmd-webConsole"
|
||||
modifiers="accel,shift"/>
|
||||
</keyset>
|
||||
|
||||
|
||||
<menubar id="ws-menubar">
|
||||
<menu id="ws-file-menu" label="&fileMenu.label;"
|
||||
<menubar id="sp-menubar">
|
||||
<menu id="sp-file-menu" label="&fileMenu.label;"
|
||||
accesskey="&fileMenu.accesskey;">
|
||||
<menupopup id="ws-menu-filepopup">
|
||||
<menuitem id="ws-menu-newworkspace"
|
||||
<menupopup id="sp-menu-filepopup">
|
||||
<menuitem id="sp-menu-newscratchpad"
|
||||
label="&newWindowCmd.label;"
|
||||
accesskey="&newWindowCmd.accesskey;"
|
||||
key="ws-key-window"
|
||||
command="ws-cmd-newWindow"/>
|
||||
key="sp-key-window"
|
||||
command="sp-cmd-newWindow"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="ws-menu-open"
|
||||
<menuitem id="sp-menu-open"
|
||||
label="&openFileCmd.label;"
|
||||
command="ws-cmd-openFile"
|
||||
key="ws-key-open"
|
||||
command="sp-cmd-openFile"
|
||||
key="sp-key-open"
|
||||
accesskey="&openFileCmd.accesskey;"/>
|
||||
<menuitem id="ws-menu-save"
|
||||
<menuitem id="sp-menu-save"
|
||||
label="&saveFileCmd.label;"
|
||||
accesskey="&saveFileCmd.accesskey;"
|
||||
key="ws-key-save"
|
||||
command="ws-cmd-save"/>
|
||||
<menuitem id="ws-menu-saveas"
|
||||
key="sp-key-save"
|
||||
command="sp-cmd-save"/>
|
||||
<menuitem id="sp-menu-saveas"
|
||||
label="&saveFileAsCmd.label;"
|
||||
accesskey="&saveFileAsCmd.accesskey;"
|
||||
command="ws-cmd-saveas"/>
|
||||
command="sp-cmd-saveas"/>
|
||||
<menuseparator/>
|
||||
|
||||
<!-- TODO: bug 650340 - implement printFile
|
||||
<menuitem id="ws-menu-print"
|
||||
<menuitem id="sp-menu-print"
|
||||
label="&printCmd.label;"
|
||||
accesskey="&printCmd.accesskey;"
|
||||
command="ws-cmd-printFile"/>
|
||||
command="sp-cmd-printFile"/>
|
||||
<menuseparator/>
|
||||
-->
|
||||
|
||||
<menuitem id="ws-menu-close"
|
||||
<menuitem id="sp-menu-close"
|
||||
label="&closeCmd.label;"
|
||||
key="ws-key-close"
|
||||
key="sp-key-close"
|
||||
accesskey="&closeCmd.accesskey;"
|
||||
command="ws-cmd-close"/>
|
||||
command="sp-cmd-close"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
<menu id="ws-edit-menu" label="&editMenu.label;"
|
||||
<menu id="sp-edit-menu" label="&editMenu.label;"
|
||||
accesskey="&editMenu.accesskey;">
|
||||
<menupopup id="ws-menu_editpopup">
|
||||
<menuitem id="ws-menu_undo"
|
||||
<menupopup id="sp-menu_editpopup">
|
||||
<menuitem id="sp-menu_undo"
|
||||
label="&undoCmd.label;"
|
||||
key="key_undo"
|
||||
accesskey="&undoCmd.accesskey;"
|
||||
disabled="true"
|
||||
oncommand="cmd_undo"/>
|
||||
<menuitem id="ws-menu-redo"
|
||||
<menuitem id="sp-menu-redo"
|
||||
label="&redoCmd.label;"
|
||||
key="key_redo"
|
||||
disabled="true"
|
||||
accesskey="&redoCmd.accesskey;"
|
||||
command="cmd_redo"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="ws-menu-cut"
|
||||
<menuitem id="sp-menu-cut"
|
||||
label="&cutCmd.label;"
|
||||
key="key_cut"
|
||||
accesskey="&cutCmd.accesskey;"
|
||||
command="cmd_cut"/>
|
||||
<menuitem id="ws-menu-copy"
|
||||
<menuitem id="sp-menu-copy"
|
||||
label="©Cmd.label;"
|
||||
key="key_copy"
|
||||
accesskey="©Cmd.accesskey;"
|
||||
command="cmd_copy"/>
|
||||
<menuitem id="ws-menu-paste"
|
||||
<menuitem id="sp-menu-paste"
|
||||
label="&pasteCmd.label;"
|
||||
key="key_paste"
|
||||
accesskey="&pasteCmd.accesskey;"
|
||||
command="cmd_paste"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="ws-menu-selectAll"
|
||||
<menuitem id="sp-menu-selectAll"
|
||||
label="&selectAllCmd.label;"
|
||||
key="key_selectAll"
|
||||
accesskey="&selectAllCmd.accesskey;"
|
||||
@ -223,82 +223,82 @@
|
||||
<menuseparator/>
|
||||
|
||||
<!-- TODO: bug 650345 - implement search and replace
|
||||
<menuitem id="ws-menu-find"
|
||||
<menuitem id="sp-menu-find"
|
||||
label="&findOnCmd.label;"
|
||||
accesskey="&findOnCmd.accesskey;"
|
||||
key="key_find"
|
||||
disabled="true"
|
||||
command="cmd_find"/>
|
||||
<menuitem id="ws-menu-findAgain"
|
||||
<menuitem id="sp-menu-findAgain"
|
||||
label="&findAgainCmd.label;"
|
||||
accesskey="&findAgainCmd.accesskey;"
|
||||
key="key_findAgain"
|
||||
disabled="true"
|
||||
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;"
|
||||
accesskey="&execute.accesskey;"
|
||||
key="ws-key-execute"
|
||||
command="ws-cmd-execute"/>
|
||||
<menuitem id="ws-text-inspect"
|
||||
key="sp-key-execute"
|
||||
command="sp-cmd-execute"/>
|
||||
<menuitem id="sp-text-inspect"
|
||||
label="&inspect.label;"
|
||||
accesskey="&inspect.accesskey;"
|
||||
key="ws-key-inspect"
|
||||
command="ws-cmd-inspect"/>
|
||||
<menuitem id="ws-text-print"
|
||||
key="sp-key-inspect"
|
||||
command="sp-cmd-inspect"/>
|
||||
<menuitem id="sp-text-print"
|
||||
label="&print.label;"
|
||||
accesskey="&print.accesskey;"
|
||||
key="ws-key-print"
|
||||
command="ws-cmd-print"/>
|
||||
key="sp-key-print"
|
||||
command="sp-cmd-print"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
<menu id="ws-context-menu"
|
||||
<menu id="sp-context-menu"
|
||||
label="&contextMenu.label;"
|
||||
accesskey="&contextMenu.accesskey;">
|
||||
<menupopup id="ws-menu-context">
|
||||
<menuitem id="ws-menu-content"
|
||||
<menupopup id="sp-menu-context">
|
||||
<menuitem id="sp-menu-content"
|
||||
label="&contentContext.label;"
|
||||
accesskey="&contentContext.accesskey;"
|
||||
command="ws-cmd-contentContext"
|
||||
command="sp-cmd-contentContext"
|
||||
checked="true"
|
||||
type="radio"/>
|
||||
<menuitem id="ws-menu-chrome" hidden="true"
|
||||
command="ws-cmd-chromeContext"
|
||||
<menuitem id="sp-menu-chrome" hidden="true"
|
||||
command="sp-cmd-chromeContext"
|
||||
label="&chromeContext.label;"
|
||||
accesskey="&chromeContext.accesskey;"
|
||||
type="radio"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="ws-menu-resetContext"
|
||||
command="ws-cmd-resetContext"
|
||||
<menuitem id="sp-menu-resetContext"
|
||||
command="sp-cmd-resetContext"
|
||||
label="&resetContext.label;"
|
||||
accesskey="&resetContext.accesskey;"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
<menu id="ws-tools-menu"
|
||||
<menu id="sp-tools-menu"
|
||||
label="&toolsMenu.label;"
|
||||
accesskey="&toolsMenu.accesskey;">
|
||||
<menupopup id="ws-menu-tools">
|
||||
<menuitem id="ws-menu-errorConsole" hidden="true"
|
||||
<menupopup id="sp-menu-tools">
|
||||
<menuitem id="sp-menu-errorConsole" hidden="true"
|
||||
label="&errorConsoleCmd.label;"
|
||||
accesskey="&errorConsoleCmd.accesskey;"
|
||||
key="ws-key-errorConsole"
|
||||
command="ws-cmd-errorConsole"/>
|
||||
<menuitem id="ws-menu-webConsole"
|
||||
key="sp-key-errorConsole"
|
||||
command="sp-cmd-errorConsole"/>
|
||||
<menuitem id="sp-menu-webConsole"
|
||||
label="&webConsoleCmd.label;"
|
||||
accesskey="&webConsoleCmd.accesskey;"
|
||||
key="ws-key-webConsole"
|
||||
command="ws-cmd-webConsole"/>
|
||||
key="sp-key-webConsole"
|
||||
command="sp-cmd-webConsole"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menubar>
|
||||
|
||||
<popupset id="workspace-popups">
|
||||
<menupopup id="workspace-text-popup">
|
||||
<popupset id="scratchpad-popups">
|
||||
<menupopup id="scratchpad-text-popup">
|
||||
<menuitem id="menu_cut"/>
|
||||
<menuitem id="menu_copy"/>
|
||||
<menuitem id="menu_paste"/>
|
||||
@ -306,31 +306,31 @@
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_selectAll"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="ws-text-execute"
|
||||
<menuitem id="sp-text-execute"
|
||||
label="&execute.label;"
|
||||
accesskey="&execute.accesskey;"
|
||||
key="ws-key-execute"
|
||||
command="ws-cmd-execute"/>
|
||||
<menuitem id="ws-text-inspect"
|
||||
key="sp-key-execute"
|
||||
command="sp-cmd-execute"/>
|
||||
<menuitem id="sp-text-inspect"
|
||||
label="&inspect.label;"
|
||||
accesskey="&inspect.accesskey;"
|
||||
key="ws-key-inspect"
|
||||
command="ws-cmd-inspect"/>
|
||||
<menuitem id="ws-text-print"
|
||||
key="sp-key-inspect"
|
||||
command="sp-cmd-inspect"/>
|
||||
<menuitem id="sp-text-print"
|
||||
label="&print.label;"
|
||||
accesskey="&print.accesskey;"
|
||||
key="ws-key-print"
|
||||
command="ws-cmd-print"/>
|
||||
key="sp-key-print"
|
||||
command="sp-cmd-print"/>
|
||||
</menupopup>
|
||||
</popupset>
|
||||
|
||||
<textbox id="workspace-textbox"
|
||||
<textbox id="scratchpad-textbox"
|
||||
multiline="true"
|
||||
flex="1"
|
||||
context="workspace-text-popup"
|
||||
context="scratchpad-text-popup"
|
||||
placeholder="&textbox.placeholder;" />
|
||||
<statusbar id="workspace-statusbar" align="end">
|
||||
<statusbarpanel id="workspace-status"
|
||||
<statusbar id="scratchpad-statusbar" align="end">
|
||||
<statusbarpanel id="scratchpad-status"
|
||||
label="&contentContext.label;"
|
||||
class="statusbarpanel-iconic-text"/>
|
||||
<spacer flex="1"/>
|
@ -192,13 +192,13 @@ _BROWSER_FILES = \
|
||||
browser_inspector_treePanel_output.js \
|
||||
browser_inspector_treePanel_input.html \
|
||||
browser_inspector_treePanel_result.html \
|
||||
browser_workspace_initialization.js \
|
||||
browser_workspace_contexts.js \
|
||||
browser_workspace_execute_print.js \
|
||||
browser_workspace_inspect.js \
|
||||
browser_workspace_files.js \
|
||||
browser_workspace_ui.js \
|
||||
browser_workspace_bug_646070_chrome_context_pref.js \
|
||||
browser_scratchpad_initialization.js \
|
||||
browser_scratchpad_contexts.js \
|
||||
browser_scratchpad_execute_print.js \
|
||||
browser_scratchpad_inspect.js \
|
||||
browser_scratchpad_files.js \
|
||||
browser_scratchpad_ui.js \
|
||||
browser_scratchpad_bug_646070_chrome_context_pref.js \
|
||||
browser_overflowScroll.js \
|
||||
browser_pageInfo.js \
|
||||
browser_page_style_menu.js \
|
||||
|
@ -2,8 +2,8 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Reference to the Workspace chrome window object.
|
||||
let gWorkspaceWindow;
|
||||
// Reference to the Scratchpad chrome window object.
|
||||
let gScratchpadWindow;
|
||||
|
||||
let gOldPref;
|
||||
let DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled";
|
||||
@ -19,50 +19,50 @@ function test()
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
ok(Workspace, "Workspace variable exists");
|
||||
ok(Scratchpad, "Scratchpad variable exists");
|
||||
|
||||
gWorkspaceWindow = Workspace.openWorkspace();
|
||||
gWorkspaceWindow.addEventListener("load", runTests, false);
|
||||
gScratchpadWindow = Scratchpad.openScratchpad();
|
||||
gScratchpadWindow.addEventListener("load", runTests, false);
|
||||
}, 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()
|
||||
{
|
||||
gWorkspaceWindow.removeEventListener("load", arguments.callee, false);
|
||||
gScratchpadWindow.removeEventListener("load", arguments.callee, false);
|
||||
|
||||
let ws = gWorkspaceWindow.Workspace;
|
||||
ok(ws, "Workspace object exists in new window");
|
||||
let sp = gScratchpadWindow.Scratchpad;
|
||||
ok(sp, "Scratchpad object exists in new window");
|
||||
|
||||
let chromeContextMenu = gWorkspaceWindow.document.
|
||||
getElementById("ws-menu-chrome");
|
||||
let chromeContextMenu = gScratchpadWindow.document.
|
||||
getElementById("sp-menu-chrome");
|
||||
ok(chromeContextMenu, "Chrome context menuitem element exists");
|
||||
ok(!chromeContextMenu.hasAttribute("hidden"),
|
||||
"Chrome context menuitem is visible");
|
||||
|
||||
let errorConsoleCommand = gWorkspaceWindow.document.
|
||||
getElementById("ws-cmd-errorConsole");
|
||||
let errorConsoleCommand = gScratchpadWindow.document.
|
||||
getElementById("sp-cmd-errorConsole");
|
||||
ok(errorConsoleCommand, "Error console command element exists");
|
||||
ok(!errorConsoleCommand.hasAttribute("disabled"),
|
||||
"Error console command is enabled");
|
||||
|
||||
let errorConsoleMenu = gWorkspaceWindow.document.
|
||||
getElementById("ws-menu-errorConsole");
|
||||
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 = gWorkspaceWindow.document.
|
||||
getElementById("ws-cmd-chromeContext");
|
||||
let chromeContextCommand = gScratchpadWindow.document.
|
||||
getElementById("sp-cmd-chromeContext");
|
||||
ok(chromeContextCommand, "Chrome context command element exists");
|
||||
ok(!chromeContextCommand.hasAttribute("disabled"),
|
||||
"Chrome context command is disabled");
|
||||
|
||||
Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, gOldPref);
|
||||
|
||||
gWorkspaceWindow.close();
|
||||
gWorkspaceWindow = null;
|
||||
gScratchpadWindow.close();
|
||||
gScratchpadWindow = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
125
browser/base/content/test/browser_scratchpad_contexts.js
Normal file
125
browser/base/content/test/browser_scratchpad_contexts.js
Normal 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();
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Reference to the Workspace chrome window object.
|
||||
let gWorkspaceWindow;
|
||||
// Reference to the Scratchpad chrome window object.
|
||||
let gScratchpadWindow;
|
||||
|
||||
function test()
|
||||
{
|
||||
@ -13,103 +13,103 @@ function test()
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
gWorkspaceWindow = Workspace.openWorkspace();
|
||||
gWorkspaceWindow.addEventListener("load", runTests, false);
|
||||
gScratchpadWindow = Scratchpad.openScratchpad();
|
||||
gScratchpadWindow.addEventListener("load", runTests, false);
|
||||
}, 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()
|
||||
{
|
||||
gWorkspaceWindow.removeEventListener("load", arguments.callee, false);
|
||||
gScratchpadWindow.removeEventListener("load", arguments.callee, false);
|
||||
|
||||
let ws = gWorkspaceWindow.Workspace;
|
||||
let sp = gScratchpadWindow.Scratchpad;
|
||||
|
||||
content.wrappedJSObject.foobarBug636725 = 1;
|
||||
|
||||
ok(ws.textbox, "textbox exists");
|
||||
ws.textbox.value = "++window.foobarBug636725";
|
||||
ok(sp.textbox, "textbox exists");
|
||||
sp.textbox.value = "++window.foobarBug636725";
|
||||
|
||||
let exec = ws.execute();
|
||||
is(exec[0], ws.textbox.value, "execute()[0] is correct");
|
||||
let exec = sp.execute();
|
||||
is(exec[0], sp.textbox.value, "execute()[0] is correct");
|
||||
is(exec[1], content.wrappedJSObject.foobarBug636725,
|
||||
"execute()[1] is correct");
|
||||
|
||||
is(ws.textbox.value, "++window.foobarBug636725",
|
||||
is(sp.textbox.value, "++window.foobarBug636725",
|
||||
"execute() does not change the textbox value");
|
||||
|
||||
is(content.wrappedJSObject.foobarBug636725, 2,
|
||||
"execute() updated window.foobarBug636725");
|
||||
|
||||
ws.print();
|
||||
sp.print();
|
||||
|
||||
is(content.wrappedJSObject.foobarBug636725, 3,
|
||||
"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");
|
||||
|
||||
is(ws.selectedText, "/*\n3\n*/", "selectedText is correct");
|
||||
is(ws.textbox.selectionStart, 24, "selectionStart is correct");
|
||||
is(ws.textbox.selectionEnd, 31, "selectionEnd is correct");
|
||||
is(sp.selectedText, "/*\n3\n*/", "selectedText is correct");
|
||||
is(sp.textbox.selectionStart, 24, "selectionStart is correct");
|
||||
is(sp.textbox.selectionEnd, 31, "selectionEnd is correct");
|
||||
|
||||
// Test selection execute() and print().
|
||||
|
||||
ws.textbox.value = "window.foobarBug636725 = 'a';\n" +
|
||||
sp.textbox.value = "window.foobarBug636725 = 'a';\n" +
|
||||
"window.foobarBug636725 = 'b';";
|
||||
|
||||
ws.selectRange(1, 2);
|
||||
sp.selectRange(1, 2);
|
||||
|
||||
is(ws.textbox.selectionStart, 1, "selectionStart is 1");
|
||||
is(ws.textbox.selectionEnd, 2, "selectionEnd is 2");
|
||||
is(sp.textbox.selectionStart, 1, "selectionStart is 1");
|
||||
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(ws.textbox.selectionEnd, 29, "selectionEnd is 29");
|
||||
is(sp.textbox.selectionStart, 0, "selectionStart is 0");
|
||||
is(sp.textbox.selectionEnd, 29, "selectionEnd is 29");
|
||||
|
||||
exec = ws.execute();
|
||||
exec = sp.execute();
|
||||
|
||||
is(exec[0], "window.foobarBug636725 = 'a';",
|
||||
"execute()[0] is correct");
|
||||
is(exec[1], "a",
|
||||
"execute()[1] is correct");
|
||||
|
||||
is(ws.textbox.value, "window.foobarBug636725 = 'a';\n" +
|
||||
is(sp.textbox.value, "window.foobarBug636725 = 'a';\n" +
|
||||
"window.foobarBug636725 = 'b';",
|
||||
"execute() does not change the textbox value");
|
||||
|
||||
is(content.wrappedJSObject.foobarBug636725, "a",
|
||||
"execute() worked for the selected range");
|
||||
|
||||
ws.textbox.value = "window.foobarBug636725 = 'c';\n" +
|
||||
sp.textbox.value = "window.foobarBug636725 = 'c';\n" +
|
||||
"window.foobarBug636725 = 'b';";
|
||||
|
||||
ws.selectRange(0, 22);
|
||||
sp.selectRange(0, 22);
|
||||
|
||||
ws.print();
|
||||
sp.print();
|
||||
|
||||
is(content.wrappedJSObject.foobarBug636725, "a",
|
||||
"print() worked for the selected range");
|
||||
|
||||
is(ws.textbox.value, "window.foobarBug636725" +
|
||||
is(sp.textbox.value, "window.foobarBug636725" +
|
||||
"/*\na\n*/" +
|
||||
" = 'c';\n" +
|
||||
"window.foobarBug636725 = 'b';",
|
||||
"print() shows evaluation result in the textbox");
|
||||
|
||||
is(ws.selectedText, "/*\na\n*/", "selectedText is correct");
|
||||
is(ws.textbox.selectionStart, 22, "selectionStart is correct");
|
||||
is(ws.textbox.selectionEnd, 29, "selectionEnd is correct");
|
||||
is(sp.selectedText, "/*\na\n*/", "selectedText is correct");
|
||||
is(sp.textbox.selectionStart, 22, "selectionStart is correct");
|
||||
is(sp.textbox.selectionEnd, 29, "selectionEnd is correct");
|
||||
|
||||
ws.deselect();
|
||||
sp.deselect();
|
||||
|
||||
ok(!ws.selectedText, "selectedText is empty");
|
||||
is(ws.textbox.selectionStart, ws.textbox.selectionEnd, "deselect() works");
|
||||
ok(!sp.selectedText, "selectedText is empty");
|
||||
is(sp.textbox.selectionStart, sp.textbox.selectionEnd, "deselect() works");
|
||||
|
||||
gWorkspaceWindow.close();
|
||||
gWorkspaceWindow = null;
|
||||
gScratchpadWindow.close();
|
||||
gScratchpadWindow = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
@ -9,11 +9,11 @@ const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
|
||||
// Reference to the Workspace chrome window object.
|
||||
let gWorkspaceWindow;
|
||||
// Reference to the Scratchpad chrome window object.
|
||||
let gScratchpadWindow;
|
||||
|
||||
// Reference to the Workspace object.
|
||||
let gWorkspace;
|
||||
// Reference to the Scratchpad object.
|
||||
let gScratchpad;
|
||||
|
||||
// Reference to the temporary nsIFile we will work with.
|
||||
let gFile;
|
||||
@ -29,18 +29,18 @@ function test()
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
gWorkspaceWindow = Workspace.openWorkspace();
|
||||
gWorkspaceWindow.addEventListener("load", runTests, false);
|
||||
gScratchpadWindow = Scratchpad.openScratchpad();
|
||||
gScratchpadWindow.addEventListener("load", runTests, false);
|
||||
}, 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()
|
||||
{
|
||||
gWorkspaceWindow.removeEventListener("load", arguments.callee, false);
|
||||
gScratchpadWindow.removeEventListener("load", arguments.callee, false);
|
||||
|
||||
gWorkspace = gWorkspaceWindow.Workspace;
|
||||
gScratchpad = gScratchpadWindow.Scratchpad;
|
||||
|
||||
// Create a temporary file.
|
||||
gFile = FileUtils.getFile("TmpD", ["fileForBug636725.tmp"]);
|
||||
@ -65,52 +65,52 @@ function tempFileSaved(aStatus)
|
||||
ok(Components.isSuccessCode(aStatus),
|
||||
"the temporary file was saved successfully");
|
||||
|
||||
// Import the file into Workspace.
|
||||
gWorkspace.importFromFile(gFile.QueryInterface(Ci.nsILocalFile), true,
|
||||
// Import the file into Scratchpad.
|
||||
gScratchpad.importFromFile(gFile.QueryInterface(Ci.nsILocalFile), true,
|
||||
fileImported);
|
||||
}
|
||||
|
||||
function fileImported(aStatus, aFileContent)
|
||||
{
|
||||
ok(Components.isSuccessCode(aStatus),
|
||||
"the temporary file was imported successfully with Workspace");
|
||||
"the temporary file was imported successfully with Scratchpad");
|
||||
|
||||
is(aFileContent, gFileContent,
|
||||
"received data is correct");
|
||||
|
||||
is(gWorkspace.textbox.value, gFileContent,
|
||||
is(gScratchpad.textbox.value, gFileContent,
|
||||
"the textbox.value is correct");
|
||||
|
||||
// Save the file after changes.
|
||||
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);
|
||||
}
|
||||
|
||||
function fileExported(aStatus)
|
||||
{
|
||||
ok(Components.isSuccessCode(aStatus),
|
||||
"the temporary file was exported successfully with Workspace");
|
||||
"the temporary file was exported successfully with Scratchpad");
|
||||
|
||||
let oldContent = gFileContent;
|
||||
|
||||
// Attempt another file save, with confirmation which returns false.
|
||||
gFileContent += "// omg, saved twice!";
|
||||
gWorkspace.textbox.value = gFileContent;
|
||||
gScratchpad.textbox.value = gFileContent;
|
||||
|
||||
let oldConfirm = gWorkspaceWindow.confirm;
|
||||
let oldConfirm = gScratchpadWindow.confirm;
|
||||
let askedConfirmation = false;
|
||||
gWorkspaceWindow.confirm = function() {
|
||||
gScratchpadWindow.confirm = function() {
|
||||
askedConfirmation = true;
|
||||
return false;
|
||||
};
|
||||
|
||||
gWorkspace.exportToFile(gFile.QueryInterface(Ci.nsILocalFile), false, true,
|
||||
gScratchpad.exportToFile(gFile.QueryInterface(Ci.nsILocalFile), false, true,
|
||||
fileExported2);
|
||||
|
||||
gWorkspaceWindow.confirm = oldConfirm;
|
||||
gScratchpadWindow.confirm = oldConfirm;
|
||||
|
||||
ok(askedConfirmation, "exportToFile() asked for overwrite confirmation");
|
||||
|
||||
@ -141,9 +141,9 @@ function fileRead(aInputStream, aStatus)
|
||||
// Done!
|
||||
gFile.remove(false);
|
||||
gFile = null;
|
||||
gWorkspace = null;
|
||||
gWorkspaceWindow.close();
|
||||
gWorkspaceWindow = null;
|
||||
gScratchpad = null;
|
||||
gScratchpadWindow.close();
|
||||
gScratchpadWindow = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
@ -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();
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Reference to the Workspace chrome window object.
|
||||
let gWorkspaceWindow;
|
||||
// Reference to the Scratchpad chrome window object.
|
||||
let gScratchpadWindow;
|
||||
|
||||
function test()
|
||||
{
|
||||
@ -13,26 +13,26 @@ function test()
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
gWorkspaceWindow = Workspace.openWorkspace();
|
||||
gWorkspaceWindow.addEventListener("load", runTests, false);
|
||||
gScratchpadWindow = Scratchpad.openScratchpad();
|
||||
gScratchpadWindow.addEventListener("load", runTests, false);
|
||||
}, true);
|
||||
|
||||
content.location = "data:text/html,<title>foobarBug636725</title>" +
|
||||
"<p>test inspect() in Workspace";
|
||||
"<p>test inspect() in Scratchpad";
|
||||
}
|
||||
|
||||
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");
|
||||
ws.textbox.value = "document";
|
||||
ok(sp.textbox, "textbox exists");
|
||||
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");
|
||||
|
||||
propPanel.addEventListener("popupshown", function() {
|
||||
@ -56,8 +56,8 @@ function runTests()
|
||||
executeSoon(function() {
|
||||
propPanel.hidePopup();
|
||||
|
||||
gWorkspaceWindow.close();
|
||||
gWorkspaceWindow = null;
|
||||
gScratchpadWindow.close();
|
||||
gScratchpadWindow = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
});
|
81
browser/base/content/test/browser_scratchpad_ui.js
Normal file
81
browser/base/content/test/browser_scratchpad_ui.js
Normal 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();
|
||||
}
|
@ -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();
|
||||
}
|
@ -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();
|
||||
}
|
@ -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();
|
||||
}
|
@ -29,8 +29,8 @@ browser.jar:
|
||||
* content/browser/browser-tabPreviews.xml (content/browser-tabPreviews.xml)
|
||||
* content/browser/fullscreen-video.xhtml (content/fullscreen-video.xhtml)
|
||||
* content/browser/inspector.html (content/inspector.html)
|
||||
* content/browser/workspace.xul (content/workspace.xul)
|
||||
* content/browser/workspace.js (content/workspace.js)
|
||||
* content/browser/scratchpad.xul (content/scratchpad.xul)
|
||||
* content/browser/scratchpad.js (content/scratchpad.js)
|
||||
* content/browser/pageinfo/pageInfo.xul (content/pageinfo/pageInfo.xul)
|
||||
* content/browser/pageinfo/pageInfo.js (content/pageinfo/pageInfo.js)
|
||||
* content/browser/pageinfo/pageInfo.css (content/pageinfo/pageInfo.css)
|
||||
|
@ -191,10 +191,20 @@ can reach it easily. -->
|
||||
<!ENTITY inspectMenu.accesskey "T">
|
||||
<!ENTITY inspectMenu.commandkey "I">
|
||||
|
||||
<!ENTITY workspace.label "Workspace">
|
||||
<!ENTITY workspace.accesskey "O">
|
||||
<!ENTITY workspace.keycode "VK_F4">
|
||||
<!ENTITY workspace.keytext "F4">
|
||||
<!-- LOCALIZATION NOTE (scratchpad.label): This menu item label appears
|
||||
- in the Tools menu. See bug 653093.
|
||||
- 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 scratchpad.label "Scratchpad">
|
||||
<!ENTITY scratchpad.accesskey "r">
|
||||
<!ENTITY scratchpad.keycode "VK_F4">
|
||||
<!ENTITY scratchpad.keytext "F4">
|
||||
|
||||
<!ENTITY inspectPanelTitle.label "HTML">
|
||||
<!ENTITY inspectButton.label "Inspect">
|
||||
|
@ -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 -->
|
||||
|
||||
<!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.accesskey "F">
|
@ -1,5 +1,5 @@
|
||||
# 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.
|
||||
propertyPanel.updateButton.label=Update
|
||||
propertyPanel.updateButton.accesskey=U
|
||||
@ -9,12 +9,12 @@ propertyPanel.updateButton.accesskey=U
|
||||
export.fileOverwriteConfirmation=File exists. Overwrite?
|
||||
|
||||
# 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.
|
||||
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
|
||||
# open a file from Workspace.
|
||||
# open a file from Scratchpad.
|
||||
openFile.title=Open 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.
|
||||
|
||||
# LOCALIZATION NOTE (saveFileAs): This is the file picker title, when you save
|
||||
# a file in Workspace.
|
||||
# a file in Scratchpad.
|
||||
saveFileAs=Save File As
|
||||
|
||||
# LOCALIZATION NOTE (saveFile.failed): This is the message displayed when file
|
@ -15,8 +15,8 @@
|
||||
locale/browser/baseMenuOverlay.dtd (%chrome/browser/baseMenuOverlay.dtd)
|
||||
locale/browser/browser.properties (%chrome/browser/browser.properties)
|
||||
locale/browser/inspector.properties (%chrome/browser/inspector.properties)
|
||||
locale/browser/workspace.properties (%chrome/browser/workspace.properties)
|
||||
locale/browser/workspace.dtd (%chrome/browser/workspace.dtd)
|
||||
locale/browser/scratchpad.properties (%chrome/browser/scratchpad.properties)
|
||||
locale/browser/scratchpad.dtd (%chrome/browser/scratchpad.dtd)
|
||||
locale/browser/openLocation.dtd (%chrome/browser/openLocation.dtd)
|
||||
locale/browser/openLocation.properties (%chrome/browser/openLocation.properties)
|
||||
* locale/browser/pageInfo.dtd (%chrome/browser/pageInfo.dtd)
|
||||
|
Loading…
Reference in New Issue
Block a user