diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-03 06:00:38 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-03 06:00:38 -0500 |
commit | 8148615da179fdd60f19018e13b4e94b95609cc6 (patch) | |
tree | 771fccdd99fa3adf35fdd2c81d8197b415a89b91 /browser/base/content/test/general/browser_accesskeys.js | |
parent | 494802c1be7888025b95260d23db187467d2b9dd (diff) | |
download | UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.gz UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.lz UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.xz UXP-8148615da179fdd60f19018e13b4e94b95609cc6.zip |
Remove browser tests - Part 1: The Tests (except for experiments)
Diffstat (limited to 'browser/base/content/test/general/browser_accesskeys.js')
-rw-r--r-- | browser/base/content/test/general/browser_accesskeys.js | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/browser/base/content/test/general/browser_accesskeys.js b/browser/base/content/test/general/browser_accesskeys.js deleted file mode 100644 index 56fe3995f..000000000 --- a/browser/base/content/test/general/browser_accesskeys.js +++ /dev/null @@ -1,82 +0,0 @@ -add_task(function *() { - yield pushPrefs(["ui.key.contentAccess", 5], ["ui.key.chromeAccess", 5]); - - const gPageURL1 = "data:text/html,<body><p>" + - "<button id='button' accesskey='y'>Button</button>" + - "<input id='checkbox' type='checkbox' accesskey='z'>Checkbox" + - "</p></body>"; - let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gPageURL1); - tab1.linkedBrowser.messageManager.loadFrameScript("data:,(" + childHandleFocus.toString() + ")();", false); - - Services.focus.clearFocus(window); - - // Press an accesskey in the child document while the chrome is focused. - let focusedId = yield performAccessKey("y"); - is(focusedId, "button", "button accesskey"); - - // Press an accesskey in the child document while the content document is focused. - focusedId = yield performAccessKey("z"); - is(focusedId, "checkbox", "checkbox accesskey"); - - // Add an element with an accesskey to the chrome and press its accesskey while the chrome is focused. - let newButton = document.createElement("button"); - newButton.id = "chromebutton"; - newButton.setAttribute("accesskey", "z"); - document.documentElement.appendChild(newButton); - - Services.focus.clearFocus(window); - - focusedId = yield performAccessKeyForChrome("z"); - is(focusedId, "chromebutton", "chromebutton accesskey"); - - // Add a second tab and ensure that accesskey from the first tab is not used. - const gPageURL2 = "data:text/html,<body>" + - "<button id='tab2button' accesskey='y'>Button in Tab 2</button>" + - "</body>"; - let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gPageURL2); - tab2.linkedBrowser.messageManager.loadFrameScript("data:,(" + childHandleFocus.toString() + ")();", false); - - Services.focus.clearFocus(window); - - focusedId = yield performAccessKey("y"); - is(focusedId, "tab2button", "button accesskey in tab2"); - - // Press the accesskey for the chrome element while the content document is focused. - focusedId = yield performAccessKeyForChrome("z"); - is(focusedId, "chromebutton", "chromebutton accesskey"); - - newButton.parentNode.removeChild(newButton); - - gBrowser.removeTab(tab1); - gBrowser.removeTab(tab2); -}); - -function childHandleFocus() { - content.document.body.firstChild.addEventListener("focus", function focused(event) { - let focusedElement = content.document.activeElement; - focusedElement.blur(); - sendAsyncMessage("Test:FocusFromAccessKey", { focus: focusedElement.id }) - }, true); -} - -function performAccessKey(key) -{ - return new Promise(resolve => { - let mm = gBrowser.selectedBrowser.messageManager; - mm.addMessageListener("Test:FocusFromAccessKey", function listenForFocus(msg) { - mm.removeMessageListener("Test:FocusFromAccessKey", listenForFocus); - resolve(msg.data.focus); - }); - - EventUtils.synthesizeKey(key, { altKey: true, shiftKey: true }); - }); -} - -// This version is used when a chrome elemnt is expected to be found for an accesskey. -function* performAccessKeyForChrome(key, inChild) -{ - let waitFocusChangePromise = BrowserTestUtils.waitForEvent(document, "focus", true); - EventUtils.synthesizeKey(key, { altKey: true, shiftKey: true }); - yield waitFocusChangePromise; - return document.activeElement.id; -} |