mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 650760 - Create Help menu for Scratchpad; r=rcampbell
This commit is contained in:
parent
34d76d65bd
commit
85e712d7f0
@ -1068,7 +1068,15 @@ var Scratchpad = {
|
||||
handler.apply(observer, aArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
openDocumentationPage: function SP_openDocumentationPage()
|
||||
{
|
||||
let url = this.strings.GetStringFromName("help.openDocumentationPage");
|
||||
let newTab = this.gBrowser.addTab(url);
|
||||
this.browserWindow.focus();
|
||||
this.gBrowser.selectedTab = newTab;
|
||||
},
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyGetter(Scratchpad, "strings", function () {
|
||||
|
@ -83,6 +83,7 @@
|
||||
<command id="sp-cmd-webConsole" oncommand="Scratchpad.openWebConsole();"/>
|
||||
<command id="sp-cmd-undo" oncommand="Scratchpad.undo();" disabled="true"/>
|
||||
<command id="sp-cmd-redo" oncommand="Scratchpad.redo();" disabled="true"/>
|
||||
<command id="sp-cmd-documentationLink" oncommand="Scratchpad.openDocumentationPage();"/>
|
||||
</commandset>
|
||||
|
||||
<keyset id="sp-keyset">
|
||||
@ -171,6 +172,9 @@
|
||||
key="&gotoLineCmd.key;"
|
||||
command="cmd_gotoLine"
|
||||
modifiers="accel"/>
|
||||
<key id="key_openHelp"
|
||||
keycode="VK_F1"
|
||||
command="sp-cmd-documentationLink"/>
|
||||
</keyset>
|
||||
|
||||
|
||||
@ -316,6 +320,24 @@
|
||||
type="radio"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
#ifdef XP_WIN
|
||||
<menu id="sp-help-menu"
|
||||
label="&helpMenu.label;"
|
||||
accesskey="&helpMenuWin.accesskey;">
|
||||
#else
|
||||
<menu id="sp-help-menu"
|
||||
label="&helpMenu.label;"
|
||||
accesskey="&helpMenu.accesskey;">
|
||||
#endif
|
||||
<menupopup id="sp-menu-help">
|
||||
<menuitem id="sp-menu-documentation"
|
||||
label="&documentationLink.label;"
|
||||
accesskey="&documentationLink.accesskey;"
|
||||
command="sp-cmd-documentationLink"
|
||||
key="key_openHelp"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menubar>
|
||||
|
||||
<popupset id="scratchpad-popups">
|
||||
|
@ -63,6 +63,7 @@ _BROWSER_TEST_FILES = \
|
||||
browser_scratchpad_bug690552_display_outputs_errors.js \
|
||||
browser_scratchpad_bug650345_find_ui.js \
|
||||
browser_scratchpad_bug714942_goto_line_ui.js \
|
||||
browser_scratchpad_bug_650760_help_key.js \
|
||||
head.js \
|
||||
|
||||
libs:: $(_BROWSER_TEST_FILES)
|
||||
|
@ -0,0 +1,60 @@
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
content.location = "data:text/html,Test keybindings for opening Scratchpad MDN Documentation, bug 650760";
|
||||
gBrowser.selectedBrowser.addEventListener("load", function onTabLoad() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", onTabLoad, true);
|
||||
|
||||
ok(window.Scratchpad, "Scratchpad variable exists");
|
||||
|
||||
openScratchpad(runTest);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function runTest()
|
||||
{
|
||||
let sp = gScratchpadWindow.Scratchpad;
|
||||
ok(sp, "Scratchpad object exists in new window");
|
||||
ok(sp.editor.hasFocus(), "the editor has focus");
|
||||
|
||||
let keyid = gScratchpadWindow.document.getElementById("key_openHelp");
|
||||
let modifiers = keyid.getAttribute("modifiers");
|
||||
|
||||
let key = null;
|
||||
if (keyid.getAttribute("keycode"))
|
||||
key = keyid.getAttribute("keycode");
|
||||
|
||||
else if (keyid.getAttribute("key"))
|
||||
key = keyid.getAttribute("key");
|
||||
|
||||
isnot(key, null, "Successfully retrieved keycode/key");
|
||||
|
||||
var aEvent = {
|
||||
shiftKey: modifiers.match("shift"),
|
||||
ctrlKey: modifiers.match("ctrl"),
|
||||
altKey: modifiers.match("alt"),
|
||||
metaKey: modifiers.match("meta"),
|
||||
accelKey: modifiers.match("accel")
|
||||
}
|
||||
|
||||
info("check that the MDN page is opened on \"F1\"");
|
||||
let linkClicked = false;
|
||||
sp.openDocumentationPage = function(event) { linkClicked = true; };
|
||||
|
||||
EventUtils.synthesizeKey(key, aEvent, gScratchpadWindow);
|
||||
|
||||
is(linkClicked, true, "MDN page will open");
|
||||
finishTest();
|
||||
}
|
||||
|
||||
function finishTest()
|
||||
{
|
||||
gScratchpadWindow.close();
|
||||
finish();
|
||||
}
|
@ -121,6 +121,18 @@
|
||||
<!ENTITY browserContext.label "Browser">
|
||||
<!ENTITY browserContext.accesskey "B">
|
||||
|
||||
<!-- LOCALIZATION NOTE some localizations of Windows (ex:french, german) use "?"
|
||||
- for the help button in the menubar but Gnome does not.
|
||||
-->
|
||||
<!ENTITY helpMenu.label "Help">
|
||||
<!ENTITY helpMenu.accesskey "H">
|
||||
<!ENTITY helpMenuWin.label "Help">
|
||||
<!ENTITY helpMenuWin.accesskey "H">
|
||||
|
||||
<!ENTITY documentationLink.label "Scratchpad Help on MDN">
|
||||
<!ENTITY documentationLink.accesskey "D">
|
||||
|
||||
|
||||
<!-- LOCALIZATION NOTE (resetContext2.label): This command allows the developer
|
||||
- to reset/clear the global object of the environment where the code executes.
|
||||
-->
|
||||
|
@ -54,3 +54,7 @@ scratchpadIntro=/*\n * This is a JavaScript Scratchpad.\n *\n * Enter some JavaS
|
||||
# LOCALIZATION NOTE (notification.browserContext): This is the message displayed
|
||||
# over the top of the editor when the user has switched to browser context.
|
||||
browserContext.notification=This scratchpad executes in the Browser context.
|
||||
|
||||
# LOCALIZATION NOTE (help.openDocumentationPage): This returns a localized link with
|
||||
# documentation for Scratchpad on MDN.
|
||||
help.openDocumentationPage=https://developer.mozilla.org/en/Tools/Scratchpad
|
||||
|
Loading…
Reference in New Issue
Block a user