michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: /* Bug 650760 */ michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: content.location = "data:text/html,Test keybindings for opening Scratchpad MDN Documentation, bug 650760"; michael@0: gBrowser.selectedBrowser.addEventListener("load", function onTabLoad() { michael@0: gBrowser.selectedBrowser.removeEventListener("load", onTabLoad, true); michael@0: michael@0: ok(window.Scratchpad, "Scratchpad variable exists"); michael@0: michael@0: openScratchpad(runTest); michael@0: }, true); michael@0: } michael@0: michael@0: function runTest() michael@0: { michael@0: let sp = gScratchpadWindow.Scratchpad; michael@0: ok(sp, "Scratchpad object exists in new window"); michael@0: ok(sp.editor.hasFocus(), "the editor has focus"); michael@0: michael@0: let keyid = gScratchpadWindow.document.getElementById("key_openHelp"); michael@0: let modifiers = keyid.getAttribute("modifiers"); michael@0: michael@0: let key = null; michael@0: if (keyid.getAttribute("keycode")) michael@0: key = keyid.getAttribute("keycode"); michael@0: michael@0: else if (keyid.getAttribute("key")) michael@0: key = keyid.getAttribute("key"); michael@0: michael@0: isnot(key, null, "Successfully retrieved keycode/key"); michael@0: michael@0: var aEvent = { michael@0: shiftKey: modifiers.match("shift"), michael@0: ctrlKey: modifiers.match("ctrl"), michael@0: altKey: modifiers.match("alt"), michael@0: metaKey: modifiers.match("meta"), michael@0: accelKey: modifiers.match("accel") michael@0: } michael@0: michael@0: info("check that the MDN page is opened on \"F1\""); michael@0: let linkClicked = false; michael@0: sp.openDocumentationPage = function(event) { linkClicked = true; }; michael@0: michael@0: EventUtils.synthesizeKey(key, aEvent, gScratchpadWindow); michael@0: michael@0: is(linkClicked, true, "MDN page will open"); michael@0: finishTest(); michael@0: } michael@0: michael@0: function finishTest() michael@0: { michael@0: gScratchpadWindow.close(); michael@0: finish(); michael@0: }