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