|
1 /* vim: set ts=2 et sw=2 tw=80: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 /* Bug 650760 */ |
|
5 |
|
6 function test() |
|
7 { |
|
8 waitForExplicitFinish(); |
|
9 |
|
10 gBrowser.selectedTab = gBrowser.addTab(); |
|
11 content.location = "data:text/html,Test keybindings for opening Scratchpad MDN Documentation, bug 650760"; |
|
12 gBrowser.selectedBrowser.addEventListener("load", function onTabLoad() { |
|
13 gBrowser.selectedBrowser.removeEventListener("load", onTabLoad, true); |
|
14 |
|
15 ok(window.Scratchpad, "Scratchpad variable exists"); |
|
16 |
|
17 openScratchpad(runTest); |
|
18 }, true); |
|
19 } |
|
20 |
|
21 function runTest() |
|
22 { |
|
23 let sp = gScratchpadWindow.Scratchpad; |
|
24 ok(sp, "Scratchpad object exists in new window"); |
|
25 ok(sp.editor.hasFocus(), "the editor has focus"); |
|
26 |
|
27 let keyid = gScratchpadWindow.document.getElementById("key_openHelp"); |
|
28 let modifiers = keyid.getAttribute("modifiers"); |
|
29 |
|
30 let key = null; |
|
31 if (keyid.getAttribute("keycode")) |
|
32 key = keyid.getAttribute("keycode"); |
|
33 |
|
34 else if (keyid.getAttribute("key")) |
|
35 key = keyid.getAttribute("key"); |
|
36 |
|
37 isnot(key, null, "Successfully retrieved keycode/key"); |
|
38 |
|
39 var aEvent = { |
|
40 shiftKey: modifiers.match("shift"), |
|
41 ctrlKey: modifiers.match("ctrl"), |
|
42 altKey: modifiers.match("alt"), |
|
43 metaKey: modifiers.match("meta"), |
|
44 accelKey: modifiers.match("accel") |
|
45 } |
|
46 |
|
47 info("check that the MDN page is opened on \"F1\""); |
|
48 let linkClicked = false; |
|
49 sp.openDocumentationPage = function(event) { linkClicked = true; }; |
|
50 |
|
51 EventUtils.synthesizeKey(key, aEvent, gScratchpadWindow); |
|
52 |
|
53 is(linkClicked, true, "MDN page will open"); |
|
54 finishTest(); |
|
55 } |
|
56 |
|
57 function finishTest() |
|
58 { |
|
59 gScratchpadWindow.close(); |
|
60 finish(); |
|
61 } |