1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/scratchpad/test/browser_scratchpad_help_key.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +/* vim: set ts=2 et sw=2 tw=80: */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 +/* Bug 650760 */ 1.8 + 1.9 +function test() 1.10 +{ 1.11 + waitForExplicitFinish(); 1.12 + 1.13 + gBrowser.selectedTab = gBrowser.addTab(); 1.14 + content.location = "data:text/html,Test keybindings for opening Scratchpad MDN Documentation, bug 650760"; 1.15 + gBrowser.selectedBrowser.addEventListener("load", function onTabLoad() { 1.16 + gBrowser.selectedBrowser.removeEventListener("load", onTabLoad, true); 1.17 + 1.18 + ok(window.Scratchpad, "Scratchpad variable exists"); 1.19 + 1.20 + openScratchpad(runTest); 1.21 + }, true); 1.22 +} 1.23 + 1.24 +function runTest() 1.25 +{ 1.26 + let sp = gScratchpadWindow.Scratchpad; 1.27 + ok(sp, "Scratchpad object exists in new window"); 1.28 + ok(sp.editor.hasFocus(), "the editor has focus"); 1.29 + 1.30 + let keyid = gScratchpadWindow.document.getElementById("key_openHelp"); 1.31 + let modifiers = keyid.getAttribute("modifiers"); 1.32 + 1.33 + let key = null; 1.34 + if (keyid.getAttribute("keycode")) 1.35 + key = keyid.getAttribute("keycode"); 1.36 + 1.37 + else if (keyid.getAttribute("key")) 1.38 + key = keyid.getAttribute("key"); 1.39 + 1.40 + isnot(key, null, "Successfully retrieved keycode/key"); 1.41 + 1.42 + var aEvent = { 1.43 + shiftKey: modifiers.match("shift"), 1.44 + ctrlKey: modifiers.match("ctrl"), 1.45 + altKey: modifiers.match("alt"), 1.46 + metaKey: modifiers.match("meta"), 1.47 + accelKey: modifiers.match("accel") 1.48 + } 1.49 + 1.50 + info("check that the MDN page is opened on \"F1\""); 1.51 + let linkClicked = false; 1.52 + sp.openDocumentationPage = function(event) { linkClicked = true; }; 1.53 + 1.54 + EventUtils.synthesizeKey(key, aEvent, gScratchpadWindow); 1.55 + 1.56 + is(linkClicked, true, "MDN page will open"); 1.57 + finishTest(); 1.58 +} 1.59 + 1.60 +function finishTest() 1.61 +{ 1.62 + gScratchpadWindow.close(); 1.63 + finish(); 1.64 +}