зеркало из https://github.com/mozilla/gecko-dev.git
Bug 657131 - Create a new Execute menu for Scratchpad; r=mihai.sucan,sdwilsh
This commit is contained in:
Родитель
6820b80e95
Коммит
df5074b693
|
@ -283,7 +283,7 @@ var Scratchpad = {
|
|||
* Execute the selected text (if any) or the entire textbox content in the
|
||||
* current context.
|
||||
*/
|
||||
execute: function SP_execute()
|
||||
run: function SP_run()
|
||||
{
|
||||
let selection = this.selectedText || this.textbox.value;
|
||||
let result = this.evalForContext(selection);
|
||||
|
@ -298,7 +298,7 @@ var Scratchpad = {
|
|||
*/
|
||||
inspect: function SP_inspect()
|
||||
{
|
||||
let [selection, result] = this.execute();
|
||||
let [selection, result] = this.run();
|
||||
|
||||
if (result) {
|
||||
this.openPropertyPanel(selection, result);
|
||||
|
@ -307,11 +307,11 @@ var Scratchpad = {
|
|||
|
||||
/**
|
||||
* Execute the selected text (if any) or the entire textbox content in the
|
||||
* current context. The evaluation result is "printed" in the textbox after
|
||||
* current context. The evaluation result is inserted into the textbox after
|
||||
* the selected text, or at the end of the textbox value if there is no
|
||||
* selected text.
|
||||
*/
|
||||
print: function SP_print()
|
||||
display: function SP_display()
|
||||
{
|
||||
let selectionStart = this.textbox.selectionStart;
|
||||
let selectionEnd = this.textbox.selectionEnd;
|
||||
|
@ -319,7 +319,7 @@ var Scratchpad = {
|
|||
selectionEnd = this.textbox.value.length;
|
||||
}
|
||||
|
||||
let [selection, result] = this.execute();
|
||||
let [selection, result] = this.run();
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -70,9 +70,9 @@
|
|||
-->
|
||||
|
||||
<command id="sp-cmd-close" oncommand="window.close();"/>
|
||||
<command id="sp-cmd-execute" oncommand="Scratchpad.execute();"/>
|
||||
<command id="sp-cmd-run" oncommand="Scratchpad.run();"/>
|
||||
<command id="sp-cmd-inspect" oncommand="Scratchpad.inspect();"/>
|
||||
<command id="sp-cmd-print" oncommand="Scratchpad.print();"/>
|
||||
<command id="sp-cmd-display" oncommand="Scratchpad.display();"/>
|
||||
<command id="sp-cmd-contentContext" oncommand="Scratchpad.setContentContext();"/>
|
||||
<command id="sp-cmd-browserContext" oncommand="Scratchpad.setBrowserContext();" disabled="true"/>
|
||||
<command id="sp-cmd-resetContext" oncommand="Scratchpad.resetContext();"/>
|
||||
|
@ -118,17 +118,17 @@
|
|||
<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="sp-key-execute"
|
||||
key="&execute.key;"
|
||||
command="sp-cmd-execute"
|
||||
<key id="sp-key-run"
|
||||
key="&run.key;"
|
||||
command="sp-cmd-run"
|
||||
modifiers="accel"/>
|
||||
<key id="sp-key-inspect"
|
||||
key="&inspect.key;"
|
||||
command="sp-cmd-inspect"
|
||||
modifiers="accel"/>
|
||||
<key id="sp-key-print"
|
||||
key="&print.key;"
|
||||
command="sp-cmd-print"
|
||||
<key id="sp-key-display"
|
||||
key="&display.key;"
|
||||
command="sp-cmd-display"
|
||||
modifiers="accel"/>
|
||||
<key id="sp-key-errorConsole"
|
||||
key="&errorConsoleCmd.commandkey;"
|
||||
|
@ -220,7 +220,6 @@
|
|||
key="key_selectAll"
|
||||
accesskey="&selectAllCmd.accesskey;"
|
||||
command="cmd_selectAll"/>
|
||||
<menuseparator/>
|
||||
|
||||
<!-- TODO: bug 650345 - implement search and replace
|
||||
<menuitem id="sp-menu-find"
|
||||
|
@ -238,21 +237,27 @@
|
|||
<menuseparator id="sp-execute-separator"/>
|
||||
-->
|
||||
|
||||
<menuitem id="sp-text-execute"
|
||||
label="&execute.label;"
|
||||
accesskey="&execute.accesskey;"
|
||||
key="sp-key-execute"
|
||||
command="sp-cmd-execute"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
<menu id="sp-execute-menu" label="&executeMenu.label;"
|
||||
accesskey="&executeMenu.accesskey;">
|
||||
<menupopup id="sp-menu_executepopup">
|
||||
<menuitem id="sp-text-run"
|
||||
label="&run.label;"
|
||||
accesskey="&run.accesskey;"
|
||||
key="sp-key-run"
|
||||
command="sp-cmd-run"/>
|
||||
<menuitem id="sp-text-inspect"
|
||||
label="&inspect.label;"
|
||||
accesskey="&inspect.accesskey;"
|
||||
key="sp-key-inspect"
|
||||
command="sp-cmd-inspect"/>
|
||||
<menuitem id="sp-text-print"
|
||||
label="&print.label;"
|
||||
accesskey="&print.accesskey;"
|
||||
key="sp-key-print"
|
||||
command="sp-cmd-print"/>
|
||||
<menuitem id="sp-text-display"
|
||||
label="&display.label;"
|
||||
accesskey="&display.accesskey;"
|
||||
key="sp-key-display"
|
||||
command="sp-cmd-display"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
|
@ -306,21 +311,21 @@
|
|||
<menuseparator/>
|
||||
<menuitem id="menu_selectAll"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="sp-text-execute"
|
||||
label="&execute.label;"
|
||||
accesskey="&execute.accesskey;"
|
||||
key="sp-key-execute"
|
||||
command="sp-cmd-execute"/>
|
||||
<menuitem id="sp-text-run"
|
||||
label="&run.label;"
|
||||
accesskey="&run.accesskey;"
|
||||
key="sp-key-run"
|
||||
command="sp-cmd-run"/>
|
||||
<menuitem id="sp-text-inspect"
|
||||
label="&inspect.label;"
|
||||
accesskey="&inspect.accesskey;"
|
||||
key="sp-key-inspect"
|
||||
command="sp-cmd-inspect"/>
|
||||
<menuitem id="sp-text-print"
|
||||
label="&print.label;"
|
||||
accesskey="&print.accesskey;"
|
||||
key="sp-key-print"
|
||||
command="sp-cmd-print"/>
|
||||
<menuitem id="sp-text-display"
|
||||
label="&display.label;"
|
||||
accesskey="&display.accesskey;"
|
||||
key="sp-key-display"
|
||||
command="sp-cmd-display"/>
|
||||
</menupopup>
|
||||
</popupset>
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ function runTests()
|
|||
ok(!content.wrappedJSObject.foobarBug636725,
|
||||
"no content.foobarBug636725");
|
||||
|
||||
sp.execute();
|
||||
sp.run();
|
||||
|
||||
is(content.wrappedJSObject.foobarBug636725, "aloha",
|
||||
"content.foobarBug636725 has been set");
|
||||
|
@ -77,37 +77,37 @@ function runTests()
|
|||
|
||||
ok(!window.foobarBug636725, "no window.foobarBug636725");
|
||||
|
||||
sp.execute();
|
||||
sp.run();
|
||||
|
||||
is(window.foobarBug636725, "aloha2", "window.foobarBug636725 has been set");
|
||||
|
||||
sp.textbox.value = "window.gBrowser";
|
||||
|
||||
is(typeof sp.execute()[1].addTab, "function",
|
||||
is(typeof sp.run()[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");
|
||||
is(sp.run()[1], "undefined", "global variable does not exist");
|
||||
|
||||
sp.textbox.value = "var foobarBug636725cache = 'foo';";
|
||||
sp.execute();
|
||||
sp.run();
|
||||
|
||||
sp.textbox.value = "typeof foobarBug636725cache;";
|
||||
is(sp.execute()[1], "string",
|
||||
is(sp.run()[1], "string",
|
||||
"global variable exists across two different executions");
|
||||
|
||||
sp.resetContext();
|
||||
|
||||
is(sp.execute()[1], "undefined",
|
||||
is(sp.run()[1], "undefined",
|
||||
"global variable no longer exists after calling resetContext()");
|
||||
|
||||
sp.textbox.value = "var foobarBug636725cache2 = 'foo';";
|
||||
sp.execute();
|
||||
sp.run();
|
||||
|
||||
sp.textbox.value = "typeof foobarBug636725cache2;";
|
||||
is(sp.execute()[1], "string",
|
||||
is(sp.run()[1], "string",
|
||||
"global variable exists across two different executions");
|
||||
|
||||
sp.setContentContext();
|
||||
|
@ -115,7 +115,7 @@ function runTests()
|
|||
is(sp.executionContext, gScratchpadWindow.SCRATCHPAD_CONTEXT_CONTENT,
|
||||
"executionContext is content");
|
||||
|
||||
is(sp.execute()[1], "undefined",
|
||||
is(sp.run()[1], "undefined",
|
||||
"global variable no longer exists after changing the context");
|
||||
|
||||
gScratchpadWindow.close();
|
||||
|
|
|
@ -17,7 +17,7 @@ function test()
|
|||
gScratchpadWindow.addEventListener("load", runTests, false);
|
||||
}, true);
|
||||
|
||||
content.location = "data:text/html,<p>test execute() and print() in Scratchpad";
|
||||
content.location = "data:text/html,<p>test run() and display() in Scratchpad";
|
||||
}
|
||||
|
||||
function runTests()
|
||||
|
@ -31,7 +31,7 @@ function runTests()
|
|||
ok(sp.textbox, "textbox exists");
|
||||
sp.textbox.value = "++window.foobarBug636725";
|
||||
|
||||
let exec = sp.execute();
|
||||
let exec = sp.run();
|
||||
is(exec[0], sp.textbox.value, "execute()[0] is correct");
|
||||
is(exec[1], content.wrappedJSObject.foobarBug636725,
|
||||
"execute()[1] is correct");
|
||||
|
@ -42,7 +42,7 @@ function runTests()
|
|||
is(content.wrappedJSObject.foobarBug636725, 2,
|
||||
"execute() updated window.foobarBug636725");
|
||||
|
||||
sp.print();
|
||||
sp.display();
|
||||
|
||||
is(content.wrappedJSObject.foobarBug636725, 3,
|
||||
"print() updated window.foobarBug636725");
|
||||
|
@ -69,7 +69,7 @@ function runTests()
|
|||
is(sp.textbox.selectionStart, 0, "selectionStart is 0");
|
||||
is(sp.textbox.selectionEnd, 29, "selectionEnd is 29");
|
||||
|
||||
exec = sp.execute();
|
||||
exec = sp.run();
|
||||
|
||||
is(exec[0], "window.foobarBug636725 = 'a';",
|
||||
"execute()[0] is correct");
|
||||
|
@ -88,7 +88,7 @@ function runTests()
|
|||
|
||||
sp.selectRange(0, 22);
|
||||
|
||||
sp.print();
|
||||
sp.display();
|
||||
|
||||
is(content.wrappedJSObject.foobarBug636725, "a",
|
||||
"print() worked for the selected range");
|
||||
|
|
|
@ -28,9 +28,9 @@ function runTests()
|
|||
|
||||
let sp = gScratchpadWindow.Scratchpad;
|
||||
ok(sp, "Scratchpad object exists in new window");
|
||||
is(typeof sp.execute, "function", "Scratchpad.execute() exists");
|
||||
is(typeof sp.run, "function", "Scratchpad.run() exists");
|
||||
is(typeof sp.inspect, "function", "Scratchpad.inspect() exists");
|
||||
is(typeof sp.print, "function", "Scratchpad.print() exists");
|
||||
is(typeof sp.display, "function", "Scratchpad.display() exists");
|
||||
|
||||
let chromeContextMenu = gScratchpadWindow.document.
|
||||
getElementById("sp-menu-browser");
|
||||
|
|
|
@ -33,8 +33,9 @@ function runTests()
|
|||
"sp-menu-open": "openFile",
|
||||
"sp-menu-save": "saveFile",
|
||||
"sp-menu-saveas": "saveFileAs",
|
||||
"sp-text-execute": "execute",
|
||||
"sp-text-run": "run",
|
||||
"sp-text-inspect": "inspect",
|
||||
"sp-text-display": "display",
|
||||
"sp-menu-content": "setContentContext",
|
||||
"sp-menu-browser": "setBrowserContext",
|
||||
"sp-menu-resetContext": "resetContext",
|
||||
|
|
|
@ -61,17 +61,17 @@
|
|||
<!ENTITY selectAllCmd.key "A">
|
||||
<!ENTITY selectAllCmd.accesskey "A">
|
||||
|
||||
<!ENTITY execute.label "Execute">
|
||||
<!ENTITY execute.accesskey "E">
|
||||
<!ENTITY execute.key "t">
|
||||
<!ENTITY run.label "Run">
|
||||
<!ENTITY run.accesskey "R">
|
||||
<!ENTITY run.key "r">
|
||||
|
||||
<!ENTITY inspect.label "Inspect">
|
||||
<!ENTITY inspect.accesskey "I">
|
||||
<!ENTITY inspect.key "i">
|
||||
|
||||
<!ENTITY print.label "Print">
|
||||
<!ENTITY print.accesskey "p">
|
||||
<!ENTITY print.key "r">
|
||||
<!ENTITY display.label "Display">
|
||||
<!ENTITY display.accesskey "D">
|
||||
<!ENTITY display.key "l">
|
||||
|
||||
<!-- LOCALIZATION NOTE (environmentMenu.label, accesskey): This menu item was
|
||||
- renamed from "Context" to avoid confusion with the right-click context
|
||||
|
@ -110,6 +110,9 @@
|
|||
<!ENTITY resetContext.label "Reset">
|
||||
<!ENTITY resetContext.accesskey "R">
|
||||
|
||||
<!ENTITY executeMenu.label "Execute">
|
||||
<!ENTITY executeMenu.accesskey "X">
|
||||
|
||||
<!ENTITY toolsMenu.label "Tools">
|
||||
<!ENTITY toolsMenu.accesskey "T">
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче