diff --git a/browser/devtools/scratchpad/scratchpad.js b/browser/devtools/scratchpad/scratchpad.js index 3700143549e..6e1e609faea 100644 --- a/browser/devtools/scratchpad/scratchpad.js +++ b/browser/devtools/scratchpad/scratchpad.js @@ -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 () { diff --git a/browser/devtools/scratchpad/scratchpad.xul b/browser/devtools/scratchpad/scratchpad.xul index eb3c17b08c2..b0dc59960bb 100644 --- a/browser/devtools/scratchpad/scratchpad.xul +++ b/browser/devtools/scratchpad/scratchpad.xul @@ -83,6 +83,7 @@ + @@ -171,6 +172,9 @@ key="&gotoLineCmd.key;" command="cmd_gotoLine" modifiers="accel"/> + @@ -316,6 +320,24 @@ type="radio"/> + +#ifdef XP_WIN + +#else + +#endif + + + + diff --git a/browser/devtools/scratchpad/test/Makefile.in b/browser/devtools/scratchpad/test/Makefile.in index eeddd624212..f812f49d337 100644 --- a/browser/devtools/scratchpad/test/Makefile.in +++ b/browser/devtools/scratchpad/test/Makefile.in @@ -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) diff --git a/browser/devtools/scratchpad/test/browser_scratchpad_bug_650760_help_key.js b/browser/devtools/scratchpad/test/browser_scratchpad_bug_650760_help_key.js new file mode 100644 index 00000000000..bc132ba156f --- /dev/null +++ b/browser/devtools/scratchpad/test/browser_scratchpad_bug_650760_help_key.js @@ -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(); +} diff --git a/browser/locales/en-US/chrome/browser/devtools/scratchpad.dtd b/browser/locales/en-US/chrome/browser/devtools/scratchpad.dtd index 44cbb75d953..35d5303d714 100644 --- a/browser/locales/en-US/chrome/browser/devtools/scratchpad.dtd +++ b/browser/locales/en-US/chrome/browser/devtools/scratchpad.dtd @@ -121,6 +121,18 @@ + + + + + + + + + + diff --git a/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties b/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties index 3e7362b1b72..8d10a5db883 100644 --- a/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties +++ b/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties @@ -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