author | Masayuki Nakano <masayuki@d-toybox.com> |
Thu, 15 Feb 2018 04:15:39 +0900 | |
changeset 404362 | 50d6fe2d0bca50837dd34eb4a79957885c55bffc |
parent 404361 | a9313b86c72f9ea594da0bd4ba65a53c23a299a0 |
child 404363 | 2ff1d57860b67bdd7fec1648c92e135971e44393 |
push id | 33471 |
push user | ncsoregi@mozilla.com |
push date | Mon, 19 Feb 2018 09:48:44 +0000 |
treeherder | mozilla-central@fc7f1c7fb157 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | smaug |
bugs | 1438157 |
milestone | 60.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/accessible/tests/browser/general/browser_test_urlbar.js +++ b/accessible/tests/browser/general/browser_test_urlbar.js @@ -10,17 +10,17 @@ add_task(async function testAutocomplete let tab = await openNewTab("data:text/html;charset=utf-8,"); let accService = await initAccessibilityService(); info("Opening the URL bar and entering a key to show the PopupAutoCompleteRichResult panel"); let urlbar = document.getElementById("urlbar"); urlbar.focus(); let urlbarPopup = document.getElementById("PopupAutoCompleteRichResult"); let shown = BrowserTestUtils.waitForEvent(urlbarPopup, "popupshown"); - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); await shown; info("Waiting for accessibility to be created for the richlistbox"); let richlistbox = document.getAnonymousElementByAttribute(urlbarPopup, "anonid", "richlistbox"); await BrowserTestUtils.waitForCondition(() => accService.getAccessibleFor(richlistbox)); info("Confirming that the special case is handled in XULListboxAccessible"); let accessible = accService.getAccessibleFor(richlistbox);
--- a/accessible/tests/mochitest/events.js +++ b/accessible/tests/mochitest/events.js @@ -1400,17 +1400,17 @@ function openCombobox(aComboboxID) { * Close combobox, autocomplete and etc popup, check expandable states. */ function closeCombobox(aComboboxID) { this.eventSeq = [ new stateChangeChecker(STATE_EXPANDED, false, false, aComboboxID) ]; this.invoke = function closeCombobox_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); }; this.getID = function closeCombobox_getID() { return "close combobox " + prettyName(aComboboxID); }; } @@ -1454,22 +1454,22 @@ function moveToLineEnd(aID, aCaretOffset /** * Move the caret to the end of previous line if any. */ function moveToPrevLineEnd(aID, aCaretOffset) { this.__proto__ = new synthAction(aID, new caretMoveChecker(aCaretOffset, aID)); this.invoke = function moveToPrevLineEnd_invoke() { - synthesizeKey("VK_UP", { }); + synthesizeKey("KEY_ArrowUp"); if (MAC) - synthesizeKey("VK_RIGHT", { metaKey: true }); + synthesizeKey("Key_ArrowRight", {metaKey: true}); else - synthesizeKey("VK_END", { }); + synthesizeKey("KEY_End"); }; this.getID = function moveToPrevLineEnd_getID() { return "move to previous line end in " + prettyName(aID); }; } /**
--- a/accessible/tests/mochitest/events/test_contextmenu.html +++ b/accessible/tests/mochitest/events/test_contextmenu.html @@ -41,32 +41,32 @@ } function selectMenuItem() { this.eventSeq = [ new invokerChecker(EVENT_FOCUS, getFocusedMenuItem) ]; this.invoke = function selectMenuItem_invoke() { - synthesizeKey("VK_DOWN", { }); + synthesizeKey("KEY_ArrowDown"); }; this.getID = function selectMenuItem_getID() { return "select first menuitem"; }; } function closeContextMenu(aID) { this.eventSeq = [ new invokerChecker(EVENT_MENUPOPUP_END, getAccessible(getContextMenuNode())) ]; this.invoke = function closeContextMenu_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); }; this.getID = function closeContextMenu_getID() { return "close context menu"; }; } function getContextMenuNode() {
--- a/accessible/tests/mochitest/events/test_focus_autocomplete.xul +++ b/accessible/tests/mochitest/events/test_focus_autocomplete.xul @@ -122,34 +122,34 @@ } function removeChar(aID, aCheckerOrEventSeq) { this.__proto__ = new synthAction(aID, aCheckerOrEventSeq); this.invoke = function removeChar_invoke() { - synthesizeKey("VK_LEFT", { shiftKey: true }); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_ArrowLeft", {shiftKey: true}); + synthesizeKey("KEY_Delete"); } this.getID = function removeChar_getID() { return "remove char on " + prettyName(aID); } } function replaceOnChar(aID, aChar, aCheckerOrEventSeq) { this.__proto__ = new synthAction(aID, aCheckerOrEventSeq); this.invoke = function replaceOnChar_invoke() { this.DOMNode.select(); - synthesizeKey(aChar, {}); + sendString(aChar); } this.getID = function replaceOnChar_getID() { return "replace on char '" + aChar + "' for" + prettyName(aID); } }
--- a/accessible/tests/mochitest/events/test_fromUserInput.html +++ b/accessible/tests/mochitest/events/test_fromUserInput.html @@ -27,17 +27,17 @@ this.eventSeq = [ new textChangeChecker(aID, aStart, aEnd, aText, false, aFromUser) ]; this.invoke = function removeTextFromInput_invoke() { this.DOMNode.focus(); this.DOMNode.setSelectionRange(aStart, aEnd); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); }; this.getID = function removeTextFromInput_getID() { return "Remove text from " + aStart + " to " + aEnd + " for " + prettyName(aID); }; } @@ -55,17 +55,17 @@ this.DOMNode.focus(); this.textNode = getNode(aID).firstChild; var selection = window.getSelection(); var range = document.createRange(); range.setStart(this.textNode, aStart); range.setEnd(this.textNode, aEnd); selection.addRange(range); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); }; this.getID = function removeTextFromContentEditable_getID() { return "Remove text from " + aStart + " to " + aEnd + " for " + prettyName(aID); }; }
--- a/accessible/tests/mochitest/events/test_menu.xul +++ b/accessible/tests/mochitest/events/test_menu.xul @@ -22,17 +22,17 @@ this.eventSeq = [ new invokerChecker(EVENT_MENU_START, getNode("menubar")), new invokerChecker(EVENT_MENUPOPUP_START, getNode("menupopup-file")) // new invokerChecker(EVENT_FOCUS, getNode("menuitem-newtab")) intermitent failure ]; this.invoke = function openFileMenu_invoke() { - synthesizeKey("F", { altKey: true, shiftKey: true }); + synthesizeKey("F", {altKey: true, shiftKey: true}); } this.getID = function openFileMenu_getID() { return "open file menu by alt+F press"; } } @@ -41,17 +41,17 @@ this.eventSeq = [ new invokerChecker(EVENT_MENUPOPUP_END, getNode("menupopup-file")), new invokerChecker(EVENT_MENUPOPUP_START, getNode("menupopup-edit")) // new invokerChecker(EVENT_FOCUS, getNode("menuitem-undo")) intermitent failure ]; this.invoke = function openEditMenu_invoke() { - synthesizeKey("VK_RIGHT", { }); + synthesizeKey("KEY_ArrowRight"); } this.getID = function openEditMenu_getID() { return "open edit menu by lef arrow press"; } } @@ -60,17 +60,17 @@ this.eventSeq = [ //new invokerChecker(EVENT_FOCUS, document), intermitent failure new invokerChecker(EVENT_MENUPOPUP_END, getNode("menupopup-edit")), new invokerChecker(EVENT_MENU_END, getNode("menubar")) ]; this.invoke = function closeEditMenu_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); } this.getID = function closeEditMenu_getID() { return "close edit menu, leave menubar"; } } @@ -78,34 +78,34 @@ { this.eventSeq = [ new invokerChecker(EVENT_MENU_START, getNode("menubar")) // new invokerChecker(EVENT_FOCUS, getNode("menuitem-file")) //intermitent failure ]; this.invoke = function focusFileMenu_invoke() { - synthesizeKey("VK_ALT", { }); + synthesizeKey("KEY_Alt"); } this.getID = function focusFileMenu_getID() { return "activate menubar, focus file menu (atl press)"; } } function focusEditMenu() { this.eventSeq = [ new invokerChecker(EVENT_FOCUS, getNode("menuitem-edit")) ]; this.invoke = function focusEditMenu_invoke() { - synthesizeKey("VK_RIGHT", { }); + synthesizeKey("KEY_ArrowRight"); } this.getID = function focusEditMenu_getID() { return "focus edit menu"; } } @@ -113,17 +113,17 @@ { this.eventSeq = [ //new invokerChecker(EVENT_FOCUS, document), intermitent failure new invokerChecker(EVENT_MENU_END, getNode("menubar")) ]; this.invoke = function leaveMenubar_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); } this.getID = function leaveMenubar_getID() { return "leave menubar"; } }
--- a/accessible/tests/mochitest/events/test_text.html +++ b/accessible/tests/mochitest/events/test_text.html @@ -164,17 +164,17 @@ this.eventSeq.push(new invokerChecker(EVENT_TEXT_VALUE_CHANGE, this.DOMNode)); this.invoke = function removeTextFromInput_invoke() { this.DOMNode.focus(); this.DOMNode.setSelectionRange(aStart, aEnd); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); }; this.getID = function removeTextFromInput_getID() { return "Remove text from " + aStart + " to " + aEnd + " for " + prettyName(aID); }; } @@ -184,17 +184,17 @@ function insertTextIntoInput(aID, aStart, aEnd, aText) { this.__proto__ = new textInsertInvoker(aID, aStart, aEnd, aText); this.eventSeq.push(new invokerChecker(EVENT_TEXT_VALUE_CHANGE, this.DOMNode)); this.invoke = function insertTextIntoInput_invoke() { this.DOMNode.focus(); - synthesizeKey("a", {}); + sendString("a"); }; this.getID = function insertTextIntoInput_getID() { return "Insert text to " + aStart + " for " + prettyName(aID); }; } /** @@ -207,17 +207,17 @@ this.DOMNode.focus(); var selection = window.getSelection(); var range = document.createRange(); range.setStart(this.textNode, aStart); range.setEnd(this.textNode, aEnd); selection.addRange(range); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); }; this.getID = function removeTextFromEditable_getID() { return "Remove text from " + aStart + " to " + aEnd + " for " + prettyName(aID); }; this.textNode = getNode(aTextNode);
--- a/accessible/tests/mochitest/states/test_inputs.html +++ b/accessible/tests/mochitest/states/test_inputs.html @@ -102,17 +102,17 @@ } // ////////////////////////////////////////////////////////////////////////// // 'invalid' state // (per spec, min/maxlength validity is affected by interactive edits) var mininp = document.getElementById("minlength"); mininp.focus(); mininp.setSelectionRange(mininp.value.length, mininp.value.length); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); ok(!mininp.validity.valid, "input should be invalid after interactive edits"); testStates(mininp, STATE_INVALID); // inputs currently cannot be made longer than maxlength interactively, // so we're not testing that case. // ////////////////////////////////////////////////////////////////////////// // autocomplete states
--- a/accessible/tests/mochitest/treeupdate/test_contextmenu.xul +++ b/accessible/tests/mochitest/treeupdate/test_contextmenu.xul @@ -47,34 +47,34 @@ function selectNextMenuItem(aID) { this.eventSeq = [ new invokerChecker(EVENT_FOCUS, getNode(aID)) ]; this.invoke = function selectMenuItem_invoke() { - synthesizeKey("VK_DOWN", { }); + synthesizeKey("KEY_ArrowDown"); } this.getID = function selectMenuItem_getID() { return "select menuitem " + prettyName(aID); } } function openSubMenu(aSubMenuID, aItemID, aMenuID, aTree) { this.eventSeq = [ new invokerChecker(EVENT_FOCUS, getNode(aItemID)), ]; this.invoke = function openSubMenu_invoke() { - synthesizeKey("VK_RETURN", { }); + synthesizeKey("KEY_Enter"); } this.finalCheck = function openSubMenu_finalCheck(aEvent) { testAccessibleTree(aMenuID, aTree); } this.getID = function openSubMenu_getID() @@ -86,34 +86,34 @@ function closeSubMenu(aSubMenuID, aItemID) { this.eventSeq = [ new invokerChecker(EVENT_FOCUS, getNode(aItemID)), ]; this.invoke = function closeSubMenu_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); } this.getID = function closeSubMenu_getID() { return "close submenu " + prettyName(aSubMenuID) + " focusing item " + prettyName(aItemID); } } function closeMenu(aID) { this.eventSeq = [ new invokerChecker(EVENT_MENUPOPUP_END, getNode(aID)) ]; this.invoke = function closeMenu_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); } this.getID = function closeMenu_getID() { return "close menu " + prettyName(aID); } }
--- a/accessible/tests/mochitest/treeupdate/test_menubutton.xul +++ b/accessible/tests/mochitest/treeupdate/test_menubutton.xul @@ -50,17 +50,17 @@ { PUSHBUTTON: [ { MENUPOPUP: [ { role: menuItemRole, children: [ ] }, { role: menuItemRole, children: [ ] } ] } ] }; testAccessibleTree(this.button, tree); - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); } this.getID = function openMenu_getID() { return "open menu of the button " + prettyName(aButtonID); } }
--- a/browser/base/content/test/forms/browser_selectpopup.js +++ b/browser/base/content/test/forms/browser_selectpopup.js @@ -139,36 +139,36 @@ async function doSelectTests(contentType let isWindows = navigator.platform.includes("Win"); is(menulist.selectedIndex, 1, "Initial selection"); is(selectPopup.firstChild.localName, "menucaption", "optgroup is caption"); is(selectPopup.firstChild.getAttribute("label"), "First Group", "optgroup label"); is(selectPopup.childNodes[1].localName, "menuitem", "option is menuitem"); is(selectPopup.childNodes[1].getAttribute("label"), "One", "option label"); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(2), "Select item 2"); is(menulist.selectedIndex, isWindows ? 2 : 1, "Select item 2 selectedIndex"); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(3), "Select item 3"); is(menulist.selectedIndex, isWindows ? 3 : 1, "Select item 3 selectedIndex"); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); // On Windows, one can navigate on disabled menuitems is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(9), "Skip optgroup header and disabled items select item 7"); is(menulist.selectedIndex, isWindows ? 9 : 1, "Select or skip disabled item selectedIndex"); for (let i = 0; i < 10; i++) { is(menulist.getItemAtIndex(i).disabled, i >= 4 && i <= 7, "item " + i + " disabled"); } - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(3), "Select item 3 again"); is(menulist.selectedIndex, isWindows ? 3 : 1, "Select item 3 selectedIndex"); is((await getInputEvents()), 0, "Before closed - number of input events"); is((await getChangeEvents()), 0, "Before closed - number of change events"); is((await getClickEvents()), 0, "Before closed - number of click events"); EventUtils.synthesizeKey("a", { accelKey: true }); @@ -177,46 +177,46 @@ async function doSelectTests(contentType "Select all while popup is open"); }); // Backspace should not go back let handleKeyPress = function(event) { ok(false, "Should not get keypress event"); }; window.addEventListener("keypress", handleKeyPress); - EventUtils.synthesizeKey("VK_BACK_SPACE", { }); + EventUtils.synthesizeKey("KEY_Backspace"); window.removeEventListener("keypress", handleKeyPress); await hideSelectPopup(selectPopup); is(menulist.selectedIndex, 3, "Item 3 still selected"); is((await getInputEvents()), 1, "After closed - number of input events"); is((await getChangeEvents()), 1, "After closed - number of change events"); is((await getClickEvents()), 0, "After closed - number of click events"); // Opening and closing the popup without changing the value should not fire a change event. await openSelectPopup(selectPopup, "click"); await hideSelectPopup(selectPopup, "escape"); is((await getInputEvents()), 1, "Open and close with no change - number of input events"); is((await getChangeEvents()), 1, "Open and close with no change - number of change events"); is((await getClickEvents()), 1, "Open and close with no change - number of click events"); - EventUtils.synthesizeKey("VK_TAB", { }); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab"); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); is((await getInputEvents()), 1, "Tab away from select with no change - number of input events"); is((await getChangeEvents()), 1, "Tab away from select with no change - number of change events"); is((await getClickEvents()), 1, "Tab away from select with no change - number of click events"); await openSelectPopup(selectPopup, "click"); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); await hideSelectPopup(selectPopup, "escape"); is((await getInputEvents()), isWindows ? 2 : 1, "Open and close with change - number of input events"); is((await getChangeEvents()), isWindows ? 2 : 1, "Open and close with change - number of change events"); is((await getClickEvents()), 2, "Open and close with change - number of click events"); - EventUtils.synthesizeKey("VK_TAB", { }); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab"); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); is((await getInputEvents()), isWindows ? 2 : 1, "Tab away from select with change - number of input events"); is((await getChangeEvents()), isWindows ? 2 : 1, "Tab away from select with change - number of change events"); is((await getClickEvents()), 2, "Tab away from select with change - number of click events"); is(selectPopup.lastChild.previousSibling.label, "Seven", "Spaces collapsed"); is(selectPopup.lastChild.label, "\xA0\xA0Eight\xA0\xA0", "Non-breaking spaces not collapsed"); await BrowserTestUtils.removeTab(tab); @@ -430,17 +430,17 @@ add_task(async function test_event_order let select = content.document.getElementById(contentMode == "enter" ? "one" : "two"); for (let event of ["input", "change", "mousedown", "mouseup", "click"]) { select.addEventListener(event, onEvent); } }); }); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); await hideSelectPopup(selectPopup, mode); await eventsPromise; } }); }); async function performLargePopupTests(win) { let browser = win.gBrowser.selectedBrowser; @@ -632,32 +632,32 @@ async function performSelectSearchTests( is(selectPopup.childNodes[2].hidden, true, "First option should be hidden"); is(selectPopup.childNodes[3].hidden, true, "Second option should be hidden"); is(selectPopup.childNodes[4].hidden, false, "Third option should be visible"); EventUtils.synthesizeKey("Z", {}, win); is(selectPopup.childNodes[4].hidden, true, "Third option should be hidden"); is(selectPopup.childNodes[1].hidden, true, "First group header should be hidden"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); + EventUtils.synthesizeKey("KEY_Backspace", {}, win); is(selectPopup.childNodes[4].hidden, false, "Third option should be visible"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); + EventUtils.synthesizeKey("KEY_Backspace", {}, win); is(selectPopup.childNodes[5].hidden, false, "Second group header should be visible"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); + EventUtils.synthesizeKey("KEY_Backspace", {}, win); EventUtils.synthesizeKey("O", {}, win); EventUtils.synthesizeKey("5", {}, win); is(selectPopup.childNodes[5].hidden, false, "Second group header should be visible"); is(selectPopup.childNodes[1].hidden, true, "First group header should be hidden"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); + EventUtils.synthesizeKey("KEY_Backspace", {}, win); is(selectPopup.childNodes[1].hidden, false, "First group header should be shown"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); + EventUtils.synthesizeKey("KEY_Backspace", {}, win); is(selectPopup.childNodes[8].hidden, true, "Option hidden by content should remain hidden"); await hideSelectPopup(selectPopup, "escape", win); } // This test checks the functionality of search in select elements with groups // and a large number of options. add_task(async function test_select_search() {
--- a/browser/base/content/test/forms/browser_selectpopup_colors.js +++ b/browser/base/content/test/forms/browser_selectpopup_colors.js @@ -198,17 +198,17 @@ function testOptionColors(index, item, m if (color.toLowerCase().includes("color") && !expected[color].startsWith("rgb")) { expected[color] = getSystemColor(expected[color]); } } // Press Down to move the selected item to the next item in the // list and check the colors of this item when it's not selected. - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); if (expected.end) { return; } if (expected.unstyled) { ok(!item.hasAttribute("customoptionstyling"), `Item ${index} should not have any custom option styling`);
--- a/browser/base/content/test/general/browser_bug432599.js +++ b/browser/base/content/test/general/browser_bug432599.js @@ -1,33 +1,33 @@ /* eslint-disable mozilla/no-arbitrary-setTimeout */ function invokeUsingCtrlD(phase) { switch (phase) { case 1: - EventUtils.synthesizeKey("d", { accelKey: true }); + EventUtils.synthesizeKey("d", {accelKey: true}); break; case 2: case 4: - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); break; case 3: - EventUtils.synthesizeKey("d", { accelKey: true }); - EventUtils.synthesizeKey("d", { accelKey: true }); + EventUtils.synthesizeKey("d", {accelKey: true}); + EventUtils.synthesizeKey("d", {accelKey: true}); break; } } function invokeUsingStarButton(phase) { switch (phase) { case 1: EventUtils.synthesizeMouseAtCenter(BookmarkingUI.star, {}); break; case 2: case 4: - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); break; case 3: EventUtils.synthesizeMouseAtCenter(BookmarkingUI.star, { clickCount: 2 }); break; } }
--- a/browser/base/content/test/general/browser_bug553455.js +++ b/browser/base/content/test/general/browser_bug553455.js @@ -689,17 +689,17 @@ async function test_tabNavigate() { async function test_urlBar() { let progressPromise = waitForProgressNotification(); let dialogPromise = waitForInstallDialog(); gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank"); await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); gURLBar.value = TESTROOT + "amosigned.xpi"; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await progressPromise; let installDialog = await dialogPromise; let notificationPromise = waitForNotification("addon-install-restart"); acceptInstallDialog(installDialog); let panel = await notificationPromise;
--- a/browser/base/content/test/general/browser_bug555767.js +++ b/browser/base/content/test/general/browser_bug555767.js @@ -44,10 +44,10 @@ tabSelected = true; } // Add the TabClose, TabSelect event listeners before we press enter gBrowser.tabContainer.addEventListener("TabClose", onTabClose); gBrowser.tabContainer.addEventListener("TabSelect", onTabSelect); // Press enter! - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); });
--- a/browser/base/content/test/general/browser_domFullscreen_fullscreenMode.js +++ b/browser/base/content/test/general/browser_domFullscreen_fullscreenMode.js @@ -123,24 +123,24 @@ var gTests = [ exitFunc: () => { gMessageManager.sendAsyncMessage("Test:ExitFullscreen"); } }, { desc: "escape key", affectsFullscreenMode: false, exitFunc: () => { - executeSoon(() => EventUtils.synthesizeKey("VK_ESCAPE", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_Escape")); } }, { desc: "F11 key", affectsFullscreenMode: true, exitFunc() { - executeSoon(() => EventUtils.synthesizeKey("VK_F11", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_F11")); } } ]; function checkState(expectedStates, contentStates) { is(contentStates.inDOMFullscreen, expectedStates.inDOMFullscreen, "The DOM fullscreen state of the content should match"); // TODO window.fullScreen is not updated as soon as the fullscreen
--- a/browser/base/content/test/general/browser_focusonkeydown.js +++ b/browser/base/content/test/general/browser_focusonkeydown.js @@ -10,14 +10,14 @@ add_task(async function() { keyUps++; } }, {capture: true, once: true}); gURLBar.addEventListener("keydown", function(event) { gBrowser.selectedBrowser.focus(); }, {capture: true, once: true}); - EventUtils.synthesizeKey("v", { }); + EventUtils.sendString("v"); is(keyUps, 1, "Key up fired at url bar"); gBrowser.removeCurrentTab(); });
--- a/browser/base/content/test/general/browser_keywordBookmarklets.js +++ b/browser/base/content/test/general/browser_keywordBookmarklets.js @@ -19,17 +19,17 @@ add_task(async function test_keyword_boo let originalPrincipal = gBrowser.contentPrincipal; let originalPrincipalURI = await getPrincipalURI(tab.linkedBrowser); await PlacesUtils.keywords.insert({ keyword: "bm", url: "javascript:'1';" }); // Enter bookmarklet keyword in the URL bar gURLBar.value = "bm"; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "pageshow"); let newPrincipalURI = await getPrincipalURI(tab.linkedBrowser); is(newPrincipalURI, originalPrincipalURI, "content has the same principal"); // In e10s, null principals don't round-trip so the same null principal sent // from the child will be a new null principal. Verify that this is the
--- a/browser/base/content/test/general/browser_keywordSearch.js +++ b/browser/base/content/test/general/browser_keywordSearch.js @@ -114,10 +114,10 @@ function nextTest() { } function doTest() { info("Running test: " + gCurrTest.name); // Simulate a user entering search terms gURLBar.value = gCurrTest.testText; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); }
--- a/browser/base/content/test/general/browser_keywordSearch_postData.js +++ b/browser/base/content/test/general/browser_keywordSearch_postData.js @@ -73,17 +73,17 @@ function doTest() { let needle = "searchterms=" + gCurrTest.expectText; is(loadedText, needle, "The query POST data should be returned in the response"); nextTest(); }); // Simulate a user entering search terms gURLBar.value = gCurrTest.testText; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } function waitForLoad(cb) { let browser = gBrowser.selectedBrowser; function wantLoad(url) { return url != "about:blank"; }
--- a/browser/base/content/test/general/browser_printpreview.js +++ b/browser/base/content/test/general/browser_printpreview.js @@ -16,35 +16,35 @@ function test() { }); } function tidyUp() { BrowserTestUtils.removeTab(ourTab).then(finish); } function testClosePrintPreviewWithAccessKey() { - EventUtils.synthesizeKey("c", { altKey: true }); + EventUtils.synthesizeKey("c", {altKey: true}); checkPrintPreviewClosed(function(aSucceeded) { ok(aSucceeded, "print preview mode should be finished by access key"); openPrintPreview(testClosePrintPreviewWithEscKey); }); } function testClosePrintPreviewWithEscKey() { - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); checkPrintPreviewClosed(function(aSucceeded) { ok(aSucceeded, "print preview mode should be finished by Esc key press"); openPrintPreview(testClosePrintPreviewWithClosingWindowShortcutKey); }); } function testClosePrintPreviewWithClosingWindowShortcutKey() { - EventUtils.synthesizeKey("w", { accelKey: true }); + EventUtils.synthesizeKey("w", {accelKey: true}); checkPrintPreviewClosed(function(aSucceeded) { ok(aSucceeded, "print preview mode should be finished by closing window shortcut key"); tidyUp(); }); } function openPrintPreview(aCallback) {
--- a/browser/base/content/test/general/browser_tabfocus.js +++ b/browser/base/content/test/general/browser_tabfocus.js @@ -339,26 +339,26 @@ add_task(async function() { // Document navigation with F6 does not yet work in mutli-process browsers. if (!gMultiProcessBrowser) { gURLBar.focus(); actualEvents = new EventStore(); _lastfocus = "urlbar"; _lastfocuswindow = "main-window"; - await expectFocusShift(() => EventUtils.synthesizeKey("VK_F6", { }), + await expectFocusShift(() => EventUtils.synthesizeKey("KEY_F6"), "window1", "html1", true, "switch document forward with f6"); - EventUtils.synthesizeKey("VK_F6", { }); + EventUtils.synthesizeKey("KEY_F6"); is(fm.focusedWindow, window, "switch document forward again with f6"); browser1.style.MozUserFocus = "ignore"; browser1.clientWidth; - EventUtils.synthesizeKey("VK_F6", { }); + EventUtils.synthesizeKey("KEY_F6"); is(fm.focusedWindow, window, "switch document forward again with f6 when browser non-focusable"); browser1.style.MozUserFocus = "normal"; browser1.clientWidth; } window.removeEventListener("focus", _browser_tabfocus_test_eventOccured, true); window.removeEventListener("blur", _browser_tabfocus_test_eventOccured, true);
--- a/browser/base/content/test/general/browser_visibleFindSelection.js +++ b/browser/base/content/test/general/browser_visibleFindSelection.js @@ -6,28 +6,26 @@ add_task(async function() { let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); await promiseTabLoadEvent(tab, "data:text/html;charset=utf-8," + escape(childContent)); await SimpleTest.promiseFocus(gBrowser.selectedBrowser); let remote = gBrowser.selectedBrowser.isRemoteBrowser; let findBarOpenPromise = promiseWaitForEvent(gBrowser, "findbaropen"); - EventUtils.synthesizeKey("f", { accelKey: true }); + EventUtils.synthesizeKey("f", {accelKey: true}); await findBarOpenPromise; ok(gFindBarInitialized, "find bar is now initialized"); // Finds the div in the green box. let scrollPromise = remote ? BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "scroll") : BrowserTestUtils.waitForEvent(gBrowser, "scroll"); - EventUtils.synthesizeKey("d", {}); - EventUtils.synthesizeKey("i", {}); - EventUtils.synthesizeKey("v", {}); + EventUtils.sendString("div"); await scrollPromise; // Wait for one paint to ensure we've processed the previous key events and scrolling. await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() { return new Promise( resolve => { content.requestAnimationFrame(() => { setTimeout(resolve, 0); @@ -35,24 +33,24 @@ add_task(async function() { } ); }); // Finds the div in the red box. scrollPromise = remote ? BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "scroll") : BrowserTestUtils.waitForEvent(gBrowser, "scroll"); - EventUtils.synthesizeKey("g", { accelKey: true }); + EventUtils.synthesizeKey("g", {accelKey: true}); await scrollPromise; await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() { Assert.ok(content.document.getElementById("s").getBoundingClientRect().left >= 0, "scroll should include find result"); }); // clear the find bar - EventUtils.synthesizeKey("a", { accelKey: true }); - EventUtils.synthesizeKey("VK_DELETE", { }); + EventUtils.synthesizeKey("a", {accelKey: true}); + EventUtils.synthesizeKey("KEY_Delete"); gFindBar.close(); gBrowser.removeCurrentTab(); });
--- a/browser/base/content/test/general/browser_zbug569342.js +++ b/browser/base/content/test/general/browser_zbug569342.js @@ -36,29 +36,29 @@ var urls = [ function nextTest() { let url = urls.shift(); if (url) { testFindDisabled(url, nextTest); } else { // Make sure the find bar is re-enabled after disabled page is closed. testFindEnabled("about:blank", function() { - EventUtils.synthesizeKey("VK_ESCAPE", { }); + EventUtils.synthesizeKey("KEY_Escape"); ok(gFindBar.hidden, "Find bar should now be hidden"); finish(); }); } } function testFindDisabled(url, cb) { load(url, function() { ok(gFindBar.hidden, "Find bar should not be visible"); EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow); ok(gFindBar.hidden, "Find bar should not be visible"); - EventUtils.synthesizeKey("f", { accelKey: true }); + EventUtils.synthesizeKey("f", {accelKey: true}); ok(gFindBar.hidden, "Find bar should not be visible"); ok(document.getElementById("cmd_find").getAttribute("disabled"), "Find command should be disabled"); gBrowser.removeTab(gTab); cb(); }); } @@ -66,15 +66,15 @@ function testFindDisabled(url, cb) { function testFindEnabled(url, cb) { load(url, function() { ok(!document.getElementById("cmd_find").getAttribute("disabled"), "Find command should not be disabled"); // Open Find bar and then close it. EventUtils.synthesizeKey("f", { accelKey: true }); ok(!gFindBar.hidden, "Find bar should be visible again"); - EventUtils.synthesizeKey("VK_ESCAPE", { }); + EventUtils.synthesizeKey("KEY_Escape"); ok(gFindBar.hidden, "Find bar should now be hidden"); gBrowser.removeTab(gTab); cb(); }); }
--- a/browser/base/content/test/general/contentSearchUI.js +++ b/browser/base/content/test/general/contentSearchUI.js @@ -28,17 +28,17 @@ var messageHandlers = { content.removeEventListener("ContentSearchService", listener); ack("init"); } }); }, key(arg) { let keyName = typeof(arg) == "string" ? arg : arg.key; - content.synthesizeKey(keyName, arg.modifiers || {}); + content.synthesizeKey(keyName, arg.modifiers); let wait = arg.waitForSuggestions ? waitForSuggestions : cb => cb(); wait(ack.bind(null, "key")); }, startComposition(arg) { content.synthesizeComposition({ type: "compositionstart", data: "" }); ack("startComposition"); }, @@ -138,19 +138,19 @@ var messageHandlers = { ack("removeLastOneOff"); }, reset() { // Reset both the input and suggestions by select all + delete. If there was // no text entered, this won't have any effect, so also escape to ensure the // suggestions table is closed. gController.input.focus(); - content.synthesizeKey("a", { accelKey: true }); - content.synthesizeKey("VK_DELETE", {}); - content.synthesizeKey("VK_ESCAPE", {}); + content.synthesizeKey("a", {accelKey: true}); + content.synthesizeKey("KEY_Delete"); + content.synthesizeKey("KEY_Escape"); ack("reset"); }, }; function ack(aType, aData) { sendAsyncMessage(TEST_MSG, { type: aType, data: aData || currentState() }); }
--- a/browser/base/content/test/newtab/browser_newtab_focus.js +++ b/browser/base/content/test/newtab/browser_newtab_focus.js @@ -45,17 +45,17 @@ add_task(async function() { }); /** * Focus the urlbar and count how many focus stops to return again to the urlbar. */ function countFocus(aExpectedCount) { let focusCount = 0; do { - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); if (document.activeElement == gBrowser.selectedBrowser) { focusCount++; } } while (document.activeElement != gURLBar.inputField); ok(focusCount == aExpectedCount || focusCount == (aExpectedCount + 1), "Validate focus count in the new tab page."); }
--- a/browser/base/content/test/newtab/browser_newtab_search.js +++ b/browser/base/content/test/newtab/browser_newtab_search.js @@ -151,26 +151,26 @@ add_task(async function() { observer.observe(input, { attributes: true, attributeFilter: ["aria-expanded"], }); }); let suggestionsPromise = promiseSearchEvents(["Suggestions"]); - EventUtils.synthesizeKey("x", {}); + EventUtils.sendString("x"); // Wait for the search suggestions to become visible and for the Suggestions // message. await suggestionsOpenPromise; await suggestionsPromise; // Empty the search input, causing the suggestions to be hidden. - EventUtils.synthesizeKey("a", { accelKey: true }); - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("a", {accelKey: true}); + EventUtils.synthesizeKey("KEY_Delete"); await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() { Assert.ok(content.document.getElementById("searchSuggestionTable").hidden, "Search suggestion table hidden"); }); // Done. Revert the current engine and remove the new engines. searchEventsPromise = promiseSearchEvents(["CurrentEngine"]);
--- a/browser/base/content/test/permissions/browser_reservedkey.js +++ b/browser/base/content/test/permissions/browser_reservedkey.js @@ -12,32 +12,28 @@ add_task(async function test_reserved_sh let container = document.createElement("box"); container.unsafeSetInnerHTML(keyset); document.documentElement.appendChild(container); /* eslint-enable no-unsanitized/property */ const pageUrl = "data:text/html,<body onload='document.body.firstChild.focus();'><div onkeydown='event.preventDefault();' tabindex=0>Test</div></body>"; let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl); - EventUtils.synthesizeKey("O", { shiftKey: true }); - EventUtils.synthesizeKey("P", { shiftKey: true }); - EventUtils.synthesizeKey("Q", { shiftKey: true }); + EventUtils.sendString("OPQ"); is(document.getElementById("kt_reserved").getAttribute("count"), "1", "reserved='true' with preference off"); is(document.getElementById("kt_notreserved").getAttribute("count"), "0", "reserved='false' with preference off"); is(document.getElementById("kt_reserveddefault").getAttribute("count"), "0", "default reserved with preference off"); // Now try with reserved shortcut key handling enabled. await new Promise(resolve => { SpecialPowers.pushPrefEnv({"set": [["permissions.default.shortcuts", 2]]}, resolve); }); - EventUtils.synthesizeKey("O", { shiftKey: true }); - EventUtils.synthesizeKey("P", { shiftKey: true }); - EventUtils.synthesizeKey("Q", { shiftKey: true }); + EventUtils.sendString("OPQ"); is(document.getElementById("kt_reserved").getAttribute("count"), "2", "reserved='true' with preference on"); is(document.getElementById("kt_notreserved").getAttribute("count"), "0", "reserved='false' with preference on"); is(document.getElementById("kt_reserveddefault").getAttribute("count"), "1", "default reserved with preference on"); document.documentElement.removeChild(container); await BrowserTestUtils.removeTab(tab); @@ -51,38 +47,38 @@ if (!navigator.platform.includes("Mac")) }); const uri = "data:text/html,<body onkeydown='if (event.key == \"H\" || event.key == \"F10\") event.preventDefault();'>"; let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, uri); // Pressing Alt+H should open the Help menu. let helpPopup = document.getElementById("menu_HelpPopup"); let popupShown = BrowserTestUtils.waitForEvent(helpPopup, "popupshown"); - EventUtils.synthesizeKey("VK_ALT", { type: "keydown" }); - EventUtils.synthesizeKey("H", { altKey: true }); - EventUtils.synthesizeKey("VK_ALT", { type: "keyup" }); + EventUtils.synthesizeKey("KEY_Alt", {type: "keydown"}); + EventUtils.synthesizeKey("h", {altKey: true}); + EventUtils.synthesizeKey("KEY_Alt", {type: "keyup"}); await popupShown; ok(true, "Help menu opened"); let popupHidden = BrowserTestUtils.waitForEvent(helpPopup, "popuphidden"); helpPopup.hidePopup(); await popupHidden; // Pressing F10 should focus the menubar. On Linux, the file menu should open, but on Windows, // pressing Down will open the file menu. let menubar = document.getElementById("main-menubar"); let menubarActive = BrowserTestUtils.waitForEvent(menubar, "DOMMenuBarActive"); - EventUtils.sendKey("F10"); + EventUtils.synthesizeKey("KEY_F10"); await menubarActive; let filePopup = document.getElementById("menu_FilePopup"); popupShown = BrowserTestUtils.waitForEvent(filePopup, "popupshown"); if (navigator.platform.includes("Win")) { - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } await popupShown; ok(true, "File menu opened"); popupHidden = BrowserTestUtils.waitForEvent(filePopup, "popuphidden"); filePopup.hidePopup(); await popupHidden;
--- a/browser/base/content/test/popupNotifications/browser_popupNotification_keyboard.js +++ b/browser/base/content/test/popupNotifications/browser_popupNotification_keyboard.js @@ -18,17 +18,17 @@ var tests = [ { id: "Test#1", run() { this.notifyObj = new BasicNotification(this.id); this.notifyObj.options.persistent = true; showNotification(this.notifyObj); }, onShown(popup) { checkPopup(popup, this.notifyObj); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); }, onHidden(popup) { ok(!this.notifyObj.mainActionClicked, "mainAction was not clicked"); ok(this.notifyObj.secondaryActionClicked, "secondaryAction was clicked"); ok(!this.notifyObj.dismissalCallbackTriggered, "dismissal callback wasn't triggered"); ok(this.notifyObj.removedCallbackTriggered, "removed callback triggered"); } }, @@ -36,17 +36,17 @@ var tests = [ { id: "Test#2", async run() { await waitForWindowReadyForPopupNotifications(window); this.notifyObj = new BasicNotification(this.id); this.notification = showNotification(this.notifyObj); }, onShown(popup) { checkPopup(popup, this.notifyObj); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); }, onHidden(popup) { ok(!this.notifyObj.mainActionClicked, "mainAction was not clicked"); ok(!this.notifyObj.secondaryActionClicked, "secondaryAction was not clicked"); ok(this.notifyObj.dismissalCallbackTriggered, "dismissal callback triggered"); ok(!this.notifyObj.removedCallbackTriggered, "removed callback was not triggered"); this.notification.remove(); } @@ -61,17 +61,17 @@ var tests = [ }); this.notification = showNotification(this.notifyObj); }, onShown(popup) { checkPopup(popup, this.notifyObj); let anchor = document.getElementById(this.notifyObj.anchorID); anchor.focus(); is(document.activeElement, anchor); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); is(document.activeElement, popup.childNodes[0].closebutton); this.notification.remove(); }, onHidden(popup) { } }, // Test that you can switch between active notifications with the space key // and that the notification is focused on selection. { id: "Test#4", @@ -103,28 +103,28 @@ var tests = [ // Make sure notification 2 is visible checkPopup(popup, notifyObj2); // Activate the anchor for notification 1 and wait until it's shown. let anchor = document.getElementById(notifyObj1.anchorID); anchor.focus(); is(document.activeElement, anchor); opened = waitForNotificationPanel(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); popup = await opened; checkPopup(popup, notifyObj1); is(document.activeElement, popup.childNodes[0].checkbox); // Activate the anchor for notification 2 and wait until it's shown. anchor = document.getElementById(notifyObj2.anchorID); anchor.focus(); is(document.activeElement, anchor); opened = waitForNotificationPanel(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); popup = await opened; checkPopup(popup, notifyObj2); is(document.activeElement, popup.childNodes[0].closebutton); notification1.remove(); notification2.remove(); goNext(); @@ -142,17 +142,17 @@ var tests = [ }, onShown(popup) { checkPopup(popup, this.notifyObj); // Initial focus on open is null because a panel itself // can not be focused, next tab focus will be inside the panel. is(Services.focus.focusedElement, null); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(Services.focus.focusedElement, popup.childNodes[0].closebutton); dismissNotification(popup); }, async onHidden() { // Focus the urlbar to check that it stays focused. gURLBar.focus(); // Show another notification and make sure it's not autofocused.
--- a/browser/base/content/test/popupNotifications/browser_popupNotification_no_anchors.js +++ b/browser/base/content/test/popupNotifications/browser_popupNotification_no_anchors.js @@ -115,41 +115,41 @@ var tests = [ this.notification = showNotification(this.notifyObj); await shown; checkPopup(PopupNotifications.panel, this.notifyObj); // Typing in the location bar should hide the notification. let hidden = waitForNotificationPanelHidden(); gURLBar.select(); - EventUtils.synthesizeKey("*", {}); + EventUtils.sendString("*"); await hidden; is(document.getElementById("geo-notification-icon").boxObject.width, 0, "geo anchor shouldn't be visible"); // Moving focus to the next control should show the notifications again, // anchored to the identity icon. We clear the URL bar before moving the // focus so that the awesomebar popup doesn't get in the way. shown = waitForNotificationPanel(); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Backspace"); + EventUtils.synthesizeKey("KEY_Tab"); await shown; is(PopupNotifications.panel.anchorNode.id, "identity-icon", "notification anchored to identity icon"); // Moving focus to the location bar should hide the notification again. hidden = waitForNotificationPanelHidden(); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); await hidden; // Reverting the URL should show the notification again. shown = waitForNotificationPanel(); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await shown; checkPopup(PopupNotifications.panel, this.notifyObj); hidden = waitForNotificationPanelHidden(); this.notification.remove(); await hidden; } @@ -158,30 +158,30 @@ var tests = [ }, // Test that popupnotifications triggered while editing the URL in the // location bar are only shown later when the URL is reverted. { id: "Test#5", async run() { for (let persistent of [false, true]) { // Start editing the URL, ensuring that the awesomebar popup is hidden. gURLBar.select(); - EventUtils.synthesizeKey("*", {}); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.sendString("*"); + EventUtils.synthesizeKey("KEY_Backspace"); // Trying to show a notification should display nothing. let notShowing = promiseTopicObserved("PopupNotifications-updateNotShowing"); this.notifyObj = new BasicNotification(this.id); this.notifyObj.anchorID = "geo-notification-icon"; this.notifyObj.addOptions({ persistent }); this.notification = showNotification(this.notifyObj); await notShowing; // Reverting the URL should show the notification. let shown = waitForNotificationPanel(); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await shown; checkPopup(PopupNotifications.panel, this.notifyObj); let hidden = waitForNotificationPanelHidden(); this.notification.remove(); await hidden; } @@ -205,17 +205,17 @@ var tests = [ // Switching to a new tab should hide the notification. let hidden = waitForNotificationPanelHidden(); this.oldSelectedTab = gBrowser.selectedTab; await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/"); await hidden; // Start editing the URL. gURLBar.select(); - EventUtils.synthesizeKey("*", {}); + EventUtils.sendString("*"); // Switching to the old tab should show the notification again. shown = waitForNotificationPanel(); gBrowser.removeTab(gBrowser.selectedTab); gBrowser.selectedTab = this.oldSelectedTab; await shown; checkPopup(PopupNotifications.panel, this.notifyObj);
--- a/browser/base/content/test/popupNotifications/head.js +++ b/browser/base/content/test/popupNotifications/head.js @@ -118,17 +118,17 @@ function showNotification(notifyObj) { notifyObj.anchorID, notifyObj.mainAction, notifyObj.secondaryActions, notifyObj.options); } function dismissNotification(popup) { info("Dismissing notification " + popup.childNodes[0].id); - executeSoon(() => EventUtils.synthesizeKey("VK_ESCAPE", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_Escape")); } function BasicNotification(testId) { this.browser = gBrowser.selectedBrowser; this.id = "test-notification-" + testId; this.message = "This is popup notification for " + testId; this.anchorID = null; this.mainAction = { @@ -304,18 +304,18 @@ function triggerSecondaryCommand(popup, // Extra secondary actions appear in a menu. notification.secondaryButton.nextSibling.nextSibling.focus(); popup.addEventListener("popupshown", function() { info("Command popup open for notification " + notification.id); // Press down until the desired command is selected. Decrease index by one // since the secondary action was handled above. for (let i = 0; i <= index - 1; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } // Activate - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); }, {once: true}); // One down event to open the popup info("Open the popup to trigger secondary command for notification " + notification.id); - EventUtils.synthesizeKey("VK_DOWN", { altKey: !navigator.platform.includes("Mac") }); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: !navigator.platform.includes("Mac")}); }
--- a/browser/base/content/test/siteIdentity/browser_identityPopup_focus.js +++ b/browser/base/content/test/siteIdentity/browser_identityPopup_focus.js @@ -14,14 +14,14 @@ add_task(async function testIdentityPopu // Access the identity popup via keyboard. Focus should be moved inside. add_task(async function testIdentityPopupFocusKeyboard() { await SpecialPowers.pushPrefEnv({"set": [["accessibility.tabfocus", 7]]}); await BrowserTestUtils.withNewTab("https://example.com", async function() { let focused = BrowserTestUtils.waitForEvent(gIdentityHandler._identityBox, "focus"); gIdentityHandler._identityBox.focus(); await focused; let shown = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown"); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await shown; is(Services.focus.focusedElement, document.getElementById("identity-popup-security-expander")); }); });
--- a/browser/base/content/test/urlbar/browser_action_searchengine_alias.js +++ b/browser/base/content/test/urlbar/browser_action_searchengine_alias.js @@ -22,16 +22,16 @@ add_task(async function() { await promiseAutocompleteResultPopup("moz open a search"); let result = await waitForAutocompleteResultAt(0); ok(result.hasAttribute("image"), "Result should have an image attribute"); ok(result.getAttribute("image") === engine.iconURI.spec, "Image attribute should have the search engine's icon"); let tabPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - EventUtils.synthesizeKey("VK_RETURN", { }); + EventUtils.synthesizeKey("KEY_Enter"); await tabPromise; is(gBrowser.selectedBrowser.currentURI.spec, "http://example.com/?q=open+a+search"); gURLBar.popup.hidePopup(); await promisePopupHidden(gURLBar.popup); });
--- a/browser/base/content/test/urlbar/browser_autocomplete_autoselect.js +++ b/browser/base/content/test/urlbar/browser_autocomplete_autoselect.js @@ -51,45 +51,45 @@ add_task(async function() { let popup = gURLBar.popup; let results = popup.richlistbox.children; is(results.length, maxResults, "Should get maxResults=" + maxResults + " results"); is_selected(0); info("Key Down to select the next item"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is_selected(1); info("Key Down maxResults-1 times should select the first one-off"); - repeat(maxResults - 1, () => EventUtils.synthesizeKey("VK_DOWN", {})); + repeat(maxResults - 1, () => EventUtils.synthesizeKey("KEY_ArrowDown")); is_selected_one_off(0); info("Key Down numButtons-1 should select the last one-off"); let numButtons = gURLBar.popup.oneOffSearchButtons.getSelectableButtons(true).length; - repeat(numButtons - 1, () => EventUtils.synthesizeKey("VK_DOWN", {})); + repeat(numButtons - 1, () => EventUtils.synthesizeKey("KEY_ArrowDown")); is_selected_one_off(numButtons - 1); info("Key Down twice more should select the second result"); - repeat(2, () => EventUtils.synthesizeKey("VK_DOWN", {})); + repeat(2, () => EventUtils.synthesizeKey("KEY_ArrowDown")); is_selected(1); info("Key Down maxResults + numButtons times should wrap around"); repeat(maxResults + numButtons, - () => EventUtils.synthesizeKey("VK_DOWN", {})); + () => EventUtils.synthesizeKey("KEY_ArrowDown")); is_selected(1); info("Key Up maxResults + numButtons times should wrap around the other way"); - repeat(maxResults + numButtons, () => EventUtils.synthesizeKey("VK_UP", {})); + repeat(maxResults + numButtons, () => EventUtils.synthesizeKey("KEY_ArrowUp")); is_selected(1); info("Page Up will go up the list, but not wrap"); - EventUtils.synthesizeKey("VK_PAGE_UP", {}); + EventUtils.synthesizeKey("KEY_PageUp"); is_selected(0); info("Page Up again will wrap around to the end of the list"); - EventUtils.synthesizeKey("VK_PAGE_UP", {}); + EventUtils.synthesizeKey("KEY_PageUp"); is_selected(maxResults - 1); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promisePopupHidden(gURLBar.popup); });
--- a/browser/base/content/test/urlbar/browser_autocomplete_cursor.js +++ b/browser/base/content/test/urlbar/browser_autocomplete_cursor.js @@ -5,16 +5,16 @@ add_task(async function() { let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:mozilla"); await promiseAutocompleteResultPopup("www.mozilla.org"); gURLBar.selectTextRange(4, 4); is(gURLBar.popup.state, "open", "Popup should be open"); is(gURLBar.popup.richlistbox.selectedIndex, 0, "Should have selected something"); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); await promisePopupHidden(gURLBar.popup); is(gURLBar.selectionStart, 5, "Should have moved the cursor"); is(gURLBar.selectionEnd, 5, "And not selected anything"); await BrowserTestUtils.removeTab(tab); });
--- a/browser/base/content/test/urlbar/browser_autocomplete_edit_completed.js +++ b/browser/base/content/test/urlbar/browser_autocomplete_edit_completed.js @@ -15,33 +15,33 @@ add_task(async function() { await promiseAutocompleteResultPopup("http://example.com"); await waitForAutocompleteResultAt(1); let popup = gURLBar.popup; let list = popup.richlistbox; let initialIndex = list.selectedIndex; info("Key Down to select the next item."); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); let nextIndex = initialIndex + 1; let nextValue = gURLBar.controller.getFinalCompleteValueAt(nextIndex); is(list.selectedIndex, nextIndex, "The next item is selected."); is(gURLBar.value, nextValue, "The selected URL is completed."); info("Press backspace"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); await promiseSearchComplete(); let editedValue = gURLBar.textValue; is(list.selectedIndex, initialIndex, "The initial index is selected again."); isnot(editedValue, nextValue, "The URL has changed."); let docLoad = waitForDocLoadAndStopIt("http://" + editedValue); info("Press return to load edited URL."); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await Promise.all([ promisePopupHidden(gURLBar.popup), docLoad, ]); });
--- a/browser/base/content/test/urlbar/browser_autocomplete_enter_race.js +++ b/browser/base/content/test/urlbar/browser_autocomplete_enter_race.js @@ -15,47 +15,47 @@ add_task(async function setup() { url: "http://example.com/?q=%s" }); // Needs at least one success. ok(true, "Setup complete"); }); add_task(async function test_keyword() { await promiseAutocompleteResultPopup("keyword bear"); gURLBar.focus(); - EventUtils.synthesizeKey("d", {}); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.sendString("d"); + EventUtils.synthesizeKey("KEY_Enter"); info("wait for the page to load"); await BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, false, "http://example.com/?q=beard"); }); add_task(async function test_sametext() { await promiseAutocompleteResultPopup("example.com", window, true); // Simulate re-entering the same text searched the last time. This may happen // through a copy paste, but clipboard handling is not much reliable, so just // fire an input event. info("synthesize input event"); let event = document.createEvent("Events"); event.initEvent("input", true, true); gURLBar.dispatchEvent(event); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); info("wait for the page to load"); await BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, false, "http://example.com/"); }); add_task(async function test_after_empty_search() { await promiseAutocompleteResultPopup(""); gURLBar.focus(); // Add www. to avoid a switch-to-tab. gURLBar.value = "www.e"; - EventUtils.synthesizeKey("x", {}); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("x"); + EventUtils.synthesizeKey("KEY_Enter"); info("wait for the page to load"); await BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, false, "http://www.example.com/"); }); add_task(async function test_disabled_ac() { // Disable autocomplete. @@ -82,18 +82,18 @@ add_task(async function test_disabled_ac if (mozSearchEngine) { Services.search.removeEngine(mozSearchEngine); } } registerCleanupFunction(cleanup); gURLBar.focus(); gURLBar.value = "e"; - EventUtils.synthesizeKey("x", {}); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.sendString("x"); + EventUtils.synthesizeKey("KEY_Enter"); info("wait for the page to load"); await BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, false, "http://example.com/?q=ex"); await cleanup(); }); add_task(async function test_delay() { @@ -110,15 +110,15 @@ add_task(async function test_delay() { let start = Date.now(); await promiseAutocompleteResultPopup(""); Assert.ok((Date.now() - start) < TIMEOUT); start = Date.now(); gURLBar.closePopup(); gURLBar.focus(); gURLBar.value = "e"; - EventUtils.synthesizeKey("x", {}); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.sendString("x"); + EventUtils.synthesizeKey("KEY_Enter"); info("wait for the page to load"); await BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, false, "http://example.com/"); Assert.ok((Date.now() - start) < TIMEOUT); });
--- a/browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js +++ b/browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js @@ -26,36 +26,36 @@ add_task(async function test_switchtab_o gURLBar.onSearchComplete = function() { ok(gURLBar.popupOpen, "The autocomplete popup is correctly open"); onSearchComplete.apply(gURLBar); deferred.resolve(); }; gURLBar.focus(); gURLBar.value = "dummy_pag"; - EventUtils.synthesizeKey("e", {}); + EventUtils.sendString("e"); await deferred.promise; info("Select second autocomplete popup entry"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(/moz-action:switchtab/.test(gURLBar.value), "switch to tab entry found"); info("Override switch-to-tab"); deferred = PromiseUtils.defer(); // In case of failure this would switch tab. let onTabSelect = event => { deferred.reject(new Error("Should have overridden switch to tab")); }; gBrowser.tabContainer.addEventListener("TabSelect", onTabSelect); registerCleanupFunction(() => { gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelect); }); // Otherwise it would load the page. BrowserTestUtils.browserLoaded(secondTab.linkedBrowser).then(deferred.resolve); - EventUtils.synthesizeKey("VK_SHIFT", { type: "keydown" }); - EventUtils.synthesizeKey("VK_RETURN", { }); + EventUtils.synthesizeKey("KEY_Shift", {type: "keydown"}); + EventUtils.synthesizeKey("KEY_Enter"); info(`gURLBar.value = ${gURLBar.value}`); - EventUtils.synthesizeKey("VK_SHIFT", { type: "keyup" }); + EventUtils.synthesizeKey("KEY_Shift", {type: "keyup"}); await deferred.promise; await PlacesUtils.history.clear(); });
--- a/browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js +++ b/browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js @@ -15,23 +15,23 @@ add_task(async function test_switchtab_o gBrowser.removeTab(tab); gBrowser.removeTab(secondTab); } catch (ex) { /* tabs may have already been closed in case of failure */ } return PlacesUtils.history.clear(); }); gURLBar.focus(); gURLBar.value = "dummy_pag"; - EventUtils.synthesizeKey("e", {}); + EventUtils.sendString("e"); await promiseSearchComplete(); info("Select second autocomplete popup entry"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(/moz-action:switchtab/.test(gURLBar.value), "switch to tab entry found"); info("Shift+left on switch-to-tab entry"); - EventUtils.synthesizeKey("VK_SHIFT", { type: "keydown" }); - EventUtils.synthesizeKey("VK_LEFT", { shiftKey: true }); - EventUtils.synthesizeKey("VK_SHIFT", { type: "keyup" }); + EventUtils.synthesizeKey("KEY_Shift", {type: "keydown"}); + EventUtils.synthesizeKey("KEY_ArrowLeft", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_Shift", {type: "keyup"}); ok(!/moz-action:switchtab/.test(gURLBar.inputField.value), "switch to tab should be hidden"); });
--- a/browser/base/content/test/urlbar/browser_bug1070778.js +++ b/browser/base/content/test/urlbar/browser_bug1070778.js @@ -29,27 +29,27 @@ add_task(async function() { let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:mozilla"); await promiseAutocompleteResultPopup("keyword a"); await waitForAutocompleteResultAt(1); // First item should already be selected is_selected(0); // Select next one (important!) - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is_selected(1); // Re-select keyword item - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is_selected(0); - EventUtils.synthesizeKey("b", {}); + EventUtils.sendString("b"); await promiseSearchComplete(); is(gURLBar.textValue, "keyword ab", "urlbar should have expected input"); let result = await waitForAutocompleteResultAt(0); isnot(result, null, "Should have first item"); let uri = NetUtil.newURI(result.getAttribute("url")); is(uri.spec, PlacesUtils.mozActionURI("keyword", {url: "http://example.com/?q=ab", input: "keyword ab"}), "Expect correct url"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promisePopupHidden(gURLBar.popup); gBrowser.removeTab(tab); });
--- a/browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js +++ b/browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js @@ -5,24 +5,24 @@ add_task(async function test_switchtab_d info("Opening and selecting second tab"); gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); info("Wait for autocomplete"); await promiseAutocompleteResultPopup("dummy_page"); info("Select autocomplete popup entry"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(gURLBar.value.startsWith("moz-action:switchtab"), "switch to tab entry found"); info("switch-to-tab"); await new Promise((resolve, reject) => { // In case of success it should switch tab. gBrowser.tabContainer.addEventListener("TabSelect", function() { is(gBrowser.selectedTab, tab, "Should have switched to the right tab"); resolve(); }, {once: true}); - EventUtils.synthesizeKey("VK_RETURN", { }); + EventUtils.synthesizeKey("KEY_Enter"); }); gBrowser.removeCurrentTab(); await PlacesUtils.history.clear(); });
--- a/browser/base/content/test/urlbar/browser_bug1225194-remotetab.js +++ b/browser/base/content/test/urlbar/browser_bug1225194-remotetab.js @@ -3,14 +3,14 @@ add_task(async function test_remotetab_o await BrowserTestUtils.withNewTab({url: "about:robots", gBrowser}, async function() { // Set the urlbar to include the moz-action gURLBar.value = "moz-action:remotetab," + JSON.stringify({ url }); // Focus the urlbar so we can press enter gURLBar.focus(); // The URL is going to open in the current tab as it is currently about:blank let promiseTabLoaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await promiseTabLoaded; Assert.equal(gBrowser.selectedTab.linkedBrowser.currentURI.spec, url, "correct URL loaded"); }); });
--- a/browser/base/content/test/urlbar/browser_bug304198.js +++ b/browser/base/content/test/urlbar/browser_bug304198.js @@ -46,17 +46,17 @@ add_task(async function() { gBrowser.selectedBrowser.focus(); gURLBar.addEventListener("input", function() { resolve(); }, {once: true}); gURLBar.focus(); if (gURLBar.selectionStart == gURLBar.selectionEnd) { gURLBar.selectionStart = gURLBar.selectionEnd = gURLBar.textValue.length; } - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); }); } async function prepareDeletedURLTab() { await BrowserTestUtils.switchTab(gBrowser, deletedURLTab); is(gURLBar.textValue, testURL, "gURLBar.textValue should be testURL after initial switch to deletedURLTab"); // simulate the user removing the whole url from the location bar
--- a/browser/base/content/test/urlbar/browser_canonizeURL.js +++ b/browser/base/content/test/urlbar/browser_canonizeURL.js @@ -27,16 +27,16 @@ add_task(async function() { for (let [inputValue, expectedURL, options] of testcases) { let promiseLoad = waitForDocLoadAndStopIt(expectedURL); gURLBar.focus(); if (Object.keys(options).length > 0) { gURLBar.selectionStart = gURLBar.selectionEnd = gURLBar.inputField.value.length; gURLBar.inputField.value = inputValue.slice(0, -1); - EventUtils.synthesizeKey(inputValue.slice(-1), {}); + EventUtils.sendString(inputValue.slice(-1)); } else { gURLBar.textValue = inputValue; } - EventUtils.synthesizeKey("VK_RETURN", options); + EventUtils.synthesizeKey("KEY_Enter", options); await promiseLoad; } });
--- a/browser/base/content/test/urlbar/browser_locationBarCommand.js +++ b/browser/base/content/test/urlbar/browser_locationBarCommand.js @@ -154,27 +154,25 @@ add_task(async function load_in_new_tab_ gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab(); } }); function triggerCommand(shouldClick, event) { gURLBar.focus(); gURLBar.value = ""; - for (let c of TEST_VALUE) { - EventUtils.synthesizeKey(c, {}); - } + EventUtils.sendString(TEST_VALUE); if (shouldClick) { ok(gURLBar.hasAttribute("usertyping"), "usertyping attribute must be set for the go button to be visible"); EventUtils.synthesizeMouseAtCenter(gURLBar.goButton, event); } else { - EventUtils.synthesizeKey("VK_RETURN", event); + EventUtils.synthesizeKey("KEY_Enter", event); } } function promiseLoadStarted() { return new Promise(resolve => { gBrowser.addTabsProgressListener({ onStateChange(browser, webProgress, req, flags, status) { if (flags & Ci.nsIWebProgressListener.STATE_START) {
--- a/browser/base/content/test/urlbar/browser_locationBarExternalLoad.js +++ b/browser/base/content/test/urlbar/browser_locationBarExternalLoad.js @@ -8,26 +8,23 @@ add_task(async function() { const url = "data:text/html,<body>hi"; await testURL(url, urlEnter); await testURL(url, urlClick); }); function urlEnter(url) { gURLBar.value = url; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } function urlClick(url) { gURLBar.focus(); gURLBar.value = ""; - for (let c of url) { - EventUtils.synthesizeKey(c, {}); - } - + EventUtils.sendString(url); EventUtils.synthesizeMouseAtCenter(gURLBar.goButton, {}); } function promiseNewTabSwitched() { return new Promise(resolve => { gBrowser.addEventListener("TabSwitchDone", function() { executeSoon(resolve); }, {once: true});
--- a/browser/base/content/test/urlbar/browser_urlbarAutoFillTrimURLs.js +++ b/browser/base/content/test/urlbar/browser_urlbarAutoFillTrimURLs.js @@ -22,17 +22,17 @@ add_task(async function setup() { uri: "https://www.secureautofillurl.com/whatever", transition: Ci.nsINavHistoryService.TRANSITION_TYPED, }]); }); async function promiseSearch(searchtext) { gURLBar.focus(); gURLBar.inputField.value = searchtext.substr(0, searchtext.length - 1); - EventUtils.synthesizeKey(searchtext.substr(-1, 1), {}); + EventUtils.sendString(searchtext.substr(-1, 1)); await promiseSearchComplete(); } async function promiseTestResult(test) { info("Searching for '${test.search}'"); await promiseSearch(test.search); @@ -106,11 +106,11 @@ add_task(async function autofill_tests() }); add_task(async function autofill_complete_domain() { await promiseSearch("http://www.autofilltrimurl.com"); is(gURLBar.inputField.value, "http://www.autofilltrimurl.com/", "Autofilled value is as expected"); // Now ensure selecting from the popup correctly trims. is(gURLBar.controller.matchCount, 2, "Found the expected number of matches"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(gURLBar.inputField.value, "www.autofilltrimurl.com/whatever", "trim was applied correctly"); });
--- a/browser/base/content/test/urlbar/browser_urlbarDelete.js +++ b/browser/base/content/test/urlbar/browser_urlbarDelete.js @@ -8,24 +8,24 @@ add_task(async function() { }); await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, testDelete); }); function sendHome() { // unclear why VK_HOME doesn't work on Mac, but it doesn't... if (Services.appinfo.OS == "Darwin") { - EventUtils.synthesizeKey("VK_LEFT", { altKey: true }); + EventUtils.synthesizeKey("KEY_ArrowLeft", {altKey: true}); } else { - EventUtils.synthesizeKey("VK_HOME", {}); + EventUtils.synthesizeKey("KEY_Home"); } } function sendDelete() { - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("KEY_Delete"); } async function testDelete() { await promiseAutocompleteResultPopup("bug1105244"); // move to the start. sendHome(); // delete the first few chars - each delete should operate on the input field.
--- a/browser/base/content/test/urlbar/browser_urlbarEnter.js +++ b/browser/base/content/test/urlbar/browser_urlbarEnter.js @@ -6,17 +6,17 @@ const TEST_VALUE = "example.com/\xF7?\xF7"; const START_VALUE = "example.com/%C3%B7?%C3%B7"; add_task(async function() { info("Simple return keypress"); let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, START_VALUE); gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); // Check url bar and selected tab. is(gURLBar.textValue, TEST_VALUE, "Urlbar should preserve the value on return keypress"); is(gBrowser.selectedTab, tab, "New URL was loaded in the current tab"); // Cleanup. await BrowserTestUtils.removeTab(gBrowser.selectedTab); @@ -25,17 +25,17 @@ add_task(async function() { add_task(async function() { info("Alt+Return keypress"); // due to bug 691608, we must wait for the load event, else isTabEmpty() will // return true on e10s for this tab, so it will be reused even with altKey. let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, START_VALUE); let tabOpenPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen"); gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {altKey: true}); + EventUtils.synthesizeKey("KEY_Enter", {altKey: true}); // wait for the new tab to appear. await tabOpenPromise; // Check url bar and selected tab. is(gURLBar.textValue, TEST_VALUE, "Urlbar should preserve the value on return keypress"); isnot(gBrowser.selectedTab, tab, "New URL was loaded in a new tab");
--- a/browser/base/content/test/urlbar/browser_urlbarEnterAfterMouseOver.js +++ b/browser/base/content/test/urlbar/browser_urlbarEnterAfterMouseOver.js @@ -2,17 +2,17 @@ function repeat(limit, func) { for (let i = 0; i < limit; i++) { func(i); } } async function promiseAutoComplete(inputText) { gURLBar.focus(); gURLBar.value = inputText.slice(0, -1); - EventUtils.synthesizeKey(inputText.slice(-1), {}); + EventUtils.sendString(inputText.slice(-1)); await promiseSearchComplete(); } function is_selected(index) { is(gURLBar.popup.richlistbox.selectedIndex, index, `Item ${index + 1} should be selected`); } let gMaxResults; @@ -40,30 +40,30 @@ add_task(async function() { let popup = gURLBar.popup; let results = popup.richlistbox.children; is(results.length, gMaxResults, "Should get gMaxResults=" + gMaxResults + " results"); let initiallySelected = gURLBar.popup.richlistbox.selectedIndex; info("Key Down to select the next item"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is_selected(initiallySelected + 1); let expectedURL = gURLBar.controller.getFinalCompleteValueAt(initiallySelected + 1); is(gURLBar.value, gURLBar.controller.getValueAt(initiallySelected + 1), "Value in the URL bar should be updated by keyboard selection"); // Verify that what we're about to do changes the selectedIndex: isnot(initiallySelected + 1, 3, "Shouldn't be changing the selectedIndex to the same index we keyboard-selected."); // Would love to use a synthetic mousemove event here, but that doesn't seem to do anything. // EventUtils.synthesizeMouseAtCenter(results[3], {type: "mousemove"}); gURLBar.popup.richlistbox.selectedIndex = 3; is_selected(3); let autocompletePopupHidden = promisePopupHidden(gURLBar.popup); let openedExpectedPage = waitForDocLoadAndStopIt(expectedURL); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await Promise.all([autocompletePopupHidden, openedExpectedPage]); gBrowser.removeCurrentTab(); });
--- a/browser/base/content/test/urlbar/browser_urlbarOneOffs.js +++ b/browser/base/content/test/urlbar/browser_urlbarOneOffs.js @@ -29,77 +29,77 @@ add_task(async function init() { } await PlacesTestUtils.addVisits(visits); }); // Keys up and down through the history panel, i.e., the panel that's shown when // there's no text in the textbox. add_task(async function history() { gURLBar.focus(); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); await promisePopupShown(gURLBar.popup); await waitForAutocompleteResultAt(gMaxResults - 1); assertState(-1, -1, ""); // Key down through each result. for (let i = 0; i < gMaxResults; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(i, -1, "example.com/browser_urlbarOneOffs.js/?" + (gMaxResults - i - 1)); } // Key down through each one-off. let numButtons = gURLBar.popup.oneOffSearchButtons.getSelectableButtons(true).length; for (let i = 0; i < numButtons; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(-1, i, ""); } // Key down once more. Nothing should be selected. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(-1, -1, ""); // Once more. The first result should be selected. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(0, -1, "example.com/browser_urlbarOneOffs.js/?" + (gMaxResults - 1)); // Now key up. Nothing should be selected again. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(-1, -1, ""); // Key up through each one-off. for (let i = numButtons - 1; i >= 0; i--) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(-1, i, ""); } // Key right through each one-off. for (let i = 1; i < numButtons; i++) { - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); assertState(-1, i, ""); } // Key left through each one-off. for (let i = numButtons - 2; i >= 0; i--) { - EventUtils.synthesizeKey("VK_LEFT", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); assertState(-1, i, ""); } // Key up through each result. for (let i = gMaxResults - 1; i >= 0; i--) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(i, -1, "example.com/browser_urlbarOneOffs.js/?" + (gMaxResults - i - 1)); } // Key up once more. Nothing should be selected. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(-1, -1, ""); await hidePopup(); }); // Keys up and down through the non-history panel, i.e., the panel that's shown // when you type something in the textbox. add_task(async function() { @@ -108,52 +108,52 @@ add_task(async function() { let typedValue = "browser_urlbarOneOffs"; await promiseAutocompleteResultPopup(typedValue, window, true); await waitForAutocompleteResultAt(gMaxResults - 1); assertState(0, -1, typedValue); // Key down through each result. The first result is already selected, which // is why gMaxResults - 1 is the correct number of times to do this. for (let i = 0; i < gMaxResults - 1; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); // i starts at zero so that the textValue passed to assertState is correct. // But that means that i + 1 is the expected selected index, since initially // (when this loop starts) the first result is selected. assertState(i + 1, -1, "example.com/browser_urlbarOneOffs.js/?" + (gMaxResults - i - 1)); } // Key down through each one-off. let numButtons = gURLBar.popup.oneOffSearchButtons.getSelectableButtons(true).length; for (let i = 0; i < numButtons; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(-1, i, typedValue); } // Key down once more. The selection should wrap around to the first result. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(0, -1, typedValue); // Now key up. The selection should wrap back around to the one-offs. Key // up through all the one-offs. for (let i = numButtons - 1; i >= 0; i--) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(-1, i, typedValue); } // Key up through each non-heuristic result. for (let i = gMaxResults - 2; i >= 0; i--) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(i + 1, -1, "example.com/browser_urlbarOneOffs.js/?" + (gMaxResults - i - 1)); } // Key up once more. The heuristic result should be selected. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(0, -1, typedValue); await hidePopup(); }); // Checks that "Search with Current Search Engine" items are updated to "Search // with One-Off Engine" when a one-off is selected. add_task(async function searchWith() { @@ -164,17 +164,17 @@ add_task(async function searchWith() { let item = gURLBar.popup.richlistbox.firstChild; Assert.equal(item._actionText.textContent, "Search with " + Services.search.currentEngine.name, "Sanity check: first result's action text"); // Alt+Down to the first one-off. Now the first result and the first one-off // should both be selected. - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); + EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }); assertState(0, 0, typedValue); let engineName = gURLBar.popup.oneOffSearchButtons.selectedButton.engine.name; Assert.notEqual(engineName, Services.search.currentEngine.name, "Sanity check: First one-off engine should not be " + "the current engine"); Assert.equal(item._actionText.textContent, "Search with " + engineName, @@ -211,23 +211,23 @@ add_task(async function oneOffReturn() { // We are explicitly using something that looks like a url, to make the test // stricter. Even if it looks like a url, we should search. let typedValue = "foo.bar"; await promiseAutocompleteResultPopup(typedValue, window, true); await waitForAutocompleteResultAt(1); assertState(0, -1, typedValue); // Alt+Down to select the first one-off. - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); + EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }); assertState(0, 0, typedValue); let resultsPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, "http://mochi.test:8888/?terms=foo.bar"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await resultsPromise; gBrowser.removeTab(gBrowser.selectedTab); }); add_task(async function collapsedOneOffs() { // Disable all the engines but the current one, check the oneoffs are // collapsed and that moving up selects the last match. @@ -238,27 +238,27 @@ add_task(async function collapsedOneOffs ]}); let typedValue = "foo"; await promiseAutocompleteResultPopup(typedValue, window, true); await waitForAutocompleteResultAt(0); assertState(0, -1); Assert.ok(gURLBar.popup.oneOffSearchButtons.buttons.collapsed, "The one-off buttons should be collapsed"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(1, -1); await hidePopup(); }); function assertState(result, oneOff, textValue = undefined) { Assert.equal(gURLBar.popup.selectedIndex, result, "Expected result should be selected"); Assert.equal(gURLBar.popup.oneOffSearchButtons.selectedButtonIndex, oneOff, "Expected one-off should be selected"); if (textValue !== undefined) { Assert.equal(gURLBar.textValue, textValue, "Expected textValue"); } } async function hidePopup() { - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promisePopupHidden(gURLBar.popup); }
--- a/browser/base/content/test/urlbar/browser_urlbarOneOffs_searchSuggestions.js +++ b/browser/base/content/test/urlbar/browser_urlbarOneOffs_searchSuggestions.js @@ -26,52 +26,52 @@ add_task(async function oneOffReturnAfte let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser); let typedValue = "foo"; await promiseAutocompleteResultPopup(typedValue, window, true); await promiseSuggestionsPresent(); assertState(0, -1, typedValue); // Down to select the first search suggestion. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(1, -1, "foofoo"); // Down to select the next search suggestion. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(2, -1, "foobar"); // Alt+Down to select the first one-off. - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); assertState(2, 0, "foobar"); let resultsPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, `http://mochi.test:8888/?terms=foobar`); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await resultsPromise; await PlacesUtils.history.clear(); await BrowserTestUtils.removeTab(tab); }); // Clicks a one-off engine after selecting a search suggestion. add_task(async function oneOffClickAfterSuggestion() { let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser); let typedValue = "foo"; await promiseAutocompleteResultPopup(typedValue, window, true); await promiseSuggestionsPresent(); assertState(0, -1, typedValue); // Down to select the first search suggestion. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(1, -1, "foofoo"); // Down to select the next search suggestion. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(2, -1, "foobar"); let oneOffs = gURLBar.popup.oneOffSearchButtons.getSelectableButtons(true); let resultsPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, `http://mochi.test:8888/?terms=foobar`); EventUtils.synthesizeMouseAtCenter(oneOffs[0], {}); await resultsPromise; @@ -82,21 +82,21 @@ add_task(async function oneOffClickAfter add_task(async function overridden_engine_not_reused() { info("An overridden search suggestion item should not be reused by a search with another engine"); let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser); let typedValue = "foo"; await promiseAutocompleteResultPopup(typedValue, window, true); await promiseSuggestionsPresent(); // Down to select the first search suggestion. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(1, -1, "foofoo"); // ALT+Down to select the second search engine. - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); assertState(1, 1, "foofoo"); let label = gURLBar.popup.richlistbox.children[gURLBar.popup.richlistbox.selectedIndex].label; // Run again the query, check the label has been replaced. await promiseAutocompleteResultPopup(typedValue, window, true); await promiseSuggestionsPresent(); assertState(0, -1, "foo"); let newLabel = gURLBar.popup.richlistbox.children[1].label; @@ -111,11 +111,11 @@ function assertState(result, oneOff, tex Assert.equal(gURLBar.popup.oneOffSearchButtons.selectedButtonIndex, oneOff, "Expected one-off should be selected"); if (textValue !== undefined) { Assert.equal(gURLBar.textValue, textValue, "Expected textValue"); } } async function hidePopup() { - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promisePopupHidden(gURLBar.popup); }
--- a/browser/base/content/test/urlbar/browser_urlbarRevert.js +++ b/browser/base/content/test/urlbar/browser_urlbarRevert.js @@ -23,15 +23,15 @@ function checkURLBarRevert() { gBrowser.userTypedValue = "foobar"; gBrowser.selectedTab = gBrowser.tabs[0]; gBrowser.selectedTab = tab; is(gURLBar.value, "foobar", "location bar displays typed value"); gURLBar.focus(); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); is(gURLBar.value, originalValue, "ESC reverted the location bar value"); gBrowser.removeTab(tab); finish(); }
--- a/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions.js +++ b/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions.js @@ -51,19 +51,19 @@ async function testPressEnterOnSuggestio if (!expectedUrl) { expectedUrl = Services.search.currentEngine.getSubmission(suggestion).uri.spec; } let promiseLoad = waitForDocLoadAndStopIt(expectedUrl); for (let i = 0; i < idx; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } - EventUtils.synthesizeKey("VK_RETURN", keyModifiers); + EventUtils.synthesizeKey("KEY_Enter", keyModifiers); await promiseLoad; await BrowserTestUtils.removeTab(tab); } add_task(async function plainEnterOnSuggestion() { await testPressEnterOnSuggestion(); }); @@ -75,23 +75,23 @@ add_task(async function ctrlEnterOnSugge { ctrlKey: true }); }); add_task(async function copySuggestionText() { gURLBar.focus(); await promiseAutocompleteResultPopup("foo"); let [idx, suggestion] = await promiseFirstSuggestion(); for (let i = 0; i < idx; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } gURLBar.select(); await new Promise((resolve, reject) => waitForClipboard(suggestion, function() { goDoCommand("cmd_copy"); }, resolve, reject)); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promisePopupHidden(gURLBar.popup); }); function getFirstSuggestion() { let controller = gURLBar.popup.input.controller; let matchCount = controller.matchCount; for (let i = 0; i < matchCount; i++) { let url = controller.getValueAt(i);
--- a/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions_opt-out.js +++ b/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions_opt-out.js @@ -42,19 +42,17 @@ add_task(async function focus() { focusAndSelectUrlBar(true); await popupPromise; Assert.ok(gURLBar.popup.popupOpen, "popup should be open"); assertVisible(true); assertFooterVisible(false); Assert.equal(gURLBar.popup.matchCount, 0, "popup should have no results"); // Start searching. - EventUtils.synthesizeKey("r", {}); - EventUtils.synthesizeKey("n", {}); - EventUtils.synthesizeKey("d", {}); + EventUtils.sendString("rnd"); await promiseSearchComplete(); Assert.ok(suggestionsPresent()); assertVisible(true); assertFooterVisible(true); // Check the Change Options link. let changeOptionsLink = document.getElementById("search-suggestions-change-settings"); let prefsPromise = BrowserTestUtils.waitForLocationChange(gBrowser, "about:preferences#search");
--- a/browser/base/content/test/urlbar/browser_urlbar_autoFill_backspaced.js +++ b/browser/base/content/test/urlbar/browser_urlbar_autoFill_backspaced.js @@ -6,17 +6,17 @@ async function test_autocomplete(data) { let {desc, typed, autofilled, modified, keys, action, onAutoFill} = data; info(desc); await promiseAutocompleteResultPopup(typed); is(gURLBar.textValue, autofilled, "autofilled value is as expected"); if (onAutoFill) onAutoFill(); - keys.forEach(key => EventUtils.synthesizeKey(key, {})); + keys.forEach(key => EventUtils.synthesizeKey(key)); is(gURLBar.textValue, modified, "backspaced value is as expected"); await promiseSearchComplete(); ok(gURLBar.popup.richlistbox.children.length > 0, "Should get at least 1 result"); let result = gURLBar.popup.richlistbox.children[0]; let type = result.getAttribute("type"); @@ -41,103 +41,103 @@ add_task(async function() { uri: NetUtil.newURI("http://example.com/"), transition: Ci.nsINavHistoryService.TRANSITION_TYPED }); await test_autocomplete({ desc: "DELETE the autofilled part should search", typed: "exam", autofilled: "example.com/", modified: "exam", - keys: ["VK_DELETE"], + keys: ["KEY_Delete"], action: "searchengine" }); await test_autocomplete({ desc: "DELETE the final slash should visit", typed: "example.com", autofilled: "example.com/", modified: "example.com", - keys: ["VK_DELETE"], + keys: ["KEY_Delete"], action: "visiturl" }); await test_autocomplete({ desc: "BACK_SPACE the autofilled part should search", typed: "exam", autofilled: "example.com/", modified: "exam", - keys: ["VK_BACK_SPACE"], + keys: ["KEY_Backspace"], action: "searchengine" }); await test_autocomplete({ desc: "BACK_SPACE the final slash should visit", typed: "example.com", autofilled: "example.com/", modified: "example.com", - keys: ["VK_BACK_SPACE"], + keys: ["KEY_Backspace"], action: "visiturl" }); await test_autocomplete({ desc: "DELETE the autofilled part, then BACK_SPACE, should search", typed: "exam", autofilled: "example.com/", modified: "exa", - keys: ["VK_DELETE", "VK_BACK_SPACE"], + keys: ["KEY_Delete", "KEY_Backspace"], action: "searchengine" }); await test_autocomplete({ desc: "DELETE the final slash, then BACK_SPACE, should search", typed: "example.com", autofilled: "example.com/", modified: "example.co", - keys: ["VK_DELETE", "VK_BACK_SPACE"], + keys: ["KEY_Delete", "KEY_Backspace"], action: "visiturl" }); await test_autocomplete({ desc: "BACK_SPACE the autofilled part, then BACK_SPACE, should search", typed: "exam", autofilled: "example.com/", modified: "exa", - keys: ["VK_BACK_SPACE", "VK_BACK_SPACE"], + keys: ["KEY_Backspace", "KEY_Backspace"], action: "searchengine" }); await test_autocomplete({ desc: "BACK_SPACE the final slash, then BACK_SPACE, should search", typed: "example.com", autofilled: "example.com/", modified: "example.co", - keys: ["VK_BACK_SPACE", "VK_BACK_SPACE"], + keys: ["KEY_Backspace", "KEY_Backspace"], action: "visiturl" }); await test_autocomplete({ desc: "BACK_SPACE after blur should search", typed: "ex", autofilled: "example.com/", modified: "e", - keys: ["VK_BACK_SPACE"], + keys: ["KEY_Backspace"], action: "searchengine", onAutoFill: () => { gURLBar.blur(); gURLBar.focus(); gURLBar.selectionStart = 1; gURLBar.selectionEnd = 12; } }); await test_autocomplete({ desc: "DELETE after blur should search", typed: "ex", autofilled: "example.com/", modified: "e", - keys: ["VK_DELETE"], + keys: ["KEY_Delete"], action: "searchengine", onAutoFill: () => { gURLBar.blur(); gURLBar.focus(); gURLBar.selectionStart = 1; gURLBar.selectionEnd = 12; } }); await test_autocomplete({ desc: "double BACK_SPACE after blur should search", typed: "ex", autofilled: "example.com/", modified: "e", - keys: ["VK_BACK_SPACE", "VK_BACK_SPACE"], + keys: ["KEY_Backspace", "KEY_Backspace"], action: "searchengine", onAutoFill: () => { gURLBar.blur(); gURLBar.focus(); gURLBar.selectionStart = 2; gURLBar.selectionEnd = 12; } });
--- a/browser/base/content/test/urlbar/browser_urlbar_canonize_on_autofill.js +++ b/browser/base/content/test/urlbar/browser_urlbar_canonize_on_autofill.js @@ -9,17 +9,17 @@ async function test_autocomplete(data) { let {desc, typed, autofilled, modified, waitForUrl, keys} = data; info(desc); await promiseAutocompleteResultPopup(typed); is(gURLBar.textValue, autofilled, "autofilled value is as expected"); let promiseLoad = waitForDocLoadAndStopIt(waitForUrl); - keys.forEach(([key, mods]) => EventUtils.synthesizeKey(key, mods || {})); + keys.forEach(([key, mods]) => EventUtils.synthesizeKey(key, mods)); is(gURLBar.textValue, modified, "value is as expected"); await promiseLoad; gURLBar.blur(); } add_task(async function() { @@ -36,29 +36,29 @@ add_task(async function() { transition: Ci.nsINavHistoryService.TRANSITION_TYPED }); await test_autocomplete({ desc: "CTRL+ENTER on the autofilled part should use autofill", typed: "exam", autofilled: "example.com/", modified: "example.com/", waitForUrl: "http://example.com/", - keys: [["VK_RETURN", {}]] + keys: [["KEY_Enter"]] }); await test_autocomplete({ desc: "CTRL+ENTER on the autofilled part should bypass autofill", typed: "exam", autofilled: "example.com/", modified: "www.exam.com", waitForUrl: "http://www.exam.com/", - keys: [["VK_RETURN", AppConstants.platform === "macosx" ? - { metaKey: true } : - { ctrlKey: true }]] + keys: [["KEY_Enter", AppConstants.platform === "macosx" ? + {metaKey: true} : + {ctrlKey: true}]] }); await test_autocomplete({ desc: "SHIFT+ENTER on the autofilled part should bypass autofill", typed: "exam", autofilled: "example.com/", modified: "www.exam.net", waitForUrl: "http://www.exam.net/", - keys: [["VK_RETURN", { shiftKey: true }]] + keys: [["KEY_Enter", {shiftKey: true}]] }); });
--- a/browser/base/content/test/urlbar/browser_urlbar_locationchange_urlbar_edit_dos.js +++ b/browser/base/content/test/urlbar/browser_urlbar_locationchange_urlbar_edit_dos.js @@ -1,13 +1,13 @@ "use strict"; async function checkURLBarValueStays(browser) { gURLBar.select(); - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); is(gURLBar.value, "a", "URL bar value should match after sending a key"); await new Promise(resolve => { let listener = { onLocationChange(aWebProgress, aRequest, aLocation, aFlags) { ok(aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT, "Should only get a same document location change"); gBrowser.selectedBrowser.removeProgressListener(filter); filter = null;
--- a/browser/base/content/test/urlbar/browser_urlbar_remove_match.js +++ b/browser/base/content/test/urlbar/browser_urlbar_remove_match.js @@ -12,20 +12,20 @@ add_task(async function test_remove_hist let promiseVisitRemoved = PlacesTestUtils.waitForNotification( "onDeleteURI", uri => uri.spec == TEST_URL, "history"); await promiseAutocompleteResultPopup("from_urlbar"); let result = await waitForAutocompleteResultAt(1); Assert.equal(result.getAttribute("ac-value"), TEST_URL, "Found the expected result"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); Assert.equal(gURLBar.popup.richlistbox.selectedIndex, 1); let options = AppConstants.platform == "macosx" ? { shiftKey: true } : {}; - EventUtils.synthesizeKey("VK_DELETE", options); + EventUtils.synthesizeKey("KEY_Delete", options); await promiseVisitRemoved; await BrowserTestUtils.waitForCondition( () => !gURLBar.popup.richlistbox.children.some(c => !c.collapsed && c.getAttribute("ac-value") == TEST_URL), "Waiting for the result to disappear"); gURLBar.popup.hidePopup(); await promisePopupHidden(gURLBar.popup); });
--- a/browser/base/content/test/urlbar/browser_urlbar_searchsettings.js +++ b/browser/base/content/test/urlbar/browser_urlbar_searchsettings.js @@ -9,17 +9,17 @@ add_task(async function() { ok("Skipping test"); return; } await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, async function() { let popupopened = BrowserTestUtils.waitForEvent(gURLBar.popup, "popupshown"); gURLBar.focus(); - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); await popupopened; // Since the current tab is blank the preferences pane will load there let loaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); let popupclosed = BrowserTestUtils.waitForEvent(gURLBar.popup, "popuphidden"); EventUtils.synthesizeMouseAtCenter(button, {}); await loaded; await popupclosed;
--- a/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js +++ b/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js @@ -21,34 +21,34 @@ add_task(async function() { let shownPanelPromise = promiseOverflowShown(window); sendWebSearchKeyCommand(); await shownPanelPromise; await waitForSearchBarFocus(); let hiddenPanelPromise = promiseOverflowHidden(window); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await hiddenPanelPromise; CustomizableUI.reset(); }); // Ctrl+K should give focus to the searchbar when the searchbar is in the menupanel and the panel is already opened. add_task(async function() { CustomizableUI.addWidgetToArea("search-container", CustomizableUI.AREA_FIXED_OVERFLOW_PANEL); await document.getElementById("nav-bar").overflowable.show(); sendWebSearchKeyCommand(); await waitForSearchBarFocus(); let hiddenPanelPromise = promiseOverflowHidden(window); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await hiddenPanelPromise; CustomizableUI.reset(); }); // Ctrl+K should open the overflow panel and focus the search bar if the search bar is overflowed. add_task(async function() { this.originalWindowWidth = window.outerWidth; let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); @@ -66,17 +66,17 @@ add_task(async function() { await shownPanelPromise; let chevron = document.getElementById("nav-bar-overflow-button"); await waitForCondition(() => chevron.open); await waitForSearchBarFocus(); let hiddenPanelPromise = promiseOverflowHidden(window); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await hiddenPanelPromise; Services.prefs.setBoolPref("browser.search.widget.inNavBar", false); navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); window.resizeTo(this.originalWindowWidth, window.outerHeight); await waitForCondition(() => !navbar.hasAttribute("overflowing")); ok(!navbar.hasAttribute("overflowing"), "Should not have an overflowing toolbar."); @@ -93,19 +93,19 @@ add_task(async function() { await waitForSearchBarFocus(); Services.prefs.setBoolPref("browser.search.widget.inNavBar", false); }); function sendWebSearchKeyCommand() { if (Services.appinfo.OS === "Darwin") - EventUtils.synthesizeKey("k", { accelKey: true }); + EventUtils.synthesizeKey("k", {accelKey: true}); else - EventUtils.synthesizeKey("k", { ctrlKey: true }); + EventUtils.synthesizeKey("k", {ctrlKey: true}); } function logActiveElement() { let element = document.activeElement; let str = ""; while (element && element.parentNode) { str = " (" + element.localName + "#" + element.id + "." + [...element.classList].join(".") + ") >" + str; element = element.parentNode;
--- a/browser/components/customizableui/test/browser_940307_panel_click_closure_handling.js +++ b/browser/components/customizableui/test/browser_940307_panel_click_closure_handling.js @@ -56,17 +56,17 @@ add_task(async function searchbar_in_pan let selectAll = contextmenu.querySelector("[cmd='cmd_selectAll']"); let contextMenuHidden = promisePanelElementHidden(window, contextmenu); EventUtils.synthesizeMouseAtCenter(selectAll, {}); await contextMenuHidden; ok(isOverflowOpen(), "Panel should still be open"); let hiddenPanelPromise = promiseOverflowHidden(window); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await hiddenPanelPromise; ok(!isOverflowOpen(), "Panel should no longer be open"); // Allow search bar popup to show again. searchbarPopup.removeEventListener("popupshowing", dontShowPopup); // We focused the search bar earlier - ensure we don't keep doing that. gURLBar.select();
--- a/browser/components/customizableui/test/browser_984455_bookmarks_items_reparenting.js +++ b/browser/components/customizableui/test/browser_984455_bookmarks_items_reparenting.js @@ -98,17 +98,17 @@ function checkSpecialContextMenus() { /** * Closes a focused popup by simulating pressing the Escape key, * and returns a Promise that resolves as soon as the popup is closed. * * @param aPopup the popup node to close. */ function closePopup(aPopup) { let hiddenPromise = popupHidden(aPopup); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); return hiddenPromise; } /** * Helper function that checks that the context menu of the * bookmark toolbar items chevron popup is correctly hooked up * to the controller of a view. */
--- a/browser/components/customizableui/test/browser_panelUINotifications_fullscreen.js +++ b/browser/components/customizableui/test/browser_panelUINotifications_fullscreen.js @@ -14,26 +14,26 @@ add_task(async function testFullscreen() isnot(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is showing."); let notifications = [...PanelUI.notificationPanel.children].filter(n => !n.hidden); is(notifications.length, 1, "PanelUI doorhanger is only displaying one notification."); let doorhanger = notifications[0]; is(doorhanger.id, "appMenu-update-manual-notification", "PanelUI is displaying the update-manual notification."); let popuphiddenPromise = BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popuphidden"); - EventUtils.synthesizeKey("VK_F11", {}); + EventUtils.synthesizeKey("KEY_F11"); await popuphiddenPromise; await new Promise(executeSoon); is(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is closed."); FullScreen.showNavToolbox(); is(PanelUI.menuButton.getAttribute("badge-status"), "update-manual", "Badge is displaying on PanelUI button."); let popupshownPromise = BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popupshown"); - EventUtils.synthesizeKey("VK_F11", {}); + EventUtils.synthesizeKey("KEY_F11"); await popupshownPromise; await new Promise(executeSoon); isnot(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is showing."); isnot(PanelUI.menuButton.getAttribute("badge-status"), "update-manual", "Badge is not displaying on PanelUI button."); let mainActionButton = doc.getAnonymousElementByAttribute(doorhanger, "anonid", "button"); mainActionButton.click(); ok(mainActionCalled, "Main action callback was called");
--- a/browser/components/customizableui/test/browser_panelUINotifications_fullscreen_noAutoHideToolbar.js +++ b/browser/components/customizableui/test/browser_panelUINotifications_fullscreen_noAutoHideToolbar.js @@ -45,17 +45,17 @@ add_task(async function testFullscreen() isnot(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is showing."); let notifications = [...PanelUI.notificationPanel.children].filter(n => !n.hidden); is(notifications.length, 1, "PanelUI doorhanger is only displaying one notification."); let doorhanger = notifications[0]; is(doorhanger.id, "appMenu-update-manual-notification", "PanelUI is displaying the update-manual notification."); let fullscreenPromise = waitForFullscreen(); - EventUtils.synthesizeKey("VK_F11", {}); + EventUtils.synthesizeKey("KEY_F11"); await fullscreenPromise; isnot(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is still showing after entering fullscreen."); let popuphiddenPromise = BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popuphidden"); await ContentTask.spawn(gBrowser.selectedBrowser, {}, async () => { content.document.documentElement.requestFullscreen(); }); await popuphiddenPromise; @@ -73,11 +73,11 @@ add_task(async function testFullscreen() let mainActionButton = document.getAnonymousElementByAttribute(doorhanger, "anonid", "button"); mainActionButton.click(); ok(mainActionCalled, "Main action callback was called"); is(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is closed."); is(PanelUI.menuButton.hasAttribute("badge-status"), false, "Should not have a badge status"); fullscreenPromise = BrowserTestUtils.waitForEvent(window, "fullscreen"); - EventUtils.synthesizeKey("VK_F11", {}); + EventUtils.synthesizeKey("KEY_F11"); await fullscreenPromise; });
--- a/browser/components/customizableui/test/browser_panel_keyboard_navigation.js +++ b/browser/components/customizableui/test/browser_panel_keyboard_navigation.js @@ -12,30 +12,30 @@ add_task(async function testUpDownKeys() PanelUI.show(); await promise; let buttons = PanelView.forNode(PanelUI.mainView).getNavigableElements(); for (let button of buttons) { if (button.disabled) continue; - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); Assert.equal(document.commandDispatcher.focusedElement, button, "The correct button should be focused after navigating downward"); } - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); Assert.equal(document.commandDispatcher.focusedElement, buttons[0], "Pressing upwards should cycle around and select the first button again"); for (let i = buttons.length - 1; i >= 0; --i) { let button = buttons[i]; if (button.disabled) continue; - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); Assert.equal(document.commandDispatcher.focusedElement, button, "The first button should be focused after navigating upward"); } promise = promisePanelHidden(window); PanelUI.hide(); await promise; }); @@ -43,94 +43,94 @@ add_task(async function testUpDownKeys() add_task(async function testEnterKeyBehaviors() { let promise = promisePanelShown(window); PanelUI.show(); await promise; let buttons = PanelView.forNode(PanelUI.mainView).getNavigableElements(); // Navigate to the 'Help' button, which points to a subview. - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); let focusedElement = document.commandDispatcher.focusedElement; Assert.equal(focusedElement, buttons[buttons.length - 1], "The last button should be focused after navigating upward"); promise = BrowserTestUtils.waitForEvent(PanelUI.helpView, "ViewShown"); // Make sure the Help button is in focus. while (!focusedElement || !focusedElement.id || focusedElement.id != kHelpButtonId) { - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); focusedElement = document.commandDispatcher.focusedElement; } - EventUtils.synthesizeKey("KEY_Enter", {}); + EventUtils.synthesizeKey("KEY_Enter"); await promise; let helpButtons = PanelView.forNode(PanelUI.helpView).getNavigableElements(); Assert.ok(helpButtons[0].classList.contains("subviewbutton-back"), "First button in help view should be a back button"); // For posterity, check navigating the subview using up/ down arrow keys as well. for (let i = helpButtons.length - 1; i >= 0; --i) { let button = helpButtons[i]; if (button.disabled) continue; - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); focusedElement = document.commandDispatcher.focusedElement; Assert.equal(focusedElement, button, "The first button should be focused after navigating upward"); } // Make sure the back button is in focus again. while (focusedElement != helpButtons[0]) { - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); focusedElement = document.commandDispatcher.focusedElement; } // The first button is the back button. Hittin Enter should navigate us back. promise = BrowserTestUtils.waitForEvent(PanelUI.mainView, "ViewShown"); - EventUtils.synthesizeKey("KEY_Enter", {}); + EventUtils.synthesizeKey("KEY_Enter"); await promise; // Let's test a 'normal' command button. focusedElement = document.commandDispatcher.focusedElement; const kFindButtonId = "appMenu-find-button"; while (!focusedElement || !focusedElement.id || focusedElement.id != kFindButtonId) { - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); focusedElement = document.commandDispatcher.focusedElement; } Assert.equal(focusedElement.id, kFindButtonId, "Find button should be selected"); promise = promisePanelHidden(window); - EventUtils.synthesizeKey("KEY_Enter", {}); + EventUtils.synthesizeKey("KEY_Enter"); await promise; Assert.ok(!gFindBar.hidden, "Findbar should have opened"); gFindBar.close(); }); add_task(async function testLeftRightKeys() { let promise = promisePanelShown(window); PanelUI.show(); await promise; // Navigate to the 'Help' button, which points to a subview. let focusedElement = document.commandDispatcher.focusedElement; while (!focusedElement || !focusedElement.id || focusedElement.id != kHelpButtonId) { - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); focusedElement = document.commandDispatcher.focusedElement; } Assert.equal(focusedElement.id, kHelpButtonId, "The last button should be focused after navigating upward"); // Hitting ArrowRight on a button that points to a subview should navigate us // there. promise = BrowserTestUtils.waitForEvent(PanelUI.helpView, "ViewShown"); - EventUtils.synthesizeKey("KEY_ArrowRight", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); await promise; // Hitting ArrowLeft should navigate us back. promise = BrowserTestUtils.waitForEvent(PanelUI.mainView, "ViewShown"); - EventUtils.synthesizeKey("KEY_ArrowLeft", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); await promise; focusedElement = document.commandDispatcher.focusedElement; Assert.equal(focusedElement.id, kHelpButtonId, "Help button should be focused again now that we're back in the main view"); promise = promisePanelHidden(window); PanelUI.hide(); @@ -142,22 +142,22 @@ add_task(async function testTabKey() { PanelUI.show(); await promise; let buttons = PanelView.forNode(PanelUI.mainView).getNavigableElements(); for (let button of buttons) { if (button.disabled) continue; - EventUtils.synthesizeKey("KEY_Tab", {}); + EventUtils.synthesizeKey("KEY_Tab"); Assert.equal(document.commandDispatcher.focusedElement, button, "The correct button should be focused after tabbing"); } - EventUtils.synthesizeKey("KEY_Tab", {}); + EventUtils.synthesizeKey("KEY_Tab"); Assert.equal(document.commandDispatcher.focusedElement, buttons[0], "Pressing tab should cycle around and select the first button again"); for (let i = buttons.length - 1; i >= 0; --i) { let button = buttons[i]; if (button.disabled) continue; EventUtils.synthesizeKey("Tab", {shiftKey: true}); @@ -181,19 +181,19 @@ add_task(async function testInterleavedT let buttons = PanelView.forNode(PanelUI.mainView).getNavigableElements(); let tab = false; for (let button of buttons) { if (button.disabled) continue; if (tab) { - EventUtils.synthesizeKey("KEY_Tab", {}); + EventUtils.synthesizeKey("KEY_Tab"); } else { - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } tab = !tab; } Assert.equal(document.commandDispatcher.focusedElement, buttons[buttons.length - 1], "The last button should be focused after a mix of Tab and ArrowDown"); promise = promisePanelHidden(window); @@ -207,17 +207,17 @@ add_task(async function testSpaceDownAft await promise; let buttons = PanelView.forNode(PanelUI.mainView).getNavigableElements(); let button; for (button of buttons) { if (button.disabled) continue; - EventUtils.synthesizeKey("KEY_Tab", {}); + EventUtils.synthesizeKey("KEY_Tab"); if (button.id == kHelpButtonId) { break; } } Assert.equal(document.commandDispatcher.focusedElement, button, "Help button should be focused after tabbing to it.");
--- a/browser/components/extensions/test/browser/browser_ext_omnibox.js +++ b/browser/components/extensions/test/browser/browser_ext_omnibox.js @@ -106,88 +106,82 @@ add_task(async function() { await new Promise(r => window.requestIdleCallback(r, {timeout: 1000})); } } let inputSessionSerial = 0; async function startInputSession(indexToWaitFor) { gURLBar.focus(); gURLBar.value = keyword; - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await expectEvent("on-input-started-fired"); // Always use a different input at every invokation, so that // waitForAutocompleteResultAt can distinguish different cases. let char = ((inputSessionSerial++) % 10).toString(); - EventUtils.synthesizeKey(char, {}); + EventUtils.sendString(char); await expectEvent("on-input-changed-fired", {text: char}); // Wait for the autocomplete search. Note that we cannot wait for the search // to be complete, since the add-on doesn't communicate when it's done, so // just check matches count. await waitForAutocompleteResultAt(indexToWaitFor); return char; } async function testInputEvents() { gURLBar.focus(); // Start an input session by typing in <keyword><space>. - for (let letter of keyword) { - EventUtils.synthesizeKey(letter, {}); - } - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(keyword + " "); await expectEvent("on-input-started-fired"); // Test canceling the input before any changed events fire. - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); await expectEvent("on-input-cancelled-fired"); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await expectEvent("on-input-started-fired"); // Test submitting the input before any changed events fire. - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await expectEvent("on-input-entered-fired"); gURLBar.focus(); // Start an input session by typing in <keyword><space>. - for (let letter of keyword) { - EventUtils.synthesizeKey(letter, {}); - } - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(keyword + " "); await expectEvent("on-input-started-fired"); // We should expect input changed events now that the keyword is active. - EventUtils.synthesizeKey("b", {}); + EventUtils.sendString("b"); await expectEvent("on-input-changed-fired", {text: "b"}); - EventUtils.synthesizeKey("c", {}); + EventUtils.sendString("c"); await expectEvent("on-input-changed-fired", {text: "bc"}); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); await expectEvent("on-input-changed-fired", {text: "b"}); // Even though the input is <keyword><space> We should not expect an // input started event to fire since the keyword is active. - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); await expectEvent("on-input-changed-fired", {text: ""}); // Make the keyword inactive by hitting backspace. - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); await expectEvent("on-input-cancelled-fired"); // Activate the keyword by typing a space. // Expect onInputStarted to fire. - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await expectEvent("on-input-started-fired"); // onInputChanged should fire even if a space is entered. - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await expectEvent("on-input-changed-fired", {text: " "}); // The active session should cancel if the input blurs. gURLBar.blur(); await expectEvent("on-input-cancelled-fired"); } async function testHeuristicResult(expectedText, setDefaultSuggestion) { @@ -217,19 +211,17 @@ add_task(async function() { await promiseClickOnItem(item, {}); await promiseEvent; } async function testDisposition(suggestionIndex, expectedDisposition, expectedText) { await startInputSession(suggestionIndex); // Select the suggestion. - for (let i = 0; i < suggestionIndex; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); - } + EventUtils.synthesizeKey("KEY_ArrowDown", {repeat: suggestionIndex}); let promiseEvent = expectEvent("on-input-entered-fired", { text: expectedText, disposition: expectedDisposition, }); let item = gURLBar.popup.richlistbox.children[suggestionIndex]; if (expectedDisposition == "currentTab") {
--- a/browser/components/places/tests/browser/browser_bookmarklet_windowOpen.js +++ b/browser/components/places/tests/browser/browser_bookmarklet_windowOpen.js @@ -41,17 +41,17 @@ add_task(async function openKeywordBookm PlacesUtils.bookmarks.remove(bookmarkInfo), PlacesUtils.keywords.remove(keywordForBM) ]); }); gURLBar.value = keywordForBM; gURLBar.focus(); let tabCreatedPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); info("Waiting for tab being created"); let {target: tab} = await tabCreatedPromise; info("Got tab"); let browser = tab.linkedBrowser; if (!browser.currentURI || browser.currentURI.spec != TEST_URL) { info("Waiting for browser load"); await BrowserTestUtils.browserLoaded(browser, false, TEST_URL);
--- a/browser/components/places/tests/browser/browser_stayopenmenu.js +++ b/browser/components/places/tests/browser/browser_stayopenmenu.js @@ -17,19 +17,19 @@ async function locateBookmarkAndTestCtrl async function testContextmenu(menuitem) { let doc = menuitem.ownerDocument; let cm = doc.getElementById("placesContext"); let promiseEvent = BrowserTestUtils.waitForEvent(cm, "popupshown"); EventUtils.synthesizeMouseAtCenter(menuitem, {type: "contextmenu", button: 2}); await promiseEvent; let promiseTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, null); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); BrowserTestUtils.waitForEvent(menuitem, "DOMMenuItemActive"); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); BrowserTestUtils.waitForEvent(menuitem, "DOMMenuItemActive"); EventUtils.sendKey("return"); let newTab = await promiseTabOpened; return newTab; } add_task(async function test_setup() { // Ensure BMB is available in UI.
--- a/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js +++ b/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js @@ -32,17 +32,17 @@ async function checkPopupContextMenu() { ok(!newBookmarkItem.hasAttribute("disabled"), "New bookmark item shouldn't be disabled"); let contextMenuHiddenPromise = onPopupEvent(contextMenu, "hidden"); contextMenu.hidePopup(); BMB_menuPopup.removeAttribute("style"); info("Waiting for context menu on bookmarks menu to be hidden."); await contextMenuHiddenPromise; let popupHiddenPromise = onPopupEvent(BMB_menuPopup, "hidden"); // Can't use synthesizeMouseAtCenter because the dropdown panel is in the way - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); info("Waiting for bookmarks menu to be hidden."); await popupHiddenPromise; } function onPopupEvent(popup, evt) { let fullEvent = "popup" + evt; return new Promise(resolve => { let onPopupHandler = (e) => {
--- a/browser/components/places/tests/chrome/test_editBookmarkOverlay_keywords.xul +++ b/browser/components/places/tests/chrome/test_editBookmarkOverlay_keywords.xul @@ -75,18 +75,18 @@ let node = await PlacesUIUtils.promiseNodeLikeFromFetchInfo(bm); gEditItemOverlay.initPanel({ node }); is(document.getElementById("editBMPanel_keywordField").value, "", "The keyword field should be empty"); info("Add a keyword to the bookmark"); let promise = promiseOnItemChanged(); keywordField.focus(); keywordField.value = "kw"; - synthesizeKey(i.toString(), {}); - synthesizeKey("VK_RETURN", {}); + sendString(i.toString()); + synthesizeKey("KEY_Enter"); keywordField.blur(); let {property, value} = await promise; is(property, "keyword", "The keyword should have been changed"); is(value, `kw${i}`, "The new keyword value is correct"); } for (let i = 0; i < 2; ++i) { let entry = await PlacesUtils.keywords.fetch({ url: `http://www.test${i}.me/` });
--- a/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js +++ b/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js @@ -11,52 +11,52 @@ add_task(async function() { await BrowserTestUtils.withNewTab({ gBrowser, url: tabURL }, async function(browser) { // eslint-disable-next-line mozilla/no-cpows-in-tests let doc = browser.contentDocument; let container = doc.getElementById("container"); // Test button let button = doc.getElementById("button"); button.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await checkPageScrolling(container, "button"); // Test checkbox let checkbox = doc.getElementById("checkbox"); checkbox.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); ok(checkbox.checked, "Checkbox is checked"); await checkPageScrolling(container, "checkbox"); // Test listbox let listbox = doc.getElementById("listbox"); let listitem = doc.getElementById("listitem"); listbox.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); ok(listitem.selected, "Listitem is selected"); await checkPageScrolling(container, "listbox"); // Test radio let radiogroup = doc.getElementById("radiogroup"); radiogroup.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await checkPageScrolling(container, "radio"); }); await BrowserTestUtils.withNewTab({ gBrowser, url: "about:preferences#search" }, async function(browser) { // eslint-disable-next-line mozilla/no-cpows-in-tests let doc = browser.contentDocument; let container = doc.getElementsByClassName("main-content")[0]; // Test search let engineList = doc.getElementById("engineList"); engineList.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); is(engineList.view.selection.currentIndex, 0, "Search engineList is selected"); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await checkPageScrolling(container, "search engineList"); }); // Test session restore const CRASH_URL = "about:mozilla"; const CRASH_FAVICON = "chrome://branding/content/icon32.png"; const CRASH_SHENTRY = {url: CRASH_URL}; const CRASH_TAB = {entries: [CRASH_SHENTRY], image: CRASH_FAVICON}; @@ -75,17 +75,17 @@ add_task(async function() { await BrowserTestUtils.browserLoaded(tab.linkedBrowser); let doc = tab.linkedBrowser.contentDocument; // Make body scrollable doc.body.style.height = (doc.body.clientHeight + 100) + "px"; let tabsToggle = doc.getElementById("tabsToggle"); tabsToggle.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await checkPageScrolling(doc.documentElement, "session restore"); gBrowser.removeCurrentTab(); finish(); }); function checkPageScrolling(container, type) { return new Promise(resolve => {
--- a/browser/components/preferences/in-content/tests/browser_cookies_dialog.js +++ b/browser/components/preferences/in-content/tests/browser_cookies_dialog.js @@ -28,19 +28,19 @@ add_task(async function testDeleteCookie Services.cookies.add(URI.host, URI.pathQueryRef, "", "", false, false, true, Date.now()); let tree = doc.getElementById("cookiesList"); Assert.equal(tree.view.rowCount, 1, "Row count should initially be 1"); tree.focus(); tree.view.selection.select(0); if (AppConstants.platform == "macosx") { - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); } else { - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("KEY_Delete"); } await TestUtils.waitForCondition(() => tree.view.rowCount == 0); // eslint-disable-next-line mozilla/no-cpows-in-tests is_element_visible(content.gSubDialog._dialogs[0]._box, "Subdialog is visible after deleting an element");
--- a/browser/components/preferences/in-content/tests/browser_password_management.js +++ b/browser/components/preferences/in-content/tests/browser_password_management.js @@ -54,19 +54,19 @@ add_task(async function test_deletePassw let doc = passwordsDialog.document; let tree = doc.getElementById("signonsTree"); Assert.equal(tree.view.rowCount, 1, "Row count should initially be 1"); tree.focus(); tree.view.selection.select(0); if (AppConstants.platform == "macosx") { - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); } else { - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("KEY_Delete"); } await TestUtils.waitForCondition(() => tree.view.rowCount == 0); // eslint-disable-next-line mozilla/no-cpows-in-tests is_element_visible(content.gSubDialog._dialogs[0]._box, "Subdialog is visible after deleting an element"); });
--- a/browser/components/preferences/in-content/tests/browser_site_login_exceptions.js +++ b/browser/components/preferences/in-content/tests/browser_site_login_exceptions.js @@ -59,19 +59,19 @@ add_task(async function deleteALoginExce let doc = exceptionsDialog.document; let tree = doc.getElementById("permissionsTree"); Assert.equal(tree.view.rowCount, 1, "Row count should initially be 1"); tree.focus(); tree.view.selection.select(0); if (AppConstants.platform == "macosx") { - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); } else { - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("KEY_Delete"); } await TestUtils.waitForCondition(() => tree.view.rowCount == 0); // eslint-disable-next-line mozilla/no-cpows-in-tests is_element_visible(content.gSubDialog._dialogs[0]._box, "Subdialog is visible after deleting an element"); });
--- a/browser/components/search/test/browser_426329.js +++ b/browser/components/search/test/browser_426329.js @@ -130,27 +130,27 @@ add_task(async function testSetup() { }); add_task(async function testSetupEngine() { await promiseSetEngine(); }); add_task(async function testReturn() { await prepareTest(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); is(gBrowser.tabs.length, preTabNo, "Return key did not open new tab"); is(gBrowser.currentURI.spec, expectedURL(searchBar.value), "testReturn opened correct search page"); }); add_task(async function testAltReturn() { await prepareTest(); await BrowserTestUtils.openNewForegroundTab(gBrowser, () => { - EventUtils.synthesizeKey("VK_RETURN", { altKey: true }); + EventUtils.synthesizeKey("KEY_Enter", {altKey: true}); }); is(gBrowser.tabs.length, preTabNo + 1, "Alt+Return key added new tab"); is(gBrowser.currentURI.spec, expectedURL(searchBar.value), "testAltReturn opened correct search page"); }); // Shift key has no effect for now, so skip it add_task(async function testShiftAltReturn() { @@ -232,17 +232,17 @@ add_task(async function testAutocomplete add_task(async function testClearHistory() { // Open the textbox context menu to trigger controller attachment. let textbox = searchBar.textbox; let popupShownPromise = BrowserTestUtils.waitForEvent(textbox, "popupshown"); EventUtils.synthesizeMouseAtCenter(textbox, { type: "contextmenu", button: 2 }); await popupShownPromise; // Close the context menu. - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); let controller = searchBar.textbox.controllers.getControllerForCommand("cmd_clearhistory"); ok(controller.isCommandEnabled("cmd_clearhistory"), "Clear history command enabled"); let historyCleared = promiseObserver("satchel-storage-changed"); controller.doCommand("cmd_clearhistory"); await historyCleared; let count = await countEntries();
--- a/browser/components/search/test/browser_google_behavior.js +++ b/browser/components/search/test/browser_google_behavior.js @@ -133,37 +133,37 @@ async function testSearchEngine(engineDe } }, { name: "keyword search", searchURL: base + engineDetails.codes.keyword, run() { gURLBar.value = "? foo"; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } }, { name: "keyword search with alias", searchURL: base + engineDetails.codes.keyword, run() { gURLBar.value = `${engineDetails.alias} foo`; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } }, { name: "search bar search", searchURL: base + engineDetails.codes.submission, run() { Services.prefs.setBoolPref("browser.search.widget.inNavBar", true); let sb = BrowserSearch.searchBar; sb.focus(); sb.value = "foo"; - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); }, postTest() { BrowserSearch.searchBar.value = ""; Services.prefs.setBoolPref("browser.search.widget.inNavBar", false); } }, { name: "new tab search", @@ -176,17 +176,17 @@ async function testSearchEngine(engineDe await promiseContentSearchReady(browser); }, async run(tab) { await ContentTask.spawn(tab.linkedBrowser, {}, async function(args) { let input = content.document.querySelector("input[id*=search-]"); input.focus(); input.value = "foo"; }); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } } ]; let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser); for (let test of engineTests) { info(`Running: ${test.name}`);
--- a/browser/components/search/test/browser_healthreport.js +++ b/browser/components/search/test/browser_healthreport.js @@ -42,17 +42,17 @@ function test() { Assert.ok(histogramKey in hs, "The histogram must contain the correct key"); Assert.equal(hs[histogramKey].sum, numSearchesBefore + 1, "Performing a search increments the related SEARCH_COUNTS key by 1."); let fooEngine = Services.search.getEngineByName("Foo"); Services.search.removeEngine(fooEngine); } - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); executeSoon(() => executeSoon(afterSearch)); } function observer(subject, topic, data) { switch (data) { case "engine-added": let engine = Services.search.getEngineByName("Foo"); ok(engine, "Engine was added.");
--- a/browser/components/search/test/browser_hiddenOneOffs_diacritics.js +++ b/browser/components/search/test/browser_hiddenOneOffs_diacritics.js @@ -39,17 +39,17 @@ add_task(async function test_hidden() { EventUtils.synthesizeMouseAtCenter(searchIcon, {}); await promise; ok(!getOneOffs().some(x => x.getAttribute("tooltiptext") == diacritic_engine), "Search engines with diacritics are hidden when added to hiddenOneOffs preference."); promise = promiseEvent(searchPopup, "popuphidden"); info("Closing search panel"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; }); add_task(async function test_shown() { Preferences.set("browser.search.hiddenOneOffs", ""); let promise = promiseEvent(searchPopup, "popupshown"); info("Opening search panel");
--- a/browser/components/search/test/browser_oneOffContextMenu.js +++ b/browser/components/search/test/browser_oneOffContextMenu.js @@ -69,17 +69,17 @@ async function doTest() { // Click the Search in New Tab menu item. promise = BrowserTestUtils.waitForNewTab(gBrowser); EventUtils.synthesizeMouseAtCenter(searchInNewTabMenuItem, {}); let tab = await promise; // By default the search will open in the background and the popup will stay open: promise = promiseEvent(searchPopup, "popuphidden"); info("Closing search panel"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; // Check the loaded tab. Assert.equal(tab.linkedBrowser.currentURI.spec, "http://mochi.test:8888/browser/browser/components/search/test/", "Expected search tab should have loaded"); await BrowserTestUtils.removeTab(tab);
--- a/browser/components/search/test/browser_oneOffContextMenu_setDefault.js +++ b/browser/components/search/test/browser_oneOffContextMenu_setDefault.js @@ -145,17 +145,17 @@ async function openPopupAndGetEngineButt // We have to open the popups in differnt ways. if (isSearch) { // Use the search icon to avoid hitting the network. EventUtils.synthesizeMouseAtCenter(searchIcon, {}); } else { // There's no history at this stage, so we need to press a key. urlbar.focus(); - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); } await promise; const contextMenu = document.getAnonymousElementByAttribute( oneOffBinding, "anonid", "search-one-offs-context-menu" ); const oneOffButtons = document.getAnonymousElementByAttribute( oneOffBinding, "anonid", "search-panel-one-offs" @@ -190,14 +190,14 @@ async function openPopupAndGetEngineButt /** * Closes the popup and moves the mouse away from it. * * @param {Button} popup The popup to close. */ async function promiseClosePopup(popup) { // close the panel using the escape key. let promise = promiseEvent(popup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; // Move the cursor out of the panel area to avoid messing with other tests. await EventUtils.synthesizeNativeMouseMove(popup); }
--- a/browser/components/search/test/browser_oneOffHeader.js +++ b/browser/components/search/test/browser_oneOffHeader.js @@ -89,17 +89,17 @@ add_task(async function test_notext() { await synthesizeNativeMouseMove(buttons[0]); is(header.getAttribute("selectedIndex"), 2, "Header has the correct index selected when a search engine has been selected"); is(getHeaderText(), "Search " + buttons[0].engine.name, "Is the header text correct when a search engine is selected and no terms have been entered."); promise = promiseEvent(searchPopup, "popuphidden"); info("Closing search panel"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; }); add_task(async function test_text() { searchbar._textbox.value = "foo"; registerCleanupFunction(() => { searchbar._textbox.value = ""; });
--- a/browser/components/search/test/browser_searchEngine_behaviors.js +++ b/browser/components/search/test/browser_searchEngine_behaviors.js @@ -154,39 +154,39 @@ async function testSearchEngine(engineDe } }, { name: "keyword search", searchURL: base + engineDetails.codes.keyword, run() { gURLBar.value = "? foo"; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } }, { name: "keyword search with alias", searchURL: base + engineDetails.codes.keyword, run() { gURLBar.value = `${engineDetails.alias} foo`; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } }, { name: "search bar search", searchURL: base + engineDetails.codes.submission, run() { let sb = BrowserSearch.searchBar; sb.focus(); sb.value = "foo"; registerCleanupFunction(function() { sb.value = ""; }); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } }, { name: "new tab search", searchURL: base + engineDetails.codes.newTab, async preTest(tab) { let browser = tab.linkedBrowser; await BrowserTestUtils.loadURI(browser, "about:newtab"); @@ -195,17 +195,17 @@ async function testSearchEngine(engineDe await promiseContentSearchReady(browser); }, async run(tab) { await ContentTask.spawn(tab.linkedBrowser, {}, async function(args) { let input = content.document.querySelector("input[id*=search-]"); input.focus(); input.value = "foo"; }); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } } ]; let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser); for (let test of engineTests) { info(`Running: ${test.name}`);
--- a/browser/components/search/test/browser_searchbar_keyboard_navigation.js +++ b/browser/components/search/test/browser_searchbar_keyboard_navigation.js @@ -87,117 +87,117 @@ add_task(async function test_arrows() { // than 4 default engines, but it's safer to check this assumption. let oneOffs = getOneOffs(); ok(oneOffs.length >= 4, "we have at least 4 one-off buttons displayed"); ok(!textbox.selectedButton, "no one-off button should be selected"); // The down arrow should first go through the suggestions. for (let i = 0; i < kValues.length; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(searchPopup.selectedIndex, i, "the suggestion at index " + i + " should be selected"); is(textbox.value, kValues[i], "the textfield value should be " + kValues[i]); } // Pressing down again should remove suggestion selection and change the text // field value back to what the user typed, and select the first one-off. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, kUserValue, "the textfield value should be back to initial value"); // now cycle through the one-off items, the first one is already selected. for (let i = 0; i < oneOffs.length; ++i) { is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); // We should now be back to the initial situation. is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); ok(!textbox.selectedButton, "no one-off button should be selected"); info("now test the up arrow key"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // cycle through the one-off items, the first one is already selected. for (let i = oneOffs.length; i; --i) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, oneOffs[i - 1], "the one-off button #" + i + " should be selected"); } // Another press on up should clear the one-off selection and select the // last suggestion. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); ok(!textbox.selectedButton, "no one-off button should be selected"); for (let i = kValues.length - 1; i >= 0; --i) { is(searchPopup.selectedIndex, i, "the suggestion at index " + i + " should be selected"); is(textbox.value, kValues[i], "the textfield value should be " + kValues[i]); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); } is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, kUserValue, "the textfield value should be back to initial value"); }); add_task(async function test_typing_clears_button_selection() { is(Services.focus.focusedElement, textbox.inputField, "the search bar should be focused"); // from the previous test. ok(!textbox.selectedButton, "no button should be selected"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // Type a character. - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); ok(!textbox.selectedButton, "the settings item should be de-selected"); // Remove the character. - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); }); add_task(async function test_tab() { is(Services.focus.focusedElement, textbox.inputField, "the search bar should be focused"); // from the previous test. let oneOffs = getOneOffs(); ok(!textbox.selectedButton, "no one-off button should be selected"); // Pressing tab should select the first one-off without selecting suggestions. // now cycle through the one-off items, the first one is already selected. for (let i = 0; i < oneOffs.length; ++i) { - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); } is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, kUserValue, "the textfield value should be unmodified"); // One more <tab> selects the settings button. - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // Pressing tab again should close the panel... let promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await promise; // ... and move the focus out of the searchbox. isnot(Services.focus.focusedElement, textbox.inputField, "the search bar no longer be focused"); }); add_task(async function test_shift_tab() { @@ -206,185 +206,185 @@ add_task(async function test_shift_tab() info("Opening search panel"); searchbar.focus(); await promise; let oneOffs = getOneOffs(); ok(!textbox.selectedButton, "no one-off button should be selected"); // Press up once to select the last button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // Press up again to select the last one-off button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); // Pressing shift+tab should cycle through the one-off items. for (let i = oneOffs.length - 1; i >= 0; --i) { is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); if (i) - EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); } is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, kUserValue, "the textfield value should be unmodified"); // Pressing shift+tab again should close the panel... promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); await promise; // ... and move the focus out of the searchbox. isnot(Services.focus.focusedElement, textbox.inputField, "the search bar no longer be focused"); }); add_task(async function test_alt_down() { // First refocus the panel. let promise = promiseEvent(searchPopup, "popupshown"); info("Opening search panel"); searchbar.focus(); await promise; // close the panel using the escape key. promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; // check that alt+down opens the panel... promise = promiseEvent(searchPopup, "popupshown"); - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); await promise; // ... and does nothing else. ok(!textbox.selectedButton, "no one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, kUserValue, "the textfield value should be unmodified"); // Pressing alt+down should select the first one-off without selecting suggestions // and cycle through the one-off items. let oneOffs = getOneOffs(); for (let i = 0; i < oneOffs.length; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); } // One more alt+down keypress and nothing should be selected. - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); ok(!textbox.selectedButton, "no one-off button should be selected"); // another one and the first one-off should be selected. - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); }); add_task(async function test_alt_up() { // close the panel using the escape key. let promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; // check that alt+up opens the panel... promise = promiseEvent(searchPopup, "popupshown"); - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); await promise; // ... and does nothing else. ok(!textbox.selectedButton, "no one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, kUserValue, "the textfield value should be unmodified"); // Pressing alt+up should select the last one-off without selecting suggestions // and cycle up through the one-off items. let oneOffs = getOneOffs(); for (let i = oneOffs.length - 1; i >= 0; --i) { - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); } // One more alt+down keypress and nothing should be selected. - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); ok(!textbox.selectedButton, "no one-off button should be selected"); // another one and the last one-off should be selected. - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); is(textbox.selectedButton, oneOffs[oneOffs.length - 1], "the last one-off button should be selected"); // Cleanup for the next test. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(!textbox.selectedButton, "no one-off should be selected anymore"); }); add_task(async function test_tab_and_arrows() { // Check the initial state is as expected. ok(!textbox.selectedButton, "no one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, kUserValue, "the textfield value should be unmodified"); // After pressing down, the first sugggestion should be selected. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(searchPopup.selectedIndex, 0, "first suggestion should be selected"); is(textbox.value, kValues[0], "the textfield value should have changed"); ok(!textbox.selectedButton, "no one-off button should be selected"); // After pressing tab, the first one-off should be selected, // and no suggestion should be selected. let oneOffs = getOneOffs(); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing down, the second one-off should be selected. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton, oneOffs[1], "the second one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing right, the third one-off should be selected. - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); is(textbox.selectedButton, oneOffs[2], "the third one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing left, the second one-off should be selected again. - EventUtils.synthesizeKey("VK_LEFT", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); is(textbox.selectedButton, oneOffs[1], "the second one-off button should be selected again"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing up, the first one-off should be selected again. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected again"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing up again, the last suggestion should be selected. // the textfield value back to the user-typed value, and still the first one-off // selected. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(searchPopup.selectedIndex, kValues.length - 1, "last suggestion should be selected"); is(textbox.value, kValues[kValues.length - 1], "the textfield value should match the suggestion"); is(textbox.selectedButton, null, "no one-off button should be selected"); // Now pressing down should select the first one-off. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); is(searchPopup.selectedIndex, -1, "there should be no selected suggestion"); // Finally close the panel. let promise = promiseEvent(searchPopup, "popuphidden"); searchPopup.hidePopup(); await promise; @@ -402,44 +402,44 @@ add_task(async function test_open_search let engines = getOpenSearchItems(); is(engines.length, 2, "the opensearch.html page exposes 2 engines"); // Check that there's initially no selection. is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); ok(!textbox.selectedButton, "no button should be selected"); // Pressing up once selects the setting button... - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // ...and then pressing up selects open search engines. for (let i = engines.length; i; --i) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); let selectedButton = textbox.selectedButton; is(selectedButton, engines[i - 1], "the engine #" + i + " should be selected"); ok(selectedButton.classList.contains("addengine-item"), "the button is themed as an engine item"); } // Pressing up again should select the last one-off button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, getOneOffs().pop(), "the last one-off button should be selected"); info("now check that the down key navigates open search items as expected"); for (let i = 0; i < engines.length; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton, engines[i], "the engine #" + (i + 1) + " should be selected"); } // Pressing down on the last engine item selects the settings button. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); promise = promiseEvent(searchPopup, "popuphidden"); searchPopup.hidePopup(); await promise; gBrowser.removeCurrentTab();
--- a/browser/components/search/test/browser_searchbar_openpopup.js +++ b/browser/components/search/test/browser_searchbar_openpopup.js @@ -241,17 +241,17 @@ add_task(async function focus_change_clo isnot(searchPopup.getAttribute("showonlysettings"), "true", "Should show the full popup"); is(Services.focus.focusedElement, textbox.inputField, "Should have focused the search bar"); is(textbox.selectionStart, 0, "Should have selected all of the text"); is(textbox.selectionEnd, 3, "Should have selected all of the text"); promise = promiseEvent(searchPopup, "popuphidden"); let promise2 = promiseEvent(searchbar, "blur"); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); await promise; await promise2; textbox.value = ""; }); // Moving focus away from the search box should close the small popup add_task(async function focus_change_closes_small_popup() { @@ -264,17 +264,17 @@ add_task(async function focus_change_clo }); await promise; is(searchPopup.getAttribute("showonlysettings"), "true", "Should show the small popup"); is(Services.focus.focusedElement, textbox.inputField, "Should have focused the search bar"); promise = promiseEvent(searchPopup, "popuphidden"); let promise2 = promiseEvent(searchbar, "blur"); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); await promise; await promise2; }); // Pressing escape should close the popup. add_task(async function escape_closes_popup() { gURLBar.focus(); textbox.value = "foo"; @@ -284,17 +284,17 @@ add_task(async function escape_closes_po await promise; isnot(searchPopup.getAttribute("showonlysettings"), "true", "Should show the full popup"); is(Services.focus.focusedElement, textbox.inputField, "Should have focused the search bar"); is(textbox.selectionStart, 0, "Should have selected all of the text"); is(textbox.selectionEnd, 3, "Should have selected all of the text"); promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; textbox.value = ""; }); // Pressing contextmenu should close the popup. add_task(async function contextmenu_closes_popup() { gURLBar.focus(); @@ -327,17 +327,17 @@ add_task(async function contextmenu_clos }); // Tabbing to the search box should open the popup if it contains text. add_task(async function tab_opens_popup() { gURLBar.focus(); textbox.value = "foo"; let promise = promiseEvent(searchPopup, "popupshown"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await promise; isnot(searchPopup.getAttribute("showonlysettings"), "true", "Should show the full popup"); is(Services.focus.focusedElement, textbox.inputField, "Should have focused the search bar"); is(textbox.selectionStart, 0, "Should have selected all of the text"); is(textbox.selectionEnd, 3, "Should have selected all of the text"); promise = promiseEvent(searchPopup, "popuphidden"); @@ -347,17 +347,17 @@ add_task(async function tab_opens_popup( textbox.value = ""; }); // Tabbing to the search box should not open the popup if it doesn't contain text. add_no_popup_task(function tab_doesnt_open_popup() { gURLBar.focus(); textbox.value = "foo"; - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(Services.focus.focusedElement, textbox.inputField, "Should have focused the search bar"); is(textbox.selectionStart, 0, "Should have selected all of the text"); is(textbox.selectionEnd, 3, "Should have selected all of the text"); textbox.value = ""; }); @@ -399,17 +399,17 @@ add_task(async function refocus_window_d }); // Switching back to the window when the search box has focus from keyboard should not open the popup. add_task(async function refocus_window_doesnt_open_popup_keyboard() { gURLBar.focus(); textbox.value = "foo"; let promise = promiseEvent(searchPopup, "popupshown"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await promise; isnot(searchPopup.getAttribute("showonlysettings"), "true", "Should show the full popup"); is(Services.focus.focusedElement, textbox.inputField, "Should have focused the search bar"); is(textbox.selectionStart, 0, "Should have selected all of the text"); is(textbox.selectionEnd, 3, "Should have selected all of the text"); promise = promiseEvent(searchPopup, "popuphidden"); @@ -497,75 +497,75 @@ add_task(async function dont_rollup_onca gURLBar.focus(); textbox.value = "long text"; let promise = promiseEvent(searchPopup, "popupshown"); EventUtils.synthesizeMouseAtCenter(textbox, {}); await promise; // Deselect the text - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); is(textbox.selectionStart, 9, "Should have moved the caret (selectionStart after deselect right)"); is(textbox.selectionEnd, 9, "Should have moved the caret (selectionEnd after deselect right)"); is(searchPopup.state, "open", "Popup should still be open"); - EventUtils.synthesizeKey("VK_LEFT", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); is(textbox.selectionStart, 8, "Should have moved the caret (selectionStart after left)"); is(textbox.selectionEnd, 8, "Should have moved the caret (selectionEnd after left)"); is(searchPopup.state, "open", "Popup should still be open"); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); is(textbox.selectionStart, 9, "Should have moved the caret (selectionStart after right)"); is(textbox.selectionEnd, 9, "Should have moved the caret (selectionEnd after right)"); is(searchPopup.state, "open", "Popup should still be open"); // Ensure caret movement works while a suggestion is selected. is(textbox.popup.selectedIndex, -1, "No selected item in list"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.popup.selectedIndex, 0, "Selected item in list"); is(textbox.selectionStart, 9, "Should have moved the caret to the end (selectionStart after selection)"); is(textbox.selectionEnd, 9, "Should have moved the caret to the end (selectionEnd after selection)"); - EventUtils.synthesizeKey("VK_LEFT", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); is(textbox.selectionStart, 8, "Should have moved the caret again (selectionStart after left)"); is(textbox.selectionEnd, 8, "Should have moved the caret again (selectionEnd after left)"); is(searchPopup.state, "open", "Popup should still be open"); - EventUtils.synthesizeKey("VK_LEFT", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); is(textbox.selectionStart, 7, "Should have moved the caret (selectionStart after left)"); is(textbox.selectionEnd, 7, "Should have moved the caret (selectionEnd after left)"); is(searchPopup.state, "open", "Popup should still be open"); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); is(textbox.selectionStart, 8, "Should have moved the caret (selectionStart after right)"); is(textbox.selectionEnd, 8, "Should have moved the caret (selectionEnd after right)"); is(searchPopup.state, "open", "Popup should still be open"); if (!navigator.platform.includes("Mac")) { - EventUtils.synthesizeKey("VK_HOME", {}); + EventUtils.synthesizeKey("KEY_Home"); is(textbox.selectionStart, 0, "Should have moved the caret (selectionStart after home)"); is(textbox.selectionEnd, 0, "Should have moved the caret (selectionEnd after home)"); is(searchPopup.state, "open", "Popup should still be open"); } // Close the popup again promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; textbox.value = ""; }); // Entering customization mode shouldn't open the popup. add_task(async function dont_open_in_customization() { gURLBar.focus(); textbox.value = "foo"; let promise = promiseEvent(searchPopup, "popupshown"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await promise; isnot(searchPopup.getAttribute("showonlysettings"), "true", "Should show the full popup"); info("Entering customization mode"); let sawPopup = false; function listener() { sawPopup = true; }
--- a/browser/components/search/test/browser_searchbar_smallpanel_keyboard_navigation.js +++ b/browser/components/search/test/browser_searchbar_smallpanel_keyboard_navigation.js @@ -90,79 +90,79 @@ info("textbox.mController.searchString = // before-last one-off buttons aren't different. We should always have more // than 4 default engines, but it's safer to check this assumption. let oneOffs = getOneOffs(); ok(oneOffs.length >= 4, "we have at least 4 one-off buttons displayed"); ok(!textbox.selectedButton, "no one-off button should be selected"); // Pressing should select the first one-off. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, "", "the textfield value should be unmodified"); // now cycle through the one-off items, the first one is already selected. for (let i = 0; i < oneOffs.length; ++i) { is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); // We should now be back to the initial situation. is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); ok(!textbox.selectedButton, "no one-off button should be selected"); info("now test the up arrow key"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // cycle through the one-off items, the first one is already selected. for (let i = oneOffs.length; i; --i) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, oneOffs[i - 1], "the one-off button #" + i + " should be selected"); } // Another press on up should clear the one-off selection. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); ok(!textbox.selectedButton, "no one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, "", "the textfield value should be unmodified"); }); add_task(async function test_tab() { is(Services.focus.focusedElement, textbox.inputField, "the search bar should be focused"); // from the previous test. let oneOffs = getOneOffs(); ok(!textbox.selectedButton, "no one-off button should be selected"); // Pressing tab should select the first one-off without selecting suggestions. // now cycle through the one-off items, the first one is already selected. for (let i = 0; i < oneOffs.length; ++i) { - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); } is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, "", "the textfield value should be unmodified"); // One more <tab> selects the settings button. - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // Pressing tab again should close the panel... let promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await promise; // ... and move the focus out of the searchbox. isnot(Services.focus.focusedElement, textbox.inputField, "the search bar no longer be focused"); }); add_task(async function test_shift_tab() { @@ -174,36 +174,36 @@ add_task(async function test_shift_tab() }); await promise; let oneOffs = getOneOffs(); ok(!textbox.selectedButton, "no one-off button should be selected"); is(searchPopup.getAttribute("showonlysettings"), "true", "Should show the small popup"); // Press up once to select the last button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // Press up again to select the last one-off button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); // Pressing shift+tab should cycle through the one-off items. for (let i = oneOffs.length - 1; i >= 0; --i) { is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); if (i) - EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); } is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, "", "the textfield value should be unmodified"); // Pressing shift+tab again should close the panel... promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); await promise; // ... and move the focus out of the searchbox. isnot(Services.focus.focusedElement, textbox.inputField, "the search bar no longer be focused"); }); add_task(async function test_alt_down() { @@ -220,90 +220,90 @@ add_task(async function test_alt_down() ok(!textbox.selectedButton, "no one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, "", "the textfield value should be unmodified"); // Pressing alt+down should select the first one-off without selecting suggestions // and cycle through the one-off items. let oneOffs = getOneOffs(); for (let i = 0; i < oneOffs.length; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); } // One more alt+down keypress and nothing should be selected. - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); ok(!textbox.selectedButton, "no one-off button should be selected"); // another one and the first one-off should be selected. - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); // Clear the selection with an alt+up keypress - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); ok(!textbox.selectedButton, "no one-off button should be selected"); }); add_task(async function test_alt_up() { // Check the initial state of the panel ok(!textbox.selectedButton, "no one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, "", "the textfield value should be unmodified"); // Pressing alt+up should select the last one-off without selecting suggestions // and cycle up through the one-off items. let oneOffs = getOneOffs(); for (let i = oneOffs.length - 1; i >= 0; --i) { - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); } // One more alt+down keypress and nothing should be selected. - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); ok(!textbox.selectedButton, "no one-off button should be selected"); // another one and the last one-off should be selected. - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); is(textbox.selectedButton, oneOffs[oneOffs.length - 1], "the last one-off button should be selected"); // Cleanup for the next test. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(!textbox.selectedButton, "no one-off should be selected anymore"); }); add_task(async function test_tab_and_arrows() { // Check the initial state is as expected. ok(!textbox.selectedButton, "no one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, "", "the textfield value should be unmodified"); // After pressing down, the first one-off should be selected. let oneOffs = getOneOffs(); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing tab, the second one-off should be selected. - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton, oneOffs[1], "the second one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing up, the first one-off should be selected again. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // Finally close the panel. let promise = promiseEvent(searchPopup, "popuphidden"); searchPopup.hidePopup(); await promise; @@ -322,44 +322,44 @@ add_task(async function test_open_search let engines = getOpenSearchItems(); is(engines.length, 2, "the opensearch.html page exposes 2 engines"); // Check that there's initially no selection. is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); ok(!textbox.selectedButton, "no button should be selected"); // Pressing up once selects the setting button... - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // ...and then pressing up selects open search engines. for (let i = engines.length; i; --i) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); let selectedButton = textbox.selectedButton; is(selectedButton, engines[i - 1], "the engine #" + i + " should be selected"); ok(selectedButton.classList.contains("addengine-item"), "the button is themed as an engine item"); } // Pressing up again should select the last one-off button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, getOneOffs().pop(), "the last one-off button should be selected"); info("now check that the down key navigates open search items as expected"); for (let i = 0; i < engines.length; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton, engines[i], "the engine #" + (i + 1) + " should be selected"); } // Pressing down on the last engine item selects the settings button. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); promise = promiseEvent(searchPopup, "popuphidden"); searchPopup.hidePopup(); await promise; gBrowser.removeCurrentTab();
--- a/browser/components/search/test/browser_tooManyEnginesOffered.js +++ b/browser/components/search/test/browser_tooManyEnginesOffered.js @@ -19,17 +19,17 @@ add_task(async function test() { let rootDir = getRootDirectory(gTestPath); let url = rootDir + "tooManyEnginesOffered.html"; await BrowserTestUtils.openNewForegroundTab(gBrowser, url); // Open the search popup. let promise = promiseEvent(searchPopup, "popupshown"); info("Opening search panel"); searchbar.focus(); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); await promise; // Make sure it has only one add-engine menu button item. let items = getOpenSearchItems(); Assert.equal(items.length, 1, "A single button"); let menuButton = items[0]; Assert.equal(menuButton.type, "menu", "A menu button"); @@ -55,29 +55,29 @@ add_task(async function test() { await promise; Assert.ok(!menuButton.open, "Submenu should be closed"); // Key up until the menu button is selected. for (let button = null; button != menuButton; button = searchbar.textbox.popup.oneOffButtons.selectedButton) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); } // Press the Right arrow key. The submenu should open. promise = promiseEvent(buttonPopup, "popupshown"); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); await promise; Assert.ok(menuButton.open, "Submenu should be open"); // Press the Esc key. The submenu should close. promise = promiseEvent(buttonPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; Assert.ok(!menuButton.open, "Submenu should be closed"); gBrowser.removeCurrentTab(); }); function getOpenSearchItems() {
--- a/browser/components/sessionstore/test/browser_522545.js +++ b/browser/components/sessionstore/test/browser_522545.js @@ -226,17 +226,17 @@ function test() { // Make sure this tab isn't loading and state is clear before we test. is(browser.userTypedValue, null, "userTypedValue is empty to start"); ok(!browser.didStartLoadSinceLastUserTyping(), "Initially, no load should be ongoing"); let inputText = "example.org"; gURLBar.focus(); gURLBar.value = inputText.slice(0, -1); - EventUtils.synthesizeKey(inputText.slice(-1), {}); + EventUtils.sendString(inputText.slice(-1)); executeSoon(function() { is(browser.userTypedValue, "example.org", "userTypedValue was set when changing URLBar value"); ok(!browser.didStartLoadSinceLastUserTyping(), "No load started since changing URLBar value"); // Now make sure ss gets these values too
--- a/browser/extensions/formautofill/test/mochitest/formautofill_common.js +++ b/browser/extensions/formautofill/test/mochitest/formautofill_common.js @@ -114,17 +114,17 @@ function triggerAutofillAndCheckProfile( const checkFieldAutofilled = Promise.all([ new Promise(resolve => element.addEventListener("input", resolve, {once: true})), new Promise(resolve => element.addEventListener(expectingEvent, resolve, {once: true})), ]).then(() => checkFieldValue(element, value)); promises.push(checkFieldAutofilled); } // Press Enter key and trigger form autofill. - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); return Promise.all(promises); } async function onStorageChanged(type) { info(`expecting the storage changed: ${type}`); return new Promise(resolve => { formFillChromeScript.addMessageListener("formautofill-storage-changed", function onChanged(data) { @@ -238,20 +238,20 @@ function popupShownListener() { } function initPopupListener() { registerPopupShownListener(popupShownListener); } async function triggerPopupAndHoverItem(fieldSelector, selectIndex) { await focusAndWaitForFieldsIdentified(fieldSelector); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); for (let i = 0; i <= selectIndex; i++) { - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); } await notifySelectedIndex(selectIndex); } function formAutoFillCommonSetup() { let chromeURL = SimpleTest.getTestFileURL("formautofill_parent_utils.js"); formFillChromeScript = SpecialPowers.loadChromeScript(chromeURL); formFillChromeScript.addMessageListener("onpopupshown", ({results}) => {
--- a/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html @@ -34,17 +34,17 @@ initPopupListener(); async function setupAddressStorage() { await addAddress(MOCK_STORAGE[0]); await addAddress(MOCK_STORAGE[1]); } add_task(async function check_autocomplete_on_autofocus_field() { await setupAddressStorage(); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({primary: address.organization, secondary: address["street-address"]}) )); }); </script>
--- a/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html @@ -49,134 +49,134 @@ async function setupFormHistory() { initPopupListener(); // Form with history only. add_task(async function history_only_menu_checking() { await setupFormHistory(); await setInput("#tel", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["+1234567890"], false); }); // Display history search result if less than 3 inputs are covered by all saved // fields in the storage. add_task(async function all_saved_fields_less_than_threshold() { await addAddress({ email: "test@test.com", }); await setInput("#email", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["foo@mozilla.com"], false); await cleanUpAddresses(); }); // Form with both history and address storage. add_task(async function check_menu_when_both_existed() { await setupAddressStorage(); await setInput("#organization", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ primary: address.organization, secondary: FormAutofillUtils.toOneLineAddress(address["street-address"]), }) )); await setInput("#street-address", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ primary: FormAutofillUtils.toOneLineAddress(address["street-address"]), secondary: address.organization, }) )); await setInput("#tel", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ primary: address.tel, secondary: FormAutofillUtils.toOneLineAddress(address["street-address"]), }) )); await setInput("#address-line1", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ primary: FormAutofillUtils.toOneLineAddress(address["street-address"]), secondary: address.organization, }) )); }); // Display history search result if no matched data in addresses. add_task(async function check_fallback_for_mismatched_field() { await setInput("#email", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["foo@mozilla.com"], false); }); // Display history search result if address autofill is disabled. add_task(async function check_search_result_for_pref_off() { await SpecialPowers.pushPrefEnv({ set: [["extensions.formautofill.addresses.enabled", false]], }); await setInput("#tel", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["+1234567890"], false); await SpecialPowers.popPrefEnv(); }); // Autofill the address from dropdown menu. add_task(async function check_fields_after_form_autofill() { const focusedInput = await setInput("#organization", "Moz"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ primary: address.organization, secondary: FormAutofillUtils.toOneLineAddress(address["street-address"]), }) ).slice(1)); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await triggerAutofillAndCheckProfile(MOCK_STORAGE[1]); - synthesizeKey("KEY_Escape", {}); + synthesizeKey("KEY_Escape"); is(focusedInput.value, "Mozilla", "Filled field shouldn't be reverted by ESC key"); }); // Fallback to history search after autofill address. add_task(async function check_fallback_after_form_autofill() { await setInput("#tel", "", true); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["+1234567890"], false); }); // Resume form autofill once all the autofilled fileds are changed. add_task(async function check_form_autofill_resume() { document.querySelector("#tel").blur(); document.querySelector("#form1").reset(); await setInput("#tel", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ primary: address.tel, secondary: FormAutofillUtils.toOneLineAddress(address["street-address"]), }) )); });
--- a/browser/extensions/formautofill/test/mochitest/test_basic_creditcard_autocomplete_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_basic_creditcard_autocomplete_form.html @@ -57,134 +57,134 @@ add_task(async function history_only_men // timing to start. // // After test process was re-spawning to https scheme. Wait 2 secs // to ensure the environment is ready to do storage setup. await sleep(2000); await setupFormHistory(); await setInput("#cc-exp-year", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["2023"], false); }); // Display credit card result even if the number of fillable fields is less than the threshold. add_task(async function all_saved_fields_less_than_threshold() { await addCreditCard(reducedMockRecord); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries([reducedMockRecord].map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-name"], secondary: cc.ccNumberFmt.affix + cc.ccNumberFmt.label, }))); await cleanUpCreditCards(); }); // Form with both history and credit card storage. add_task(async function check_menu_when_both_existed() { await setupCreditCardStorage(); await setInput("#cc-number", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primaryAffix: cc.ccNumberFmt.affix, primary: cc.ccNumberFmt.label, secondary: cc["cc-name"], }))); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-name"], secondary: cc.ccNumberFmt.affix + cc.ccNumberFmt.label, }))); await setInput("#cc-exp-year", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-exp-year"], secondary: cc.ccNumberFmt.affix + cc.ccNumberFmt.label, }))); await setInput("#cc-exp-month", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-exp-month"], secondary: cc.ccNumberFmt.affix + cc.ccNumberFmt.label, }))); await cleanUpCreditCards(); }); // Display history search result if no matched data in credit card. add_task(async function check_fallback_for_mismatched_field() { await addCreditCard(reducedMockRecord); await setInput("#cc-exp-year", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["2023"], false); await cleanUpCreditCards(); }); // Display history search result if credit card autofill is disabled. add_task(async function check_search_result_for_pref_off() { await setupCreditCardStorage(); await SpecialPowers.pushPrefEnv({ set: [["extensions.formautofill.creditCards.enabled", false]], }); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["John Smith"], false); await SpecialPowers.popPrefEnv(); }); // Autofill the credit card from dropdown menu. add_task(async function check_fields_after_form_autofill() { await setInput("#cc-exp-year", 202); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.slice(1).map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-exp-year"], secondary: cc.ccNumberFmt.affix + cc.ccNumberFmt.label, }))); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await triggerAutofillAndCheckProfile(MOCK_STORAGE[1]); }); // Fallback to history search after autofill address. add_task(async function check_fallback_after_form_autofill() { await setInput("#cc-name", "", true); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["John Smith"], false); }); // Resume form autofill once all the autofilled fileds are changed. add_task(async function check_form_autofill_resume() { document.querySelector("#cc-name").blur(); document.querySelector("#form1").reset(); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-name"], secondary: cc.ccNumberFmt.affix + cc.ccNumberFmt.label, }))); }); </script>
--- a/browser/extensions/formautofill/test/mochitest/test_clear_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_clear_form.html @@ -66,61 +66,61 @@ function checkIsFormCleared(patch = {}) } } add_task(async function simple_clear() { await triggerPopupAndHoverItem("#organization", 0); await triggerAutofillAndCheckProfile(MOCK_ADDR_STORAGE[0]); await triggerPopupAndHoverItem("#tel", 0); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); checkIsFormCleared(); }); add_task(async function clear_adapted_record() { await triggerPopupAndHoverItem("#street-address", 0); await triggerAutofillAndCheckProfile(MOCK_ADDR_STORAGE[0]); await triggerPopupAndHoverItem("#street-address", 0); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); checkIsFormCleared(); }); add_task(async function clear_modified_form() { await triggerPopupAndHoverItem("#organization", 0); await triggerAutofillAndCheckProfile(MOCK_ADDR_STORAGE[0]); await setInput("#tel", "+1111111111", true); await triggerPopupAndHoverItem("#street-address", 0); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); checkIsFormCleared({tel: "+1111111111"}); }); add_task(async function clear_distinct_section() { document.getElementById("form1").reset(); await triggerPopupAndHoverItem("#cc-name", 0); await triggerAutofillAndCheckProfile(MOCK_CC_STORAGE[0]); await triggerPopupAndHoverItem("#organization", 0); await triggerAutofillAndCheckProfile(MOCK_ADDR_STORAGE[0]); await triggerPopupAndHoverItem("#street-address", 0); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); for (const [id, val] of Object.entries(MOCK_CC_STORAGE[0])) { const element = document.getElementById(id); if (!element) { return; } checkFieldValue(element, val); checkFieldHighlighted(element, true); } await triggerPopupAndHoverItem("#cc-name", 0); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); checkIsFormCleared(); }); </script> <p id="display"></p> <div id="content">
--- a/browser/extensions/formautofill/test/mochitest/test_creditcard_autocomplete_off.html +++ b/browser/extensions/formautofill/test/mochitest/test_creditcard_autocomplete_off.html @@ -46,40 +46,40 @@ async function setupFormHistory() { initPopupListener(); // Show Form History popup for non-autocomplete="off" field only add_task(async function history_only_menu_checking() { await setupFormHistory(); await setInput("#cc-number", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["1234000056780000"], false); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await notExpectPopup(); }); // Show Form Autofill popup for the credit card fields. add_task(async function check_menu_when_both_with_autocomplete_off() { await setupCreditCardStorage(); await setInput("#cc-number", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primaryAffix: cc.ccNumberFmt.affix, primary: cc.ccNumberFmt.label, secondary: cc["cc-name"], }))); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-name"], secondary: cc.ccNumberFmt.affix + cc.ccNumberFmt.label, }))); }); </script>
--- a/browser/extensions/formautofill/test/mochitest/test_form_changes.html +++ b/browser/extensions/formautofill/test/mochitest/test_form_changes.html @@ -45,38 +45,38 @@ function addInputField(form, className) newElem.autocomplete = className; newElem.type = "text"; form.appendChild(newElem); } async function checkFormChangeHappened(formId) { info("expecting form changed"); await focusAndWaitForFieldsIdentified(`#${formId} input[name=tel]`); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({primary: address.tel, secondary: address.name}) )); // This is for checking the changes of element count. addInputField(document.querySelector(`#${formId}`), "address-level2"); await focusAndWaitForFieldsIdentified(`#${formId} input[name=name]`); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({primary: address.name, secondary: address["address-level2"]}) )); // This is for checking the changes of element removed and added then. document.querySelector(`#${formId} input[name=address-level2]`).remove(); addInputField(document.querySelector(`#${formId}`), "address-level2"); await focusAndWaitForFieldsIdentified(`#${formId} input[name=address-level2]`, true); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({primary: address["address-level2"], secondary: address.name}) )); } add_task(async function init_storage() { await setupAddressStorage();
--- a/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html +++ b/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html @@ -50,32 +50,32 @@ add_task(async function setup_storage() await addAddress(MOCK_STORAGE[0]); await addAddress(MOCK_STORAGE[1]); await addAddress(MOCK_STORAGE[2]); }); add_task(async function check_preview() { const focusedInput = await setInput("#organization", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkFormFieldsStyle(null); for (let i = 0; i < MOCK_STORAGE.length; i++) { - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await notifySelectedIndex(i); checkFormFieldsStyle(MOCK_STORAGE[i]); } // Navigate to the footer - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await notifySelectedIndex(MOCK_STORAGE.length); checkFormFieldsStyle(null); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await notifySelectedIndex(-1); checkFormFieldsStyle(null); focusedInput.blur(); }); add_task(async function check_filled_highlight() { await triggerPopupAndHoverItem("#organization", 0);
--- a/browser/extensions/formautofill/test/mochitest/test_multi_locale_CA_address_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_multi_locale_CA_address_form.html @@ -84,17 +84,17 @@ function checkFormFilled(selector, addre } else { let converted = address[prop]; if (prop == "street-address") { converted = FormAutofillUtils.toOneLineAddress(converted); } promises.push(...checkElementFilled(element, converted)); } } - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); return Promise.all(promises); } async function setupAddressStorage() { for (let address of MOCK_STORAGE) { await addAddress(address); } } @@ -107,52 +107,52 @@ add_task(async function setup() { await SpecialPowers.pushPrefEnv({"set": [["extensions.formautofill.supportedCountries", "US,CA"]]}); await setupAddressStorage(); }); // Autofill the address with address level 1 code. add_task(async function autofill_with_level1_code() { await setInput("#organization-en", "Mozilla Toronto"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); // Replace address level 1 code with full name in English for test result let result = Object.assign({}, MOCK_STORAGE[1], {"address-level1": "Ontario"}); await checkFormFilled("#form-en", result); await setInput("#organization-fr", "Mozilla Vancouver"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); // Replace address level 1 code with full name in French for test result result = Object.assign({}, MOCK_STORAGE[0], {"address-level1": "Colombie-Britannique"}); await checkFormFilled("#form-fr", result); document.querySelector("#form-en").reset(); document.querySelector("#form-fr").reset(); }); // Autofill the address with address level 1 full name. add_task(async function autofill_with_level1_full_name() { await setInput("#organization-en", "ExpoCité"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); // Replace address level 1 code with full name in French for test result let result = Object.assign({}, MOCK_STORAGE[3], {"address-level1": "Quebec"}); await checkFormFilled("#form-en", result); await setInput("#organization-fr", "Prince of Wales Northern Heritage"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); // Replace address level 1 code with full name in English for test result result = Object.assign({}, MOCK_STORAGE[2], {"address-level1": "Territoires du Nord-Ouest"}); await checkFormFilled("#form-fr", result); }); </script> <p id="display"></p>
--- a/browser/extensions/formautofill/test/mochitest/test_multiple_forms.html +++ b/browser/extensions/formautofill/test/mochitest/test_multiple_forms.html @@ -28,29 +28,29 @@ let MOCK_STORAGE = [{ initPopupListener(); add_task(async function setupStorage() { await addAddress(MOCK_STORAGE[0]); }); add_task(async function check_switch_form_popup() { await setInput("#additional-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); // We need an intentional wait here before switching form. await sleep(); await setInput("#organization", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); const {open: popupOpen} = await getPopupState(); is(popupOpen, false); await sleep(); await setInput("#given-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); }); </script> <div> <form>
--- a/browser/extensions/formautofill/test/mochitest/test_on_address_submission.html +++ b/browser/extensions/formautofill/test/mochitest/test_on_address_submission.html @@ -70,17 +70,17 @@ add_task(async function check_storage_af addressesInMenu.push(TEST_ADDRESSES[0]); // let expectedAddresses = TEST_ADDRESSES.slice(0); await onStorageChanged("add"); let matching = await checkAddresses(TEST_ADDRESSES); ok(matching, "New address saved as expected"); await setInput("#organization", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(addressesInMenu.map(address => JSON.stringify({primary: address.organization, secondary: address["street-address"]}) )); }); // Submit another new address that is mergeable. add_task(async function new_address_submitted_and_merged() { @@ -105,20 +105,20 @@ add_task(async function new_address_subm // Submit an updated autofill address and merge. add_task(async function check_storage_after_form_submitted() { document.querySelector("form").reset(); // Add country to second address in storage await setInput("#country", "US"); TEST_ADDRESSES[1].country = "US"; await setInput("#organization", "Moz"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); - synthesizeKey("KEY_ArrowDown", {}); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_Enter"); clickOnElement("input[type=submit]"); let expectedAddresses = TEST_ADDRESSES.slice(0); await onStorageChanged("update"); let matching = await checkAddresses(expectedAddresses); ok(matching, "Updated address merged as expected"); });
--- a/browser/modules/test/browser/browser_UsageTelemetry_searchbar.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_searchbar.js @@ -96,17 +96,17 @@ add_task(async function test_plainQuery( let resultMethodHist = getAndClearHistogram("FX_SEARCHBAR_SELECTED_RESULT_METHOD"); let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS"); let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); info("Simulate entering a simple search."); let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInSearchbar("simple query"); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_Enter"); await p; // Check if the scalars contain the expected values. const scalars = getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false); checkKeyedScalar(scalars, SCALAR_SEARCHBAR, "search_enter", 1); Assert.equal(Object.keys(scalars[SCALAR_SEARCHBAR]).length, 1, "This search must only increment one entry in the scalar."); @@ -138,18 +138,18 @@ add_task(async function test_oneOff_ente let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); info("Perform a one-off search using the first engine."); let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInSearchbar("query"); info("Pressing Alt+Down to highlight the first one off engine."); - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); + EventUtils.synthesizeKey("KEY_Enter"); await p; // Check if the scalars contain the expected values. const scalars = getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false); checkKeyedScalar(scalars, SCALAR_SEARCHBAR, "search_oneoff", 1); Assert.equal(Object.keys(scalars[SCALAR_SEARCHBAR]).length, 1, "This search must only increment one entry in the scalar."); @@ -193,19 +193,19 @@ add_task(async function test_oneOff_ente let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); info("Type a query. Suggestions should be generated by the test engine."); let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInSearchbar("query"); info("Select the second result, press Alt+Down to take us to the first one-off engine."); - EventUtils.synthesizeKey("VK_DOWN", {}); - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_ArrowDown"); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); + EventUtils.synthesizeKey("KEY_Enter"); await p; let resultMethods = resultMethodHist.snapshot(); checkHistogramResults(resultMethods, URLBAR_SELECTED_RESULT_METHODS.enterSelection, "FX_SEARCHBAR_SELECTED_RESULT_METHOD"); Services.search.currentEngine = previousEngine; @@ -317,18 +317,18 @@ add_task(async function test_suggestion_ Services.search.currentEngine = suggestionEngine; let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); info("Type a query. Suggestions should be generated by the test engine."); let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInSearchbar("query"); info("Select the second result and press Return."); - EventUtils.synthesizeKey("VK_DOWN", {}); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_ArrowDown"); + EventUtils.synthesizeKey("KEY_Enter"); await p; let resultMethods = resultMethodHist.snapshot(); checkHistogramResults(resultMethods, URLBAR_SELECTED_RESULT_METHODS.enterSelection, "FX_SEARCHBAR_SELECTED_RESULT_METHOD"); Services.search.currentEngine = previousEngine;
--- a/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js @@ -130,17 +130,17 @@ add_task(async function test_simpleQuery let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD"); let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS"); let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); info("Simulate entering a simple search."); let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInAwesomebar("simple query"); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_Enter"); await p; // Check if the scalars contain the expected values. const scalars = getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false); checkKeyedScalar(scalars, SCALAR_URLBAR, "search_enter", 1); Assert.equal(Object.keys(scalars[SCALAR_URLBAR]).length, 1, "This search must only increment one entry in the scalar."); @@ -185,17 +185,17 @@ add_task(async function test_searchAlias let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD"); let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS"); let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); info("Search using a search alias."); let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInAwesomebar("mozalias query"); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_Enter"); await p; // Check if the scalars contain the expected values. const scalars = getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);