--- 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);
checkKeyedScalar(scalars, SCALAR_URLBAR, "search_alias", 1);
Assert.equal(Object.keys(scalars[SCALAR_URLBAR]).length, 1,
"This search must only increment one entry in the scalar.");
@@ -244,18 +244,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 searchInAwesomebar("query");
info("Pressing Alt+Down to take us to 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_URLBAR, "search_oneoff", 1);
Assert.equal(Object.keys(scalars[SCALAR_URLBAR]).length, 1,
"This search must only increment one entry in the scalar.");
@@ -313,19 +313,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 searchInAwesomebar("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_URLBAR_SELECTED_RESULT_METHOD");
Services.search.currentEngine = previousEngine;
@@ -455,18 +455,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 searchInAwesomebar("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_URLBAR_SELECTED_RESULT_METHOD");
Services.search.currentEngine = previousEngine;
--- a/browser/modules/test/browser/formValidation/browser_form_validation.js
+++ b/browser/modules/test/browser/formValidation/browser_form_validation.js
@@ -183,17 +183,17 @@ add_task(async function() {
let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
let popupHiddenPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popuphidden");
- EventUtils.synthesizeKey("a", {});
+ EventUtils.sendString("a");
await popupHiddenPromise;
gBrowser.removeCurrentTab();
});
/**
* In this test, we check that, we don't hide the popup by interacting with the
* invalid element if the element is still invalid.
@@ -206,17 +206,17 @@ add_task(async function() {
let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
await new Promise((resolve, reject) => {
- EventUtils.synthesizeKey("a", {});
+ EventUtils.sendString("a");
executeSoon(function() {
checkPopupShow();
resolve();
});
});
gBrowser.removeCurrentTab();
});
@@ -255,17 +255,17 @@ add_task(async function() {
let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
let popupHiddenPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popuphidden");
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
await popupHiddenPromise;
gBrowser.removeCurrentTab();
});
/**
* In this test, we check that the popup will hide if we move to another tab.
*/
@@ -389,17 +389,17 @@ add_task(async function() {
await clickChildElement(browser);
await popupShownPromise;
checkPopupShow();
await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let inputPromise = BrowserTestUtils.waitForEvent(gBrowser.contentDocument.getElementById("i"), "input");
- EventUtils.synthesizeKey("f", {});
+ EventUtils.sendString("f");
await inputPromise;
// Now, the element suffers from another error, the message should have
// been updated.
await new Promise((resolve, reject) => {
// XXXndeakin This isn't really going to work when the content is another process
executeSoon(function() {
checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent);
--- a/devtools/client/debugger/test/mochitest/browser_dbg_instruments-pane-collapse_keyboard.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_instruments-pane-collapse_keyboard.js
@@ -13,30 +13,30 @@ async function test() {
let [aTab,, aPanel] = await initDebugger(TAB_URL);
let doc = aPanel.panelWin.document;
let panel = doc.getElementById("instruments-pane");
let button = doc.getElementById("instruments-pane-toggle");
ok(panel.classList.contains("pane-collapsed"),
"The instruments panel is initially in collapsed state");
- await togglePane(button, "Press on the toggle button to expand", panel, "VK_RETURN");
+ await togglePane(button, "Press on the toggle button to expand", panel, "KEY_Enter");
ok(!panel.classList.contains("pane-collapsed"),
"The instruments panel is in the expanded state");
- await togglePane(button, "Press on the toggle button to collapse", panel, "VK_SPACE");
+ await togglePane(button, "Press on the toggle button to collapse", panel, " ");
ok(panel.classList.contains("pane-collapsed"),
"The instruments panel is in the collapsed state");
closeDebuggerAndFinish(aPanel);
}
-async function togglePane(button, message, pane, keycode) {
+async function togglePane(button, message, pane, key) {
let onTransitionEnd = once(pane, "transitionend");
info(message);
button.focus();
- EventUtils.synthesizeKey(keycode, {});
+ EventUtils.synthesizeKey(key);
await onTransitionEnd;
// Wait for the next event tick to make sure all transitionend event
// handlers finish.
await waitForTick();
}
--- a/devtools/client/debugger/test/mochitest/browser_dbg_paused-keybindings.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_paused-keybindings.js
@@ -32,19 +32,18 @@ function test() {
yield waitForTick();
yield removeTab(tab2);
yield ensureCaretAt(panel, 20);
// Try to use the Cmd-L keybinding to see if it still works.
let caretMove = ensureCaretAt(panel, 15, 1, true);
// Wait a tick for the editor focus event to occur first.
executeSoon(function () {
- EventUtils.synthesizeKey("l", { accelKey: true });
- EventUtils.synthesizeKey("1", {});
- EventUtils.synthesizeKey("5", {});
+ EventUtils.synthesizeKey("l", {accelKey: true});
+ EventUtils.sendString("15");
});
yield caretMove;
yield resumeDebuggerThenCloseAndFinish(panel);
}).catch(aError => {
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
});
}
--- a/devtools/client/debugger/test/mochitest/browser_dbg_split-console-keypress.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_split-console-keypress.js
@@ -40,25 +40,25 @@ function test() {
// * the debugger cursor is where we want it
let jsterm = yield getSplitConsole(gToolbox, gDebugger);
// The console is now open (if not make the test fail already)
ok(gToolbox.splitConsole, "Split console is shown.");
// Information for sub-tests. When 'key' is synthesized 'keyRepeat' times,
// cursor should be at 'caretLine' of this test..
let stepTests = [
- {key: "VK_F11", keyRepeat: 1, caretLine: 16},
- {key: "VK_F11", keyRepeat: 2, caretLine: 18},
- {key: "VK_F11", keyRepeat: 2, caretLine: 27},
- {key: "VK_F10", keyRepeat: 1, caretLine: 27},
- {key: "VK_F11", keyRepeat: 1, caretLine: 18},
- {key: "VK_F11", keyRepeat: 5, caretLine: 32},
- {key: "VK_F11", modifier:"Shift", keyRepeat: 1, caretLine: 29},
- {key: "VK_F11", modifier:"Shift", keyRepeat: 2, caretLine: 34},
- {key: "VK_F11", modifier:"Shift", keyRepeat: 2, caretLine: 34}
+ {key: "KEY_F11", keyRepeat: 1, caretLine: 16},
+ {key: "KEY_F11", keyRepeat: 2, caretLine: 18},
+ {key: "KEY_F11", keyRepeat: 2, caretLine: 27},
+ {key: "KEY_F10", keyRepeat: 1, caretLine: 27},
+ {key: "KEY_F11", keyRepeat: 1, caretLine: 18},
+ {key: "KEY_F11", keyRepeat: 5, caretLine: 32},
+ {key: "KEY_F11", modifier:"Shift", keyRepeat: 1, caretLine: 29},
+ {key: "KEY_F11", modifier:"Shift", keyRepeat: 2, caretLine: 34},
+ {key: "KEY_F11", modifier:"Shift", keyRepeat: 2, caretLine: 34}
];
// Trigger script that stops at debugger statement
executeSoon(() => generateMouseClickInTab(gTab,
"content.document.getElementById('start')"));
yield waitForPause(gThreadClient);
// Focus the console and add event listener to track whether it loses focus
// (Must happen after generateMouseClickInTab() call)
@@ -87,17 +87,17 @@ function test() {
// "Test " + i + ": CaretPos at line " + thisTest.caretLine);
ok(isDebugPos(gPanel, thisTest.caretLine),
"Test " + i + ": DebugPos at line " + thisTest.caretLine);
}
// Did focus go missing while we were stepping?
is(consoleLostFocus, false, "Console input should not lose focus");
// We're done with the tests in the stepTests array
// Last key we test is "resume"
- executeSoon(() => EventUtils.synthesizeKey("VK_F8", {}));
+ executeSoon(() => EventUtils.synthesizeKey("KEY_F8"));
// We reset the variable tracking loss of focus to test the resume case
consoleLostFocus = false;
gPanel.target.on("thread-resumed", () => {
is(gThreadClient.paused, false,
"Should not be paused after resume");
// Final test: did we preserve console inputNode focus during resume?
--- a/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-accessibility.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-accessibility.js
@@ -78,403 +78,403 @@ function performTest() {
"The 'someProp1' item should be focused.");
gVariablesView.focusPrevItem();
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
// Part 1: Make sure that UP/DOWN keys don't scroll the variables view.
- yield synthesizeKeyAndWaitForTick("VK_DOWN", {});
+ yield synthesizeKeyAndWaitForTick("KEY_ArrowDown");
is(gVariablesView._parent.scrollTop, 0,
"The 'variables' view shouldn't scroll when pressing the DOWN key.");
- yield synthesizeKeyAndWaitForTick("VK_UP", {});
+ yield synthesizeKeyAndWaitForTick("KEY_ArrowUp");
is(gVariablesView._parent.scrollTop, 0,
"The 'variables' view shouldn't scroll when pressing the UP key.");
// Part 2: Make sure that RETURN/ESCAPE toggle input elements.
- yield synthesizeKeyAndWaitForElement("VK_RETURN", {}, ".element-value-input", true);
- yield synthesizeKeyAndWaitForElement("VK_ESCAPE", {}, ".element-value-input", false);
- yield synthesizeKeyAndWaitForElement("VK_RETURN", { shiftKey: true }, ".element-name-input", true);
- yield synthesizeKeyAndWaitForElement("VK_ESCAPE", {}, ".element-name-input", false);
+ yield synthesizeKeyAndWaitForElement("KEY_Enter", {}, ".element-value-input", true);
+ yield synthesizeKeyAndWaitForElement("KEY_Escape", {}, ".element-value-input", false);
+ yield synthesizeKeyAndWaitForElement("KEY_Enter", {shiftKey: true}, ".element-name-input", true);
+ yield synthesizeKeyAndWaitForElement("KEY_Escape", {}, ".element-name-input", false);
// Part 3: Test simple navigation.
- EventUtils.sendKey("DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp1",
"The 'someProp1' item should be focused.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp5",
"The 'someProp5' item should be focused.");
- EventUtils.sendKey("PAGE_UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("END", gDebugger);
+ EventUtils.synthesizeKey("KEY_End", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
- EventUtils.sendKey("HOME", gDebugger);
+ EventUtils.synthesizeKey("KEY_Home", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
// Part 4: Test if pressing the same navigation key twice works as expected.
- EventUtils.sendKey("DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp1",
"The 'someProp1' item should be focused.");
- EventUtils.sendKey("DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp2",
"The 'someProp2' item should be focused.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp1",
"The 'someProp1' item should be focused.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp5",
"The 'someProp5' item should be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
- EventUtils.sendKey("PAGE_UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp5",
"The 'someProp5' item should be focused.");
- EventUtils.sendKey("PAGE_UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
// Part 5: Test that HOME/PAGE_UP/PAGE_DOWN are symmetrical.
- EventUtils.sendKey("HOME", gDebugger);
+ EventUtils.synthesizeKey("KEY_Home", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("HOME", gDebugger);
+ EventUtils.synthesizeKey("KEY_Home", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("PAGE_UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("HOME", gDebugger);
+ EventUtils.synthesizeKey("KEY_Home", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("END", gDebugger);
+ EventUtils.synthesizeKey("KEY_End", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
- EventUtils.sendKey("END", gDebugger);
+ EventUtils.synthesizeKey("KEY_End", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
- EventUtils.sendKey("END", gDebugger);
+ EventUtils.synthesizeKey("KEY_End", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
// Part 6: Test that focus doesn't leave the variables view.
- EventUtils.sendKey("PAGE_UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp5",
"The 'someProp5' item should be focused.");
- EventUtils.sendKey("PAGE_UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp5",
"The 'someProp5' item should be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
// Part 7: Test that random offsets don't occur in tandem with HOME/END.
- EventUtils.sendKey("HOME", gDebugger);
+ EventUtils.synthesizeKey("KEY_Home", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp1",
"The 'someProp1' item should be focused.");
- EventUtils.sendKey("END", gDebugger);
+ EventUtils.synthesizeKey("KEY_End", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
- EventUtils.sendKey("DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
// Part 8: Test that the RIGHT key expands elements as intended.
- EventUtils.sendKey("PAGE_UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp5",
"The 'someProp5' item should be focused.");
is(gVariablesView.getFocusedItem().expanded, false,
"The 'someProp5' item should not be expanded yet.");
- yield synthesizeKeyAndWaitForTick("VK_RIGHT", {});
+ yield synthesizeKeyAndWaitForTick("KEY_ArrowRight");
is(gVariablesView.getFocusedItem().name, "someProp5",
"The 'someProp5' item should be focused.");
is(gVariablesView.getFocusedItem().expanded, true,
"The 'someProp5' item should now be expanded.");
is(gVariablesView.getFocusedItem()._store.size, 9,
"There should be 9 properties in the selected variable.");
is(gVariablesView.getFocusedItem()._enumItems.length, 7,
"There should be 7 enumerable properties in the selected variable.");
is(gVariablesView.getFocusedItem()._nonEnumItems.length, 2,
"There should be 2 non-enumerable properties in the selected variable.");
yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 7);
yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 2);
- EventUtils.sendKey("RIGHT", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "0",
"The '0' item should be focused.");
- EventUtils.sendKey("RIGHT", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "0",
"The '0' item should still be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "5",
"The '5' item should be focused.");
is(gVariablesView.getFocusedItem().expanded, false,
"The '5' item should not be expanded yet.");
- yield synthesizeKeyAndWaitForTick("VK_RIGHT", {});
+ yield synthesizeKeyAndWaitForTick("KEY_ArrowRight");
is(gVariablesView.getFocusedItem().name, "5",
"The '5' item should be focused.");
is(gVariablesView.getFocusedItem().expanded, true,
"The '5' item should now be expanded.");
is(gVariablesView.getFocusedItem()._store.size, 5,
"There should be 5 properties in the selected variable.");
is(gVariablesView.getFocusedItem()._enumItems.length, 3,
"There should be 3 enumerable properties in the selected variable.");
is(gVariablesView.getFocusedItem()._nonEnumItems.length, 2,
"There should be 2 non-enumerable properties in the selected variable.");
yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 3);
yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 2);
- EventUtils.sendKey("RIGHT", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "0",
"The '0' item should be focused.");
- EventUtils.sendKey("RIGHT", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "0",
"The '0' item should still be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "6",
"The '6' item should be focused.");
is(gVariablesView.getFocusedItem().expanded, false,
"The '6' item should not be expanded yet.");
- yield synthesizeKeyAndWaitForTick("VK_RIGHT", {});
+ yield synthesizeKeyAndWaitForTick("KEY_ArrowRight");
is(gVariablesView.getFocusedItem().name, "6",
"The '6' item should be focused.");
is(gVariablesView.getFocusedItem().expanded, true,
"The '6' item should now be expanded.");
is(gVariablesView.getFocusedItem()._store.size, 3,
"There should be 3 properties in the selected variable.");
is(gVariablesView.getFocusedItem()._enumItems.length, 2,
"There should be 2 enumerable properties in the selected variable.");
is(gVariablesView.getFocusedItem()._nonEnumItems.length, 1,
"There should be 1 non-enumerable properties in the selected variable.");
yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 2);
yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 1);
- EventUtils.sendKey("RIGHT", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "prop1",
"The 'prop1' item should be focused.");
- EventUtils.sendKey("RIGHT", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "prop1",
"The 'prop1' item should still be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp6",
"The 'someProp6' item should be focused.");
is(gVariablesView.getFocusedItem().expanded, false,
"The 'someProp6' item should not be expanded yet.");
// Part 9: Test that the RIGHT key collapses elements as intended.
- EventUtils.sendKey("LEFT", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowLeft", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp6",
"The 'someProp6' item should be focused.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
- EventUtils.sendKey("LEFT", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowLeft", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp5",
"The 'someProp5' item should be focused.");
is(gVariablesView.getFocusedItem().expanded, true,
"The '6' item should still be expanded.");
- EventUtils.sendKey("LEFT", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowLeft", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp5",
"The 'someProp5' item should still be focused.");
is(gVariablesView.getFocusedItem().expanded, false,
"The '6' item should still not be expanded anymore.");
- EventUtils.sendKey("LEFT", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowLeft", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp5",
"The 'someProp5' item should still be focused.");
// Part 9: Test continuous navigation.
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp4",
"The 'someProp4' item should be focused.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp3",
"The 'someProp3' item should be focused.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp2",
"The 'someProp2' item should be focused.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp1",
"The 'someProp1' item should be focused.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("PAGE_UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp0",
"The 'someProp0' item should be focused.");
- EventUtils.sendKey("PAGE_DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp5",
"The 'someProp5' item should be focused.");
- EventUtils.sendKey("DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp6",
"The 'someProp6' item should be focused.");
- EventUtils.sendKey("DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp7",
"The 'someProp7' item should be focused.");
- EventUtils.sendKey("DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "get",
"The 'get' item should be focused.");
- EventUtils.sendKey("DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "set",
"The 'set' item should be focused.");
- EventUtils.sendKey("DOWN", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' item should be focused.");
// Part 10: Test that BACKSPACE deletes items in the variables view.
- EventUtils.sendKey("BACK_SPACE", gDebugger);
+ EventUtils.synthesizeKey("KEY_Backspace", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "__proto__",
"The '__proto__' variable should still be focused.");
is(gVariablesView.getFocusedItem().value, "[object Object]",
"The '__proto__' variable should not have an empty value.");
is(gVariablesView.getFocusedItem().visible, false,
"The '__proto__' variable should be hidden.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "set",
"The 'set' item should be focused.");
is(gVariablesView.getFocusedItem().value, "[object Object]",
"The 'set' item should not have an empty value.");
is(gVariablesView.getFocusedItem().visible, true,
"The 'set' item should be visible.");
- EventUtils.sendKey("BACK_SPACE", gDebugger);
+ EventUtils.synthesizeKey("KEY_Backspace", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "set",
"The 'set' item should still be focused.");
is(gVariablesView.getFocusedItem().value, "[object Object]",
"The 'set' item should not have an empty value.");
is(gVariablesView.getFocusedItem().visible, true,
"The 'set' item should be visible.");
is(gVariablesView.getFocusedItem().twisty, false,
"The 'set' item should be disabled and have a hidden twisty.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "get",
"The 'get' item should be focused.");
is(gVariablesView.getFocusedItem().value, "[object Object]",
"The 'get' item should not have an empty value.");
is(gVariablesView.getFocusedItem().visible, true,
"The 'get' item should be visible.");
- EventUtils.sendKey("BACK_SPACE", gDebugger);
+ EventUtils.synthesizeKey("KEY_Backspace", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "get",
"The 'get' item should still be focused.");
is(gVariablesView.getFocusedItem().value, "[object Object]",
"The 'get' item should not have an empty value.");
is(gVariablesView.getFocusedItem().visible, true,
"The 'get' item should be visible.");
is(gVariablesView.getFocusedItem().twisty, false,
"The 'get' item should be disabled and have a hidden twisty.");
- EventUtils.sendKey("UP", gDebugger);
+ EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp7",
"The 'someProp7' item should be focused.");
is(gVariablesView.getFocusedItem().value, undefined,
"The 'someProp7' variable should have an empty value.");
is(gVariablesView.getFocusedItem().visible, true,
"The 'someProp7' variable should be visible.");
- EventUtils.sendKey("BACK_SPACE", gDebugger);
+ EventUtils.synthesizeKey("KEY_Backspace", {}, gDebugger);
is(gVariablesView.getFocusedItem().name, "someProp7",
"The 'someProp7' variable should still be focused.");
is(gVariablesView.getFocusedItem().value, undefined,
"The 'someProp7' variable should have an empty value.");
is(gVariablesView.getFocusedItem().visible, false,
"The 'someProp7' variable should be hidden.");
// Part 11: Test that Ctrl-C copies the current item to the system clipboard
--- a/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-popup-17.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-popup-17.js
@@ -29,17 +29,17 @@ function test() {
yield addBreakpoint();
yield ensureThreadClientState(gPanel, "resumed");
yield pauseDebuggee();
yield openVarPopup(gPanel, { line: 20, ch: 17 });
is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 1,
"The popup should be open with a simple text entry");
// Now we're stopped at a breakpoint with an open popup
// we'll send a keypress and check if the popup closes
- executeSoon(() => EventUtils.synthesizeKey("VK_F11", {}));
+ executeSoon(() => EventUtils.synthesizeKey("KEY_F11"));
// The keypress should cause one resumed event and one paused event
yield waitForThreadEvents(gPanel, "resumed");
yield waitForThreadEvents(gPanel, "paused");
// Here's the state we're actually interested in checking..
checkVariablePopupClosed(bubble);
yield resumeDebuggerThenCloseAndFinish(gPanel);
});
testPopupHiding();
--- a/devtools/client/framework/test/browser_menu_api.js
+++ b/devtools/client/framework/test/browser_menu_api.js
@@ -156,26 +156,26 @@ function* testSubmenu(toolbox) {
is(subMenuItems.length, 1, "Correct number of submenu items");
is(subMenuItems[0].getAttribute("label"), "Submenu item", "Correct label");
yield once(menu, "open");
let closed = once(menu, "close");
info("Using keyboard navigation to open, close, and reopen the submenu");
let shown = once(menus[0], "popupshown");
- EventUtils.synthesizeKey("VK_DOWN", {});
- EventUtils.synthesizeKey("VK_RIGHT", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
+ EventUtils.synthesizeKey("KEY_ArrowRight");
yield shown;
let hidden = once(menus[0], "popuphidden");
- EventUtils.synthesizeKey("VK_LEFT", {});
+ EventUtils.synthesizeKey("KEY_ArrowLeft");
yield hidden;
shown = once(menus[0], "popupshown");
- EventUtils.synthesizeKey("VK_RIGHT", {});
+ EventUtils.synthesizeKey("KEY_ArrowRight");
yield shown;
info("Clicking the submenu item");
EventUtils.synthesizeMouseAtCenter(subMenuItems[0], {}, toolbox.win);
yield closed;
ok(clickFired, "Click has fired");
}
--- a/devtools/client/framework/test/browser_toolbox_keyboard_navigation.js
+++ b/devtools/client/framework/test/browser_toolbox_keyboard_navigation.js
@@ -30,52 +30,54 @@ add_task(function* () {
!elm.hidden && doc.defaultView.getComputedStyle(elm).getPropertyValue(
"display") !== "none");
// Put the keyboard focus onto the first toolbar control.
toolbarControls[0].focus();
ok(containsFocus(doc, toolbar), "Focus is within the toolbar");
// Move the focus away from toolbar to a next focusable element.
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
ok(!containsFocus(doc, toolbar), "Focus is outside of the toolbar");
// Move the focus back to the toolbar.
- EventUtils.synthesizeKey("VK_TAB", { shiftKey: true });
+ EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true});
ok(containsFocus(doc, toolbar), "Focus is within the toolbar again");
// Move through the toolbar forward using the right arrow key.
for (let i = 0; i < toolbarControls.length; ++i) {
is(doc.activeElement.id, toolbarControls[i].id, "New control is focused");
if (i < toolbarControls.length - 1) {
- EventUtils.synthesizeKey("VK_RIGHT", {});
+ EventUtils.synthesizeKey("KEY_ArrowRight");
}
}
// Move the focus away from toolbar to a next focusable element.
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
ok(!containsFocus(doc, toolbar), "Focus is outside of the toolbar");
// Move the focus back to the toolbar.
- EventUtils.synthesizeKey("VK_TAB", { shiftKey: true });
+ EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true});
ok(containsFocus(doc, toolbar), "Focus is within the toolbar again");
// Move through the toolbar backward using the left arrow key.
for (let i = toolbarControls.length - 1; i >= 0; --i) {
is(doc.activeElement.id, toolbarControls[i].id, "New control is focused");
- if (i > 0) { EventUtils.synthesizeKey("VK_LEFT", {}); }
+ if (i > 0) {
+ EventUtils.synthesizeKey("KEY_ArrowLeft");
+ }
}
// Move focus to the 3rd (non-first) toolbar control.
let expectedFocusedControl = toolbarControls[2];
- EventUtils.synthesizeKey("VK_RIGHT", {});
- EventUtils.synthesizeKey("VK_RIGHT", {});
+ EventUtils.synthesizeKey("KEY_ArrowRight");
+ EventUtils.synthesizeKey("KEY_ArrowRight");
is(doc.activeElement.id, expectedFocusedControl.id, "New control is focused");
// Move the focus away from toolbar to a next focusable element.
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
ok(!containsFocus(doc, toolbar), "Focus is outside of the toolbar");
// Move the focus back to the toolbar, ensure we land on the last active
// descendant control.
- EventUtils.synthesizeKey("VK_TAB", { shiftKey: true });
+ EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true});
is(doc.activeElement.id, expectedFocusedControl.id, "New control is focused");
});
--- a/devtools/client/inspector/boxmodel/test/browser_boxmodel_navigation.js
+++ b/devtools/client/inspector/boxmodel/test/browser_boxmodel_navigation.js
@@ -26,82 +26,82 @@ add_task(function* () {
yield testChangingLevelsByClicking(inspector, view);
});
function* testInitialFocus(inspector, view) {
info("Test that the focus is on margin layout.");
let viewdoc = view.document;
let boxmodel = viewdoc.querySelector(".boxmodel-container");
boxmodel.focus();
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-main devtools-monospace",
"Should be set to the position layout.");
}
function* testChangingLevels(inspector, view) {
info("Test that using arrow keys updates level.");
let viewdoc = view.document;
let boxmodel = viewdoc.querySelector(".boxmodel-container");
boxmodel.focus();
- EventUtils.synthesizeKey("VK_RETURN", {});
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Enter");
+ EventUtils.synthesizeKey("KEY_Escape");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-margins",
"Should be set to the margin layout.");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-borders",
"Should be set to the border layout.");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-paddings",
"Should be set to the padding layout.");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-contents",
"Should be set to the content layout.");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-paddings",
"Should be set to the padding layout.");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-borders",
"Should be set to the border layout.");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-margins",
"Should be set to the margin layout.");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-main devtools-monospace",
"Should be set to the position layout.");
}
function* testTabbingWrapAround(inspector, view) {
info("Test that using arrow keys updates level.");
let viewdoc = view.document;
let boxmodel = viewdoc.querySelector(".boxmodel-container");
boxmodel.focus();
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
let editLevel = boxmodel.getAttribute("activedescendant").split(" ")[0];
let dataLevel = viewdoc.querySelector(`.${editLevel}`).getAttribute("data-box");
let editBoxes = [...viewdoc.querySelectorAll(
`[data-box="${dataLevel}"].boxmodel-editable`)];
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
editBoxes[3].focus();
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
is(editBoxes[0], viewdoc.activeElement, "Top edit box should have focus.");
editBoxes[0].focus();
- EventUtils.synthesizeKey("VK_TAB", { shiftKey: true });
+ EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true});
is(editBoxes[3], viewdoc.activeElement, "Left edit box should have focus.");
}
function* testChangingLevelsByClicking(inspector, view) {
info("Test that clicking on levels updates level.");
let viewdoc = view.document;
let boxmodel = viewdoc.querySelector(".boxmodel-container");
boxmodel.focus();
--- a/devtools/client/inspector/computed/test/browser_computed_keybindings_02.js
+++ b/devtools/client/inspector/computed/test/browser_computed_keybindings_02.js
@@ -39,28 +39,28 @@ add_task(function* () {
info("Selecting the first computed style in the list");
let firstStyle = view.styleDocument.querySelector(".computed-property-view");
ok(firstStyle, "First computed style found in panel");
firstStyle.focus();
info("Tab to select the 2nd style and press return");
let onExpanded = inspector.once("computed-view-property-expanded");
- EventUtils.synthesizeKey("VK_TAB", {});
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Tab");
+ EventUtils.synthesizeKey("KEY_Enter");
yield onExpanded;
info("Verify the 2nd style has been expanded");
let secondStyleSelectors = view.styleDocument.querySelectorAll(
".computed-property-content .matchedselectors")[1];
ok(secondStyleSelectors.childNodes.length > 0, "Matched selectors expanded");
info("Tab back up and test the same thing, with space");
onExpanded = inspector.once("computed-view-property-expanded");
- EventUtils.synthesizeKey("VK_TAB", {shiftKey: true});
- EventUtils.synthesizeKey("VK_SPACE", {});
+ EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true});
+ EventUtils.synthesizeKey(" ");
yield onExpanded;
info("Verify the 1st style has been expanded too");
let firstStyleSelectors = view.styleDocument.querySelectorAll(
".computed-property-content .matchedselectors")[0];
ok(firstStyleSelectors.childNodes.length > 0, "Matched selectors expanded");
});
--- a/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js
+++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js
@@ -37,22 +37,22 @@ add_task(function* () {
function assertNodeSelected(inspector, tagName) {
is(inspector.selection.nodeFront.tagName.toLowerCase(), tagName,
`The <${tagName}> node is selected`);
}
function selectPreviousNodeWithArrowUp(inspector) {
let onNodeHighlighted = inspector.toolbox.once("node-highlight");
let onUpdated = inspector.once("inspector-updated");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
return Promise.all([onUpdated, onNodeHighlighted]);
}
function* selectWithElementPicker(inspector, testActor) {
yield startPicker(inspector.toolbox);
yield BrowserTestUtils.synthesizeMouseAtCenter("div", {
type: "mousemove",
}, gBrowser.selectedBrowser);
- yield testActor.synthesizeKey({key: "VK_RETURN", options: {}});
+ yield testActor.synthesizeKey({key: "KEY_Enter", options: {}});
yield inspector.once("inspector-updated");
}
--- a/devtools/client/inspector/markup/test/browser_markup_load_01.js
+++ b/devtools/client/inspector/markup/test/browser_markup_load_01.js
@@ -65,14 +65,14 @@ add_task(function* () {
});
function* chooseWithInspectElementContextMenu(selector, tab) {
yield BrowserTestUtils.synthesizeMouseAtCenter(selector, {
type: "contextmenu",
button: 2
}, tab.linkedBrowser);
- yield EventUtils.synthesizeKey("Q", {});
+ yield EventUtils.sendString("Q");
}
function waitForLinkedBrowserEvent(tab, event) {
return BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, event, true);
}
--- a/devtools/client/inspector/markup/test/browser_markup_navigation.js
+++ b/devtools/client/inspector/markup/test/browser_markup_navigation.js
@@ -3,136 +3,110 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the markup-view nodes can be navigated to with the keyboard
const TEST_URL = URL_ROOT + "doc_markup_navigation.html";
const TEST_DATA = [
- ["pageup", "*doctype*"],
- ["down", "html"],
- ["down", "head"],
- ["down", "body"],
- ["down", "node0"],
- ["right", "node0"],
- ["down", "node1"],
- ["down", "node2"],
- ["down", "node3"],
- ["down", "*comment*"],
- ["down", "node4"],
- ["right", "node4"],
- ["down", "*text*"],
- ["down", "node5"],
- ["down", "*text*"],
- ["down", "node6"],
- ["down", "*text*"],
- ["down", "*comment*"],
- ["down", "node7"],
- ["right", "node7"],
- ["down", "*text*"],
- ["down", "node8"],
- ["left", "node7"],
- ["left", "node7"],
- ["right", "node7"],
- ["right", "*text*"],
- ["down", "node8"],
- ["down", "*text*"],
- ["down", "node9"],
- ["down", "*text*"],
- ["down", "node10"],
- ["down", "*text*"],
- ["down", "node11"],
- ["down", "*text*"],
- ["down", "node12"],
- ["right", "node12"],
- ["down", "*text*"],
- ["down", "node13"],
- ["down", "node14"],
- ["down", "node15"],
- ["down", "node15"],
- ["down", "node15"],
- ["up", "node14"],
- ["up", "node13"],
- ["up", "*text*"],
- ["up", "node12"],
- ["left", "node12"],
- ["down", "node14"],
- ["home", "*doctype*"],
- ["pagedown", "*text*"],
- ["down", "node5"],
- ["down", "*text*"],
- ["down", "node6"],
- ["down", "*text*"],
- ["down", "*comment*"],
- ["down", "node7"],
- ["left", "node7"],
- ["down", "*text*"],
- ["down", "node9"],
- ["down", "*text*"],
- ["down", "node10"],
- ["pageup", "*text*"],
- ["pageup", "*doctype*"],
- ["down", "html"],
- ["left", "html"],
- ["down", "head"]
+ ["KEY_PageUp", "*doctype*"],
+ ["KEY_ArrowDown", "html"],
+ ["KEY_ArrowDown", "head"],
+ ["KEY_ArrowDown", "body"],
+ ["KEY_ArrowDown", "node0"],
+ ["KEY_ArrowRight", "node0"],
+ ["KEY_ArrowDown", "node1"],
+ ["KEY_ArrowDown", "node2"],
+ ["KEY_ArrowDown", "node3"],
+ ["KEY_ArrowDown", "*comment*"],
+ ["KEY_ArrowDown", "node4"],
+ ["KEY_ArrowRight", "node4"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "node5"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "node6"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "*comment*"],
+ ["KEY_ArrowDown", "node7"],
+ ["KEY_ArrowRight", "node7"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "node8"],
+ ["KEY_ArrowLeft", "node7"],
+ ["KEY_ArrowLeft", "node7"],
+ ["KEY_ArrowRight", "node7"],
+ ["KEY_ArrowRight", "*text*"],
+ ["KEY_ArrowDown", "node8"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "node9"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "node10"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "node11"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "node12"],
+ ["KEY_ArrowRight", "node12"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "node13"],
+ ["KEY_ArrowDown", "node14"],
+ ["KEY_ArrowDown", "node15"],
+ ["KEY_ArrowDown", "node15"],
+ ["KEY_ArrowDown", "node15"],
+ ["KEY_ArrowUp", "node14"],
+ ["KEY_ArrowUp", "node13"],
+ ["KEY_ArrowUp", "*text*"],
+ ["KEY_ArrowUp", "node12"],
+ ["KEY_ArrowLeft", "node12"],
+ ["KEY_ArrowDown", "node14"],
+ ["KEY_Home", "*doctype*"],
+ ["KEY_PageDown", "*text*"],
+ ["KEY_ArrowDown", "node5"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "node6"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "*comment*"],
+ ["KEY_ArrowDown", "node7"],
+ ["KEY_ArrowLeft", "node7"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "node9"],
+ ["KEY_ArrowDown", "*text*"],
+ ["KEY_ArrowDown", "node10"],
+ ["KEY_PageUp", "*text*"],
+ ["KEY_PageUp", "*doctype*"],
+ ["KEY_ArrowDown", "html"],
+ ["KEY_ArrowLeft", "html"],
+ ["KEY_ArrowDown", "head"]
];
add_task(function* () {
let {inspector} = yield openInspectorForURL(TEST_URL);
info("Making sure the markup-view frame is focused");
inspector.markup._frame.focus();
info("Starting to iterate through the test data");
for (let [key, className] of TEST_DATA) {
info("Testing step: " + key + " to navigate to " + className);
- pressKey(key);
+ EventUtils.synthesizeKey(key);
info("Making sure markup-view children get updated");
yield waitForChildrenUpdated(inspector);
info("Checking the right node is selected");
checkSelectedNode(key, className, inspector);
}
// In theory, we should wait for the inspector-updated event at each iteration
// of the previous loop where we expect the current node to change (because
// changing the current node ends up refreshing the rule-view, breadcrumbs,
// ...), but this would make this test a *lot* slower. Instead, having a final
// catch-all event works too.
yield inspector.once("inspector-updated");
});
-function pressKey(key) {
- switch (key) {
- case "right":
- EventUtils.synthesizeKey("VK_RIGHT", {});
- break;
- case "down":
- EventUtils.synthesizeKey("VK_DOWN", {});
- break;
- case "left":
- EventUtils.synthesizeKey("VK_LEFT", {});
- break;
- case "up":
- EventUtils.synthesizeKey("VK_UP", {});
- break;
- case "pageup":
- EventUtils.synthesizeKey("VK_PAGE_UP", {});
- break;
- case "pagedown":
- EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
- break;
- case "home":
- EventUtils.synthesizeKey("VK_HOME", {});
- break;
- }
-}
-
function checkSelectedNode(key, className, inspector) {
let node = inspector.selection.nodeFront;
if (className == "*comment*") {
is(node.nodeType, Node.COMMENT_NODE,
"Found a comment after pressing " + key);
} else if (className == "*text*") {
is(node.nodeType, Node.TEXT_NODE,
--- a/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_03.js
+++ b/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_03.js
@@ -28,16 +28,16 @@ add_task(function* () {
let editor = yield focusNewRuleViewProperty(elementRuleEditor);
is(inplaceEditor(elementRuleEditor.newPropSpan), editor,
"Next focused editor should be the new property editor.");
EventUtils.sendString("background", view.styleWindow);
let onBlur = once(editor.input, "blur");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
yield onBlur;
is(elementRuleEditor.rule.textProps.length, 1,
"Should have canceled creating a new text property.");
is(view.styleDocument.activeElement, view.styleDocument.body,
"Correct element has focus");
});
--- a/devtools/client/inspector/rules/test/browser_rules_add-rule-edit-selector.js
+++ b/devtools/client/inspector/rules/test/browser_rules_add-rule-edit-selector.js
@@ -37,17 +37,17 @@ function* testEditSelector(view, name) {
info("Entering a new selector name and committing");
editor.value = name;
info("Waiting for rule view to update");
let onRuleViewChanged = once(view, "ruleview-changed");
info("Entering the commit key");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
is(view._elementStyle.rules.length, 3, "Should have 3 rules.");
ok(getRuleViewRule(view, name), "Rule with " + name + " selector exists.");
}
function* checkModifiedElement(view, name) {
is(view._elementStyle.rules.length, 2, "Should have 2 rules.");
--- a/devtools/client/inspector/rules/test/browser_rules_add-rule-then-property-edit-selector.js
+++ b/devtools/client/inspector/rules/test/browser_rules_add-rule-then-property-edit-selector.js
@@ -57,17 +57,17 @@ function* testEditSelector(view, name) {
info("Entering a new selector name: " + name);
editor.input.value = name;
info("Waiting for rule view to update");
let onRuleViewChanged = once(view, "ruleview-changed");
info("Entering the commit key");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
is(view._elementStyle.rules.length, 3, "Should have 3 rules.");
}
function* checkModifiedElement(view, name, index) {
is(view._elementStyle.rules.length, 2, "Should have 2 rules.");
ok(getRuleViewRule(view, name), "Rule with " + name + " selector exists.");
--- a/devtools/client/inspector/rules/test/browser_rules_add-rule-with-menu.js
+++ b/devtools/client/inspector/rules/test/browser_rules_add-rule-with-menu.js
@@ -33,10 +33,10 @@ function* addNewRuleFromContextMenu(insp
}
function* testNewRule(view) {
let ruleEditor = getRuleViewRuleEditor(view, 1);
let editor = ruleEditor.selectorText.ownerDocument.activeElement;
is(editor.value, "#testid", "Selector editor value is as expected");
info("Escaping from the selector field the change");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
}
--- a/devtools/client/inspector/rules/test/browser_rules_edit-property-computed.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-computed.js
@@ -48,17 +48,17 @@ function* editAndCheck(view) {
yield onPropertyChange;
info("Waiting for ruleview-refreshed after previewValue was applied.");
yield onRefreshAfterPreview;
let onBlur = once(editor.input, "blur");
info("Entering the commit key and finishing edit");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
info("Waiting for blur on the field");
yield onBlur;
info("Waiting for the style changes to be applied");
yield once(view, "ruleview-changed");
let computed = prop.computed;
--- a/devtools/client/inspector/rules/test/browser_rules_edit-property_08.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-property_08.js
@@ -46,12 +46,12 @@ add_task(function* () {
"rgb(255, 0, 0)");
is((yield getComputedStyleProperty("#testid", null, "color")),
"rgb(255, 255, 255)", "color is white");
// The value field is still focused. Blur it now and wait for the
// ruleview-changed event to avoid pending requests.
onRuleViewChanged = view.once("ruleview-changed");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
yield onRuleViewChanged;
});
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector-click-on-scrollbar.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector-click-on-scrollbar.js
@@ -65,17 +65,17 @@ add_task(function* () {
"The editor input should still be focused.");
info("Check a new value can still be committed in the editable field");
let newValue = ".testclass.a.b.c.d.e.f";
let onRuleViewChanged = once(view, "ruleview-changed");
info("Enter new value and commit.");
editor.input.value = newValue;
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
ok(getRuleViewRule(view, newValue), "Rule with '" + newValue + " 'exists.");
});
function* clickOnRuleviewScrollbar(view) {
let container = view.element.parentNode;
let onScroll = once(container, "scroll");
let rect = container.getBoundingClientRect();
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_01.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_01.js
@@ -42,17 +42,17 @@ function* testEditSelector(view, name) {
info("Entering a new selector name and committing");
editor.input.value = name;
info("Waiting for rule view to update");
let onRuleViewChanged = once(view, "ruleview-changed");
info("Entering the commit key");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
is(view._elementStyle.rules.length, 2, "Should have 2 rules.");
ok(getRuleViewRule(view, name), "Rule with " + name + " selector exists.");
ok(getRuleViewRuleEditor(view, 1).element.getAttribute("unmatched"),
"Rule with " + name + " does not match the current element.");
}
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_02.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_02.js
@@ -65,17 +65,17 @@ function* testEditSelector(view, name) {
info("Entering a new selector name: " + name);
editor.input.value = name;
info("Waiting for rule view to update");
let onRuleViewChanged = once(view, "ruleview-changed");
info("Entering the commit key");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
is(view._elementStyle.rules.length, 2, "Should have 2 rule.");
ok(getRuleViewRule(view, name), "Rule with " + name + " selector exists.");
let newRuleEditor = getRuleViewRuleEditor(view, 1) ||
getRuleViewRuleEditor(view, 1, 0);
ok(newRuleEditor.element.getAttribute("unmatched"),
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_03.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_03.js
@@ -32,17 +32,17 @@ function* testEditSelector(view, name) {
let editor = yield focusEditableField(view, ruleEditor.selectorText);
is(inplaceEditor(ruleEditor.selectorText), editor,
"The selector editor got focused");
info("Entering a new selector name and committing");
editor.input.value = name;
let onRuleViewChanged = once(view, "ruleview-invalid-selector");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
is(view._elementStyle.rules.length, 2, "Should have 2 rules.");
is(getRuleViewRule(view, name), undefined,
"Rule with " + name + " selector should not exist.");
ok(getRuleViewRule(view, ".testclass"),
"Rule with .testclass selector exists.");
}
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_04.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_04.js
@@ -54,16 +54,16 @@ function* testEditSelector(view, name) {
is(inplaceEditor(ruleEditor.selectorText), editor,
"The selector editor got focused");
info("Waiting for rule view to update");
let onToggled = view.once("ruleview-selectorhighlighter-toggled");
info("Entering a new selector name and committing");
editor.input.value = name;
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
let isVisible = yield onToggled;
ok(!view.highlighters.selectorHighlighterShown,
"The selectorHighlighterShown instance was removed");
ok(!isVisible, "The toggle event says the highlighter is not visible");
}
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_05.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_05.js
@@ -45,17 +45,17 @@ function* testEditSelector(view, name) {
info("Entering a new selector name and committing");
editor.input.value = name;
info("Waiting for rule view to update");
let onRuleViewChanged = once(view, "ruleview-changed");
info("Entering the commit key");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
is(view._elementStyle.rules.length, 2, "Should have 2 rules.");
ok(getRuleViewRule(view, name), "Rule with " + name + " selector exists.");
ok(getRuleViewRuleEditor(view, 1).element.getAttribute("unmatched"),
"Rule with " + name + " does not match the current element.");
// Escape the new property editor after editing the selector
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_06.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_06.js
@@ -27,17 +27,17 @@ add_task(function* () {
});
function* testEditClassSelector(view) {
let ruleEditor = getRuleViewRuleEditor(view, 1);
let editor = yield focusEditableField(view, ruleEditor.selectorText);
editor.input.value = "body";
let onRuleViewChanged = once(view, "ruleview-changed");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
// Get the new rule editor that replaced the original
ruleEditor = getRuleViewRuleEditor(view, 1);
let propEditor = ruleEditor.rule.textProps[0].editor;
info("Check that the correct rules are visible");
is(view._elementStyle.rules.length, 3, "Should have 3 rules.");
@@ -52,17 +52,17 @@ function* testEditClassSelector(view) {
}
function* testEditDivSelector(view) {
let ruleEditor = getRuleViewRuleEditor(view, 2);
let editor = yield focusEditableField(view, ruleEditor.selectorText);
editor.input.value = "asdf";
let onRuleViewChanged = once(view, "ruleview-changed");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
// Get the new rule editor that replaced the original
ruleEditor = getRuleViewRuleEditor(view, 2);
info("Check that the correct rules are visible");
is(view._elementStyle.rules.length, 3, "Should have 3 rules.");
ok(ruleEditor.element.getAttribute("unmatched"), "Rule editor is unmatched.");
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_07.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_07.js
@@ -41,17 +41,17 @@ function* testEditSelector(view, name) {
is(inplaceEditor(ruleEditor.selectorText), editor,
"The selector editor got focused");
info("Entering a new selector name and committing");
editor.input.value = name;
info("Entering the commit key");
let onRuleViewChanged = once(view, "ruleview-changed");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
// Get the new rule editor that replaced the original
ruleEditor = getRuleViewRuleEditor(view, 1);
let rule = ruleEditor.rule;
let textPropEditor = rule.textProps[0].editor;
is(view._elementStyle.rules.length, 3, "Should have 3 rules.");
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_08.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_08.js
@@ -35,17 +35,17 @@ add_task(function* () {
info("Entering a new selector name and committing");
editor.input.value = "pre";
info("Waiting for rule view to update");
let onRuleViewChanged = once(view, "ruleview-changed");
info("Entering the commit key");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
info("Re-focusing the selector name in the rule-view");
idRuleEditor = getRuleViewRuleEditor(view, 2);
editor = yield focusEditableField(view, idRuleEditor.selectorText);
is(view._elementStyle.rules.length, 2, "Should have 2 rules.");
ok(getRuleViewRule(view, "pre"), "Rule with pre selector exists.");
@@ -56,16 +56,16 @@ add_task(function* () {
// Now change it back.
info("Re-entering original selector name and committing");
editor.input.value = "span";
info("Waiting for rule view to update");
onRuleViewChanged = once(view, "ruleview-changed");
info("Entering the commit key");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
is(view._elementStyle.rules.length, 2, "Should have 2 rules.");
ok(getRuleViewRule(view, "span"), "Rule with span selector exists.");
is(getRuleViewRuleEditor(view, 2).element.getAttribute("unmatched"),
"false", "Rule with span matches the current element.");
});
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_09.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_09.js
@@ -46,26 +46,26 @@ function* testEditSelector(view, name) {
info("Entering a new selector name and committing");
editor.input.value = name;
info("Waiting for rule view to update");
let onRuleViewChanged = once(view, "ruleview-changed");
info("Entering the commit key");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
ok(getRuleViewRule(view, name), "Rule with " + name + " selector exists.");
ok(getRuleViewRuleEditor(view, 1).element.getAttribute("unmatched"),
"Rule with " + name + " does not match the current element.");
// Escape the new property editor after editing the selector
let onBlur = once(view.styleDocument.activeElement, "blur");
- EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow);
+ EventUtils.synthesizeKey("KEY_Escape", {}, view.styleWindow);
yield onBlur;
}
function* testAddImportantProperty(view) {
info("Test creating a new property with !important");
let textProp = yield addProperty(view, 1, "color", "red !important");
is(textProp.value, "red", "Text prop should have been changed.");
@@ -92,19 +92,19 @@ function* testAddMatchedRule(view, name)
info("Entering a new selector name and committing");
editor.input.value = name;
info("Waiting for rule view to update");
let onRuleViewChanged = once(view, "ruleview-changed");
info("Entering the commit key");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
is(getRuleViewRuleEditor(view, 1).element.getAttribute("unmatched"), "false",
"Rule with " + name + " does match the current element.");
// Escape the new property editor after editing the selector
let onBlur = once(view.styleDocument.activeElement, "blur");
- EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow);
+ EventUtils.synthesizeKey("KEY_Escape", {}, view.styleWindow);
yield onBlur;
}
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_10.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_10.js
@@ -31,22 +31,22 @@ add_task(function* () {
});
function* testEditSelector(view) {
let ruleEditor = getRuleViewRuleEditor(view, 1);
let editor = yield focusEditableField(view, ruleEditor.selectorText);
editor.input.value = "#testid span";
let onRuleViewChanged = once(view, "ruleview-changed");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
// Escape the new property editor after editing the selector
let onBlur = once(view.styleDocument.activeElement, "blur");
- EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow);
+ EventUtils.synthesizeKey("KEY_Escape", {}, view.styleWindow);
yield onBlur;
// Get the new rule editor that replaced the original
ruleEditor = getRuleViewRuleEditor(view, 1);
info("Check that the correct rules are visible");
is(view._elementStyle.rules.length, 3, "Should have 3 rules.");
is(ruleEditor.element.getAttribute("unmatched"), "false", "Rule editor is matched.");
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_11.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_11.js
@@ -34,22 +34,22 @@ add_task(function* () {
});
function* testEditSelector(view) {
let ruleEditor = getRuleViewRuleEditor(view, 1);
let editor = yield focusEditableField(view, ruleEditor.selectorText);
editor.input.value = ".pickme";
let onRuleViewChanged = once(view, "ruleview-changed");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
// Escape the new property editor after editing the selector
let onBlur = once(view.styleDocument.activeElement, "blur");
- EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow);
+ EventUtils.synthesizeKey("KEY_Escape", {}, view.styleWindow);
yield onBlur;
// Get the new rule editor that replaced the original
ruleEditor = getRuleViewRuleEditor(view, 1);
info("Check that the correct rules are visible");
is(view._elementStyle.rules.length, 4, "Should have 4 rules.");
is(ruleEditor.element.getAttribute("unmatched"), "false", "Rule editor is matched.");
--- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_12.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_12.js
@@ -16,22 +16,22 @@ add_task(function* () {
info("Focus the selector in the rule-view");
let ruleEditor = getRuleViewRuleEditor(view, 1);
let editor = yield focusEditableField(view, ruleEditor.selectorText);
info("Change the selector to something else");
editor.input.value = "div";
let onRuleViewChanged = once(view, "ruleview-changed");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
info("Escape the new property editor after editing the selector");
let onBlur = once(view.styleDocument.activeElement, "blur");
- EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow);
+ EventUtils.synthesizeKey("KEY_Escape", {}, view.styleWindow);
yield onBlur;
info("Check the rules are still displayed correctly");
is(view._elementStyle.rules.length, 3, "The element still has 3 rules.");
ruleEditor = getRuleViewRuleEditor(view, 1);
is(ruleEditor.element.getAttribute("unmatched"), "false", "Rule editor is matched.");
is(ruleEditor.selectorText.textContent, "div", "The new selector is correct");
--- a/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_01.js
+++ b/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_01.js
@@ -21,18 +21,18 @@ const TEST_URI = `
</style>
<div id='testid'>Styled Node</div>
`;
add_task(function* () {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openRuleView();
yield selectNode("#testid", inspector);
- yield testEditableFieldFocus(inspector, view, "VK_RETURN");
- yield testEditableFieldFocus(inspector, view, "VK_TAB");
+ yield testEditableFieldFocus(inspector, view, "KEY_Enter");
+ yield testEditableFieldFocus(inspector, view, "KEY_Tab");
});
function* testEditableFieldFocus(inspector, view, commitKey) {
info("Click on the selector of the inline style ('element')");
let ruleEditor = getRuleViewRuleEditor(view, 0);
let onFocus = once(ruleEditor.element, "focus", true);
ruleEditor.selectorText.click();
yield onFocus;
@@ -74,17 +74,17 @@ function* testEditableFieldFocus(inspect
ruleEditor = getRuleViewRuleEditor(view, 2);
yield focusNextEditableField(view, ruleEditor, commitKey);
assertEditor(view, ruleEditor.selectorText,
"Focus should have moved to the next rule selector");
info("Blur the selector field");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
}
function* focusNextEditableField(view, ruleEditor, commitKey) {
let onFocus = once(ruleEditor.element, "focus", true);
EventUtils.synthesizeKey(commitKey, {}, view.styleWindow);
yield onFocus;
}
--- a/devtools/client/inspector/rules/test/browser_rules_livepreview.js
+++ b/devtools/client/inspector/rules/test/browser_rules_livepreview.js
@@ -53,19 +53,19 @@ function* testLivePreviewData(data, rule
info("Entering value in the editor: " + data.value);
let onPreviewDone = ruleView.once("ruleview-changed");
EventUtils.sendString(data.value, ruleView.styleWindow);
ruleView.debounce.flush();
yield onPreviewDone;
let onValueDone = ruleView.once("ruleview-changed");
if (data.escape) {
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
} else {
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
}
yield onValueDone;
// While the editor is still focused in, the display should have
// changed already
is((yield getComputedStyleProperty(selector, null, "display")),
data.expected,
"Element should be previewed as " + data.expected);
--- a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_06.js
+++ b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_06.js
@@ -33,17 +33,17 @@ function* testMarkOverridden(inspector,
info("Focusing an existing selector name in the rule-view");
let editor = yield focusEditableField(view, ruleEditor.selectorText);
info("Entering a new selector name and committing");
editor.input.value = "div[class]";
let onRuleViewChanged = once(view, "ruleview-changed");
info("Entering the commit key");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
view.searchField.focus();
checkProperties(rule);
}
// A helper to perform a repeated set of checks.
function checkProperties(rule) {
--- a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_04.js
+++ b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_04.js
@@ -40,17 +40,17 @@ function* testModifyPropertyValueFilter(
"margin text property is not highlighted.");
ok(rule.textProps[1].editor.container.classList
.contains("ruleview-highlight"),
"top text property is correctly highlighted.");
let onBlur = once(editor.input, "blur");
let onModification = view.once("ruleview-changed");
EventUtils.sendString("4px 0px", view.styleWindow);
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onBlur;
yield onModification;
ok(propEditor.container.classList.contains("ruleview-highlight"),
"margin text property is correctly highlighted.");
ok(!computed.hasAttribute("filter-open"), "margin computed list is closed.");
ok(!computed.children[0].classList.contains("ruleview-highlight"),
"margin-top computed property is not highlighted.");
--- a/devtools/client/inspector/rules/test/browser_rules_search-filter_07.js
+++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_07.js
@@ -42,21 +42,21 @@ add_task(function* () {
.contains("ruleview-highlight"),
"height text property is correctly highlighted.");
info("Change the width property to margin-left");
EventUtils.sendString("margin-left", view.styleWindow);
info("Submit the change");
let onRuleViewChanged = view.once("ruleview-changed");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
ok(propEditor.container.classList.contains("ruleview-highlight"),
"margin-left text property is correctly highlighted.");
// After pressing return on the property name, the value has been focused
// automatically. Blur it now and wait for the rule-view to refresh to avoid
// pending requests.
onRuleViewChanged = view.once("ruleview-changed");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
yield onRuleViewChanged;
});
--- a/devtools/client/inspector/rules/test/browser_rules_search-filter_08.js
+++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_08.js
@@ -40,14 +40,14 @@ add_task(function* () {
.contains("ruleview-highlight"),
"width text property is correctly highlighted.");
ok(!propEditor.container.classList.contains("ruleview-highlight"),
"height text property is not highlighted.");
info("Change the height property value to 100%");
let onRuleViewChanged = view.once("ruleview-changed");
EventUtils.sendString("100%", view.styleWindow);
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
ok(propEditor.container.classList.contains("ruleview-highlight"),
"height text property is correctly highlighted.");
});
--- a/devtools/client/inspector/rules/test/head.js
+++ b/devtools/client/inspector/rules/test/head.js
@@ -439,17 +439,17 @@ function* addNewRuleAndDismissEditor(ins
info("Getting the new rule at index " + expectedIndex);
let ruleEditor = getRuleViewRuleEditor(view, expectedIndex);
let editor = ruleEditor.selectorText.ownerDocument.activeElement;
is(editor.value, expectedSelector,
"The editor for the new selector has the correct value: " + expectedSelector);
info("Pressing escape to leave the editor");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
is(ruleEditor.selectorText.textContent, expectedSelector,
"The new selector has the correct text: " + expectedSelector);
}
/**
* Simulate a sequence of non-character keys (return, escape, tab) and wait for
* a given element to receive the focus.
--- a/devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-color_02.js
+++ b/devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-color_02.js
@@ -37,17 +37,17 @@ function* testCopyToClipboard(inspector,
let menuitemCopyColor = allMenuItems.find(item => item.label ===
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copyColor"));
ok(menuitemCopyColor.visible, "Copy color is visible");
yield waitForClipboardPromise(() => menuitemCopyColor.click(),
"#123ABC");
- EventUtils.synthesizeKey("VK_ESCAPE", { });
+ EventUtils.synthesizeKey("KEY_Escape");
}
function* testManualEdit(inspector, view) {
info("Testing manually edited colors");
yield selectNode("div", inspector);
let {valueSpan} = getRuleViewProperty(view, "div", "color");
--- a/devtools/client/inspector/test/browser_inspector_breadcrumbs_keybinding.js
+++ b/devtools/client/inspector/test/browser_inspector_breadcrumbs_keybinding.js
@@ -3,37 +3,37 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the breadcrumbs keybindings work.
const TEST_URI = URL_ROOT + "doc_inspector_breadcrumbs.html";
const TEST_DATA = [{
desc: "Pressing left should select the parent <body>",
- key: "VK_LEFT",
+ key: "KEY_ArrowLeft",
newSelection: "body"
}, {
desc: "Pressing left again should select the parent <html>",
- key: "VK_LEFT",
+ key: "KEY_ArrowLeft",
newSelection: "html"
}, {
desc: "Pressing left again should stay on <html>, it's the first element",
- key: "VK_LEFT",
+ key: "KEY_ArrowLeft",
newSelection: "html"
}, {
desc: "Pressing right should go to <body>",
- key: "VK_RIGHT",
+ key: "KEY_ArrowRight",
newSelection: "body"
}, {
desc: "Pressing right again should go to #i2",
- key: "VK_RIGHT",
+ key: "KEY_ArrowRight",
newSelection: "#i2"
}, {
desc: "Pressing right again should stay on #i2, it's the last element",
- key: "VK_RIGHT",
+ key: "KEY_ArrowRight",
newSelection: "#i2"
}];
add_task(function* () {
let {inspector} = yield openInspectorForURL(TEST_URI);
info("Selecting the test node");
yield selectNode("#i2", inspector);
@@ -51,17 +51,17 @@ add_task(function* () {
// If the selection will change, wait for the breadcrumb to update,
// otherwise continue.
let onUpdated = null;
if (newSelection !== currentSelection) {
info("Expecting a new node to be selected");
onUpdated = inspector.once("breadcrumbs-updated");
}
- EventUtils.synthesizeKey(key, {});
+ EventUtils.synthesizeKey(key);
yield onUpdated;
let newNodeFront = yield getNodeFront(newSelection, inspector);
is(newNodeFront, inspector.selection.nodeFront,
"The current selection is correct");
is(container.getAttribute("aria-activedescendant"),
container.querySelector("button[checked]").id,
"aria-activedescendant is set correctly");
--- a/devtools/client/inspector/test/browser_inspector_delete-selected-node-02.js
+++ b/devtools/client/inspector/test/browser_inspector_delete-selected-node-02.js
@@ -78,17 +78,17 @@ add_task(function* () {
let expectedCrumbs = ["html", "body", "div#deleteToMakeSingleTextNode"];
yield assertNodeSelectedAndCrumbsUpdated(expectedCrumbs,
Node.TEXT_NODE);
// Delete node with key, as cannot delete text node with
// context menu at this time.
inspector.markup._frame.focus();
- EventUtils.synthesizeKey("VK_DELETE", {});
+ EventUtils.synthesizeKey("KEY_Delete");
yield inspector.once("inspector-updated");
expectedCrumbs = ["html", "body", "div#deleteToMakeSingleTextNode"];
yield assertNodeSelectedAndCrumbsUpdated(expectedCrumbs,
Node.ELEMENT_NODE);
}
function* deleteNodeWithContextMenu(selector) {
@@ -103,17 +103,17 @@ add_task(function* () {
});
let menuItem = allMenuItems.find(item => item.id === "node-menu-delete");
info("Clicking 'Delete Node' in the context menu.");
is(menuItem.disabled, false, "delete menu item is enabled");
menuItem.click();
// close the open context menu
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
info("Waiting for inspector to update.");
yield inspector.once("inspector-updated");
// Since the mutations are sent asynchronously from the server, the
// inspector-updated event triggered by the deletion might happen before
// the mutation is received and the element is removed from the
// breadcrumbs. See bug 1284125.
--- a/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-clipboard.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-clipboard.js
@@ -20,17 +20,17 @@ add_task(function* () {
info("Show the eyedropper with the copyOnSelect option");
yield show("html", {copyOnSelect: true});
info("Make sure to wait until the eyedropper is done taking a screenshot of the page");
yield waitForElementAttributeSet("root", "drawn", helper);
yield waitForClipboardPromise(() => {
info("Activate the eyedropper so the background color is copied");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
}, "#ff0000");
ok(true, "The clipboard contains the right value");
yield waitForElementAttributeRemoved("root", "drawn", helper);
yield waitForElementAttributeSet("root", "hidden", helper);
ok(true, "The eyedropper is now hidden");
--- a/devtools/client/inspector/test/browser_inspector_keyboard-shortcuts.js
+++ b/devtools/client/inspector/test/browser_inspector_keyboard-shortcuts.js
@@ -7,22 +7,22 @@
// intended.
const TEST_URI = "data:text/html;charset=utf-8," +
"<html><head><title>Test for the highlighter keybindings</title></head>" +
"<body><p><strong>Greetings, earthlings!</strong>" +
" I come in peace.</p></body></html>";
const TEST_DATA = [
- { key: "VK_LEFT", selectedNode: "p" },
- { key: "VK_LEFT", selectedNode: "body" },
- { key: "VK_LEFT", selectedNode: "html" },
- { key: "VK_RIGHT", selectedNode: "body" },
- { key: "VK_RIGHT", selectedNode: "p" },
- { key: "VK_RIGHT", selectedNode: "strong" },
+ { key: "KEY_ArrowLeft", selectedNode: "p" },
+ { key: "KEY_ArrowLeft", selectedNode: "body" },
+ { key: "KEY_ArrowLeft", selectedNode: "html" },
+ { key: "KEY_ArrowRight", selectedNode: "body" },
+ { key: "KEY_ArrowRight", selectedNode: "p" },
+ { key: "KEY_ArrowRight", selectedNode: "strong" },
];
add_task(function* () {
let { inspector } = yield openInspectorForURL(TEST_URI);
info("Selecting the deepest element to start with");
yield selectNode("strong", inspector);
@@ -33,16 +33,16 @@ add_task(function* () {
info("Focusing the currently active breadcrumb button");
let bc = inspector.breadcrumbs;
bc.nodeHierarchy[bc.currentIndex].button.focus();
for (let { key, selectedNode } of TEST_DATA) {
info("Pressing " + key + " to select " + selectedNode);
let updated = inspector.once("inspector-updated");
- EventUtils.synthesizeKey(key, {});
+ EventUtils.synthesizeKey(key);
yield updated;
let selectedNodeFront = yield getNodeFront(selectedNode, inspector);
is(inspector.selection.nodeFront, selectedNodeFront,
selectedNode + " is selected.");
}
});
--- a/devtools/client/inspector/test/browser_inspector_menu-05-attribute-items.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-05-attribute-items.js
@@ -17,19 +17,19 @@ add_task(function* () {
yield testEditAttribute();
yield testRemoveAttribute();
function* testAddAttribute() {
info("Triggering 'Add Attribute' and waiting for mutation to occur");
let addAttribute = getMenuItem("node-menu-add-attribute");
addAttribute.click();
- EventUtils.synthesizeKey('class="u-hidden"', {});
+ EventUtils.sendString('class="u-hidden"');
let onMutation = inspector.once("markupmutation");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onMutation;
let hasAttribute = testActor.hasNode("#attributes.u-hidden");
ok(hasAttribute, "attribute was successfully added");
}
function* testCopyAttributeValue() {
info("Testing 'Copy Attribute Value' and waiting for clipboard promise to resolve");
@@ -67,19 +67,19 @@ add_task(function* () {
let editAttribute = getMenuItem("node-menu-edit-attribute");
info("Triggering 'Edit Attribute' and waiting for mutation to occur");
inspector.nodeMenuTriggerInfo = {
type: "attribute",
name: "data-edit"
};
editAttribute.click();
- EventUtils.synthesizeKey("data-edit='edited'", {});
+ EventUtils.sendString("data-edit='edited'");
let onMutation = inspector.once("markupmutation");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onMutation;
let isAttributeChanged =
yield testActor.hasNode("#attributes[data-edit='edited']");
ok(isAttributeChanged, "attribute was successfully edited");
}
function* testRemoveAttribute() {
@@ -101,12 +101,12 @@ add_task(function* () {
function getMenuItem(id) {
let allMenuItems = openContextMenuAndGetAllItems(inspector, {
target: getContainerForSelector("#attributes", inspector).tagLine,
});
let menuItem = allMenuItems.find(i => i.id === id);
ok(menuItem, "Menu item '" + id + "' found");
// Close the menu so synthesizing future keys won't select menu items.
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
return menuItem;
}
});
--- a/devtools/client/netmonitor/test/browser_net_filter-autocomplete.js
+++ b/devtools/client/netmonitor/test/browser_net_filter-autocomplete.js
@@ -53,75 +53,75 @@ add_task(async function () {
EventUtils.synthesizeMouseAtCenter(
document.querySelector(".devtools-filterinput"), {}, window);
// Empty Mouse click should keep autocomplete hidden
ok(!document.querySelector(".devtools-autocomplete-popup"),
"Autocomplete Popup still hidden");
document.querySelector(".devtools-filterinput").focus();
// Typing a char should invoke a autocomplete
- EventUtils.synthesizeKey("s", {});
+ EventUtils.sendString("s");
ok(document.querySelector(".devtools-autocomplete-popup"),
"Autocomplete Popup Created");
testAutocompleteContents([
"scheme:",
"set-cookie-domain:",
"set-cookie-name:",
"set-cookie-value:",
"size:",
"status-code:",
], document);
- EventUtils.synthesizeKey("c", {});
+ EventUtils.sendString("c");
testAutocompleteContents(["scheme:"], document);
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
// Tab selection should hide autocomplete
ok(document.querySelector(".devtools-autocomplete-popup"),
"Autocomplete Popup alive with content values");
testAutocompleteContents(["scheme:http"], document);
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
is(document.querySelector(".devtools-filterinput").value,
"scheme:http", "Value correctly set after Enter");
ok(!document.querySelector(".devtools-autocomplete-popup"),
"Autocomplete Popup hidden after keyboard Enter key");
// Space separated tokens
// The last token where autocomplete is availabe shall generate the popup
- EventUtils.synthesizeKey(" p", {});
+ EventUtils.sendString(" p");
testAutocompleteContents(["protocol:"], document);
// The new value of the text box should be previousTokens + latest value selected
// First return selects "protocol:"
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
// Second return selects "protocol:HTTP/1.1"
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
is(document.querySelector(".devtools-filterinput").value,
"scheme:http protocol:HTTP/1.1",
"Tokenized click generates correct value in input box");
// Explicitly type in `flag:` renders autocomplete with values
- EventUtils.synthesizeKey(" status-code:", {});
+ EventUtils.sendString(" status-code:");
testAutocompleteContents(["status-code:200", "status-code:304"], document);
// Typing the exact value closes autocomplete
- EventUtils.synthesizeKey("304", {});
+ EventUtils.sendString("304");
ok(!document.querySelector(".devtools-autocomplete-popup"),
"Typing the exact value closes autocomplete");
// Check if mime-type has been correctly parsed out and values also get autocomplete
- EventUtils.synthesizeKey(" mime-type:text", {});
+ EventUtils.sendString(" mime-type:text");
testAutocompleteContents([
"mime-type:text/css",
"mime-type:text/html",
"mime-type:text/plain"
], document);
// The negative filter flags
- EventUtils.synthesizeKey(" -", {});
+ EventUtils.sendString(" -");
testAutocompleteContents([
"-cause:",
"-domain:",
"-has-response-header:",
"-is:",
"-larger-than:",
"-method:",
"-mime-type:",
@@ -134,13 +134,13 @@ add_task(async function () {
"-set-cookie-value:",
"-size:",
"-status-code:",
"-transferred-larger-than:",
"-transferred:",
], document);
// Autocomplete for negative filtering
- EventUtils.synthesizeKey("is:", {});
+ EventUtils.sendString("is:");
testAutocompleteContents(["-is:cached", "-is:from-cache", "-is:running"], document);
await teardown(monitor);
});
--- a/devtools/client/responsive.html/test/browser/browser_device_width.js
+++ b/devtools/client/responsive.html/test/browser/browser_device_width.js
@@ -40,38 +40,38 @@ async function setViewportSizeWithInputK
await resized;
let dimensions = ui.toolWindow.document.querySelectorAll(".viewport-dimension-input");
// Increase width value to 420 by using the Up arrow key
resized = waitForViewportResizeTo(ui, 420, height);
dimensions[0].focus();
for (let i = 1; i <= 100; i++) {
- EventUtils.synthesizeKey("KEY_ArrowUp", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
}
await resized;
// Resetting width value back to 320 using `Shift + Down` arrow
resized = waitForViewportResizeTo(ui, width, height);
dimensions[0].focus();
for (let i = 1; i <= 10; i++) {
EventUtils.synthesizeKey("KEY_ArrowDown", {shiftKey: true});
}
await resized;
// Increase height value to 600 by using `PageUp + Shift` key
resized = waitForViewportResizeTo(ui, width, 600);
dimensions[1].focus();
- EventUtils.synthesizeKey("VK_PAGE_UP", {shiftKey: true});
+ EventUtils.synthesizeKey("KEY_PageUp", {shiftKey: true});
await resized;
// Resetting height value back to 500 by using `PageDown + Shift` key
resized = waitForViewportResizeTo(ui, width, height);
dimensions[1].focus();
- EventUtils.synthesizeKey("VK_PAGE_DOWN", {shiftKey: true});
+ EventUtils.synthesizeKey("KEY_PageDown", {shiftKey: true});
await resized;
}
async function doInitialChecks(ui) {
let { innerWidth, matchesMedia } = await grabContentInfo(ui);
is(innerWidth, 110, "initial width should be 110px");
ok(!matchesMedia, "media query shouldn't match.");
}
--- a/devtools/client/responsive.html/test/browser/browser_toolbox_rule_view.js
+++ b/devtools/client/responsive.html/test/browser/browser_toolbox_rule_view.js
@@ -58,17 +58,17 @@ async function testGrow(ruleView, ui, ma
is(numberOfRules(ruleView), 2, "Should have two rules after growing.");
}
async function testEscapeOpensSplitConsole(inspector) {
ok(!inspector._toolbox._splitConsole, "Console is not split.");
info("Press escape");
let onSplit = inspector._toolbox.once("split-console");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
await onSplit;
ok(inspector._toolbox._splitConsole, "Console is split after pressing ESC.");
}
function numberOfRules(ruleView) {
return ruleView.element.querySelectorAll(".ruleview-code").length;
}
--- a/devtools/client/shared/components/test/mochitest/test_searchbox-with-autocomplete.html
+++ b/devtools/client/shared/components/test/mochitest/test_searchbox-with-autocomplete.html
@@ -114,89 +114,89 @@ window.onload = async function () {
ok(!$(".devtools-autocomplete-popup"), "Autocomplete list removed from DOM");
}
async function testKeyEventsWithAutocomplete() {
// Clear the initial input
$(".devtools-searchinput").focus();
// ArrowDown
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
await forceRender(component);
is(refs.autocomplete.state.selectedIndex, 0, "selectedIndex is 0");
ok($(".devtools-autocomplete-listbox .autocomplete-item:nth-child(1)")
.className.includes("autocomplete-selected"),
"Selection class applied");
// ArrowUp should roll back to the bottom of the list
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
await forceRender(component);
is(refs.autocomplete.state.selectedIndex, 6, "ArrowUp works");
// PageDown should take -5 places up
- synthesizeKey("VK_PAGE_UP", {});
+ synthesizeKey("KEY_PageUp");
await forceRender(component);
is(refs.autocomplete.state.selectedIndex, 1, "PageUp works");
// PageDown should take +5 places down
- synthesizeKey("VK_PAGE_DOWN", {});
+ synthesizeKey("KEY_PageDown");
await forceRender(component);
is(refs.autocomplete.state.selectedIndex, 6, "PageDown works");
// Home should take to the top of the list
- synthesizeKey("VK_HOME", {});
+ synthesizeKey("KEY_Home");
await forceRender(component);
is(refs.autocomplete.state.selectedIndex, 0, "Home works");
// End should take to the bottom of the list
- synthesizeKey("VK_END", {});
+ synthesizeKey("KEY_End");
await forceRender(component);
is(refs.autocomplete.state.selectedIndex, 6, "End works");
// Key down in existing state should rollover to the top
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
await forceRender(component);
// Tab should select the component and hide popup
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
await forceRender(component);
is(component.state.value, "ABC", "Tab hit selects the item");
ok(!$(".devtools-autocomplete-popup"), "Tab hit hides the popup");
// Activate popup by removing a key
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
await forceRender(component);
ok($(".devtools-autocomplete-popup"), "Popup is up");
compareAutocompleteList($(".devtools-autocomplete-listbox"), ["ABC", "abc"]);
// Enter key selection
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
await forceRender(component);
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
is(component.state.value, "abc", "Enter selection");
ok(!$(".devtools-autocomplete-popup"), "Enter/Return hides the popup");
// Escape should remove the autocomplete component
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
await forceRender(component);
- synthesizeKey("VK_ESCAPE", {});
+ synthesizeKey("KEY_Escape");
await forceRender(component);
ok(!$(".devtools-autocomplete-popup"),
"Autocomplete list removed from DOM on Escape");
}
async function testMouseEventsWithAutocomplete() {
$(".devtools-searchinput").focus();
await setState(component, {
value: "",
focused: true,
});
await forceRender(component);
// ArrowDown
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
await forceRender(component);
synthesizeMouseAtCenter($(".devtools-searchinput"), {}, window);
await forceRender(component);
is(component.state.focused, true, "Component should now be focused");
sendString("pq");
await forceRender(component);
synthesizeMouseAtCenter(
--- a/devtools/client/shared/webpack/shims/test/test_clipboard.html
+++ b/devtools/client/shared/webpack/shims/test/test_clipboard.html
@@ -49,17 +49,17 @@ async function pre_do_tests() {
function do_tests() {
let elt = document.querySelector("#key");
elt.addEventListener("keydown", doCopy);
// Set the clipboard to something other than what we expect.
SpecialPowers.clipboardCopyString("snowy owl");
elt.focus();
- synthesizeKey("x", {});
+ sendString("x");
is(SpecialPowers.getClipboardData("text/unicode"), RESULT, "clipboard copying worked");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
--- a/devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js
+++ b/devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js
@@ -8,18 +8,18 @@
add_task(function* () {
yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cookies.html");
showAllColumns(true);
showColumn("uniqueKey", false);
let id = getCookieId("test4", "test1.example.org", "/browser");
yield startCellEdit(id, "name");
- yield typeWithTerminator("test6", "VK_TAB");
- yield typeWithTerminator(".example.org", "VK_TAB");
- yield typeWithTerminator("/", "VK_TAB");
- yield typeWithTerminator("Tue, 25 Dec 2040 12:00:00 GMT", "VK_TAB");
- yield typeWithTerminator("test6value", "VK_TAB");
- yield typeWithTerminator("false", "VK_TAB");
- yield typeWithTerminator("false", "VK_TAB");
+ yield typeWithTerminator("test6", "KEY_Tab");
+ yield typeWithTerminator(".example.org", "KEY_Tab");
+ yield typeWithTerminator("/", "KEY_Tab");
+ yield typeWithTerminator("Tue, 25 Dec 2040 12:00:00 GMT", "KEY_Tab");
+ yield typeWithTerminator("test6value", "KEY_Tab");
+ yield typeWithTerminator("false", "KEY_Tab");
+ yield typeWithTerminator("false", "KEY_Tab");
yield finishTests();
});
--- a/devtools/client/storage/test/head.js
+++ b/devtools/client/storage/test/head.js
@@ -704,17 +704,17 @@ function getCellValue(id, column) {
* The uniqueId of the changed row.
*/
function* editCell(id, column, newValue, validate = true) {
let row = getRowCells(id, true);
let editableFieldsEngine = gUI.table._editableFieldsEngine;
editableFieldsEngine.edit(row[column]);
- yield typeWithTerminator(newValue, "VK_RETURN", validate);
+ yield typeWithTerminator(newValue, "KEY_Enter", validate);
}
/**
* Begin edit mode for a cell.
*
* @param {String} id
* The uniqueId of the row.
* @param {String} column
@@ -803,17 +803,17 @@ function showAllColumns(state) {
/**
* Type a string in the currently selected editor and then wait for the row to
* be updated.
*
* @param {String} str
* The string to type.
* @param {String} terminator
- * The terminating key e.g. VK_RETURN or VK_TAB
+ * The terminating key e.g. KEY_Enter or KEY_Tab
* @param {Boolean} validate
* Validate result? Default true.
*/
function* typeWithTerminator(str, terminator, validate = true) {
let editableFieldsEngine = gUI.table._editableFieldsEngine;
let textbox = editableFieldsEngine.textbox;
let colName = textbox.closest(".table-widget-column").id;
@@ -822,17 +822,17 @@ function* typeWithTerminator(str, termin
if (!changeExpected) {
return editableFieldsEngine.currentTarget.getAttribute("data-id");
}
info("Typing " + str);
EventUtils.sendString(str);
info("Pressing " + terminator);
- EventUtils.synthesizeKey(terminator, {});
+ EventUtils.synthesizeKey(terminator);
if (validate) {
info("Validating results... waiting for ROW_EDIT event.");
let uniqueId = yield gUI.table.once(TableWidget.EVENTS.ROW_EDIT);
checkCell(uniqueId, colName, str);
return uniqueId;
}
--- a/devtools/client/styleeditor/test/browser_styleeditor_syncEditSelector.js
+++ b/devtools/client/styleeditor/test/browser_styleeditor_syncEditSelector.js
@@ -23,17 +23,17 @@ add_task(function* () {
yield addTab(TESTCASE_URI);
let { inspector, view } = yield openRuleView();
yield selectNode("#testid", inspector);
let ruleEditor = getRuleViewRuleEditor(view, 1);
let editor = yield focusEditableField(view, ruleEditor.selectorText);
editor.input.value = "#testid, span";
let onRuleViewChanged = once(view, "ruleview-changed");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield onRuleViewChanged;
let { ui } = yield openStyleEditor();
editor = yield ui.editors[0].getSourceEditor();
let text = editor.sourceEditor.getText();
is(text, expectedText, "selector edits are synced");
});
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_accessibility.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_accessibility.js
@@ -32,17 +32,17 @@ add_task(async function () {
ok(wasBlurred, "jsterm input received a blur event before received back the focus");
wasFocused = true;
}, {
once: true
});
info("Close the autocomplete popup by simulating a TAB key event");
let onPopupClosed = jsterm.autocompletePopup.once("popup-closed");
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
info("Wait for the autocomplete popup to be closed");
await onPopupClosed;
ok(wasFocused, "jsterm input received a focus event");
});
async function autocomplete(jsterm, value) {
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_add_edited_input_to_history.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_add_edited_input_to_history.js
@@ -20,36 +20,36 @@ function testEditedInputHistory(hud) {
let jsterm = hud.jsterm;
let inputNode = jsterm.inputNode;
ok(!jsterm.getInputValue(), "jsterm.getInputValue() is empty");
is(inputNode.selectionStart, 0);
is(inputNode.selectionEnd, 0);
jsterm.setInputValue('"first item"');
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), '"first item"', "null test history up");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), '"first item"', "null test history down");
jsterm.execute();
is(jsterm.getInputValue(), "", "cleared input line after submit");
jsterm.setInputValue('"editing input 1"');
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), '"first item"', "test history up");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), '"editing input 1"',
"test history down restores in-progress input");
jsterm.setInputValue('"second item"');
jsterm.execute();
jsterm.setInputValue('"editing input 2"');
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), '"second item"', "test history up");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), '"first item"', "test history up");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), '"second item"', "test history down");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), '"editing input 2"',
"test history down restores new in-progress input again");
}
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_array_no_index.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_array_no_index.js
@@ -23,21 +23,21 @@ add_task(async function () {
completeNode,
inputNode,
} = jsterm;
let onPopUpOpen = popup.once("popup-opened");
info("wait for popup to show");
jsterm.setInputValue("foo");
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString(".");
await onPopUpOpen;
let popupItems = popup.getItems().map(e => e.label);
is(popupItems.includes("0"), false, "Completing on an array doesn't show numbers.");
info("press Escape to close the popup");
const onPopupClose = popup.once("popup-closed");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
await onPopupClose;
});
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_crossdomain_iframe.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_crossdomain_iframe.js
@@ -15,22 +15,22 @@ add_task(async function () {
const onParentTitle = waitForMessage(hud, "iframe parent");
jsterm.execute("document.title");
await onParentTitle;
ok(true, "root document's title is accessible");
// Make sure we don't throw when trying to autocomplete
let autocompleteUpdated = hud.jsterm.once("autocomplete-updated");
jsterm.setInputValue("window[0].document");
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString(".");
await autocompleteUpdated;
hud.jsterm.setInputValue("window[0].document.title");
const onPermissionDeniedMessage = waitForMessage(hud, "Permission denied");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
const permissionDenied = await onPermissionDeniedMessage;
ok(permissionDenied.node.classList.contains("error"),
"A message error is shown when trying to inspect window[0]");
const onParentLocation = waitForMessage(hud, "test-iframe-parent.html");
hud.jsterm.execute("window.location");
await onParentLocation;
ok(true, "root document's location is accessible");
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_escape_key.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_escape_key.js
@@ -31,25 +31,25 @@ add_task(async function () {
completeNode,
inputNode,
} = jsterm;
let onPopUpOpen = popup.once("popup-opened");
info("wait for completion: window.foo.");
jsterm.setInputValue("window.foo");
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString(".");
await onPopUpOpen;
ok(popup.isOpen, "popup is open");
ok(popup.itemCount, "popup has items");
info("press Escape to close the popup");
const onPopupClose = popup.once("popup-closed");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
await onPopupClose;
ok(!popup.isOpen, "popup is not open after VK_ESCAPE");
is(jsterm.getInputValue(), "window.foo.", "completion was cancelled");
ok(!completeNode.value, "completeNode is empty");
});
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_inside_text.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_inside_text.js
@@ -26,34 +26,34 @@ add_task(async function () {
inputNode,
} = jsterm;
const onPopUpOpen = popup.once("popup-opened");
const dumpString = "dump(window.testBu)";
jsterm.setInputValue(dumpString);
inputNode.selectionStart = inputNode.selectionEnd = dumpString.indexOf(")");
- EventUtils.synthesizeKey("g", {});
+ EventUtils.sendString("g");
await onPopUpOpen;
ok(popup.isOpen, "popup is open");
is(popup.itemCount, 2, "popup.itemCount is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(popup.selectedIndex, 0, "popup.selectedIndex is correct");
ok(!completeNode.value, "completeNode.value is empty");
let items = popup.getItems().map(e => e.label);
let expectedItems = ["testBugB", "testBugA"];
is(items.join("-"), expectedItems.join("-"), "getItems returns the items we expect");
info("press Tab and wait for popup to hide");
const onPopupClose = popup.once("popup-closed");
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
await onPopupClose;
// At this point the completion suggestion should be accepted.
ok(!popup.isOpen, "popup is not open");
const expectedInput = "dump(window.testBugB)";
is(jsterm.getInputValue(), expectedInput, "completion was successful after VK_TAB");
is(inputNode.selectionStart, expectedInput.length - 1, "cursor location is correct");
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_native_getters.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_native_getters.js
@@ -17,39 +17,39 @@ add_task(async function () {
autocompletePopup: popup,
completeNode,
} = jsterm;
ok(!popup.isOpen, "popup is not open");
let onPopupOpen = popup.once("popup-opened");
jsterm.setInputValue("document.body");
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString(".");
await onPopupOpen;
ok(popup.isOpen, "popup is open");
is(popup.itemCount, jsterm._autocompleteCache.length, "popup.itemCount is correct");
ok(jsterm._autocompleteCache.includes("addEventListener"),
"addEventListener is in the list of suggestions");
ok(jsterm._autocompleteCache.includes("bgColor"),
"bgColor is in the list of suggestions");
ok(jsterm._autocompleteCache.includes("ATTRIBUTE_NODE"),
"ATTRIBUTE_NODE is in the list of suggestions");
let onPopupClose = popup.once("popup-closed");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
await onPopupClose;
ok(!popup.isOpen, "popup is not open");
let onAutoCompleteUpdated = jsterm.once("autocomplete-updated");
let inputStr = "document.b";
jsterm.setInputValue(inputStr);
- EventUtils.synthesizeKey("o", {});
+ EventUtils.sendString("o");
await onAutoCompleteUpdated;
// Build the spaces that are placed in the input to place the autocompletion result at
// the expected spot:
// > document.bo <-- input
// > -----------dy <-- autocomplete
const spaces = " ".repeat(inputStr.length + 1);
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_nav_and_tab_key.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_nav_and_tab_key.js
@@ -35,17 +35,17 @@ add_task(async function () {
} = jsterm;
ok(!popup.isOpen, "popup is not open");
const onPopUpOpen = popup.once("popup-opened");
jsterm.setInputValue("window.foo");
// Shows the popup
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString(".");
await onPopUpOpen;
ok(popup.isOpen, "popup is open");
const popupItems = popup.getItems().map(e => e.label);
const expectedPopupItems = [
"item3",
"item2",
@@ -54,56 +54,56 @@ add_task(async function () {
];
is(popup.itemCount, expectedPopupItems.length, "popup.itemCount is correct");
is(popupItems.join("-"), expectedPopupItems.join("-"),
"getItems returns the items we expect");
is(popup.selectedIndex, expectedPopupItems.length - 1,
"Index of the first item from bottom is selected.");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
is(popup.selectedIndex, 0, "index 0 is selected");
is(popup.selectedItem.label, "item3", "item3 is selected");
is(completeNode.value, prefix + "item3", "completeNode.value holds item3");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(popup.selectedIndex, 1, "index 1 is selected");
is(popup.selectedItem.label, "item2", "item2 is selected");
is(completeNode.value, prefix + "item2", "completeNode.value holds item2");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(popup.selectedIndex, 0, "index 0 is selected");
is(popup.selectedItem.label, "item3", "item3 is selected");
is(completeNode.value, prefix + "item3", "completeNode.value holds item3");
let currentSelectionIndex = popup.selectedIndex;
- EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
+ EventUtils.synthesizeKey("KEY_PageDown");
ok(popup.selectedIndex > currentSelectionIndex, "Index is greater after PGDN");
currentSelectionIndex = popup.selectedIndex;
- EventUtils.synthesizeKey("VK_PAGE_UP", {});
+ EventUtils.synthesizeKey("KEY_PageUp");
ok(popup.selectedIndex < currentSelectionIndex, "Index is less after Page UP");
- EventUtils.synthesizeKey("VK_END", {});
+ EventUtils.synthesizeKey("KEY_End");
is(popup.selectedIndex, expectedPopupItems.length - 1, "index is last after End");
- EventUtils.synthesizeKey("VK_HOME", {});
+ EventUtils.synthesizeKey("KEY_Home");
is(popup.selectedIndex, 0, "index is first after Home");
info("press Tab and wait for popup to hide");
const onPopupClose = popup.once("popup-closed");
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
await onPopupClose;
// At this point the completion suggestion should be accepted.
ok(!popup.isOpen, "popup is not open");
is(jsterm.getInputValue(), "window.foo.item3",
- "completion was successful after VK_TAB");
+ "completion was successful after KEY_Tab");
ok(!completeNode.value, "completeNode is empty");
});
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key.js
@@ -37,45 +37,44 @@ add_task(async function () {
inputNode,
} = jsterm;
let onPopUpOpen = popup.once("popup-opened");
info("wait for completion suggestions: window.foobar.");
jsterm.setInputValue("window.fooba");
- EventUtils.synthesizeKey("r", {});
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString("r.");
await onPopUpOpen;
ok(popup.isOpen, "popup is open");
const expectedPopupItems = [
"item3",
"item2",
"item1",
"item0",
];
is(popup.itemCount, expectedPopupItems.length, "popup.itemCount is correct");
is(popup.selectedIndex, expectedPopupItems.length - 1,
"First index from bottom is selected");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(popup.selectedIndex, 0, "index 0 is selected");
is(popup.selectedItem.label, "item3", "item3 is selected");
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
is(completeNode.value, prefix + "item3", "completeNode.value holds item3");
info("press Return to accept suggestion. wait for popup to hide");
const onPopupClose = popup.once("popup-closed");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
await onPopupClose;
- ok(!popup.isOpen, "popup is not open after VK_RETURN");
+ ok(!popup.isOpen, "popup is not open after KEY_Enter");
is(jsterm.getInputValue(), "window.foobar.item3",
- "completion was successful after VK_RETURN");
+ "completion was successful after KEY_Enter");
ok(!completeNode.value, "completeNode is empty");
Services.prefs.clearUserPref(PREF_AUTO_MULTILINE);
});
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key_no_selection.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key_no_selection.js
@@ -23,27 +23,27 @@ add_task(async function () {
completeNode,
inputNode,
} = jsterm;
const onPopUpOpen = popup.once("popup-opened");
info("wait for popup to show");
jsterm.setInputValue("window.testBu");
- EventUtils.synthesizeKey("g", {});
+ EventUtils.sendString("g");
await onPopUpOpen;
ok(popup.isOpen, "popup is open");
is(popup.itemCount, 2, "popup.itemCount is correct");
isnot(popup.selectedIndex, -1, "popup.selectedIndex is correct");
info("press Return and wait for popup to hide");
const onPopUpClose = popup.once("popup-closed");
- executeSoon(() => EventUtils.synthesizeKey("VK_RETURN", {}));
+ executeSoon(() => EventUtils.synthesizeKey("KEY_Enter"));
await onPopUpClose;
- ok(!popup.isOpen, "popup is not open after VK_RETURN");
- is(jsterm.getInputValue(), "", "inputNode is empty after VK_RETURN");
+ ok(!popup.isOpen, "popup is not open after KEY_Enter");
+ is(jsterm.getInputValue(), "", "inputNode is empty after KEY_Enter");
is(completeNode.value, "", "completeNode is empty");
is(jsterm.history[jsterm.history.length - 1], "window.testBug",
"jsterm history is correct");
});
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_ctrl_key_nav.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_ctrl_key_nav.js
@@ -24,37 +24,37 @@ add_task(async function () {
testSingleLineInputNavNoHistory(jsterm);
testMultiLineInputNavNoHistory(jsterm);
testNavWithHistory(jsterm);
});
function testSingleLineInputNavNoHistory(jsterm) {
let inputNode = jsterm.inputNode;
// Single char input
- EventUtils.synthesizeKey("1", {});
+ EventUtils.sendString("1");
is(inputNode.selectionStart, 1, "caret location after single char input");
// nav to start/end with ctrl-a and ctrl-e;
synthesizeLineStartKey();
is(inputNode.selectionStart, 0,
"caret location after single char input and ctrl-a");
synthesizeLineEndKey();
is(inputNode.selectionStart, 1,
"caret location after single char input and ctrl-e");
// Second char input
- EventUtils.synthesizeKey("2", {});
+ EventUtils.sendString("2");
// nav to start/end with up/down keys; verify behaviour using ctrl-p/ctrl-n
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(inputNode.selectionStart, 0,
- "caret location after two char input and VK_UP");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ "caret location after two char input and KEY_ArrowUp");
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(inputNode.selectionStart, 2,
- "caret location after two char input and VK_DOWN");
+ "caret location after two char input and KEY_ArrowDown");
synthesizeLineStartKey();
is(inputNode.selectionStart, 0,
"move caret to beginning of 2 char input with ctrl-a");
synthesizeLineStartKey();
is(inputNode.selectionStart, 0,
"no change of caret location on repeat ctrl-a");
synthesizeLineUpKey();
@@ -80,34 +80,34 @@ function testSingleLineInputNavNoHistory
function testMultiLineInputNavNoHistory(jsterm) {
let inputNode = jsterm.inputNode;
let lineValues = ["one", "2", "something longer", "", "", "three!"];
jsterm.setInputValue("");
// simulate shift-return
for (let i = 0; i < lineValues.length; i++) {
jsterm.setInputValue(jsterm.getInputValue() + lineValues[i]);
- EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true });
+ EventUtils.synthesizeKey("KEY_Enter", {shiftKey: true});
}
let inputValue = jsterm.getInputValue();
is(inputNode.selectionStart, inputNode.selectionEnd);
is(inputNode.selectionStart, inputValue.length,
"caret at end of multiline input");
// possibility newline is represented by one ('\r', '\n') or two
// ('\r\n') chars
let newlineString = inputValue.match(/(\r\n?|\n\r?)$/)[0];
// Ok, test navigating within the multi-line string!
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
let expectedStringAfterCarat = lineValues[5] + newlineString;
is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat,
"up arrow from end of multiline");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue().slice(inputNode.selectionStart), "",
"down arrow from within multiline");
// navigate up through input lines
synthesizeLineUpKey();
is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat,
"ctrl-p from end of multiline");
@@ -221,22 +221,22 @@ function testNavWithHistory(jsterm) {
synthesizeLineStartKey();
synthesizeLineUpKey();
is(jsterm.getInputValue(), values[values.length - 1],
"ctrl-p from start of multi-line triggers history");
}
function synthesizeLineStartKey() {
- EventUtils.synthesizeKey("a", { ctrlKey: true });
+ EventUtils.synthesizeKey("a", {ctrlKey: true});
}
function synthesizeLineEndKey() {
- EventUtils.synthesizeKey("e", { ctrlKey: true });
+ EventUtils.synthesizeKey("e", {ctrlKey: true});
}
function synthesizeLineUpKey() {
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
}
function synthesizeLineDownKey() {
- EventUtils.synthesizeKey("n", { ctrlKey: true });
+ EventUtils.synthesizeKey("n", {ctrlKey: true});
}
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_nav.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_nav.js
@@ -29,20 +29,20 @@ add_task(async function () {
ok(!popup.isOpen, "popup is not open");
ok(!jsterm.lastInputValue, "no lastInputValue");
jsterm.setInputValue("window.foobarBug660806.location");
is(jsterm.lastInputValue, "window.foobarBug660806.location",
"lastInputValue is correct");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
let onSetInputValue = jsterm.once("set-input-value");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
await onSetInputValue;
// We don't have an explicit event to wait for here, so we just wait for the next tick
// before checking the popup status.
await new Promise(executeSoon);
is(jsterm.lastInputValue, "window.foobarBug660806.location",
"lastInputValue is correct, again");
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_persist.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_persist.js
@@ -101,12 +101,12 @@ async function populateInputHistory(hud)
*/
function testNavigatingHistoryInUI(hud) {
let jsterm = hud.jsterm;
jsterm.focus();
// Count backwards from original input and make sure that pressing up
// restores this.
for (let i = INPUT_HISTORY_COUNT - 1; i >= 0; i--) {
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), i, "Pressing up restores last input");
}
}
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_input_expansion.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_input_expansion.js
@@ -23,16 +23,16 @@ add_task(async function () {
input.value = "hello\nworld\n";
// Set the caret at the end of input
let length = input.value.length;
input.selectionEnd = length;
input.selectionStart = length;
info("Type 'd' in jsterm to trigger height change for the input");
- EventUtils.synthesizeKey("d", {});
+ EventUtils.sendString("d");
ok(input.clientHeight > ordinaryHeight, "the input expanded");
info("Erase the value and test if the inputNode shrinks again");
input.value = "";
- EventUtils.synthesizeKey("d", {});
+ EventUtils.sendString("d");
is(input.clientHeight, ordinaryHeight, "the input's height is normal again");
});
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_autocompletion_on_defined_variables.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_autocompletion_on_defined_variables.js
@@ -16,23 +16,22 @@ add_task(async function () {
});
function testCompletion(hud) {
let jsterm = hud.jsterm;
let input = jsterm.inputNode;
// Test typing 'var d = 5;' and press RETURN
jsterm.setInputValue("var d = ");
- EventUtils.synthesizeKey("5", {});
- EventUtils.synthesizeKey(";", {});
+ EventUtils.sendString("5;");
is(input.value, "var d = 5;", "var d = 5;");
is(jsterm.completeNode.value, "", "no completion");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
is(jsterm.completeNode.value, "", "clear completion on execute()");
// Test typing 'var a = d' and press RETURN
jsterm.setInputValue("var a = ");
- EventUtils.synthesizeKey("d", {});
+ EventUtils.sendString("d");
is(input.value, "var a = d", "var a = d");
is(jsterm.completeNode.value, "", "no completion");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
is(jsterm.completeNode.value, "", "clear completion on execute()");
}
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_and_tab_key_pressed.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_and_tab_key_pressed.js
@@ -14,21 +14,21 @@ add_task(async function() {
testCompletion(hud);
});
function testCompletion(hud) {
let jsterm = hud.jsterm;
let input = jsterm.inputNode;
jsterm.setInputValue("");
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
is(jsterm.completeNode.value, "<- no result", "<- no result - matched");
is(input.value, "", "inputnode is empty - matched");
ok(hasFocus(input), "input is still focused");
// Any thing which is not in property autocompleter
jsterm.setInputValue("window.Bug583816");
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
is(jsterm.completeNode.value, " <- no result",
"completenode content - matched");
is(input.value, "window.Bug583816", "inputnode content - matched");
ok(hasFocus(input), "input is still focused");
}
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_change_and_tab_key_pressed.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_change_and_tab_key_pressed.js
@@ -10,24 +10,24 @@
const TEST_URI = "data:text/html,Testing jsterm focus";
add_task(async function() {
let hud = await openNewTabAndConsole(TEST_URI);
let jsterm = hud.jsterm;
let input = jsterm.inputNode;
is(hasFocus(input), true, "input has focus");
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
is(hasFocus(input), false, "focus moved away");
// Test user changed something
input.focus();
- EventUtils.synthesizeKey("A", {});
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.sendString("A");
+ EventUtils.synthesizeKey("KEY_Tab");
is(hasFocus(input), true, "input is still focused");
// Test non empty input but not changed since last focus
input.blur();
input.focus();
- EventUtils.synthesizeKey("VK_RIGHT", {});
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_ArrowRight");
+ EventUtils.synthesizeKey("KEY_Tab");
is(hasFocus(input), false, "focus moved away");
});
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_popup_close_on_tab_switch.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_popup_close_on_tab_switch.js
@@ -12,16 +12,16 @@ const TEST_URI = "data:text/html;charset
const TEST_URI_NAVIGATE = "data:text/html;charset=utf-8,<p>testing autocomplete closes";
add_task(async function () {
let hud = await openNewTabAndConsole(TEST_URI);
let popup = hud.jsterm.autocompletePopup;
let popupShown = once(popup, "popup-opened");
hud.jsterm.setInputValue("sc");
- EventUtils.synthesizeKey("r", {});
+ EventUtils.sendString("r");
await popupShown;
await addTab(TEST_URI_NAVIGATE);
ok(!popup.isOpen, "Popup closes on tab switch");
});
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_selfxss.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_selfxss.js
@@ -20,17 +20,17 @@ add_task(async function () {
let {jsterm} = await openNewTabAndConsole(TEST_URI);
jsterm.clearOutput();
ok(!jsterm.completeNode.value, "no completeNode.value");
jsterm.setInputValue("doc");
info("wait for completion value after typing 'docu'");
let onAutocompleteUpdated = jsterm.once("autocomplete-updated");
- EventUtils.synthesizeKey("u", {});
+ EventUtils.sendString("u");
await onAutocompleteUpdated;
const completionValue = jsterm.completeNode.value;
// Arguments: expected, setup.
await waitForClipboardPromise(() =>
clipboardHelper.copyString(stringToCopy), stringToCopy);
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_close_sidebar.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_close_sidebar.js
@@ -60,17 +60,17 @@ add_task(async function () {
await onSidebarShown;
sidebar = hud.ui.document.querySelector(".sidebar");
ok(!sidebar, "Sidebar hidden after clicking on close button");
await showSidebar(hud);
info("Send escape to hide sidebar");
onSidebarShown = waitForNodeMutation(wrapper, { childList: true });
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
await onSidebarShown;
sidebar = hud.ui.document.querySelector(".sidebar");
ok(!sidebar, "Sidebar hidden after sending esc");
});
async function showSidebar(hud) {
let onMessage = waitForMessage(hud, "Object");
ContentTask.spawn(gBrowser.selectedBrowser, {}, function () {
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_filter_scroll.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_filter_scroll.js
@@ -25,44 +25,44 @@ add_task(async function () {
ok(isScrolledToBottom(outputContainer), "The console is scrolled to the bottom");
info("Filter out some messages and check that the scroll position is not impacted");
const filterInput = hud.ui.outputNode.querySelector(".text-filter");
filterInput.value = "init-";
filterInput.focus();
let onMessagesFiltered = waitFor(() => !findMessage(hud, "init-1"), null, 200);
- EventUtils.synthesizeKey("9", {});
+ EventUtils.sendString("9");
await onMessagesFiltered;
ok(isScrolledToBottom(outputContainer),
"The console is still scrolled to the bottom after filtering");
info("Clear the text filter and check that the scroll position is not impacted");
let onMessagesUnFiltered = waitFor(() => findMessage(hud, "init-1"), null, 200);
filterInput.select();
- EventUtils.synthesizeKey("VK_DELETE", {});
+ EventUtils.synthesizeKey("KEY_Delete");
await onMessagesUnFiltered;
ok(isScrolledToBottom(outputContainer),
"The console is still scrolled to the bottom after clearing the filter");
info("Scroll up");
outputContainer.scrollTop = 0;
filterInput.value = "init-";
filterInput.focus();
onMessagesFiltered = waitFor(() => !findMessage(hud, "init-1"), null, 200);
- EventUtils.synthesizeKey("9", {});
+ EventUtils.sendString("9");
await onMessagesFiltered;
is(outputContainer.scrollTop, 0,
"The console is still scrolled to the top after filtering");
info("Clear the text filter and check that the scroll position is not impacted");
onMessagesUnFiltered = waitFor(() => findMessage(hud, "init-1"), null, 200);
filterInput.select();
- EventUtils.synthesizeKey("VK_DELETE", {});
+ EventUtils.synthesizeKey("KEY_Delete");
await onMessagesUnFiltered;
is(outputContainer.scrollTop, 0,
"The console is still scrolled to the top after clearing the filter");
});
function hasVerticalOverflow(container) {
return container.scrollHeight > container.clientHeight;
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_history_arrow_keys.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_history_arrow_keys.js
@@ -33,120 +33,120 @@ add_task(async function () {
performTests(jsterm);
});
function performTests(jsterm) {
let { inputNode } = jsterm;
let values = TEST_VALUES;
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[4],
"VK_UP: jsterm.getInputValue() #4 is correct");
ok(inputNode.selectionStart == values[4].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[3],
"VK_UP: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == values[3].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
inputNode.setSelectionRange(values[3].length - 2, values[3].length - 2);
- EventUtils.synthesizeKey("VK_UP", {});
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[3],
"VK_UP two times: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == jsterm.getInputValue().indexOf("\n") &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[3],
"VK_UP again: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == 0 &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[2],
"VK_UP: jsterm.getInputValue() #2 is correct");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[1],
"VK_UP: jsterm.getInputValue() #1 is correct");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[0],
"VK_UP: jsterm.getInputValue() #0 is correct");
ok(inputNode.selectionStart == values[0].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[1],
"VK_DOWN: jsterm.getInputValue() #1 is correct");
ok(inputNode.selectionStart == values[1].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[2],
"VK_DOWN: jsterm.getInputValue() #2 is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[3],
"VK_DOWN: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == values[3].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
inputNode.setSelectionRange(2, 2);
- EventUtils.synthesizeKey("VK_DOWN", {});
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[3],
"VK_DOWN two times: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart > jsterm.getInputValue().lastIndexOf("\n") &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[3],
"VK_DOWN again: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == values[3].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[4],
"VK_DOWN: jsterm.getInputValue() #4 is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
ok(!jsterm.getInputValue(),
"VK_DOWN: jsterm.getInputValue() is empty");
}
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_keyboard_accessibility.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_keyboard_accessibility.js
@@ -20,31 +20,31 @@ add_task(async function () {
let hud = await openNewTabAndConsole(TEST_URI);
info("Web Console opened");
const outputScroller = hud.ui.outputScroller;
await waitFor(() => findMessages(hud, "").length == 100);
let currentPosition = outputScroller.scrollTop;
const bottom = currentPosition;
hud.jsterm.inputNode.focus();
// Page up.
- EventUtils.synthesizeKey("VK_PAGE_UP", {});
+ EventUtils.synthesizeKey("KEY_PageUp");
isnot(outputScroller.scrollTop, currentPosition,
"scroll position changed after page up");
// Page down.
currentPosition = outputScroller.scrollTop;
- EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
+ EventUtils.synthesizeKey("KEY_PageDown");
ok(outputScroller.scrollTop > currentPosition,
"scroll position now at bottom");
// Home
- EventUtils.synthesizeKey("VK_HOME", {});
+ EventUtils.synthesizeKey("KEY_Home");
is(outputScroller.scrollTop, 0, "scroll position now at top");
// End
- EventUtils.synthesizeKey("VK_END", {});
+ EventUtils.synthesizeKey("KEY_End");
let scrollTop = outputScroller.scrollTop;
ok(scrollTop > 0 && Math.abs(scrollTop - bottom) <= 5,
"scroll position now at bottom");
// Clear output
info("try ctrl-l to clear output");
let clearShortcut;
if (Services.appinfo.OS === "Darwin") {
--- a/devtools/client/webconsole/test/browser_bug_865871_variables_view_close_on_esc_key.js
+++ b/devtools/client/webconsole/test/browser_bug_865871_variables_view_close_on_esc_key.js
@@ -29,30 +29,30 @@ function test() {
{ name: "testProp", value: "testValue" });
let prop = result.matchedProp;
ok(prop, "matched the |testProp| property in the variables view");
vview.window.focus();
let sidebarClosed = jsterm.once("sidebar-closed");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
yield sidebarClosed;
jsterm.clearOutput();
yield openSidebar("window.location",
"Location \u2192 http://example.com/browser/",
{ name: "host", value: "example.com" });
vview.window.focus();
msg.scrollIntoView();
sidebarClosed = jsterm.once("sidebar-closed");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
yield sidebarClosed;
function* openSidebar(objName, expectedText, expectedObj) {
msg = yield jsterm.execute(objName);
ok(msg, "output message found");
let anchor = msg.querySelector("a");
let body = msg.querySelector(".message-body");
--- a/devtools/client/webconsole/test/browser_console_history_persist.js
+++ b/devtools/client/webconsole/test/browser_console_history_persist.js
@@ -108,12 +108,12 @@ function* populateInputHistory(hud) {
*/
function* testNaviatingHistoryInUI(hud) {
let jsterm = hud.jsterm;
jsterm.focus();
// Count backwards from original input and make sure that pressing up
// restores this.
for (let i = INPUT_HISTORY_COUNT - 1; i >= 0; i--) {
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), i, "Pressing up restores last input");
}
}
--- a/devtools/client/webconsole/test/browser_console_keyboard_accessibility.js
+++ b/devtools/client/webconsole/test/browser_console_keyboard_accessibility.js
@@ -28,29 +28,29 @@ add_task(async function () {
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
});
let currentPosition = hud.ui.outputWrapper.scrollTop;
let bottom = currentPosition;
- EventUtils.synthesizeKey("VK_PAGE_UP", {});
+ EventUtils.synthesizeKey("KEY_PageUp");
isnot(hud.ui.outputWrapper.scrollTop, currentPosition,
"scroll position changed after page up");
currentPosition = hud.ui.outputWrapper.scrollTop;
- EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
+ EventUtils.synthesizeKey("KEY_PageDown");
ok(hud.ui.outputWrapper.scrollTop > currentPosition,
"scroll position now at bottom");
- EventUtils.synthesizeKey("VK_HOME", {});
+ EventUtils.synthesizeKey("KEY_Home");
is(hud.ui.outputWrapper.scrollTop, 0, "scroll position now at top");
- EventUtils.synthesizeKey("VK_END", {});
+ EventUtils.synthesizeKey("KEY_End");
let scrollTop = hud.ui.outputWrapper.scrollTop;
ok(scrollTop > 0 && Math.abs(scrollTop - bottom) <= 5,
"scroll position now at bottom");
info("try ctrl-l to clear output");
executeSoon(() => {
let clearShortcut;
@@ -75,19 +75,19 @@ add_task(async function () {
synthesizeKeyShortcut(WCUL10n.getStr("webconsole.find.key"));
ok(!hud.jsterm.inputNode.getAttribute("focused"),
"jsterm input is not focused");
is(hud.ui.filterBox.getAttribute("focused"), "true",
"filter input is focused");
if (Services.appinfo.OS == "Darwin") {
ok(hud.ui.getFilterState("network"), "network category is enabled");
- EventUtils.synthesizeKey("t", { ctrlKey: true });
+ EventUtils.synthesizeKey("t", {ctrlKey: true});
ok(!hud.ui.getFilterState("network"), "accesskey for Network works");
- EventUtils.synthesizeKey("t", { ctrlKey: true });
+ EventUtils.synthesizeKey("t", {ctrlKey: true});
ok(hud.ui.getFilterState("network"), "accesskey for Network works (again)");
} else {
- EventUtils.synthesizeKey("N", { altKey: true });
+ EventUtils.synthesizeKey("n", {altKey: true});
let net = hud.ui.document.querySelector("toolbarbutton[category=net]");
is(hud.ui.document.activeElement, net,
"accesskey for Network category focuses the Net button");
}
});
--- a/devtools/client/webconsole/test/browser_webconsole_autocomplete_accessibility.js
+++ b/devtools/client/webconsole/test/browser_webconsole_autocomplete_accessibility.js
@@ -34,17 +34,17 @@ add_task(function* () {
ok(wasBlurred, "jsterm input received a blur event before received back the focus");
wasFocused = true;
}, {
once: true
});
info("Close the autocomplete popup by simulating a TAB key event");
let onPopupClosed = jsterm.autocompletePopup.once("popup-closed");
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
info("Wait for the autocomplete popup to be closed");
yield onPopupClosed;
ok(wasFocused, "jsterm input received a focus event");
});
function* autocomplete(jsterm, value) {
--- a/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js
+++ b/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js
@@ -119,12 +119,12 @@ function consoleOpened(HUD) {
executeSoon(() => {
EventUtils.synthesizeKey("v", {accelKey: true});
});
}
info("wait for completion value after typing 'docu'");
jsterm.once("autocomplete-updated", onCompletionValue);
- EventUtils.synthesizeKey("u", {});
+ EventUtils.sendString("u");
return deferred.promise;
}
--- a/devtools/client/webconsole/test/browser_webconsole_autocomplete_crossdomain_iframe.js
+++ b/devtools/client/webconsole/test/browser_webconsole_autocomplete_crossdomain_iframe.js
@@ -27,23 +27,23 @@ function test() {
category: CATEGORY_OUTPUT,
}],
});
let autocompleteUpdated = hud.jsterm.once("autocomplete-updated");
hud.jsterm.setInputValue("window[0].document");
executeSoon(() => {
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString(".");
});
yield autocompleteUpdated;
hud.jsterm.setInputValue("window[0].document.title");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
yield waitForMessages({
webconsole: hud,
messages: [{
text: "Permission denied",
category: CATEGORY_OUTPUT,
severity: SEVERITY_ERROR,
}],
--- a/devtools/client/webconsole/test/browser_webconsole_autocomplete_popup_close_on_tab_switch.js
+++ b/devtools/client/webconsole/test/browser_webconsole_autocomplete_popup_close_on_tab_switch.js
@@ -12,16 +12,16 @@ const TEST_URI = "data:text/html;charset
add_task(function* () {
yield loadTab(TEST_URI);
let hud = yield openConsole();
let popup = hud.jsterm.autocompletePopup;
let popupShown = once(popup, "popup-opened");
hud.jsterm.setInputValue("sc");
- EventUtils.synthesizeKey("r", {});
+ EventUtils.sendString("r");
yield popupShown;
yield loadTab("data:text/html;charset=utf-8,<p>testing autocomplete closes");
ok(!popup.isOpen, "Popup closes on tab switch");
});
--- a/devtools/client/webconsole/test/browser_webconsole_bug_583816_No_input_and_Tab_key_pressed.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_583816_No_input_and_Tab_key_pressed.js
@@ -15,21 +15,21 @@ add_task(function* () {
testCompletion(hud);
});
function testCompletion(hud) {
let jsterm = hud.jsterm;
let input = jsterm.inputNode;
jsterm.setInputValue("");
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
is(jsterm.completeNode.value, "<- no result", "<- no result - matched");
is(input.value, "", "inputnode is empty - matched");
is(input.getAttribute("focused"), "true", "input is still focused");
// Any thing which is not in property autocompleter
jsterm.setInputValue("window.Bug583816");
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
is(jsterm.completeNode.value, " <- no result",
"completenode content - matched");
is(input.value, "window.Bug583816", "inputnode content - matched");
is(input.getAttribute("focused"), "true", "input is still focused");
}
--- a/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js
@@ -83,170 +83,169 @@ var consoleOpened = Task.async(function*
"toSource",
"toString",
"valueOf",
][index] === prop;
}), "getItems returns the items we expect");
is(popup.selectedIndex, 16,
"Index of the first item from bottom is selected.");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
is(popup.selectedIndex, 0, "index 0 is selected");
is(popup.selectedItem.label, "valueOf", "valueOf is selected");
is(completeNode.value, prefix + "valueOf",
"completeNode.value holds valueOf");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(popup.selectedIndex, 1, "index 1 is selected");
is(popup.selectedItem.label, "toString", "toString is selected");
is(completeNode.value, prefix + "toString",
"completeNode.value holds toString");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(popup.selectedIndex, 0, "index 0 is selected");
is(popup.selectedItem.label, "valueOf", "valueOf is selected");
is(completeNode.value, prefix + "valueOf",
"completeNode.value holds valueOf");
let currentSelectionIndex = popup.selectedIndex;
- EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
+ EventUtils.synthesizeKey("KEY_PageDown");
ok(popup.selectedIndex > currentSelectionIndex,
"Index is greater after PGDN");
currentSelectionIndex = popup.selectedIndex;
- EventUtils.synthesizeKey("VK_PAGE_UP", {});
+ EventUtils.synthesizeKey("KEY_PageUp");
ok(popup.selectedIndex < currentSelectionIndex,
"Index is less after Page UP");
- EventUtils.synthesizeKey("VK_END", {});
+ EventUtils.synthesizeKey("KEY_End");
is(popup.selectedIndex, 16, "index is last after End");
- EventUtils.synthesizeKey("VK_HOME", {});
+ EventUtils.synthesizeKey("KEY_Home");
is(popup.selectedIndex, 0, "index is first after Home");
info("press Tab and wait for popup to hide");
popup.once("popup-closed", () => {
deferred.resolve();
});
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
});
jsterm.setInputValue("window.foobarBug585991");
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString(".");
return deferred.promise;
});
function popupHideAfterTab() {
let deferred = defer();
// At this point the completion suggestion should be accepted.
ok(!popup.isOpen, "popup is not open");
is(jsterm.getInputValue(), "window.foobarBug585991.valueOf",
- "completion was successful after VK_TAB");
+ "completion was successful after KEY_Tab");
ok(!completeNode.value, "completeNode is empty");
popup.once("popup-opened", function onShown() {
ok(popup.isOpen, "popup is open");
is(popup.itemCount, 17, "popup.itemCount is correct");
is(popup.selectedIndex, 16, "First index from bottom is selected");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
is(popup.selectedIndex, 0, "index 0 is selected");
is(popup.selectedItem.label, "valueOf", "valueOf is selected");
is(completeNode.value, prefix + "valueOf",
"completeNode.value holds valueOf");
popup.once("popup-closed", function onHidden() {
- ok(!popup.isOpen, "popup is not open after VK_ESCAPE");
+ ok(!popup.isOpen, "popup is not open after KEY_Escape");
is(jsterm.getInputValue(), "window.foobarBug585991.",
"completion was cancelled");
ok(!completeNode.value, "completeNode is empty");
deferred.resolve();
}, false);
info("press Escape to close the popup");
executeSoon(function () {
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
});
}, false);
info("wait for completion: window.foobarBug585991.");
executeSoon(function () {
jsterm.setInputValue("window.foobarBug585991");
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString(".");
});
return deferred.promise;
}
function testReturnKey() {
let deferred = defer();
popup.once("popup-opened", function onShown() {
ok(popup.isOpen, "popup is open");
is(popup.itemCount, 17, "popup.itemCount is correct");
is(popup.selectedIndex, 16, "First index from bottom is selected");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
let prefix = jsterm.getInputValue().replace(/[\S]/g, " ");
is(popup.selectedIndex, 0, "index 0 is selected");
is(popup.selectedItem.label, "valueOf", "valueOf is selected");
is(completeNode.value, prefix + "valueOf",
"completeNode.value holds valueOf");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(popup.selectedIndex, 1, "index 1 is selected");
is(popup.selectedItem.label, "toString", "toString is selected");
is(completeNode.value, prefix + "toString",
"completeNode.value holds toString");
popup.once("popup-closed", function onHidden() {
- ok(!popup.isOpen, "popup is not open after VK_RETURN");
+ ok(!popup.isOpen, "popup is not open after KEY_Enter");
is(jsterm.getInputValue(), "window.foobarBug585991.toString",
- "completion was successful after VK_RETURN");
+ "completion was successful after KEY_Enter");
ok(!completeNode.value, "completeNode is empty");
deferred.resolve();
}, false);
info("press Return to accept suggestion. wait for popup to hide");
- executeSoon(() => EventUtils.synthesizeKey("VK_RETURN", {}));
+ executeSoon(() => EventUtils.synthesizeKey("KEY_Enter"));
}, false);
info("wait for completion suggestions: window.foobarBug585991.");
executeSoon(function () {
jsterm.setInputValue("window.foobarBug58599");
- EventUtils.synthesizeKey("1", {});
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString("1.");
});
return deferred.promise;
}
function* dontShowArrayNumbers() {
let deferred = defer();
@@ -266,23 +265,23 @@ function* dontShowArrayNumbers() {
prop === "0";
}), "Completing on an array doesn't show numbers.");
popup.once("popup-closed", function popupHidden() {
deferred.resolve();
}, false);
info("wait for popup to hide");
- executeSoon(() => EventUtils.synthesizeKey("VK_ESCAPE", {}));
+ executeSoon(() => EventUtils.synthesizeKey("KEY_Escape"));
}, false);
info("wait for popup to show");
executeSoon(() => {
jsterm.setInputValue("window.foobarBug585991");
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString(".");
});
return deferred.promise;
}
function testReturnWithNoSelection() {
let deferred = defer();
@@ -292,74 +291,74 @@ function testReturnWithNoSelection() {
ok(popup.isOpen, "popup is open");
is(popup.itemCount, 2, "popup.itemCount is correct");
isnot(popup.selectedIndex, -1, "popup.selectedIndex is correct");
info("press Return and wait for popup to hide");
popup.once("popup-closed", function popupHidden() {
deferred.resolve();
});
- executeSoon(() => EventUtils.synthesizeKey("VK_RETURN", {}));
+ executeSoon(() => EventUtils.synthesizeKey("KEY_Enter"));
});
executeSoon(() => {
info("wait for popup to show");
jsterm.setInputValue("window.testBu");
- EventUtils.synthesizeKey("g", {});
+ EventUtils.sendString("g");
});
return deferred.promise;
}
function popupHideAfterReturnWithNoSelection() {
- ok(!popup.isOpen, "popup is not open after VK_RETURN");
+ ok(!popup.isOpen, "popup is not open after KEY_Enter");
- is(jsterm.getInputValue(), "", "inputNode is empty after VK_RETURN");
+ is(jsterm.getInputValue(), "", "inputNode is empty after KEY_Enter");
is(completeNode.value, "", "completeNode is empty");
is(jsterm.history[jsterm.history.length - 1], "window.testBug",
"jsterm history is correct");
return promise.resolve();
}
function testCompletionInText() {
info("test that completion works inside text, see bug 812618");
let deferred = defer();
popup.once("popup-opened", function onShown() {
ok(popup.isOpen, "popup is open");
is(popup.itemCount, 2, "popup.itemCount is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(popup.selectedIndex, 0, "popup.selectedIndex is correct");
ok(!completeNode.value, "completeNode.value is empty");
let items = popup.getItems().reverse().map(e => e.label);
let sameItems = items.every((prop, index) =>
["testBug873250a", "testBug873250b"][index] === prop);
ok(sameItems, "getItems returns the items we expect");
info("press Tab and wait for popup to hide");
popup.once("popup-closed", function popupHidden() {
deferred.resolve();
});
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
});
jsterm.setInputValue("dump(window.testBu)");
inputNode.selectionStart = inputNode.selectionEnd = 18;
- EventUtils.synthesizeKey("g", {});
+ EventUtils.sendString("g");
return deferred.promise;
}
function popupHideAfterCompletionInText() {
// At this point the completion suggestion should be accepted.
ok(!popup.isOpen, "popup is not open");
is(jsterm.getInputValue(), "dump(window.testBug873250b)",
- "completion was successful after VK_TAB");
+ "completion was successful after KEY_Tab");
is(inputNode.selectionStart, 26, "cursor location is correct");
is(inputNode.selectionStart, inputNode.selectionEnd,
"cursor location (confirmed)");
ok(!completeNode.value, "completeNode is empty");
return promise.resolve();
}
--- a/devtools/client/webconsole/test/browser_webconsole_bug_588967_input_expansion.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_588967_input_expansion.js
@@ -27,18 +27,18 @@ function testInputExpansion(hud) {
// Tests if the inputNode expands.
input.value = "hello\nworld\n";
let length = input.value.length;
input.selectionEnd = length;
input.selectionStart = length;
// Performs an "d". This will trigger/test for the input event that should
// change the height of the inputNode.
- EventUtils.synthesizeKey("d", {});
+ EventUtils.sendString("d");
ok(input.clientHeight > ordinaryHeight, "the input expanded");
// Test if the inputNode shrinks again.
input.value = "";
- EventUtils.synthesizeKey("d", {});
+ EventUtils.sendString("d");
is(input.clientHeight, ordinaryHeight, "the input's height is normal again");
input = length = null;
}
--- a/devtools/client/webconsole/test/browser_webconsole_bug_594497_history_arrow_keys.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_594497_history_arrow_keys.js
@@ -35,121 +35,121 @@ function setup(HUD) {
// Execute each of the values;
for (let i = 0; i < values.length; i++) {
jsterm.setInputValue(values[i]);
jsterm.execute();
}
}
function performTests() {
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[4],
- "VK_UP: jsterm.getInputValue() #4 is correct");
+ "KEY_ArrowUp: jsterm.getInputValue() #4 is correct");
ok(inputNode.selectionStart == values[4].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[3],
- "VK_UP: jsterm.getInputValue() #3 is correct");
+ "KEY_ArrowUp: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == values[3].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
inputNode.setSelectionRange(values[3].length - 2, values[3].length - 2);
- EventUtils.synthesizeKey("VK_UP", {});
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[3],
- "VK_UP two times: jsterm.getInputValue() #3 is correct");
+ "KEY_ArrowUp two times: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == jsterm.getInputValue().indexOf("\n") &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[3],
- "VK_UP again: jsterm.getInputValue() #3 is correct");
+ "KEY_ArrowUp again: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == 0 &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[2],
- "VK_UP: jsterm.getInputValue() #2 is correct");
+ "KEY_ArrowUp: jsterm.getInputValue() #2 is correct");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[1],
- "VK_UP: jsterm.getInputValue() #1 is correct");
+ "KEY_ArrowUp: jsterm.getInputValue() #1 is correct");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), values[0],
- "VK_UP: jsterm.getInputValue() #0 is correct");
+ "KEY_ArrowUp: jsterm.getInputValue() #0 is correct");
ok(inputNode.selectionStart == values[0].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[1],
- "VK_DOWN: jsterm.getInputValue() #1 is correct");
+ "KEY_ArrowDown: jsterm.getInputValue() #1 is correct");
ok(inputNode.selectionStart == values[1].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[2],
- "VK_DOWN: jsterm.getInputValue() #2 is correct");
+ "KEY_ArrowDown: jsterm.getInputValue() #2 is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[3],
- "VK_DOWN: jsterm.getInputValue() #3 is correct");
+ "KEY_ArrowDown: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == values[3].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
inputNode.setSelectionRange(2, 2);
- EventUtils.synthesizeKey("VK_DOWN", {});
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[3],
- "VK_DOWN two times: jsterm.getInputValue() #3 is correct");
+ "KEY_ArrowDown two times: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart > jsterm.getInputValue().lastIndexOf("\n") &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[3],
- "VK_DOWN again: jsterm.getInputValue() #3 is correct");
+ "KEY_ArrowDown again: jsterm.getInputValue() #3 is correct");
ok(inputNode.selectionStart == values[3].length &&
inputNode.selectionStart == inputNode.selectionEnd,
"caret location is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), values[4],
- "VK_DOWN: jsterm.getInputValue() #4 is correct");
+ "KEY_ArrowDown: jsterm.getInputValue() #4 is correct");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
ok(!jsterm.getInputValue(),
- "VK_DOWN: jsterm.getInputValue() is empty");
+ "KEY_ArrowDown: jsterm.getInputValue() is empty");
}
--- a/devtools/client/webconsole/test/browser_webconsole_bug_613642_maintain_scroll.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_613642_maintain_scroll.js
@@ -44,17 +44,17 @@ add_task(function* () {
if (scrollBox.scrollTop != 0) {
// Wait for scroll to 0.
return;
}
scrollBox.onscroll = null;
is(scrollBox.scrollTop, 0, "scroll location updated (moved to top)");
scrolled.resolve();
};
- EventUtils.synthesizeKey("VK_HOME", {}, hud.iframeWindow);
+ EventUtils.synthesizeKey("KEY_Home", {}, hud.iframeWindow);
yield scrolled.promise;
// add a message and make sure scroll doesn't change
ContentTask.spawn(gBrowser.selectedBrowser, null,
"() => content.console.log('test message 150')");
yield waitForMessages({
@@ -91,17 +91,17 @@ add_task(function* () {
if (scrollBox.scrollTop == 0) {
// Wait for scroll to bottom.
return;
}
scrollBox.onscroll = null;
isnot(scrollBox.scrollTop, 0, "scroll location updated (moved to bottom)");
scrolled.resolve();
};
- EventUtils.synthesizeKey("VK_END", {});
+ EventUtils.synthesizeKey("KEY_End");
yield scrolled.promise;
let oldScrollTop = scrollBox.scrollTop;
ContentTask.spawn(gBrowser.selectedBrowser, null,
"() => content.console.log('test message 151')");
scrolled = defer();
--- a/devtools/client/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js
@@ -43,21 +43,21 @@ function consoleOpened() {
isnot(jsterm._autocompleteCache.indexOf("bgColor"), -1,
"bgColor is in the list of suggestions");
isnot(jsterm._autocompleteCache.indexOf("ATTRIBUTE_NODE"), -1,
"ATTRIBUTE_NODE is in the list of suggestions");
popup.once("popup-closed", () => {
deferred.resolve();
});
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
});
jsterm.setInputValue("document.body");
- EventUtils.synthesizeKey(".", {});
+ EventUtils.sendString(".");
return deferred.promise;
}
function autocompletePopupHidden() {
let deferred = defer();
let jsterm = gHUD.jsterm;
@@ -68,17 +68,17 @@ function autocompletePopupHidden() {
jsterm.once("autocomplete-updated", function () {
is(completeNode.value, testStr + "dy", "autocomplete shows document.body");
deferred.resolve();
});
let inputStr = "document.b";
jsterm.setInputValue(inputStr);
- EventUtils.synthesizeKey("o", {});
+ EventUtils.sendString("o");
let testStr = inputStr.replace(/./g, " ") + " ";
return deferred.promise;
}
function testPropertyPanel() {
let deferred = defer();
--- a/devtools/client/webconsole/test/browser_webconsole_bug_660806_history_nav.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_660806_history_nav.js
@@ -34,18 +34,18 @@ function consoleOpened(HUD) {
ok(!popup.isOpen, "popup is not open");
ok(!jsterm.lastInputValue, "no lastInputValue");
jsterm.setInputValue("window.foobarBug660806.location");
is(jsterm.lastInputValue, "window.foobarBug660806.location",
"lastInputValue is correct");
- EventUtils.synthesizeKey("VK_RETURN", {});
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_Enter");
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.lastInputValue, "window.foobarBug660806.location",
"lastInputValue is correct, again");
executeSoon(function () {
ok(!popup.isOpen, "popup is not open");
popup.off("popup-opened", onShown);
executeSoon(deferred.resolve);
--- a/devtools/client/webconsole/test/browser_webconsole_bug_704295.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_704295.js
@@ -19,23 +19,22 @@ add_task(function* () {
});
function testCompletion(hud) {
let jsterm = hud.jsterm;
let input = jsterm.inputNode;
// Test typing 'var d = 5;' and press RETURN
jsterm.setInputValue("var d = ");
- EventUtils.synthesizeKey("5", {});
- EventUtils.synthesizeKey(";", {});
+ EventUtils.sendString("5;");
is(input.value, "var d = 5;", "var d = 5;");
is(jsterm.completeNode.value, "", "no completion");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
is(jsterm.completeNode.value, "", "clear completion on execute()");
// Test typing 'var a = d' and press RETURN
jsterm.setInputValue("var a = ");
- EventUtils.synthesizeKey("d", {});
+ EventUtils.sendString("d");
is(input.value, "var a = d", "var a = d");
is(jsterm.completeNode.value, "", "no completion");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
is(jsterm.completeNode.value, "", "clear completion on execute()");
}
--- a/devtools/client/webconsole/test/browser_webconsole_bug_734061_No_input_change_and_Tab_key_pressed.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_734061_No_input_change_and_Tab_key_pressed.js
@@ -12,24 +12,24 @@ add_task(function* () {
yield loadTab(TEST_URI);
let hud = yield openConsole();
let jsterm = hud.jsterm;
let input = jsterm.inputNode;
is(input.getAttribute("focused"), "true", "input has focus");
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_Tab");
is(input.getAttribute("focused"), "", "focus moved away");
// Test user changed something
input.focus();
- EventUtils.synthesizeKey("A", {});
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.sendString("a");
+ EventUtils.synthesizeKey("KEY_Tab");
is(input.getAttribute("focused"), "true", "input is still focused");
// Test non empty input but not changed since last focus
input.blur();
input.focus();
- EventUtils.synthesizeKey("VK_RIGHT", {});
- EventUtils.synthesizeKey("VK_TAB", {});
+ EventUtils.synthesizeKey("KEY_ArrowRight");
+ EventUtils.synthesizeKey("KEY_Tab");
is(input.getAttribute("focused"), "", "input moved away");
});
--- a/devtools/client/webconsole/test/browser_webconsole_bug_804845_ctrl_key_nav.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_804845_ctrl_key_nav.js
@@ -31,130 +31,130 @@ function doTests(HUD) {
testSingleLineInputNavNoHistory();
testMultiLineInputNavNoHistory();
testNavWithHistory();
}
function testSingleLineInputNavNoHistory() {
// Single char input
- EventUtils.synthesizeKey("1", {});
+ EventUtils.sendString("1");
is(inputNode.selectionStart, 1, "caret location after single char input");
// nav to start/end with ctrl-a and ctrl-e;
- EventUtils.synthesizeKey("a", { ctrlKey: true });
+ EventUtils.synthesizeKey("a", {ctrlKey: true});
is(inputNode.selectionStart, 0,
"caret location after single char input and ctrl-a");
- EventUtils.synthesizeKey("e", { ctrlKey: true });
+ EventUtils.synthesizeKey("e", {ctrlKey: true});
is(inputNode.selectionStart, 1,
"caret location after single char input and ctrl-e");
// Second char input
- EventUtils.synthesizeKey("2", {});
+ EventUtils.sendString("2");
// nav to start/end with up/down keys; verify behaviour using ctrl-p/ctrl-n
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(inputNode.selectionStart, 0,
- "caret location after two char input and VK_UP");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ "caret location after two char input and KEY_ArrowUp");
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(inputNode.selectionStart, 2,
- "caret location after two char input and VK_DOWN");
+ "caret location after two char input and KEY_ArrowDown");
- EventUtils.synthesizeKey("a", { ctrlKey: true });
+ EventUtils.synthesizeKey("a", {ctrlKey: true});
is(inputNode.selectionStart, 0,
"move caret to beginning of 2 char input with ctrl-a");
- EventUtils.synthesizeKey("a", { ctrlKey: true });
+ EventUtils.synthesizeKey("a", {ctrlKey: true});
is(inputNode.selectionStart, 0,
"no change of caret location on repeat ctrl-a");
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
is(inputNode.selectionStart, 0,
"no change of caret location on ctrl-p from beginning of line");
- EventUtils.synthesizeKey("e", { ctrlKey: true });
+ EventUtils.synthesizeKey("e", {ctrlKey: true});
is(inputNode.selectionStart, 2,
"move caret to end of 2 char input with ctrl-e");
- EventUtils.synthesizeKey("e", { ctrlKey: true });
+ EventUtils.synthesizeKey("e", {ctrlKey: true});
is(inputNode.selectionStart, 2,
"no change of caret location on repeat ctrl-e");
- EventUtils.synthesizeKey("n", { ctrlKey: true });
+ EventUtils.synthesizeKey("n", {ctrlKey: true});
is(inputNode.selectionStart, 2,
"no change of caret location on ctrl-n from end of line");
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
is(inputNode.selectionStart, 0, "ctrl-p moves to start of line");
- EventUtils.synthesizeKey("n", { ctrlKey: true });
+ EventUtils.synthesizeKey("n", {ctrlKey: true});
is(inputNode.selectionStart, 2, "ctrl-n moves to end of line");
}
function testMultiLineInputNavNoHistory() {
let lineValues = ["one", "2", "something longer", "", "", "three!"];
jsterm.setInputValue("");
// simulate shift-return
for (let i = 0; i < lineValues.length; i++) {
jsterm.setInputValue(jsterm.getInputValue() + lineValues[i]);
- EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true });
+ EventUtils.synthesizeKey("KEY_Enter", {shiftKey: true});
}
let inputValue = jsterm.getInputValue();
is(inputNode.selectionStart, inputNode.selectionEnd);
is(inputNode.selectionStart, inputValue.length,
"caret at end of multiline input");
// possibility newline is represented by one ('\r', '\n') or two
// ('\r\n') chars
let newlineString = inputValue.match(/(\r\n?|\n\r?)$/)[0];
// Ok, test navigating within the multi-line string!
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
let expectedStringAfterCarat = lineValues[5] + newlineString;
is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat,
"up arrow from end of multiline");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue().slice(inputNode.selectionStart), "",
"down arrow from within multiline");
// navigate up through input lines
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat,
"ctrl-p from end of multiline");
for (let i = 4; i >= 0; i--) {
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
expectedStringAfterCarat = lineValues[i] + newlineString +
expectedStringAfterCarat;
is(jsterm.getInputValue().slice(inputNode.selectionStart),
expectedStringAfterCarat, "ctrl-p from within line " + i +
" of multiline input");
}
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
is(inputNode.selectionStart, 0, "reached start of input");
is(jsterm.getInputValue(), inputValue,
"no change to multiline input on ctrl-p from beginning of multiline");
// navigate to end of first line
- EventUtils.synthesizeKey("e", { ctrlKey: true });
+ EventUtils.synthesizeKey("e", {ctrlKey: true});
let caretPos = inputNode.selectionStart;
let expectedStringBeforeCarat = lineValues[0];
is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat,
"ctrl-e into multiline input");
- EventUtils.synthesizeKey("e", { ctrlKey: true });
+ EventUtils.synthesizeKey("e", {ctrlKey: true});
is(inputNode.selectionStart, caretPos,
"repeat ctrl-e doesn't change caret position in multiline input");
// navigate down one line; ctrl-a to the beginning; ctrl-e to end
for (let i = 1; i < lineValues.length; i++) {
- EventUtils.synthesizeKey("n", { ctrlKey: true });
- EventUtils.synthesizeKey("a", { ctrlKey: true });
+ EventUtils.synthesizeKey("n", {ctrlKey: true});
+ EventUtils.synthesizeKey("a", {ctrlKey: true});
caretPos = inputNode.selectionStart;
expectedStringBeforeCarat += newlineString;
is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat,
"ctrl-a to beginning of line " + (i + 1) + " in multiline input");
- EventUtils.synthesizeKey("e", { ctrlKey: true });
+ EventUtils.synthesizeKey("e", {ctrlKey: true});
caretPos = inputNode.selectionStart;
expectedStringBeforeCarat += lineValues[i];
is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat,
"ctrl-e to end of line " + (i + 1) + "in multiline input");
}
}
function testNavWithHistory() {
@@ -166,62 +166,62 @@ function testNavWithHistory() {
];
// submit to history
for (let i = 0; i < values.length; i++) {
jsterm.setInputValue(values[i]);
jsterm.execute();
}
is(inputNode.selectionStart, 0, "caret location at start of empty line");
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
is(inputNode.selectionStart, values[values.length - 1].length,
"caret location correct at end of last history input");
// Navigate backwards history with ctrl-p
for (let i = values.length - 1; i > 0; i--) {
let match = values[i].match(/(\n)/g);
if (match) {
// multi-line inputs won't update from history unless caret at beginning
- EventUtils.synthesizeKey("a", { ctrlKey: true });
+ EventUtils.synthesizeKey("a", {ctrlKey: true});
for (let j = 0; j < match.length; j++) {
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
}
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
} else {
// single-line inputs will update from history from end of line
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
}
is(jsterm.getInputValue(), values[i - 1],
"ctrl-p updates inputNode from backwards history values[" + i - 1 + "]");
}
let inputValue = jsterm.getInputValue();
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
is(inputNode.selectionStart, 0,
"ctrl-p at beginning of history moves caret location to beginning " +
"of line");
is(jsterm.getInputValue(), inputValue,
"no change to input value on ctrl-p from beginning of line");
// Navigate forwards history with ctrl-n
for (let i = 1; i < values.length; i++) {
- EventUtils.synthesizeKey("n", { ctrlKey: true });
+ EventUtils.synthesizeKey("n", {ctrlKey: true});
is(jsterm.getInputValue(), values[i],
"ctrl-n updates inputNode from forwards history values[" + i + "]");
is(inputNode.selectionStart, values[i].length,
"caret location correct at end of history input for values[" + i + "]");
}
- EventUtils.synthesizeKey("n", { ctrlKey: true });
+ EventUtils.synthesizeKey("n", {ctrlKey: true});
ok(!jsterm.getInputValue(), "ctrl-n at end of history updates to empty input");
// Simulate editing multi-line
inputValue = "one\nlinebreak";
jsterm.setInputValue(inputValue);
// Attempt nav within input
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
is(jsterm.getInputValue(), inputValue,
"ctrl-p from end of multi-line does not trigger history");
- EventUtils.synthesizeKey("a", { ctrlKey: true });
- EventUtils.synthesizeKey("p", { ctrlKey: true });
+ EventUtils.synthesizeKey("a", {ctrlKey: true});
+ EventUtils.synthesizeKey("p", {ctrlKey: true});
is(jsterm.getInputValue(), values[values.length - 1],
"ctrl-p from start of multi-line triggers history");
}
--- a/devtools/client/webconsole/test/browser_webconsole_bug_817834_add_edited_input_to_history.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_817834_add_edited_input_to_history.js
@@ -22,36 +22,36 @@ add_task(function* () {
function testEditedInputHistory(HUD) {
let jsterm = HUD.jsterm;
let inputNode = jsterm.inputNode;
ok(!jsterm.getInputValue(), "jsterm.getInputValue() is empty");
is(inputNode.selectionStart, 0);
is(inputNode.selectionEnd, 0);
jsterm.setInputValue('"first item"');
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), '"first item"', "null test history up");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), '"first item"', "null test history down");
jsterm.execute();
is(jsterm.getInputValue(), "", "cleared input line after submit");
jsterm.setInputValue('"editing input 1"');
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), '"first item"', "test history up");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), '"editing input 1"',
"test history down restores in-progress input");
jsterm.setInputValue('"second item"');
jsterm.execute();
jsterm.setInputValue('"editing input 2"');
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), '"second item"', "test history up");
- EventUtils.synthesizeKey("VK_UP", {});
+ EventUtils.synthesizeKey("KEY_ArrowUp");
is(jsterm.getInputValue(), '"first item"', "test history up");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), '"second item"', "test history down");
- EventUtils.synthesizeKey("VK_DOWN", {});
+ EventUtils.synthesizeKey("KEY_ArrowDown");
is(jsterm.getInputValue(), '"editing input 2"',
"test history down restores new in-progress input again");
}
--- a/devtools/client/webconsole/test/browser_webconsole_js_input_expansion.js
+++ b/devtools/client/webconsole/test/browser_webconsole_js_input_expansion.js
@@ -25,31 +25,31 @@ add_task(function* () {
input.selectionEnd = length;
input.selectionStart = length;
function getHeight() {
return input.clientHeight;
}
let initialHeight = getHeight();
// Performs an "d". This will trigger/test for the input event that should
// change the "row" attribute of the inputNode.
- EventUtils.synthesizeKey("d", {});
+ EventUtils.sendString("d");
let newHeight = getHeight();
ok(initialHeight < newHeight, "Height changed: " + newHeight);
// Add some more rows. Tests for the 8 row limit.
input.value = "row1\nrow2\nrow3\nrow4\nrow5\nrow6\nrow7\nrow8\nrow9\nrow10\n";
length = input.value.length;
input.selectionEnd = length;
input.selectionStart = length;
- EventUtils.synthesizeKey("d", {});
+ EventUtils.sendString("d");
let newerHeight = getHeight();
ok(newerHeight > newHeight, "height changed: " + newerHeight);
// Test if the inputNode shrinks again.
input.value = "";
- EventUtils.synthesizeKey("d", {});
+ EventUtils.sendString("d");
let height = getHeight();
info("height: " + height);
info("initialHeight: " + initialHeight);
let finalHeightDifference = Math.abs(initialHeight - height);
ok(finalHeightDifference <= 1, "height shrank to original size within 1px");
});
--- a/docshell/test/browser/browser_uriFixupIntegration.js
+++ b/docshell/test/browser/browser_uriFixupIntegration.js
@@ -31,17 +31,17 @@ add_task(async function test() {
for (let searchParams of ["foo bar", "brokenprotocol:somethingelse"]) {
// Add a new blank tab.
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
// Enter search terms and start a search.
gURLBar.value = searchParams;
gURLBar.focus();
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
// Check that we arrived at the correct URL.
let escapedParams = encodeURIComponent(searchParams).replace("%20", "+");
let expectedURL = kSearchEngineURL.replace("{searchTerms}", escapedParams);
is(gBrowser.selectedBrowser.currentURI.spec, expectedURL,
"New tab should have loaded with expected url.");
--- a/dom/events/test/bug299673.js
+++ b/dom/events/test/bug299673.js
@@ -78,18 +78,18 @@ function doTest1_rest1(expectedEventLog,
}
}
function doTest1(expectedEventLog,focusAfterCloseId) {
try {
var select1 = document.getElementById('Select1');
select1.focus();
is(document.activeElement, select1, "select element should be focused");
- synthesizeKey("VK_DOWN",{});
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Tab");
SimpleTest.waitForFocus(function () { doTest1_rest1(expectedEventLog,focusAfterCloseId); }, popup);
} catch(e) {
if (popup)
popup.close();
throw e;
}
}
--- a/dom/events/test/test_bug1305458.html
+++ b/dom/events/test/test_bug1305458.html
@@ -29,22 +29,22 @@ https://bugzilla.mozilla.org/show_bug.cg
let input = document.getElementById("test_input");
let div = document.getElementById("test_div");
input.addEventListener("change", () => {
++change_count;
});
// mouse hover
input.focus();
synthesizeMouse(input, 1, 1, {type: "mousemove"});
- synthesizeKey("1", {});
+ sendString("1");
input.blur();
is(change_count, 1, "input should fire change when blur");
input.focus();
synthesizeMouse(div, 1, 1, {type: "mousemove"});
- synthesizeKey("1", {});
+ sendString("1");
input.blur();
is(change_count, 2, "input should fire change when blur");
SimpleTest.finish();
}
</script>
</body>
</html>
--- a/dom/events/test/test_bug450876.html
+++ b/dom/events/test/test_bug450876.html
@@ -20,17 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
/** Test for Bug 450876 **/
function doTest() {
is(document.activeElement, document.body, "body element should be focused");
document.getElementById('a').focus();
is(document.activeElement, document.getElementById('a'), "link should have focus");
is(document.hasFocus(), true, "document should be focused");
- synthesizeKey("KEY_Tab", {});
+ synthesizeKey("KEY_Tab");
is(document.activeElement, document.getElementById('a'), "body element should be focused");
is(document.hasFocus(), false, "document should not be focused");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
--- a/dom/events/test/test_dom_keyboard_event.html
+++ b/dom/events/test/test_dom_keyboard_event.html
@@ -414,17 +414,17 @@ function testEnterKeyPressEvent()
const kDescription = "<" + targetId.replace("_", " ") + ">: ";
let isEditable = kDescription.includes("readonly");
let isTextarea = kDescription.includes("textarea");
target.focus();
reset();
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
is(keydownFired, true,
kDescription + "keydown event should be fired when Enter key is pressed");
is(keypressFired, true,
kDescription + "keypress event should be fired when Enter key is pressed");
if (isEditable) {
todo_is(beforeinputFired, true,
kDescription + "beforeinput event should be fired when Enter key is pressed");
} else {
--- a/dom/events/test/window_bug1369072.html
+++ b/dom/events/test/window_bug1369072.html
@@ -79,19 +79,19 @@ async function runTests()
// Wait scroll event
function onScroll() {
SimpleTest.executeSoon(resolve);
}
window.addEventListener("scroll", onScroll, { once: true });
iframe.contentWindow.addEventListener("scroll", onScroll, { once: true });
if (aVertical) {
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
} else {
- synthesizeKey("KEY_ArrowRight", {});
+ synthesizeKey("KEY_ArrowRight");
}
});
}
// When iframe element has focus and the iframe document isn't scrollable, the parent document should be scrolled instead.
document.body.focus();
iframe.focus();
await tryToScrollWithKey(true);
--- a/dom/html/test/browser_fullscreen-api-keys.js
+++ b/dom/html/test/browser_fullscreen-api-keys.js
@@ -1,16 +1,16 @@
"use strict";
/** Test for Bug 545812 **/
// List of key codes which should exit full-screen mode.
const kKeyList = [
- { code: "VK_ESCAPE", suppressed: true},
- { code: "VK_F11", suppressed: false},
+ { key: "Escape", keyCode: "VK_ESCAPE", suppressed: true},
+ { key: "F11", keyCode: "VK_F11", suppressed: false},
];
const kStrictKeyPressEvents =
SpecialPowers.getBoolPref("dom.keyboardevent.keypress.dispatch_non_printable_keys_only_system_group_in_content");
function frameScript() {
let doc = content.document;
addMessageListener("Test:RequestFullscreen", () => {
@@ -131,42 +131,42 @@ add_task(async function() {
"Test:KeyReceived", captureUnexpectedKeyEvent);
registerCleanupFunction(() => {
gMessageManager.removeMessageListener(
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
gMessageManager.removeMessageListener(
"Test:KeyReceived", captureUnexpectedKeyEvent);
});
- for (let {code, suppressed} of kKeyList) {
- var keyCode = KeyEvent["DOM_" + code];
- info(`Test keycode ${code} (${keyCode})`);
+ for (let {key, keyCode, suppressed} of kKeyList) {
+ let keyCodeValue = KeyEvent["DOM_" + keyCode];
+ info(`Test keycode ${key} (${keyCodeValue})`);
info("Enter fullscreen");
await temporaryRemoveUnexpectedFullscreenChangeCapture(async function() {
gMessageManager.sendAsyncMessage("Test:RequestFullscreen");
let state = await promiseOneMessage("Test:FullscreenChanged");
ok(state, "The content should have entered fullscreen");
ok(document.fullscreenElement,
"The chrome should also be in fullscreen");
});
info("Dispatch untrusted key events from content");
await temporaryRemoveUnexpectedKeyEventCapture(async function() {
- let promiseExpectedKeyEvents = receiveExpectedKeyEvents(keyCode, false);
- gMessageManager.sendAsyncMessage("Test:DispatchUntrustedKeyEvents", code);
+ let promiseExpectedKeyEvents = receiveExpectedKeyEvents(keyCodeValue, false);
+ gMessageManager.sendAsyncMessage("Test:DispatchUntrustedKeyEvents", keyCode);
await promiseExpectedKeyEvents;
});
info("Send trusted key events");
await temporaryRemoveUnexpectedFullscreenChangeCapture(async function() {
await temporaryRemoveUnexpectedKeyEventCapture(async function() {
let promiseExpectedKeyEvents = suppressed ?
- Promise.resolve() : receiveExpectedKeyEvents(keyCode, true);
- EventUtils.synthesizeKey(code, {});
+ Promise.resolve() : receiveExpectedKeyEvents(keyCodeValue, true);
+ EventUtils.synthesizeKey("KEY_" + key);
await promiseExpectedKeyEvents;
let state = await promiseOneMessage("Test:FullscreenChanged");
ok(!state, "The content should have exited fullscreen");
ok(!document.fullscreenElement,
"The chrome should also have exited fullscreen");
});
});
}
--- a/dom/html/test/browser_fullscreen-contextmenu-esc.js
+++ b/dom/html/test/browser_fullscreen-contextmenu-esc.js
@@ -79,29 +79,29 @@ add_task(async function() {
let popupShownPromise = promiseWaitForEvent(window, "popupshown");
EventUtils.synthesizeMouse(browser, screen.width / 2, screen.height / 2,
{type: "contextmenu", button: 2}, window);
await popupShownPromise;
is(contextMenu.state, "open", "Should have opened context menu");
info("Send the first escape");
let popupHidePromise = promiseWaitForEvent(window, "popuphidden");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
await popupHidePromise;
is(contextMenu.state, "closed", "Should have closed context menu");
// Wait a small time to confirm that the first ESC key
// does not exit fullscreen.
await new Promise(resolve => setTimeout(resolve, 1000));
gMessageManager.sendAsyncMessage("Test:QueryFullscreenState");
state = await promiseOneMessage("Test:FullscreenState");
ok(state, "The content should still be in fullscreen");
ok(document.fullscreenElement, "The chrome should still be in fullscreen");
info("Send the second escape");
gMessageManager.removeMessageListener(
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
let fullscreenExitPromise = promiseOneMessage("Test:FullscreenChanged");
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
state = await fullscreenExitPromise;
ok(!state, "The content should have exited fullscreen");
ok(!document.fullscreenElement, "The chrome should have exited fullscreen");
});
--- a/dom/html/test/file_fullscreen-denied.html
+++ b/dom/html/test/file_fullscreen-denied.html
@@ -112,17 +112,17 @@ function testLongRunningEventHandler() {
addFullscreenErrorContinuation(() => {
ok(!document.fullscreenElement,
"Should not grant request in long-running event handler.");
// Restore the pref environment we changed before
// entering testNonTrustContext.
SpecialPowers.popPrefEnv(finish);
});
window.addEventListener("keypress", longRunningHandler);
- synthesizeKey("VK_A", {});
+ sendString("a");
}
function finish() {
opener.nextTest();
}
</script>
</body>
--- a/dom/html/test/file_fullscreen-esc-exit-inner.html
+++ b/dom/html/test/file_fullscreen-esc-exit-inner.html
@@ -43,16 +43,16 @@ window.addEventListener("keydown", keyHa
window.addEventListener("keyup", keyHandler, true);
window.addEventListener("keypress", keyHandler, true);
function startTest() {
ok(!document.fullscreenElement, "Subdoc should not be in full-screen mode");
ok(parent.document.fullscreenElement, "Parent should be in full-screen mode");
escKeySent = true;
window.focus();
- synthesizeKey("VK_ESCAPE", {});
+ synthesizeKey("KEY_Escape");
}
</script>
</pre>
<p>Inner frame</p>
</body>
</html>
--- a/dom/html/test/file_fullscreen-selector.html
+++ b/dom/html/test/file_fullscreen-selector.html
@@ -153,17 +153,17 @@ function exit0() {
fullscreenElems[1].requestFullscreen();
fullscreenElems[2].requestFullscreen();
}
function enterAll() {
checkFullscreenStates([true, true, true]);
info("Fully-exiting fullscreen");
addFullscreenChangeContinuation("exit", exitAll);
- synthesizeKey("VK_ESCAPE", {});
+ synthesizeKey("KEY_Escape");
}
function exitAll() {
checkFullscreenStates([false, false, false]);
opener.nextTest();
}
</script>
--- a/dom/html/test/forms/test_bug1283915.html
+++ b/dom/html/test/forms/test_bug1283915.html
@@ -19,40 +19,40 @@ https://bugzilla.mozilla.org/show_bug.cg
is(field.selectionStart, field.value.length);
is(field.selectionEnd, field.value.length);
}
function test() {
var tField = document.getElementById("textField");
tField.focus();
- synthesizeKey("a", {});
+ sendString("a");
is(tField.value, "a");
isCursorAtEnd(tField);
document.body.offsetWidth; // frame must be created after type change
- synthesizeKey("b", {});
+ sendString("b");
is(tField.value, "ab");
isCursorAtEnd(tField);
- synthesizeKey("c", {});
+ sendString("c");
is(tField.value, "abc");
isCursorAtEnd(tField);
var nField = document.getElementById("numField");
nField.focus();
- synthesizeKey("1", {});
+ sendString("1");
is(nField.value, "1");
document.body.offsetWidth;
- synthesizeKey("2", {});
+ sendString("2");
is(nField.value, "12");
- synthesizeKey("3", {});
+ sendString("3");
is(nField.value, "123");
SimpleTest.finish();
}
SimpleTest.waitForFocus(test);
</script>
</head>
--- a/dom/html/test/forms/test_bug1286509.html
+++ b/dom/html/test/forms/test_bug1286509.html
@@ -30,20 +30,20 @@ https://bugzilla.mozilla.org/show_bug.cg
expectedEventSequence.forEach((eventName) => {
eventCounts[eventName] = 0;
range.addEventListener(eventName, (e) => {
++eventCounts[eventName];
is(expectedEventSequence[expectedEventIdx], e.type, "Events sequence should be keydown, change, keyup");
expectedEventIdx = (expectedEventIdx + 1) % 3;
});
});
- synthesizeKey("VK_UP", {});
- synthesizeKey("VK_DOWN", {});
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKey("KEY_ArrowRight");
is(eventCounts['change'], 4, "Expect key up/down/left/right should trigger range input to fire change events");
SimpleTest.finish();
}
addLoadEvent(test);
</script>
</pre>
</body>
</html>
--- a/dom/html/test/forms/test_change_event.html
+++ b/dom/html/test/forms/test_change_event.html
@@ -99,60 +99,60 @@ https://bugzilla.mozilla.org/show_bug.cg
// remove it, otherwise cleanup() opens a native file picker!
input.remove();
MockFilePicker.cleanup();
//text, email, search, telephone, url & password input tests
for (var i = 0; i < textInputTypes.length; ++i) {
input = document.getElementById("input_" + textInputTypes[i]);
input.focus();
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
is(textInputChange[i], 0, "Change event shouldn't be dispatched on " + textInputTypes[i] + " input element");
- synthesizeKey("m", {});
- synthesizeKey("VK_RETURN", {});
+ sendString("m");
+ synthesizeKey("KEY_Enter");
is(textInputChange[i], 1, textInputTypes[i] + " input element should have dispatched change event.");
}
//focus and blur text input
input = document.getElementById("input_text");
input.focus();
- synthesizeKey("f", {});
+ sendString("f");
input.blur();
is(textInputChange[0], 2, "text input element should have dispatched change event (2).");
// value being set while focused
input.focus();
input.value = 'foo';
input.blur();
is(textInputChange[0], 2, "text input element should not have dispatched change event (2).");
// value being set while focused after being modified manually
input.focus();
- synthesizeKey("f", {});
+ sendString("f");
input.value = 'bar';
input.blur();
is(textInputChange[0], 3, "text input element should have dispatched change event (3).");
//focus and blur textarea
var textarea = document.getElementById("textarea");
textarea.focus();
- synthesizeKey("f", {});
+ sendString("f");
textarea.blur();
is(textareaChange, 1, "Textarea element should have dispatched change event.");
// value being set while focused
textarea.focus();
textarea.value = 'foo';
textarea.blur();
is(textareaChange, 1, "textarea should not have dispatched change event (1).");
// value being set while focused after being modified manually
textarea.focus();
- synthesizeKey("f", {});
+ sendString("f");
textarea.value = 'bar';
textarea.blur();
is(textareaChange, 2, "textearea should have dispatched change event (2).");
//Non-text input tests:
for (var i = 0; i < NonTextInputTypes.length; ++i) {
//button, submit, image and reset input type tests.
if (i < 4) {
@@ -181,45 +181,44 @@ https://bugzilla.mozilla.org/show_bug.cg
is(NonTextInputChange[i], 1, "Change event shouldn't be dispatched if click event is cancelled");
input.removeEventListener("click", preventDefault);
}
}
// Special case type=number
var number = document.getElementById("input_number");
number.focus();
- synthesizeKey("a", {});
+ sendString("a");
number.blur();
is(numberChange, 0, "Change event shouldn't be dispatched on number input element for key changes that don't change its value");
number.value = "";
number.focus();
- synthesizeKey("1", {});
- synthesizeKey("2", {});
+ sendString("12");
is(numberChange, 0, "Change event shouldn't be dispatched on number input element for keyboard input until it loses focus");
number.blur();
is(numberChange, 1, "Change event should be dispatched on number input element on blur");
is(number.value, "12", "Sanity check that number keys were actually handled");
if (isDesktop) { // up/down arrow keys not supported on android/b2g
number.value = "";
number.focus();
- synthesizeKey("VK_UP", {});
- synthesizeKey("VK_UP", {});
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_ArrowDown");
is(numberChange, 4, "Change event should be dispatched on number input element for up/down arrow keys (a special case)");
is(number.value, "1", "Sanity check that number and arrow keys were actually handled");
}
// Special case type=range
var range = document.getElementById("input_range");
range.focus();
- synthesizeKey("a", {});
+ sendString("a");
range.blur();
is(rangeChange, 0, "Change event shouldn't be dispatched on range input element for key changes that don't change its value");
range.focus();
- synthesizeKey("VK_HOME", {});
+ synthesizeKey("VK_HOME");
is(rangeChange, 1, "Change event should be dispatched on range input element for key changes");
range.blur();
is(rangeChange, 1, "Change event shouldn't be dispatched on range input element on blur");
range.focus();
var bcr = range.getBoundingClientRect();
var centerOfRangeX = bcr.width / 2;
var centerOfRangeY = bcr.height / 2;
synthesizeMouse(range, centerOfRangeX - 10, centerOfRangeY, { type: "mousedown" });
@@ -229,40 +228,40 @@ https://bugzilla.mozilla.org/show_bug.cg
synthesizeMouse(range, centerOfRangeX, centerOfRangeY, { type: "mouseup" });
is(rangeChange, 2, "Change event should be dispatched on range input element at end of drag");
range.blur();
is(rangeChange, 2, "Change event shouldn't be dispatched on range input element when range loses focus after a drag");
synthesizeMouse(range, centerOfRangeX - 10, centerOfRangeY, {});
is(rangeChange, 3, "Change event should be dispatched on range input element for a click that gives the range focus");
if (isDesktop) { // up/down arrow keys not supported on android/b2g
- synthesizeKey("VK_UP", {});
- is(rangeChange, 4, "Change event should be dispatched on range input element for key changes that change its value (VK_UP)");
- synthesizeKey("VK_DOWN", {});
- is(rangeChange, 5, "Change event should be dispatched on range input element for key changes that change its value (VK_DOWN)");
- synthesizeKey("VK_RIGHT", {});
- is(rangeChange, 6, "Change event should be dispatched on range input element for key changes that change its value (VK_RIGHT)");
- synthesizeKey("VK_LEFT", {});
- is(rangeChange, 7, "Change event should be dispatched on range input element for key changes that change its value (VK_LEFT)");
- synthesizeKey("VK_UP", {shiftKey: true});
- is(rangeChange, 8, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_UP)");
- synthesizeKey("VK_DOWN", {shiftKey: true});
- is(rangeChange, 9, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_DOWN)");
- synthesizeKey("VK_RIGHT", {shiftKey: true});
- is(rangeChange, 10, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_RIGHT)");
- synthesizeKey("VK_LEFT", {shiftKey: true});
- is(rangeChange, 11, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_LEFT)");
- synthesizeKey("VK_PAGE_UP", {});
- is(rangeChange, 12, "Change event should be dispatched on range input element for key changes that change its value (VK_PAGE_UP)");
- synthesizeKey("VK_PAGE_DOWN", {});
- is(rangeChange, 13, "Change event should be dispatched on range input element for key changes that change its value (VK_PAGE_DOWN");
- synthesizeKey("VK_RIGHT", {shiftKey: true});
- is(rangeChange, 14, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_PAGE_UP)");
- synthesizeKey("VK_LEFT", {shiftKey: true});
- is(rangeChange, 15, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_PAGE_DOWN)");
+ synthesizeKey("KEY_ArrowUp");
+ is(rangeChange, 4, "Change event should be dispatched on range input element for key changes that change its value (KEY_ArrowUp)");
+ synthesizeKey("KEY_ArrowDown");
+ is(rangeChange, 5, "Change event should be dispatched on range input element for key changes that change its value (KEY_ArrowDown)");
+ synthesizeKey("KEY_ArrowRight");
+ is(rangeChange, 6, "Change event should be dispatched on range input element for key changes that change its value (KEY_ArrowRight)");
+ synthesizeKey("KEY_ArrowLeft");
+ is(rangeChange, 7, "Change event should be dispatched on range input element for key changes that change its value (KEY_ArrowLeft)");
+ synthesizeKey("KEY_ArrowUp", {shiftKey: true});
+ is(rangeChange, 8, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_ArrowUp)");
+ synthesizeKey("KEY_ArrowDown", {shiftKey: true});
+ is(rangeChange, 9, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_ArrowDown)");
+ synthesizeKey("KEY_ArrowRight", {shiftKey: true});
+ is(rangeChange, 10, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_ArrowRight)");
+ synthesizeKey("KEY_ArrowLeft", {shiftKey: true});
+ is(rangeChange, 11, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_ArrowLeft)");
+ synthesizeKey("KEY_PageUp");
+ is(rangeChange, 12, "Change event should be dispatched on range input element for key changes that change its value (KEY_PageUp)");
+ synthesizeKey("KEY_PageDown");
+ is(rangeChange, 13, "Change event should be dispatched on range input element for key changes that change its value (KEY_PageDown");
+ synthesizeKey("KEY_ArrowRight", {shiftKey: true});
+ is(rangeChange, 14, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_PageUp)");
+ synthesizeKey("KEY_ArrowLeft", {shiftKey: true});
+ is(rangeChange, 15, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_PageDown)");
}
//Input type change test.
input = document.getElementById("input_checkbox");
input.type = "text";
input.focus();
input.click();
input.blur();
is(NonTextInputChange[5], 1, "Change event shouldn't be dispatched for checkbox ---> text input type change");
--- a/dom/html/test/forms/test_formaction_attribute.html
+++ b/dom/html/test/forms/test_formaction_attribute.html
@@ -127,32 +127,32 @@ function runTests()
}, {once: true});
document.getElementById('bsbis').addEventListener('focus', function(aEvent) {
document.getElementById('bsbis').click();
document.getElementById('is2').focus();
}, {once: true});
document.getElementById('is2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('ii2').focus();
}, {once: true});
document.getElementById('ii2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('bs2').focus();
}, {once: true});
document.getElementById('bs2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('enter').focus();
}, {once: true});
document.getElementById('enter').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
}, {once: true});
document.getElementById('is').focus();
}
function frameLoaded(aFrame) {
// Check if formaction/action has the correct behavior.
is(aFrame.contentWindow.location.href, gTestResults[aFrame.name],
--- a/dom/html/test/forms/test_formnovalidate_attribute.html
+++ b/dom/html/test/forms/test_formnovalidate_attribute.html
@@ -68,17 +68,17 @@ if (observers.hasMoreElements()) {
});
document.getElementById('bv').addEventListener("invalid", function(aEvent) {
aEvent.target.removeAttribute("invalid", arguments.callee, false);
ok(true, "formnovalidate should not apply on if not set on the submit " +
"control used for the submission");
var c = document.getElementById('c');
c.focus();
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
});
document.getElementById('c').addEventListener("invalid", function(aEvent) {
aEvent.target.removeAttribute("invalid", arguments.callee, false);
ok(true, "formnovalidate should only apply on submit controls");
document.getElementById('d').click();
});
--- a/dom/html/test/forms/test_input_date_bad_input.html
+++ b/dom/html/test/forms/test_input_date_bad_input.html
@@ -48,18 +48,18 @@ function checkValidity(aElement, aIsBadI
"validationMessage should be: " + (aIsBadInput ? DATE_BAD_INPUT_MSG : ""));
is(window.getComputedStyle(aElement).getPropertyValue('background-color'),
aIsBadInput ? "rgb(255, 0, 0)" : "rgb(0, 255, 0)",
(aIsBadInput ? ":invalid" : "valid") + " pseudo-classs should apply");
}
function sendKeys(aKey) {
- if (aKey.startsWith("VK")) {
- synthesizeKey(aKey, {});
+ if (aKey.startsWith("KEY_")) {
+ synthesizeKey(aKey);
} else {
sendString(aKey);
}
}
function test() {
var elem = document.getElementById("input");
var inputRect = input.getBoundingClientRect();
@@ -80,17 +80,17 @@ function test() {
elem.focus();
sendKeys("06312000");
elem.blur();
checkValidity(elem, true);
// Removing any of the fields makes the input valid again.
elem.focus();
- sendKeys("VK_BACK_SPACE");
+ sendKeys("KEY_Backspace");
elem.blur();
checkValidity(elem, false);
elem.focus();
sendKeys("02292017");
elem.blur();
checkValidity(elem, true);
--- a/dom/html/test/forms/test_input_date_key_events.html
+++ b/dom/html/test/forms/test_input_date_key_events.html
@@ -84,129 +84,129 @@ var testData = [
// Type 000000 in the year field will set it to the minimum year, which is
// 0001.
keys: ["0101000000"],
initialVal: "",
expectedVal: "0001-01-01"
},
{
// Advance to year field and decrement.
- keys: ["VK_TAB", "VK_TAB", "VK_DOWN"],
+ keys: ["KEY_Tab", "KEY_Tab", "KEY_ArrowDown"],
initialVal: "2016-11-25",
expectedVal: "2015-11-25"
},
{
// Right key should do the same thing as TAB key.
- keys: ["VK_RIGHT", "VK_RIGHT", "VK_DOWN"],
+ keys: ["KEY_ArrowRight", "KEY_ArrowRight", "KEY_ArrowDown"],
initialVal: "2016-11-25",
expectedVal: "2015-11-25"
},
{
// Advance to day field then back to month field and decrement.
- keys: ["VK_RIGHT", "VK_LEFT", "VK_DOWN"],
+ keys: ["KEY_ArrowRight", "KEY_ArrowLeft", "KEY_ArrowDown"],
initialVal: "2000-05-01",
expectedVal: "2000-04-01"
},
{
// Focus starts on the first field, month in this case, and increment.
- keys: ["VK_UP"],
+ keys: ["KEY_ArrowUp"],
initialVal: "2000-03-01",
expectedVal: "2000-04-01"
},
{
// Advance to day field and decrement.
- keys: ["VK_TAB", "VK_DOWN"],
+ keys: ["KEY_Tab", "KEY_ArrowDown"],
initialVal: "1234-01-01",
expectedVal: "1234-01-31"
},
{
// Advance to day field and increment.
- keys: ["VK_TAB", "VK_UP"],
+ keys: ["KEY_Tab", "KEY_ArrowUp"],
initialVal: "1234-01-01",
expectedVal: "1234-01-02"
},
{
// PageUp on month field increments month by 3.
- keys: ["VK_PAGE_UP"],
+ keys: ["KEY_PageUp"],
initialVal: "1999-01-01",
expectedVal: "1999-04-01"
},
{
// PageDown on month field decrements month by 3.
- keys: ["VK_PAGE_DOWN"],
+ keys: ["KEY_PageDown"],
initialVal: "1999-01-01",
expectedVal: "1999-10-01"
},
{
// PageUp on day field increments day by 7.
- keys: ["VK_TAB", "VK_PAGE_UP"],
+ keys: ["KEY_Tab", "KEY_PageUp"],
initialVal: "1999-01-01",
expectedVal: "1999-01-08"
},
{
// PageDown on day field decrements day by 7.
- keys: ["VK_TAB", "VK_PAGE_DOWN"],
+ keys: ["KEY_Tab", "KEY_PageDown"],
initialVal: "1999-01-01",
expectedVal: "1999-01-25"
},
{
// PageUp on year field increments year by 10.
- keys: ["VK_TAB", "VK_TAB", "VK_PAGE_UP"],
+ keys: ["KEY_Tab", "KEY_Tab", "KEY_PageUp"],
initialVal: "1999-01-01",
expectedVal: "2009-01-01"
},
{
// PageDown on year field decrements year by 10.
- keys: ["VK_TAB", "VK_TAB", "VK_PAGE_DOWN"],
+ keys: ["KEY_Tab", "KEY_Tab", "KEY_PageDown"],
initialVal: "1999-01-01",
expectedVal: "1989-01-01"
},
{
// Home key on month field sets it to the minimum month, which is 01.
- keys: ["VK_HOME"],
+ keys: ["KEY_Home"],
initialVal: "2016-06-01",
expectedVal: "2016-01-01"
},
{
// End key on month field sets it to the maximum month, which is 12.
- keys: ["VK_END"],
+ keys: ["KEY_End"],
initialVal: "2016-06-01",
expectedVal: "2016-12-01"
},
{
// Home key on day field sets it to the minimum day, which is 01.
- keys: ["VK_TAB", "VK_HOME"],
+ keys: ["KEY_Tab", "KEY_Home"],
initialVal: "2016-01-10",
expectedVal: "2016-01-01"
},
{
// End key on day field sets it to the maximum day, which is 31.
- keys: ["VK_TAB", "VK_END"],
+ keys: ["KEY_Tab", "KEY_End"],
initialVal: "2016-01-10",
expectedVal: "2016-01-31"
},
{
// Home key should have no effect on year field.
- keys: ["VK_TAB", "VK_TAB", "VK_HOME"],
+ keys: ["KEY_Tab", "KEY_Tab", "KEY_Home"],
initialVal: "2016-01-01",
expectedVal: "2016-01-01"
},
{
// End key should have no effect on year field.
- keys: ["VK_TAB", "VK_TAB", "VK_END"],
+ keys: ["KEY_Tab", "KEY_Tab", "KEY_End"],
initialVal: "2016-01-01",
expectedVal: "2016-01-01"
},
];
function sendKeys(aKeys) {
for (let i = 0; i < aKeys.length; i++) {
let key = aKeys[i];
- if (key.startsWith("VK")) {
- synthesizeKey(key, {});
+ if (key.startsWith("KEY_")) {
+ synthesizeKey(key);
} else {
sendString(key);
}
}
}
function test() {
var elem = document.getElementById("input");
--- a/dom/html/test/forms/test_input_datetime_focus_blur_events.html
+++ b/dom/html/test/forms/test_input_datetime_focus_blur_events.html
@@ -47,35 +47,35 @@ function test() {
input.focus();
is(focusEvents[i], 1, inputTypes[i] + " input element should have dispatched focus event.");
is(focusInEvents[i], 1, inputTypes[i] + " input element should have dispatched focusin event.");
is(focusOutEvents[i], 0, inputTypes[i] + " input element should not have dispatched focusout event.");
is(blurEvents[i], 0, inputTypes[i] + " input element should not have dispatched blur event.");
// Move around inside the input element's input box.
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
is(focusEvents[i], 1, inputTypes[i] + " input element should not have dispatched focus event.");
is(focusInEvents[i], 1, inputTypes[i] + " input element should not have dispatched focusin event.");
is(focusOutEvents[i], 0, inputTypes[i] + " input element should not have dispatched focusout event.");
is(blurEvents[i], 0, inputTypes[i] + " time input element should not have dispatched blur event.");
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
is(focusEvents[i], 1, inputTypes[i] + " input element should not have dispatched focus event.");
is(focusInEvents[i], 1, inputTypes[i] + " input element should not have dispatched focusin event.");
is(focusOutEvents[i], 0, inputTypes[i] + " input element should not have dispatched focusout event.");
is(blurEvents[i], 0, inputTypes[i] + " input element should not have dispatched blur event.");
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
is(focusEvents[i], 1,inputTypes[i] + " input element should not have dispatched focus event.");
is(focusInEvents[i], 1, inputTypes[i] + " input element should not have dispatched focusin event.");
is(focusOutEvents[i], 0, inputTypes[i] + " input element should not have dispatched focusout event.");
is(blurEvents[i], 0, inputTypes[i] + " input element should not have dispatched blur event.");
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
is(focusEvents[i], 1, inputTypes[i] + " input element should not have dispatched focus event.");
is(focusInEvents[i], 1, inputTypes[i] + " input element should not have dispatched focusin event.");
is(focusOutEvents[i], 0, inputTypes[i] + " input element should not have dispatched focusout event.");
is(blurEvents[i], 0, inputTypes[i] + " input element should not have dispatched blur event.");
input.blur();
is(focusEvents[i], 1, inputTypes[i] + " input element should not have dispatched focus event.");
is(focusInEvents[i], 1, inputTypes[i] + " input element should not have dispatched focusin event.");
--- a/dom/html/test/forms/test_input_datetime_input_change_events.html
+++ b/dom/html/test/forms/test_input_datetime_input_change_events.html
@@ -57,25 +57,24 @@ function test() {
input.value = values[i];
is(input.value, values[i], "Check that value was set correctly (0).");
is(changeEvents[i], 0, "Change event should not have dispatched (0).");
is(inputEvents[i], 0, "Input event should not have dispatched (0).");
// Test that change and input events are fired when changing the value using
// up/down keys.
input.focus();
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(input.value, expectedValues[i][0], "Check that value was set correctly (1).");
is(changeEvents[i], 1, "Change event should be dispatched (1).");
is(inputEvents[i], 1, "Input event should ne dispatched (1).");
// Test that change and input events are fired when changing the value with
// the keyboard.
- synthesizeKey("0", {});
- synthesizeKey("1", {});
+ sendString("01");
is(input.value, expectedValues[i][1], "Check that value was set correctly (2).");
is(changeEvents[i], 2, "Change event should be dispatched (2).");
is(inputEvents[i], 2, "Input event should be dispatched (2).");
// Reset button is desktop only.
if (isDesktop) {
// Test that change and input events are fired when clearing the value using
// the reset button.
--- a/dom/html/test/forms/test_input_datetime_tabindex.html
+++ b/dom/html/test/forms/test_input_datetime_tabindex.html
@@ -39,37 +39,37 @@ function testTabindex(type) {
let input2 = document.getElementById(type + "2");
let input3 = document.getElementById(type + "3");
input1.focus();
is(document.activeElement, input1,
"input element with tabindex=0 is focusable");
// Advance to next inner field
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
is(document.activeElement, input1,
"input element with tabindex=0 is tabbable");
// Advance to next inner field
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
is(document.activeElement, input1,
"input element with tabindex=0 is tabbable");
// Advance to next element
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
is(document.activeElement, input3,
"input element with tabindex=-1 is not tabbable");
input2.focus();
is(document.activeElement, input2,
"input element with tabindex=-1 is still focusable");
// Changing the tabindex attribute dynamically.
input3.setAttribute("tabindex", "-1");
- synthesizeKey("VK_TAB", {}); // need only one TAB since input2 is not tabbable
+ synthesizeKey("KEY_Tab"); // need only one TAB since input2 is not tabbable
isnot(document.activeElement, input3,
"element with tabindex changed to -1 should not be tabbable");
}
function test() {
let inputTypes = ["time", "date"];
for (let i = 0; i < inputTypes.length; i++) {
--- a/dom/html/test/forms/test_input_event.html
+++ b/dom/html/test/forms/test_input_event.html
@@ -72,70 +72,70 @@ https://bugzilla.mozilla.org/show_bug.cg
setTimeout(testUserInput2, 0);
}
function testUserInput2() {
// Some generic checks for types that support the input event.
for (var i = 0; i < textTypes.length; ++i) {
input = document.getElementById("input_" + textTypes[i]);
input.focus();
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
is(textInput[i], 0, "input event shouldn't be dispatched on " + textTypes[i] + " input element");
- synthesizeKey("m", {});
+ sendString("m");
is(textInput[i], 1, textTypes[i] + " input element should have dispatched input event.");
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
is(textInput[i], 1, "input event shouldn't be dispatched on " + textTypes[i] + " input element");
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(textInput[i], 2, textTypes[i] + " input element should have dispatched input event.");
}
// Some scenarios of value changing from script and from user input.
input = document.getElementById("input_text");
input.focus();
- synthesizeKey("f", {});
+ sendString("f");
is(textInput[0], 3, "input event should have been dispatched");
input.blur();
is(textInput[0], 3, "input event should not have been dispatched");
input.focus();
input.value = 'foo';
is(textInput[0], 3, "input event should not have been dispatched");
input.blur();
is(textInput[0], 3, "input event should not have been dispatched");
input.focus();
- synthesizeKey("f", {});
+ sendString("f");
is(textInput[0], 4, "input event should have been dispatched");
input.value = 'bar';
is(textInput[0], 4, "input event should not have been dispatched");
input.blur();
is(textInput[0], 4, "input event should not have been dispatched");
// Same for textarea.
var textarea = document.getElementById("textarea");
textarea.focus();
- synthesizeKey("f", {});
+ sendString("f");
is(textareaInput, 1, "input event should have been dispatched");
textarea.blur();
is(textareaInput, 1, "input event should not have been dispatched");
textarea.focus();
textarea.value = 'foo';
is(textareaInput, 1, "input event should not have been dispatched");
textarea.blur();
is(textareaInput, 1, "input event should not have been dispatched");
textarea.focus();
- synthesizeKey("f", {});
+ sendString("f");
is(textareaInput, 2, "input event should have been dispatched");
textarea.value = 'bar';
is(textareaInput, 2, "input event should not have been dispatched");
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(textareaInput, 3, "input event should have been dispatched");
textarea.blur();
is(textareaInput, 3, "input event should not have been dispatched");
// Non-text input tests:
for (var i = 0; i < NonTextTypes.length; ++i) {
// Button, submit, image and reset input type tests.
if (i < 4) {
@@ -175,23 +175,23 @@ https://bugzilla.mozilla.org/show_bug.cg
};
input.type = 'range';
isnot(input.value, 'foo');
// Tests for type='range'.
var range = document.getElementById("input_range");
range.focus();
- synthesizeKey("a", {});
+ sendString("a");
range.blur();
is(rangeInput, 0, "input event shouldn't be dispatched on range input " +
"element for key changes that don't change its value");
range.focus();
- synthesizeKey("VK_HOME", {});
+ synthesizeKey("KEY_Home");
is(rangeInput, 1, "input event should be dispatched for key changes");
range.blur();
is(rangeInput, 1, "input event shouldn't be dispatched on blur");
range.focus();
var bcr = range.getBoundingClientRect();
var centerOfRangeX = bcr.width / 2;
var centerOfRangeY = bcr.height / 2;
@@ -205,17 +205,17 @@ https://bugzilla.mozilla.org/show_bug.cg
// Tests for type='number'.
// We only test key events here since input events for mouse event changes
// are tested in test_input_number_mouse_events.html
var number = document.getElementById("input_number");
if (isDesktop) { // up/down arrow keys not supported on android/b2g
number.value = "";
number.focus();
- synthesizeKey("KEY_ArrowUp", {});
+ synthesizeKey("KEY_ArrowUp");
is(numberInput, 1, "input event should be dispatched for up/down arrow key keypress");
is(number.value, "1", "sanity check value of number control after keypress");
synthesizeKey("KEY_ArrowDown", {repeat: 3});
is(numberInput, 4, "input event should be dispatched for each up/down arrow key keypress event, even when rapidly repeated");
is(number.value, "-2", "sanity check value of number control after multiple keydown events");
number.blur();
--- a/dom/html/test/forms/test_input_file_picker.html
+++ b/dom/html/test/forms/test_input_file_picker.html
@@ -194,17 +194,17 @@ function launchNextTest() {
} else if (testData[currentTest][0] == 'button-click' ||
testData[currentTest][0] == 'button-down' ||
testData[currentTest][0] == 'button-up' ||
testData[currentTest][0] == 'div-click' ||
testData[currentTest][0] == 'div-click-on-demand' ||
testData[currentTest][0] == 'link-click') {
synthesizeMouseAtCenter(document.getElementById(testData[currentTest][0]), {});
} else if (testData[currentTest][0] == 'div-keydown') {
- synthesizeKey("a", {});
+ sendString("a");
} else {
document.getElementById(testData[currentTest][0]).click();
}
}
function runTests() {
MockFilePicker.appendFilterCallback = function(filepicker, title, val) {
filters.push(val);
--- a/dom/html/test/forms/test_input_number_key_events.html
+++ b/dom/html/test/forms/test_input_number_key_events.html
@@ -155,82 +155,82 @@ function test() {
elem.step = 2;
var defaultValue = 0;
var oldVal, expectedVal;
for (key of ["KEY_ArrowUp", "KEY_ArrowDown"]) {
// Start at middle:
oldVal = elem.value = -1;
expectedVal = expectedValAfterKeyEvent(key, elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test " + key + " for number control with value set between min/max (" + oldVal + ")");
// Same again:
expectedVal = expectedValAfterKeyEvent(key, elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test repeat of " + key + " for number control");
// Start at maximum:
oldVal = elem.value = elem.max;
expectedVal = expectedValAfterKeyEvent(key, elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test " + key + " for number control with value set to the maximum (" + oldVal + ")");
// Same again:
expectedVal = expectedValAfterKeyEvent(key, elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test repeat of " + key + " for number control");
// Start at minimum:
oldVal = elem.value = elem.min;
expectedVal = expectedValAfterKeyEvent(key, elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test " + key + " for number control with value set to the minimum (" + oldVal + ")");
// Same again:
expectedVal = expectedValAfterKeyEvent(key, elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test repeat of " + key + " for number control");
// Test preventDefault():
elem.addEventListener(kStrictKeyPressEvents ? "keydown" : "keypress", function(evt) {
evt.preventDefault();
}, {once: true});
oldVal = elem.value = 0;
expectedVal = 0;
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test " + key + " for number control where scripted preventDefault() should prevent the value changing");
// Test step="any" behavior:
var oldStep = elem.step;
elem.step = "any";
oldVal = elem.value = 0;
expectedVal = expectedValAfterKeyEvent(key, elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test " + key + " for number control with value set to the midpoint and step='any' (" + oldVal + ")");
elem.step = oldStep; // restore
// Test that invalid input blocks UI initiated stepping:
oldVal = elem.value = "";
elem.select();
sendString("abc");
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, "", "Test " + key + " does nothing when the input is invalid");
// Test that no value does not block UI initiated stepping:
oldVal = elem.value = "";
elem.setAttribute("required", "required");
elem.select();
expectedVal = expectedValAfterKeyEvent(key, elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test " + key + " for number control with value set to the empty string and with the 'required' attribute set");
// Same again:
expectedVal = expectedValAfterKeyEvent(key, elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test repeat of " + key + " for number control");
// Reset 'required' attribute:
elem.removeAttribute("required");
}
// Test that key events are correctly dispatched
elem.max = "";
--- a/dom/html/test/forms/test_input_number_placeholder_shown.html
+++ b/dom/html/test/forms/test_input_number_placeholder_shown.html
@@ -18,13 +18,13 @@ input:placeholder-shown {
SimpleTest.finish();
});
function test() {
let input = document.querySelector('input');
input.focus();
is(getComputedStyle(input).borderLeftColor, "rgb(0, 0, 255)",
":placeholder-shown should apply")
- synthesizeKey('x', {});
+ sendString("x");
isnot(getComputedStyle(input).borderLeftColor, "rgb(0, 0, 255)",
":placeholder-shown should not apply, even though the value is invalid")
}
</script>
--- a/dom/html/test/forms/test_input_number_rounding.html
+++ b/dom/html/test/forms/test_input_number_rounding.html
@@ -68,41 +68,41 @@ function test() {
* The tests using those keys as marked as todo_is() hoping that at least part
* of them will fail when the widget will be implemented.
*/
/* No other implementations implement this, so we don't either, for now.
Seems like it might be nice though.
for (var i = 1; i < pgUpDnVals.length; ++i) {
- synthesizeKey("VK_PAGE_UP", {});
- todo_is(elem.value, pgUpDnVals[i], "Test VK_PAGE_UP");
+ synthesizeKey("KEY_PageUp");
+ todo_is(elem.value, pgUpDnVals[i], "Test KEY_PageUp");
is(elem.validity.valid, true, "Check element is valid for value " + pgUpDnVals[i]);
}
for (var i = pgUpDnVals.length - 2; i >= 0; --i) {
- synthesizeKey("VK_PAGE_DOWN", {});
+ synthesizeKey("KEY_PageDown");
// TODO: this condition is there because the todo_is() below would pass otherwise.
if (stepVals[i] == 0) { continue; }
- todo_is(elem.value, pgUpDnVals[i], "Test VK_PAGE_DOWN");
+ todo_is(elem.value, pgUpDnVals[i], "Test KEY_PageDown");
is(elem.validity.valid, true, "Check element is valid for value " + pgUpDnVals[i]);
}
*/
for (var i = 1; i < stepVals.length; ++i) {
- synthesizeKey("VK_UP", {});
- is(elem.value, stepVals[i], "Test VK_UP");
+ synthesizeKey("KEY_ArrowUp");
+ is(elem.value, stepVals[i], "Test KEY_ArrowUp");
is(elem.validity.valid, true, "Check element is valid for value " + stepVals[i]);
}
for (var i = stepVals.length - 2; i >= 0; --i) {
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
// TODO: this condition is there because the todo_is() below would pass otherwise.
if (stepVals[i] == 0) { continue; }
- is(elem.value, stepVals[i], "Test VK_DOWN");
+ is(elem.value, stepVals[i], "Test KEY_ArrowDown");
is(elem.validity.valid, true, "Check element is valid for value " + stepVals[i]);
}
for (var i = 1; i < stepVals.length; ++i) {
elem.stepUp();
is(elem.value, stepVals[i], "Test stepUp()");
is(elem.validity.valid, true, "Check element is valid for value " + stepVals[i]);
}
--- a/dom/html/test/forms/test_input_range_key_events.html
+++ b/dom/html/test/forms/test_input_range_key_events.html
@@ -115,32 +115,32 @@ function valueMinusTenPctOrStep(element)
}
// Test table:
const LTR = "ltr";
const RTL = "rtl";
var testTable = [
- ["VK_LEFT", LTR, valueMinusStep],
- ["VK_LEFT", RTL, valuePlusStep],
- ["VK_RIGHT", LTR, valuePlusStep],
- ["VK_RIGHT", RTL, valueMinusStep],
- ["VK_UP", LTR, valuePlusStep],
- ["VK_UP", RTL, valuePlusStep],
- ["VK_DOWN", LTR, valueMinusStep],
- ["VK_DOWN", RTL, valueMinusStep],
- ["VK_PAGE_UP", LTR, valuePlusTenPctOrStep],
- ["VK_PAGE_UP", RTL, valuePlusTenPctOrStep],
- ["VK_PAGE_DOWN", LTR, valueMinusTenPctOrStep],
- ["VK_PAGE_DOWN", RTL, valueMinusTenPctOrStep],
- ["VK_HOME", LTR, minimum],
- ["VK_HOME", RTL, minimum],
- ["VK_END", LTR, maximum],
- ["VK_END", RTL, maximum],
+ ["KEY_ArrowLeft", LTR, valueMinusStep],
+ ["KEY_ArrowLeft", RTL, valuePlusStep],
+ ["KEY_ArrowRight", LTR, valuePlusStep],
+ ["KEY_ArrowRight", RTL, valueMinusStep],
+ ["KEY_ArrowUp", LTR, valuePlusStep],
+ ["KEY_ArrowUp", RTL, valuePlusStep],
+ ["KEY_ArrowDown", LTR, valueMinusStep],
+ ["KEY_ArrowDown", RTL, valueMinusStep],
+ ["KEY_PageUp", LTR, valuePlusTenPctOrStep],
+ ["KEY_PageUp", RTL, valuePlusTenPctOrStep],
+ ["KEY_PageDown", LTR, valueMinusTenPctOrStep],
+ ["KEY_PageDown", RTL, valueMinusTenPctOrStep],
+ ["KEY_Home", LTR, minimum],
+ ["KEY_Home", RTL, minimum],
+ ["KEY_End", LTR, maximum],
+ ["KEY_End", RTL, maximum],
]
function test() {
var elem = document.createElement("input");
elem.type = "range";
var content = document.getElementById("content");
content.appendChild(elem);
@@ -152,56 +152,56 @@ function test() {
elem.step = "2";
elem.style.direction = dir;
var flush = document.body.clientWidth;
// Start at middle:
elem.value = oldVal = defaultValue(elem);
expectedVal = expectedFunc(elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test " + key + " for " + dir + " range with value set to the midpoint (" + oldVal + ")");
// Same again:
expectedVal = expectedFunc(elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test repeat of " + key + " for " + dir + " range");
// Start at maximum:
elem.value = oldVal = maximum(elem);
expectedVal = expectedFunc(elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test " + key + " for " + dir + " range with value set to the maximum (" + oldVal + ")");
// Same again:
expectedVal = expectedFunc(elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test repeat of " + key + " for " + dir + " range");
// Start at minimum:
elem.value = oldVal = minimum(elem);
expectedVal = expectedFunc(elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test " + key + " for " + dir + " range with value set to the minimum (" + oldVal + ")");
// Same again:
expectedVal = expectedFunc(elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test repeat of " + key + " for " + dir + " range");
// Test for a step value that is greater than 10% of the range:
elem.step = 20;
elem.value = 60;
expectedVal = expectedFunc(elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test " + key + " for " + dir + " range with a step that is greater than 10% of the range (step=" + elem.step + ")");
// Same again:
expectedVal = expectedFunc(elem);
- synthesizeKey(key, {});
+ synthesizeKey(key);
is(elem.value, String(expectedVal), "Test repeat of " + key + " for " + dir + " range");
// reset step:
elem.step = 2;
}
}
</script>
--- a/dom/html/test/forms/test_input_range_mouse_and_touch_events.html
+++ b/dom/html/test/forms/test_input_range_mouse_and_touch_events.html
@@ -175,25 +175,25 @@ function test(synthesizeFunc, clickOrTap
is(elem.value, QUARTER_OF_RANGE, "Test dragging is not occurring when " + startName + " was outside range");
elem.focus(); // RESTORE FOCUS SO WE GET THE FOCUSED STYLE FOR TESTING OR ELSE minX/midX/maxX may be wrong!
// Check what happens when a value changing key is pressed during a drag:
elem.value = QUARTER_OF_RANGE;
synthesizeFunc(elem, midX, midY, { type: startName });
is(elem.value, MIDDLE_OF_RANGE, "Test " + startName + " in middle of range");
- synthesizeKey("VK_HOME", {});
- // The VK_HOME tests are disabled until I can figure out why they fail on Android -jwatt
- //is(elem.value, MINIMUM_OF_RANGE, "Test VK_HOME during a drag sets the value to the minimum of the range");
+ synthesizeKey("KEY_Home");
+ // The KEY_Home tests are disabled until I can figure out why they fail on Android -jwatt
+ //is(elem.value, MINIMUM_OF_RANGE, "Test KEY_Home during a drag sets the value to the minimum of the range");
synthesizeFunc(elem, midX+100, midY, { type: moveName });
is(elem.value, MAXIMUM_OF_RANGE, "Test " + moveName + " outside range after key press that occurred during a drag changes the value");
synthesizeFunc(elem, midX, midY, { type: moveName });
is(elem.value, MIDDLE_OF_RANGE, "Test " + moveName + " in middle of range");
- synthesizeKey("VK_HOME", {});
- //is(elem.value, MINIMUM_OF_RANGE, "Test VK_HOME during a drag sets the value to the minimum of the range (second time)");
+ synthesizeKey("KEY_Home");
+ //is(elem.value, MINIMUM_OF_RANGE, "Test KEY_Home during a drag sets the value to the minimum of the range (second time)");
synthesizeFunc(elem, maxX+100, midY, { type: endName });
is(elem.value, MAXIMUM_OF_RANGE, "Test " + endName + " outside range after key press that occurred during a drag changes the value");
}
</script>
</pre>
</body>
</html>
--- a/dom/html/test/forms/test_input_range_rounding.html
+++ b/dom/html/test/forms/test_input_range_rounding.html
@@ -59,36 +59,36 @@ var pgUpDnVals = [
];
function test() {
var elem = document.getElementById("range");
elem.focus();
for (var i = 1; i < pgUpDnVals.length; ++i) {
- synthesizeKey("VK_PAGE_UP", {});
- is(elem.value, pgUpDnVals[i], "Test VK_PAGE_UP");
+ synthesizeKey("KEY_PageUp");
+ is(elem.value, pgUpDnVals[i], "Test KEY_PageUp");
is(elem.validity.valid, true, "Check element is valid for value " + pgUpDnVals[i]);
}
for (var i = pgUpDnVals.length - 2; i >= 0; --i) {
- synthesizeKey("VK_PAGE_DOWN", {});
- is(elem.value, pgUpDnVals[i], "Test VK_PAGE_DOWN");
+ synthesizeKey("KEY_PageDown");
+ is(elem.value, pgUpDnVals[i], "Test KEY_PageDown");
is(elem.validity.valid, true, "Check element is valid for value " + pgUpDnVals[i]);
}
for (var i = 1; i < stepVals.length; ++i) {
- synthesizeKey("VK_UP", {});
- is(elem.value, stepVals[i], "Test VK_UP");
+ synthesizeKey("KEY_ArrowUp");
+ is(elem.value, stepVals[i], "Test KEY_ArrowUp");
is(elem.validity.valid, true, "Check element is valid for value " + stepVals[i]);
}
for (var i = stepVals.length - 2; i >= 0; --i) {
- synthesizeKey("VK_DOWN", {});
- is(elem.value, stepVals[i], "Test VK_DOWN");
+ synthesizeKey("KEY_ArrowDown");
+ is(elem.value, stepVals[i], "Test KEY_ArrowDown");
is(elem.validity.valid, true, "Check element is valid for value " + stepVals[i]);
}
for (var i = 1; i < stepVals.length; ++i) {
elem.stepUp();
is(elem.value, stepVals[i], "Test stepUp()");
is(elem.validity.valid, true, "Check element is valid for value " + stepVals[i]);
}
--- a/dom/html/test/forms/test_input_textarea_set_value_no_scroll.html
+++ b/dom/html/test/forms/test_input_textarea_set_value_no_scroll.html
@@ -32,17 +32,17 @@ https://bugzilla.mozilla.org/show_bug.cg
// This is a sanity check.
var s2 = snapshotWindow(window);
var results = compareSnapshots(baseSnapshot, snapshotWindow(window), true);
ok(results[0], "sanity check: screenshots should be the same");
element.selectionStart = element.selectionEnd = element.value.length;
setTimeout(function() {
- synthesizeKey('f', {});
+ sendString('f');
requestAnimationFrame(function() {
var selectionAtTheEndSnapshot = snapshotWindow(window);
results = compareSnapshots(baseSnapshot, selectionAtTheEndSnapshot, false);
ok(results[0], "after appending a character, string should have changed");
element.value = element.value;
var tmpSnapshot = snapshotWindow(window);
--- a/dom/html/test/forms/test_input_time_key_events.html
+++ b/dom/html/test/forms/test_input_time_key_events.html
@@ -31,151 +31,151 @@ SimpleTest.waitForFocus(function() {
var testData = [
/**
* keys: keys to send to the input element.
* initialVal: initial value set to the input element.
* expectedVal: expected value of the input element after sending the keys.
*/
{
// Type 1030 and select AM.
- keys: ["1030", "VK_DOWN"],
+ keys: ["1030", "KEY_ArrowDown"],
initialVal: "",
expectedVal: "10:30"
},
{
// Type 3 in the hour field will automatically advance to the minute field.
- keys: ["330", "VK_DOWN"],
+ keys: ["330", "KEY_ArrowDown"],
initialVal: "",
expectedVal: "03:30"
},
{
// Type 5 in the hour field will automatically advance to the minute field.
// Type 7 in the minute field will automatically advance to the AM/PM field.
- keys: ["57", "VK_DOWN"],
+ keys: ["57", "KEY_ArrowDown"],
initialVal: "",
expectedVal: "05:07"
},
{
// Advance to AM/PM field and change to PM.
- keys: ["VK_TAB", "VK_TAB", "VK_DOWN"],
+ keys: ["KEY_Tab", "KEY_Tab", "KEY_ArrowDown"],
initialVal: "10:30",
expectedVal: "22:30"
},
{
// Right key should do the same thing as TAB key.
- keys: ["VK_RIGHT", "VK_RIGHT", "VK_DOWN"],
+ keys: ["KEY_ArrowRight", "KEY_ArrowRight", "KEY_ArrowDown"],
initialVal: "10:30",
expectedVal: "22:30"
},
{
// Advance to minute field then back to hour field and decrement.
- keys: ["VK_RIGHT", "VK_LEFT", "VK_DOWN"],
+ keys: ["KEY_ArrowRight", "KEY_ArrowLeft", "KEY_ArrowDown"],
initialVal: "10:30",
expectedVal: "09:30"
},
{
// Focus starts on the first field, hour in this case, and increment.
- keys: ["VK_UP"],
+ keys: ["KEY_ArrowUp"],
initialVal: "16:00",
expectedVal: "17:00"
},
{
// Advance to minute field and decrement.
- keys: ["VK_TAB", "VK_DOWN"],
+ keys: ["KEY_Tab", "KEY_ArrowDown"],
initialVal: "16:00",
expectedVal: "16:59"
},
{
// Advance to minute field and increment.
- keys: ["VK_TAB", "VK_UP"],
+ keys: ["KEY_Tab", "KEY_ArrowUp"],
initialVal: "16:59",
expectedVal: "16:00"
},
{
// PageUp on hour field increments hour by 3.
- keys: ["VK_PAGE_UP"],
+ keys: ["KEY_PageUp"],
initialVal: "05:00",
expectedVal: "08:00"
},
{
// PageDown on hour field decrements hour by 3.
- keys: ["VK_PAGE_DOWN"],
+ keys: ["KEY_PageDown"],
initialVal: "05:00",
expectedVal: "02:00"
},
{
// PageUp on minute field increments minute by 10.
- keys: ["VK_TAB", "VK_PAGE_UP"],
+ keys: ["KEY_Tab", "KEY_PageUp"],
initialVal: "14:00",
expectedVal: "14:10"
},
{
// PageDown on minute field decrements minute by 10.
- keys: ["VK_TAB", "VK_PAGE_DOWN"],
+ keys: ["KEY_Tab", "KEY_PageDown"],
initialVal: "14:00",
expectedVal: "14:50"
},
{
// Home key on hour field sets it to the minimum hour, which is 1 in 12-hour
// clock.
- keys: ["VK_HOME"],
+ keys: ["KEY_Home"],
initialVal: "03:10",
expectedVal: "01:10"
},
{
// End key on hour field sets it to the maximum hour, which is 12 in 12-hour
// clock.
- keys: ["VK_END"],
+ keys: ["KEY_End"],
initialVal: "03:10",
expectedVal: "00:10"
},
{
// Home key on minute field sets it to the minimum minute, which is 0.
- keys: ["VK_TAB", "VK_HOME"],
+ keys: ["KEY_Tab", "KEY_Home"],
initialVal: "19:30",
expectedVal: "19:00"
},
{
// End key on minute field sets it to the minimum minute, which is 59.
- keys: ["VK_TAB", "VK_END"],
+ keys: ["KEY_Tab", "KEY_End"],
initialVal: "19:30",
expectedVal: "19:59"
},
// Second field will show up when needed.
{
// PageUp on second field increments second by 10.
- keys: ["VK_TAB", "VK_TAB", "VK_PAGE_UP"],
+ keys: ["KEY_Tab", "KEY_Tab", "KEY_PageUp"],
initialVal: "08:10:10",
expectedVal: "08:10:20"
},
{
// PageDown on second field increments second by 10.
- keys: ["VK_TAB", "VK_TAB", "VK_PAGE_DOWN"],
+ keys: ["KEY_Tab", "KEY_Tab", "KEY_PageDown"],
initialVal: "08:10:10",
expectedVal: "08:10:00"
},
{
// Home key on second field sets it to the minimum second, which is 0.
- keys: ["VK_TAB", "VK_TAB", "VK_HOME"],
+ keys: ["KEY_Tab", "KEY_Tab", "KEY_Home"],
initialVal: "16:00:30",
expectedVal: "16:00:00"
},
{
// End key on second field sets it to the minimum second, which is 59.
- keys: ["VK_TAB", "VK_TAB", "VK_END"],
+ keys: ["KEY_Tab", "KEY_Tab", "KEY_End"],
initialVal: "16:00:30",
expectedVal: "16:00:59"
},
];
function sendKeys(aKeys) {
for (let i = 0; i < aKeys.length; i++) {
let key = aKeys[i];
- if (key.startsWith("VK")) {
- synthesizeKey(key, {});
+ if (key.startsWith("KEY_")) {
+ synthesizeKey(key);
} else {
sendString(key);
}
}
}
function test() {
var elem = document.getElementById("input");
--- a/dom/html/test/forms/test_input_time_sec_millisec_field.html
+++ b/dom/html/test/forms/test_input_time_sec_millisec_field.html
@@ -49,17 +49,17 @@ function countNumberOfFields(aElement) {
// Make sure to start on the first field.
synthesizeMouse(aElement, firstField_X, firstField_Y, {});
is(document.activeElement, aElement, "Input element should be focused");
let n = 0;
while (document.activeElement == aElement) {
n++;
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
}
return n;
}
function test() {
// Normal input time element.
let elem = document.getElementById("input1");
--- a/dom/html/test/forms/test_maxlength_attribute.html
+++ b/dom/html/test/forms/test_maxlength_attribute.html
@@ -46,29 +46,29 @@ function checkTooLongValidity(element)
"Element should not be too long unless the user edits it");
is(window.getComputedStyle(element).getPropertyValue('background-color'),
"rgb(0, 255, 0)", ":valid pseudo-class should apply");
ok(element.validity.valid, "Element should be valid");
ok(element.checkValidity(), "The element should be valid");
element.focus();
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(element.value, "fo", "value should have changed");
ok(element.validity.tooLong,
"Element should be too long after a user edit that does not make it short enough");
is(window.getComputedStyle(element).getPropertyValue('background-color'),
"rgb(255, 0, 0)", ":invalid pseudo-class should apply");
ok(!element.validity.valid, "Element should be invalid");
ok(!element.checkValidity(), "The element should not be valid");
is(element.validationMessage,
"Please shorten this text to 1 characters or less (you are currently using 2 characters).",
"The validation message text is not correct");
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(element.value, "f", "value should have changed");
ok(!element.validity.tooLong,
"Element should not be too long after a user edit makes it short enough");
is(window.getComputedStyle(element).getPropertyValue('background-color'),
"rgb(0, 255, 0)", ":valid pseudo-class should apply");
ok(element.validity.valid, "Element should be valid");
element.maxLength = 2;
--- a/dom/html/test/forms/test_minlength_attribute.html
+++ b/dom/html/test/forms/test_minlength_attribute.html
@@ -46,29 +46,29 @@ function checkTooShortValidity(element)
"Element should not be too short unless the user edits it");
is(window.getComputedStyle(element).getPropertyValue('background-color'),
"rgb(0, 255, 0)", ":valid pseudo-class should apply");
ok(element.validity.valid, "Element should be valid");
ok(element.checkValidity(), "The element should be valid");
element.focus();
- synthesizeKey("o", {});
+ sendString("o");
is(element.value, "fooo", "value should have changed");
ok(element.validity.tooShort,
"Element should be too short after a user edit that does not make it short enough");
is(window.getComputedStyle(element).getPropertyValue('background-color'),
"rgb(255, 0, 0)", ":invalid pseudo-class should apply");
ok(!element.validity.valid, "Element should be invalid");
ok(!element.checkValidity(), "The element should not be valid");
is(element.validationMessage,
"Please use at least 5 characters (you are currently using 4 characters).",
"The validation message text is not correct");
- synthesizeKey("o", {});
+ sendString("o");
is(element.value, "foooo", "value should have changed");
ok(!element.validity.tooShort,
"Element should not be too short after a user edit makes it long enough");
is(window.getComputedStyle(element).getPropertyValue('background-color'),
"rgb(0, 255, 0)", ":valid pseudo-class should apply");
ok(element.validity.valid, "Element should be valid");
element.minLength = 2;
--- a/dom/html/test/forms/test_novalidate_attribute.html
+++ b/dom/html/test/forms/test_novalidate_attribute.html
@@ -42,17 +42,17 @@ document.forms[0].addEventListener("subm
ok(true, "novalidate has been correctly used for first form");
document.getElementById('b').click();
}, {once: true});
document.forms[1].addEventListener("submit", function(aEvent) {
ok(true, "novalidate has been correctly used for second form");
var c = document.getElementById('c');
c.focus();
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
}, {once: true});
document.forms[2].addEventListener("submit", function(aEvent) {
ok(true, "novalidate has been correctly used for third form");
SimpleTest.executeSoon(SimpleTest.finish);
}, {once: true});
/**
--- a/dom/html/test/forms/test_radio_in_label.html
+++ b/dom/html/test/forms/test_radio_in_label.html
@@ -35,20 +35,20 @@ function startTest() {
r2.click();
ok(r2.checked,
"The second radio input element should be checked by clicking the element");
s1.click();
ok(r1.checked,
"The first radio input element should be checked by clicking other element");
r1.focus();
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
ok(r2.checked,
"The second radio input element should be checked by key");
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
ok(r1.checked,
"The first radio input element should be checked by key");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>
--- a/dom/html/test/forms/test_select_change_event.html
+++ b/dom/html/test/forms/test_select_change_event.html
@@ -24,31 +24,31 @@ https://bugzilla.mozilla.org/show_bug.cg
<pre id="test">
<script type="application/javascript">
var select = document.getElementById("select");
var selectChange = 0;
var expectedChange = 0;
select.focus();
for (var i = 1; i < select.length; i++) {
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(select.options[i].selected, true, "Option should be selected");
is(selectChange, ++expectedChange, "Down key should fire change event.");
}
// We are at the end of the list, going down should not fire change event.
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(selectChange, expectedChange, "Down key should not fire change event when reaching end of the list.");
for (var i = select.length - 2; i >= 0; i--) {
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
is(select.options[i].selected, true, "Option should be selected");
is(selectChange, ++expectedChange, "Up key should fire change event.");
}
// We are at the top of the list, going up should not fire change event.
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
is(selectChange, expectedChange, "Up key should not fire change event when reaching top of the list.");
</script>
</pre>
</body>
</html>
--- a/dom/html/test/forms/test_select_input_change_event.html
+++ b/dom/html/test/forms/test_select_input_change_event.html
@@ -36,87 +36,87 @@ https://bugzilla.mozilla.org/show_bug.cg
var selectMultiple = document.getElementsByTagName('select')[3];
var selectChange = 0;
var selectInput = 0;
var expectedChange = 0;
var expectedInput = 0;
selectSingleOneItem.focus();
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(selectInput, expectedInput, "Down key should not fire input event when reaching end of the list.");
is(selectChange, expectedChange, "Down key should not fire change event when reaching end of the list.");
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
is(selectInput, expectedInput, "Up key should not fire input event when reaching top of the list.");
is(selectChange, expectedChange, "Up key should not fire change event when reaching top of the list.");
selectSingle.focus();
for (var i = 1; i < selectSingle.length; i++) {
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(selectSingle.options[i].selected, true, "Option should be selected");
is(selectInput, ++expectedInput, "Down key should fire input event.");
is(selectChange, ++expectedChange, "Down key should fire change event.");
}
// We are at the end of the list, going down should not fire change event.
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(selectInput, expectedInput, "Down key should not fire input event when reaching end of the list.");
is(selectChange, expectedChange, "Down key should not fire change event when reaching end of the list.");
for (var i = selectSingle.length - 2; i >= 0; i--) {
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
is(selectSingle.options[i].selected, true, "Option should be selected");
is(selectInput, ++expectedInput, "Up key should fire input event.");
is(selectChange, ++expectedChange, "Up key should fire change event.");
}
// We are at the top of the list, going up should not fire change event.
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
is(selectInput, expectedInput, "Up key should not fire input event when reaching top of the list.");
is(selectChange, expectedChange, "Up key should not fire change event when reaching top of the list.");
selectMultipleOneItem.focus();
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(selectInput, ++expectedInput, "Down key should fire input event when reaching end of the list.");
is(selectChange, ++expectedChange, "Down key should fire change event when reaching end of the list.");
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(selectInput, expectedInput, "Down key should not fire input event when reaching end of the list.");
is(selectChange, expectedChange, "Down key should not fire change event when reaching end of the list.");
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
is(selectInput, expectedInput, "Up key should not fire input event when reaching top of the list.");
is(selectChange, expectedChange, "Up key should not fire change event when reaching top of the list.");
selectMultiple.focus();
for (var i = 0; i < selectMultiple.length; i++) {
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(selectMultiple.options[i].selected, true, "Option should be selected");
is(selectInput, ++expectedInput, "Down key should fire input event.");
is(selectChange, ++expectedChange, "Down key should fire change event.");
}
// We are at the end of the list, going down should not fire change event.
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(selectInput, expectedInput, "Down key should not fire input event when reaching end of the list.");
is(selectChange, expectedChange, "Down key should not fire change event when reaching end of the list.");
for (var i = selectMultiple.length - 2; i >= 0; i--) {
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
is(selectMultiple.options[i].selected, true, "Option should be selected");
is(selectInput, ++expectedInput, "Up key should fire input event.");
is(selectChange, ++expectedChange, "Up key should fire change event.");
}
// We are at the top of the list, going up should not fire change event.
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
is(selectInput, expectedInput, "Up key should not fire input event when reaching top of the list.");
is(selectChange, expectedChange, "Up key should not fire change event when reaching top of the list.");
</script>
</pre>
</body>
</html>
--- a/dom/html/test/test_bug1045270.html
+++ b/dom/html/test/test_bug1045270.html
@@ -25,19 +25,19 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForFocus(function() {
input.focus();
input.addEventListener("input", function() {
// reframe
document.body.style.display = "none";
document.body.style.display = "";
document.body.offsetLeft; // flush
});
- synthesizeKey("1", {});
+ sendString("1");
SimpleTest.executeSoon(function() {
- synthesizeKey("2", {});
+ sendString("2");
SimpleTest.executeSoon(function() {
is(input.value, "12", "Reframe should restore focus and selection properly");
SimpleTest.finish();
});
});
});
</script>
--- a/dom/html/test/test_bug1230665.html
+++ b/dom/html/test/test_bug1230665.html
@@ -6,22 +6,22 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script>
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
document.getElementById("flexbutton1").focus();
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
var e = document.getElementById("flexbutton2");
is(document.activeElement, e, "focus in flexbutton2 after TAB");
document.getElementById("gridbutton1").focus();
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
e = document.getElementById("gridbutton2");
is(document.activeElement, e, "focus in gridbutton2 after TAB");
SimpleTest.finish();
});
</script>
--- a/dom/html/test/test_bug386996.html
+++ b/dom/html/test/test_bug386996.html
@@ -23,17 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cg
var frame = document.getElementById("testIframe");
function testContentEditable() {
var focusedElement;
document.getElementById("input1").onfocus = function() { focusedElement = this };
document.getElementById("input2").onfocus = function() { focusedElement = this };
document.getElementById("input1").focus();
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
is(focusedElement.id, "input2");
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(testContentEditable);
addLoadEvent(SimpleTest.finish);
--- a/dom/html/test/test_bug406596.html
+++ b/dom/html/test/test_bug406596.html
@@ -38,20 +38,20 @@ function testTabbing(click, focus, selec
wu.sendMouseEvent("mouseup", x + selectionOffset, y, 0, 1, 0);
if (selectionOffset) {
is(selection.rangeCount, 1, "there should be one range in the selection");
var range = selection.getRangeAt(0);
}
var focusedElement = document.activeElement;
is(focusedElement, document.getElementById(focus),
"clicking should move focus to the contentEditable node");
- synthesizeKey("VK_TAB", {});
- synthesizeKey("VK_TAB", {});
- synthesizeKey("VK_TAB", { shiftKey: true });
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab");
+ synthesizeKey("KEY_Tab");
+ synthesizeKey("KEY_Tab", {shiftKey: true});
+ synthesizeKey("KEY_Tab", {shiftKey: true});
is(document.activeElement, focusedElement,
"tab/shift-tab should move focus back to the contentEditable node");
if (selectionOffset) {
is(selection.rangeCount, 1,
"there should still be one range in the selection");
var newRange = selection.getRangeAt(0);
is(newRange.compareBoundaryPoints(Range.START_TO_START, range), 0,
"the selection should be the same as before the tabbing");
--- a/dom/html/test/test_bug460568.html
+++ b/dom/html/test/test_bug460568.html
@@ -41,17 +41,17 @@ function runTest()
.getInterface(SpecialPowers.Ci.nsIWebNavigation)
.QueryInterface(SpecialPowers.Ci.nsIDocShell);
var controller =
docShell.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
.getInterface(SpecialPowers.Ci.nsISelectionDisplay)
.QueryInterface(SpecialPowers.Ci.nsISelectionController);
var sel = controller.getSelection(controller.SELECTION_NORMAL);
sel.collapse(anchorInEditor, 0);
- synthesizeKey('a', {});
+ sendString("a");
range.selectNodeContents(editor);
return prevStr != range.toString();
}
focused = false;
anchor.focus();
editor.setAttribute("contenteditable", "true");
anchorInEditor.focus();
--- a/dom/html/test/test_bug535043.html
+++ b/dom/html/test/test_bug535043.html
@@ -21,17 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<pre id="test">
<script type="text/javascript">
/** Test for Bug 535043 **/
function checkTextArea(textArea) {
textArea.value = '';
textArea.focus();
for (var j = 0; j < 3; j++) {
- synthesizeKey('x', {});
+ sendString("x");
}
var htmlMaxLength = textArea.getAttribute('maxlength');
var domMaxLength = textArea.maxLength;
if (htmlMaxLength == null) {
is(domMaxLength, -1,
'maxlength is unset but maxLength DOM attribute is not -1');
} else if (htmlMaxLength < 0) {
// Per the HTML5 spec, out-of-range values are supposed to translate to -1,
--- a/dom/html/test/test_bug556645.html
+++ b/dom/html/test/test_bug556645.html
@@ -23,21 +23,21 @@ function runTest()
childDoc.defaultView.focus();
is(document.activeElement, obj, "focus in parent after focus()");
is(childDoc.activeElement, button, "focus in child after focus()");
button.blur();
var pbutton = document.getElementById("pbutton");
pbutton.focus();
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
is(document.activeElement, obj, "focus in parent after tab");
is(childDoc.activeElement, childDoc.documentElement, "focus in child after tab");
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
is(document.activeElement, obj, "focus in parent after tab 2");
is(childDoc.activeElement, button, "focus in child after tab 2");
SimpleTest.finish();
}
</script>
--- a/dom/html/test/test_bug557087-4.html
+++ b/dom/html/test/test_bug557087-4.html
@@ -52,17 +52,17 @@ var inputs = [
document.getElementById('b'),
document.getElementById('c'),
];
function doSubmit()
{
for (e of inputs) {
e.focus();
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
}
}
SimpleTest.waitForFocus(function() {
doSubmit();
fieldsets[1].disabled = true;
fieldsets[0].disabled = false;
--- a/dom/html/test/test_bug558788-1.html
+++ b/dom/html/test/test_bug558788-1.html
@@ -54,36 +54,36 @@ function checkMissing(elementName)
{
var element = document.createElement(elementName);
element.required = true;
gContent.appendChild(element);
checkInvalidApplies(element);
element.focus();
- synthesizeKey("a", {});
+ sendString("a");
checkValidApplies(element);
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
checkInvalidApplies(element);
gContent.removeChild(element);
}
function checkTooLong(elementName)
{
var element = document.createElement(elementName);
element.value = "foo";
element.maxLength = 2;
gContent.appendChild(element);
checkInvalidApplies(element, true);
element.focus();
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
checkValidApplies(element);
gContent.removeChild(element);
}
function checkTextAreaMissing()
{
checkMissing('textarea');
}
@@ -113,87 +113,87 @@ function checkInputEmail()
{
var element = document.createElement('input');
element.type = 'email';
gContent.appendChild(element);
checkValidApplies(element);
element.focus();
- synthesizeKey("a", {});
+ sendString("a");
checkInvalidApplies(element);
sendString("@b.c");
checkValidApplies(element);
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
for (var i=0; i<4; ++i) {
if (i == 1) {
// a@b is a valid value.
checkValidApplies(element);
} else {
checkInvalidApplies(element);
}
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
}
checkValidApplies(element);
gContent.removeChild(element);
}
function checkInputURL()
{
var element = document.createElement('input');
element.type = 'url';
gContent.appendChild(element);
checkValidApplies(element);
element.focus();
- synthesizeKey("h", {});
+ sendString("h");
checkInvalidApplies(element);
sendString("ttp://mozilla.org");
checkValidApplies(element);
for (var i=0; i<10; ++i) {
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
checkValidApplies(element);
}
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
// "http://" is now invalid
for (var i=0; i<7; ++i) {
checkInvalidApplies(element);
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
}
checkValidApplies(element);
gContent.removeChild(element);
}
function checkInputPattern()
{
var element = document.createElement('input');
element.pattern = "[0-9]*"
gContent.appendChild(element);
checkValidApplies(element);
element.focus();
- synthesizeKey("0", {});
+ sendString("0");
checkValidApplies(element);
- synthesizeKey("a", {});
+ sendString("a");
checkInvalidApplies(element);
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
checkValidApplies(element);
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
checkValidApplies(element);
gContent.removeChild(element);
}
function checkInput()
{
checkInputMissing();
--- a/dom/html/test/test_bug558788-2.html
+++ b/dom/html/test/test_bug558788-2.html
@@ -128,20 +128,20 @@ function makeMinMaxLengthElementsActuall
{
// min/maxlength elements are not invalid until user edits them
var length = aInvalidElementsDesc.length;
for (var i=0; i<length; ++i) {
var e = aInvalidElements[i];
if (aInvalidElementsDesc[i][5]) { // maxlength
e.focus();
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
} else if (aInvalidElementsDesc[i][6]) { // minlength
e.focus();
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
}
}
}
function makeInvalidElementsValid(aInvalidElements,
aInvalidElementsDesc,
aValidElements)
{
--- a/dom/html/test/test_bug561636.html
+++ b/dom/html/test/test_bug561636.html
@@ -96,16 +96,16 @@ function runTest()
SimpleTest.finish();
});
}, {once: true});
document.getElementById('a').click();
document.getElementById('b').click();
var c = document.getElementById('c');
c.focus();
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('s2').click();
}
</script>
</pre>
</body>
</html>
--- a/dom/html/test/test_bug566046.html
+++ b/dom/html/test/test_bug566046.html
@@ -157,32 +157,32 @@ function runTests()
}, {once: true});
document.getElementById('bsbis').addEventListener('focus', function(aEvent) {
document.getElementById('bsbis').click();
document.getElementById('is2').focus();
}, {once: true});
document.getElementById('is2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('ii2').focus();
}, {once: true});
document.getElementById('ii2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('bs2').focus();
}, {once: true});
document.getElementById('bs2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('enter').focus();
}, {once: true});
document.getElementById('enter').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
}, {once: true});
document.getElementById('is').focus();
}
function frameLoaded(aFrame) {
// Check if when target is unspecified, it fallback correctly to the base
// element target attribute.
--- a/dom/html/test/test_bug582412-1.html
+++ b/dom/html/test/test_bug582412-1.html
@@ -148,42 +148,42 @@ function runTests()
}, {once: true});
document.getElementById('bsbis').addEventListener('focus', function(aEvent) {
document.getElementById('bsbis').click();
document.getElementById('is2').focus();
}, {once: true});
document.getElementById('is2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('ii2').focus();
}, {once: true});
document.getElementById('ii2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('bs2').focus();
}, {once: true});
document.getElementById('bs2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('enter').focus();
}, {once: true});
document.getElementById('enter').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('i8').focus();
}, {once: true});
document.getElementById('i8').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('i9').focus();
}, {once: true});
document.getElementById('i9').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
}, {once: true});
document.getElementById('is').focus();
}
function frameLoaded(aFrame) {
// Check if formaction/action has the correct behavior.
is(aFrame.contentWindow.location.href, gTestResults[aFrame.name],
--- a/dom/html/test/test_bug582412-2.html
+++ b/dom/html/test/test_bug582412-2.html
@@ -147,42 +147,42 @@ function runTests()
}, {once: true});
document.getElementById('bsbis').addEventListener('focus', function(aEvent) {
document.getElementById('bsbis').click();
document.getElementById('is2').focus();
}, {once: true});
document.getElementById('is2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('ii2').focus();
}, {once: true});
document.getElementById('ii2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('bs2').focus();
}, {once: true});
document.getElementById('bs2').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('enter').focus();
}, {once: true});
document.getElementById('enter').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('i8').focus();
}, {once: true});
document.getElementById('i8').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.getElementById('i9').focus();
}, {once: true});
document.getElementById('i9').addEventListener('focus', function(aEvent) {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
}, {once: true});
document.getElementById('is').focus();
}
function frameLoaded(aFrame) {
// Check if formaction/action has the correct behavior.
is(aFrame.contentDocument.documentElement.textContent, gTestResults[aFrame.name],
--- a/dom/html/test/test_bug605124-2.html
+++ b/dom/html/test/test_bug605124-2.html
@@ -39,37 +39,37 @@ function checkElement(aElement)
{
checkPseudoClass(aElement, false);
// Focusing while :-moz-ui-invalid doesn't apply,
// the pseudo-class should not apply while typing.
aElement.focus();
checkPseudoClass(aElement, false);
// with keys
- synthesizeKey('f', {});
+ sendString("f");
checkPseudoClass(aElement, false);
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
checkPseudoClass(aElement, false);
// with .value
aElement.value = 'f';
checkPseudoClass(aElement, false);
aElement.value = '';
checkPseudoClass(aElement, false);
aElement.blur();
checkPseudoClass(aElement, true);
// Focusing while :-moz-ui-invalid applies,
// the pseudo-class should apply while typing if appropriate.
aElement.focus();
checkPseudoClass(aElement, true);
// with keys
- synthesizeKey('f', {});
+ sendString("f");
checkPseudoClass(aElement, false);
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
checkPseudoClass(aElement, true);
// with .value
aElement.value = 'f';
checkPseudoClass(aElement, false);
aElement.value = '';
checkPseudoClass(aElement, true);
}
--- a/dom/html/test/test_bug605125-2.html
+++ b/dom/html/test/test_bug605125-2.html
@@ -39,56 +39,56 @@ function checkElement(aElement)
{
checkPseudoClass(aElement, false);
// Focusing while :-moz-ui-valid doesn't apply,
// the pseudo-class should not apply while typing.
aElement.focus();
checkPseudoClass(aElement, false);
// with keys
- synthesizeKey('f', {});
+ sendString("f");
checkPseudoClass(aElement, false);
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
checkPseudoClass(aElement, false);
// with .value
aElement.value = 'f';
checkPseudoClass(aElement, false);
aElement.value = '';
checkPseudoClass(aElement, false);
aElement.blur();
checkPseudoClass(aElement, true);
// Focusing while :-moz-ui-valid applies,
// the pseudo-class should apply while typing if appropriate.
aElement.focus();
checkPseudoClass(aElement, true);
// with keys
- synthesizeKey('f', {});
+ sendString("f");
checkPseudoClass(aElement, true);
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
checkPseudoClass(aElement, true);
// with .value
aElement.value = 'f';
checkPseudoClass(aElement, true);
aElement.value = '';
checkPseudoClass(aElement, true);
aElement.blur();
aElement.required = true;
checkPseudoClass(aElement, false);
// Focusing while :-moz-ui-invalid applies,
// the pseudo-class should apply while typing if appropriate.
aElement.focus();
checkPseudoClass(aElement, false);
// with keys
- synthesizeKey('f', {});
+ sendString("f");
checkPseudoClass(aElement, true);
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
checkPseudoClass(aElement, false);
// with .value
aElement.value = 'f';
checkPseudoClass(aElement, true);
aElement.value = '';
checkPseudoClass(aElement, false);
}
--- a/dom/html/test/test_bug613019.html
+++ b/dom/html/test/test_bug613019.html
@@ -25,42 +25,42 @@ https://bugzilla.mozilla.org/show_bug.cg
function testInteractivityOfMaxLength(elem) {
// verify that user interactivity is necessary for validity state to apply.
is(elem.value, "Test", "Element has incorrect starting value.");
is(elem.validity.tooLong, false, "Element should not be tooLong.");
elem.setSelectionRange(elem.value.length, elem.value.length)
elem.focus();
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(elem.value, "Tes", "Element value was not changed correctly.");
is(elem.validity.tooLong, true, "Element should still be tooLong.");
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(elem.value, "Te", "Element value was not changed correctly.");
is(elem.validity.tooLong, false, "Element should no longer be tooLong.");
elem.value = "Test";
is(elem.validity.tooLong, false,
"Element should not be tooLong after non-interactive value change.");
}
function testInteractivityOfMinLength(elem) {
// verify that user interactivity is necessary for validity state to apply.
is(elem.value, "Test", "Element has incorrect starting value.");
is(elem.validity.tooLong, false, "Element should not be tooShort.");
elem.setSelectionRange(elem.value.length, elem.value.length)
elem.focus();
- synthesizeKey("e", {});
+ sendString("e");
is(elem.value, "Teste", "Element value was not changed correctly.");
is(elem.validity.tooShort, true, "Element should still be tooShort.");
- synthesizeKey("d", {});
+ sendString("d");
is(elem.value, "Tested", "Element value was not changed correctly.");
is(elem.validity.tooShort, false, "Element should no longer be tooShort.");
elem.value = "Test";
is(elem.validity.tooShort, false,
"Element should not be tooShort after non-interactive value change.");
}
--- a/dom/html/test/test_bug613979.html
+++ b/dom/html/test/test_bug613979.html
@@ -23,28 +23,28 @@ https://bugzilla.mozilla.org/show_bug.cg
var testNum = 0;
var input = document.getElementsByTagName('input')[0];
input.addEventListener("input", function() {
if (testNum == 0) {
ok(input.validity.valid, "input should be valid");
testNum++;
SimpleTest.executeSoon(function() {
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
});
} else if (testNum == 1) {
ok(!input.validity.valid, "input should not be valid");
input.removeEventListener("input", arguments.callee);
SimpleTest.finish();
}
});
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
input.focus();
- synthesizeKey("a", {});
+ sendString("a");
});
</script>
</pre>
</body>
</html>
--- a/dom/html/test/test_bug615833.html
+++ b/dom/html/test/test_bug615833.html
@@ -69,17 +69,17 @@ select.addEventListener("change", functi
}, {once: true});
select.addEventListener("keyup", function() {
select.blur();
}, {once: true});
select.addEventListener("focus", function() {
SimpleTest.executeSoon(function () {
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
});
}, {once: true});
checkbox.addEventListener("change", function(aEvent) {
checkChangeEvent(aEvent);
select.focus();
}, {once: true});
@@ -106,32 +106,32 @@ textarea.addEventListener("change", func
}, {once: true});
textarea.addEventListener("input", function() {
textarea.blur();
}, {once: true});
textarea.addEventListener("focus", function() {
SimpleTest.executeSoon(function () {
- synthesizeKey('f', {});
+ sendString("f");
});
}, {once: true});
input.addEventListener("change", function(aEvent) {
checkChangeEvent(aEvent);
textarea.focus();
}, {once: true});
input.addEventListener("input", function() {
input.blur();
}, {once: true});
input.addEventListener("focus", function() {
SimpleTest.executeSoon(function () {
- synthesizeKey('f', {});
+ sendString("f");
});
}, {once: true});
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
input.focus();
});
--- a/dom/html/test/test_bug618948.html
+++ b/dom/html/test/test_bug618948.html
@@ -51,17 +51,17 @@ function endTest()
SimpleTest.finish();
}
var i = document.getElementsByTagName('input')[0];
var b = document.getElementsByTagName('button')[0];
i.onfocus = function(event) {
eventHandler(event);
- synthesizeKey('f', {});
+ sendString("f");
i.onfocus = null;
};
i.oninput = function(event) {
eventHandler(event);
b.focus();
i.oninput = null;
};
--- a/dom/html/test/test_bug619278.html
+++ b/dom/html/test/test_bug619278.html
@@ -36,17 +36,17 @@ e.addEventListener("invalid", function(e
SimpleTest.executeSoon(function() {
doElementMatchesSelector(e, ":-moz-ui-invalid");
SimpleTest.finish();
});
});
e.addEventListener("focus", function() {
SimpleTest.executeSoon(function() {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
});
}, {once: true});
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
e.focus();
});
--- a/dom/html/test/test_bug622597.html
+++ b/dom/html/test/test_bug622597.html
@@ -85,17 +85,17 @@ input.addEventListener("invalid", functi
input.blur();
input.value = '';
input.focus();
});
}, {once: true});
button.addEventListener("focus", function() {
SimpleTest.executeSoon(function() {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
});
}, {once: true});
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
button.focus();
});
--- a/dom/html/test/test_bug633058.html
+++ b/dom/html/test/test_bug633058.html
@@ -42,24 +42,24 @@ function startTest() {
content.addEventListener("keydown", () => { divGotKeyDown++; });
content.addEventListener("keypress", () => { divGotKeyPress++; });
input.addEventListener("keydown", () => { inputGotKeyDown++; });
input.addEventListener("keypress", () => { inputGotKeyPress++; });
input.addEventListener('focus', function() {
SimpleTest.executeSoon(() => {
- synthesizeKey('KEY_ArrowUp', {});
- synthesizeKey('KEY_ArrowLeft', {});
- synthesizeKey('KEY_ArrowRight', {});
- synthesizeKey('KEY_ArrowDown', {});
- synthesizeKey('KEY_Backspace', {});
- synthesizeKey('KEY_Delete', {});
- synthesizeKey('KEY_Escape', {});
- synthesizeKey('KEY_Enter', {}); // Will dispatch keypress event even in strict behavior.
+ synthesizeKey('KEY_ArrowUp');
+ synthesizeKey('KEY_ArrowLeft');
+ synthesizeKey('KEY_ArrowRight');
+ synthesizeKey('KEY_ArrowDown');
+ synthesizeKey('KEY_Backspace');
+ synthesizeKey('KEY_Delete');
+ synthesizeKey('KEY_Escape');
+ synthesizeKey('KEY_Enter'); // Will dispatch keypress event even in strict behavior.
is(inputGotKeyDown, nbExpectedKeyDown, "input got all keydown events");
is(inputGotKeyPress, nbExpectedKeyPress, "input got all keypress events");
is(divGotKeyDown, nbExpectedKeyDown, "div got all keydown events");
is(divGotKeyPress, nbExpectedKeyPress, "div got all keypress events");
SimpleTest.finish();
});
}, {once: true});
--- a/dom/html/test/test_bug651956.html
+++ b/dom/html/test/test_bug651956.html
@@ -24,17 +24,17 @@ var input = document.getElementsByTagNam
var gotInputEvent = false;
input.addEventListener("input", function() {
gotInputEvent = true;
}, {once: true});
input.addEventListener("focus", function() {
- synthesizeKey("VK_ESCAPE", {});
+ synthesizeKey("KEY_Escape");
setTimeout(function() {
ok(!gotInputEvent, "No input event should have been sent.");
SimpleTest.finish();
});
}, {once: true});
SimpleTest.waitForExplicitFinish();
--- a/dom/html/test/test_ignoreuserfocus.html
+++ b/dom/html/test/test_ignoreuserfocus.html
@@ -111,17 +111,17 @@
witness.focus();
synthesizeMouseAtCenter(innerArea, {}, iframeWindow);
is(document.activeElement, witness, "[synthesize mouse click] witness should have the focus");
// Test tabindex
witness.focus();
is(document.activeElement, witness, "witness should have the focus");
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
isnot(document.activeElement, iframe, "[synthesize tab key] iframe should not have the focus");
is(document.activeElement, witness2, "witness2 should have the focus");
SimpleTest.finish();
}, {once: true});
witness.focus();
// force reflow
iframe.setAttribute("height", "298px");
--- a/dom/html/test/test_object_plugin_nav.html
+++ b/dom/html/test/test_object_plugin_nav.html
@@ -65,32 +65,32 @@ function doTest() {
// Preliminary check: tabindex should be -1 on the object.
is(document.getElementsByTagName('object')[0].tabIndex, -1,
"the plugin shouldn't get focus while navigating in the document");
document.addEventListener("focus", function() {
checkFocus();
if (gFocusCount != gFocusNb) {
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
return;
}
document.removeEventListener("focus", arguments.callee, true);
// Just make sure that .focus() still works.
var o = document.getElementsByTagName('object')[0];
o.onfocus = function() {
SimpleTest.finish();
o.onfocus = null;
};
o.focus();
}, true);
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
}
SimpleTest.waitForFocus(function () {
// Set the focus model so that links are focusable by the tab key even on Mac
SpecialPowers.pushPrefEnv({'set': [['accessibility.tabfocus', 7]]}, doTest);
});
</script>
--- a/dom/indexedDB/test/head.js
+++ b/dom/indexedDB/test/head.js
@@ -67,17 +67,17 @@ function triggerSecondaryCommand(popup)
let notification = notifications[0];
EventUtils.synthesizeMouseAtCenter(notification.secondaryButton, {});
}
function dismissNotification(popup)
{
info("dismissing notification");
executeSoon(function() {
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
});
}
function waitForMessage(aMessage, browser)
{
return new Promise((resolve, reject) => {
/* eslint-disable no-undef */
function contentScript() {
--- a/dom/plugins/test/mochitest/browser_pluginscroll.js
+++ b/dom/plugins/test/mochitest/browser_pluginscroll.js
@@ -195,17 +195,17 @@ add_task(async function() {
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
is(result, true, "plugin is visible");
- EventUtils.synthesizeKey("VK_END", {});
+ EventUtils.synthesizeKey("KEY_End");
await waitScrollStart(gBrowser.selectedBrowser);
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
@@ -215,17 +215,17 @@ add_task(async function() {
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
is(result, false, "plugin is hidden");
- EventUtils.synthesizeKey("VK_HOME", {});
+ EventUtils.synthesizeKey("KEY_Home");
await waitScrollFinish(gBrowser.selectedBrowser);
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
@@ -260,17 +260,17 @@ add_task(async function() {
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
is(result, true, "plugin is visible");
- EventUtils.synthesizeKey("VK_END", {});
+ EventUtils.synthesizeKey("KEY_End");
await waitScrollStart(gBrowser.selectedBrowser);
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
@@ -280,17 +280,17 @@ add_task(async function() {
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
is(result, false, "plugin is hidden");
- EventUtils.synthesizeKey("VK_HOME", {});
+ EventUtils.synthesizeKey("KEY_Home");
await waitScrollFinish(gBrowser.selectedBrowser);
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
--- a/dom/svg/test/test_tabindex.html
+++ b/dom/svg/test/test_tabindex.html
@@ -60,34 +60,34 @@ function main()
is(l2.tabIndex, 4, "non-link initial tabIndex");
l2.tabIndex = 5;
is(l2.tabIndex, 5, "non-link is set to 4");
// Step 2: Checking by triggering TAB event
is(document.activeElement.tabIndex, -1, "In the beginning, the active element tabindex is -1");
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
is(document.activeElement.tabIndex, 1, "The active element tabindex is 1");
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
is(document.activeElement.tabIndex, 2, "The active element tabindex is 2");
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
is(document.activeElement.tabIndex, 3, "The active element tabindex is 3");
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
// On Mac, SVG link elements should not be focused.
if (isMac) {
is(document.activeElement.tabIndex, 6, "The active element tabindex is 6");
} else {
is(document.activeElement.tabIndex, 4, "The active element tabindex is 4");
}
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
// On Mac, SVG link elements should not be focused.
if (isMac) {
is(document.activeElement.tabIndex, 7, "The active element tabindex is 7");
} else {
is(document.activeElement.tabIndex, 5, "The active element tabindex is 5");
}
} catch(e) {
ok(false, "Got unexpected exception" + e);
--- a/dom/tests/browser/browser_cancel_keydown_keypress_event.js
+++ b/dom/tests/browser/browser_cancel_keydown_keypress_event.js
@@ -22,17 +22,17 @@ add_task(async function() {
await ContentTask.spawn(browser, null, async function() {
let input = content.document.getElementById("input");
input.focus();
input.value = "abcd";
});
// Send return key (cross process) to submit the form implicitly.
let dialogShown = awaitAndCloseAlertDialog();
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
await dialogShown;
// Check that the form should not have been submitted.
await ContentTask.spawn(browser, null, async function() {
let result = content.document.getElementById("result").innerHTML;
info("submit result: " + result);
is(result, "not submitted", "form should not have submitted");
});
--- a/dom/tests/mochitest/bugs/test_bug265203.html
+++ b/dom/tests/mochitest/bugs/test_bug265203.html
@@ -57,51 +57,51 @@ function testFocus() {
function test0() {
$("a1").focus();
expectedResult = [ $("a1"), 0, $("a1") ]
nextTest = test1;
testFocus();
}
function test1() {
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
expectedResult = [ $("a1").firstChild, 7, $("a2") ]
nextTest = test2;
testFocus();
}
function test2() {
$("a3").focus();
expectedResult = [ $("a3"), 0, $("a3") ]
nextTest = test3;
testFocus();
}
function test3() {
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
expectedResult = [ $("a3").firstChild, 7, $("a3") ]
nextTest = SimpleTest.finish;
testFocus();
}
function startTest() {
if (gTestStarted)
return;
gTestStarted = true;
- // Turn off spatial navigation because it hijacks VK_RIGHT and VK_LEFT keydown
+ // Turn off spatial navigation because it hijacks KEY_ArrowRight and KEY_ArrowLeft keydown
// events
SpecialPowers.pushPrefEnv({"set": [["accessibility.browsewithcaret", true], ["snav.enabled", false]]}, test0);
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(startTest);
</script>
--- a/dom/tests/mochitest/chrome/window_focus.xul
+++ b/dom/tests/mochitest/chrome/window_focus.xul
@@ -328,17 +328,17 @@ function mouseOnElement(element, expecte
function done()
{
var opener = window.opener;
window.close();
opener.wrappedJSObject.SimpleTest.finish();
}
-var pressTab = () => synthesizeKey("VK_TAB", { });
+var pressTab = () => synthesizeKey("KEY_Tab");
function setFocusTo(id, fwindow)
{
gLastFocus = getById(id);
gLastFocusWindow = fwindow;
if (gLastFocus)
gLastFocus.focus();
else
@@ -395,39 +395,39 @@ function startTest()
if (gPartialTabbing) {
var partialTabList = ["t3", "t5", "t9", "t10", "t11", "t12", "t13", "t14", "t15",
"t16", "t19", "t20", "t21", "t22", "t26", "t27", "t28", "t29", "t30"];
for (var idx = 0; idx < partialTabList.length; idx++) {
expectFocusShift(pressTab, null, getById(partialTabList[idx]), true, "partial tab key " + partialTabList[idx]);
}
setFocusTo("last", window);
expectFocusShift(pressTab, null, getById(partialTabList[0]), true, "partial tab key wrap to start");
- expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
+ expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}),
null, getById("last"), true, "partial shift tab key wrap to end");
for (var idx = partialTabList.length - 1; idx >= 0; idx--) {
- expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
+ expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}),
null, getById(partialTabList[idx]), true, "partial tab key " + partialTabList[idx]);
}
}
else {
// TAB key
for (var idx = 1; idx <= kTabbableSteps; idx++) {
expectFocusShift(pressTab, null, getById("t" + idx), true, "tab key t" + idx);
}
// wrapping around at end with TAB key
setFocusTo("last", window);
expectFocusShift(pressTab, null, getById("t1"), true, "tab key wrap to start");
- expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
+ expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}),
null, getById("last"), true, "shift tab key wrap to end");
// Shift+TAB key
setFocusTo("o5", window);
for (idx = kTabbableSteps; idx > 0; idx--) {
- expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
+ expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}),
null, getById("t" + idx), true, "shift tab key t" + idx);
}
}
var t19 = getById("t19");
is(t19.selectionStart, 0, "input focused from tab key selectionStart");
is(t19.selectionEnd, 5, "input focused from tab key selectionEnd");
t19.setSelectionRange(0, 0);
@@ -802,26 +802,26 @@ function startTest()
var textbox2 = document.createElement("textbox");
$("innerbox").appendChild(textbox2);
gLastFocusMethod = 0;
expectFocusShift(() => textbox2.focus(),
null, textbox2.inputField, true, "focus on textbox");
gLastFocusMethod = fm.FLAG_BYKEY;
- expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
+ expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}),
null, textbox1.inputField, true, "shift+tab on textbox");
textbox1.tabIndex = 2;
textbox2.tabIndex = 2;
gLastFocusMethod = 0;
expectFocusShift(() => textbox2.focus(),
null, textbox2.inputField, true, "focus on textbox with tabindex set");
gLastFocusMethod = fm.FLAG_BYKEY;
- expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
+ expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}),
null, textbox1.inputField, true, "shift+tab on textbox with tabindex set");
// ---- test for bug 618907 which ensures that canceling the mousedown event still focuses the
// right frame
var childContentFrame = document.getElementById("ifa")
childContentFrame.style.MozUserFocus = "";
@@ -1025,47 +1025,47 @@ function testMoveFocus()
is(newFocus, t25, "move caret to link return value");
is(fm.focusedElement, t25, "move caret to link focusedElement");
// enable caret browsing temporarily to test caret movement
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
prefs.setBoolPref("accessibility.browsewithcaret", true);
- synthesizeKey("VK_LEFT", { }, gChildWindow);
- synthesizeKey("VK_LEFT", { }, gChildWindow);
+ synthesizeKey("KEY_ArrowLeft", {}, gChildWindow);
+ synthesizeKey("KEY_ArrowLeft", {}, gChildWindow);
is(fm.focusedElement, null, "move caret away from link");
- synthesizeKey("VK_LEFT", { }, gChildWindow);
+ synthesizeKey("KEY_ArrowLeft", {}, gChildWindow);
is(fm.focusedElement, getById("t24"), "move caret away onto link");
prefs.setBoolPref("accessibility.browsewithcaret", false);
// cases where focus in on a content node with no frame
if (!gPartialTabbing) {
getById("t24").blur();
gEvents = "";
gLastFocus = null;
gLastFocusWindow = gChildWindow;
gLastFocusMethod = fm.FLAG_BYKEY;
selection.selectAllChildren(getById("hiddenspan"));
- expectFocusShift(() => synthesizeKey("VK_TAB", { }),
+ expectFocusShift(() => synthesizeKey("KEY_Tab"),
gChildWindow, getById("t26"), true, "tab with selection on hidden content");
setFocusTo($("o15"), window);
$("o15").hidden = true;
document.documentElement.getBoundingClientRect(); // flush after hiding
- expectFocusShift(() => synthesizeKey("VK_TAB", { }),
+ expectFocusShift(() => synthesizeKey("KEY_Tab"),
window, $("o17"), true, "tab with focus on hidden content");
$("o17").hidden = true;
document.documentElement.getBoundingClientRect();
- expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
+ expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}),
window, $("o13"), true, "shift+tab with focus on hidden content");
}
// cases with selection in an <input>
var t19 = getById("t19");
t19.setSelectionRange(0, 0);
setFocusTo("t18", gChildWindow);
@@ -1152,17 +1152,17 @@ function otherWindowFocused(otherWindow)
}
function modalWindowOpened(modalWindow)
{
var elem = modalWindow.document.getElementById("other");
if (gPartialTabbing)
elem.focus();
else
- synthesizeKey("VK_TAB", { }, modalWindow);
+ synthesizeKey("KEY_Tab", {}, modalWindow);
is(fm.activeWindow, modalWindow, "modal activeWindow");
is(fm.focusedElement, elem, "modal focusedElement");
modalWindow.close();
SimpleTest.waitForFocus(modalWindowClosed);
}
function modalWindowClosed()
@@ -1182,79 +1182,79 @@ function framesetWindowLoaded(framesetWi
is(fm.activeWindow, getTopWindow(framesetWindow), "frameset window active");
gOldExpectedWindow = getTopWindow(framesetWindow);
gMoveToFocusFrame = true;
for (var idx = 1; idx <= 8; idx++) {
gNewExpectedWindow = framesetWindow.frames[(idx - 1) >> 1];
if (idx % 2)
initEvents(gNewExpectedWindow);
- expectFocusShift(() => synthesizeKey("VK_TAB", { }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_Tab", {}, framesetWindow),
gNewExpectedWindow, getById("f" + idx), true, "frameset tab key f" + idx);
gMoveToFocusFrame = false;
gOldExpectedWindow = gNewExpectedWindow;
}
gNewExpectedWindow = framesetWindow.frames[0];
- expectFocusShift(() => synthesizeKey("VK_TAB", { }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_Tab", {}, framesetWindow),
gNewExpectedWindow, getById("f1"), true, "frameset tab key wrap to start");
gOldExpectedWindow = gNewExpectedWindow;
gNewExpectedWindow = framesetWindow.frames[3];
- expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}, framesetWindow),
gNewExpectedWindow, getById("f8"), true, "frameset shift tab key wrap to end");
for (idx = 7; idx >= 1; idx--) {
gOldExpectedWindow = gNewExpectedWindow;
gNewExpectedWindow = framesetWindow.frames[(idx - 1) >> 1];
- expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}, framesetWindow),
gNewExpectedWindow, getById("f" + idx), true, "frameset shift tab key f" + idx);
}
// document shifting
// XXXndeakin P3 ctrl+tab doesn't seem to be testable currently for some reason
gNewExpectedWindow = framesetWindow.frames[1];
- expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true}, framesetWindow),
gNewExpectedWindow, getById("f3"), true, "switch document forward with f6");
gOldExpectedWindow = gNewExpectedWindow;
gNewExpectedWindow = framesetWindow.frames[2];
- expectFocusShift(() => synthesizeKey("VK_F6", { }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_F6", {}, framesetWindow),
gNewExpectedWindow, getById("f5"), true, "switch document forward with ctrl+tab");
gOldExpectedWindow = gNewExpectedWindow;
gNewExpectedWindow = framesetWindow.frames[3];
- expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true}, framesetWindow),
gNewExpectedWindow, getById("f7"), true, "switch document forward with ctrl+f6");
gOldExpectedWindow = gNewExpectedWindow;
gNewExpectedWindow = framesetWindow.frames[0];
- expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true}, framesetWindow),
gNewExpectedWindow, getById("f1"), true, "switch document forward and wrap");
// going backwards by document and wrapping doesn't currently work, but didn't work
// before the focus reworking either
/*
gOldExpectedWindow = gNewExpectedWindow;
gNewExpectedWindow = framesetWindow.frames[3];
- expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
gNewExpectedWindow, getById("f7"), true, "switch document backward and wrap");
*/
fm.moveFocus(framesetWindow.frames[3], null, fm.MOVEFOCUS_ROOT, 0);
gEvents = "";
gOldExpectedWindow = gNewExpectedWindow;
gNewExpectedWindow = framesetWindow.frames[2];
- expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true, shiftKey: true}, framesetWindow),
gNewExpectedWindow, getById("f5"), true, "switch document backward with f6");
gOldExpectedWindow = gNewExpectedWindow;
gNewExpectedWindow = framesetWindow.frames[1];
- expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true, shiftKey: true}, framesetWindow),
gNewExpectedWindow, getById("f3"), true, "switch document backward with ctrl+tab");
gOldExpectedWindow = gNewExpectedWindow;
gNewExpectedWindow = framesetWindow.frames[0];
- expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
+ expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true, shiftKey: true}, framesetWindow),
gNewExpectedWindow, getById("f1"), true, "switch document backward with ctrl+f6");
// skip the window switching tests for now on Linux, as raising and lowering
// a window is asynchronous there
if (!navigator.platform.includes("Linux")) {
window.openDialog("focus_window2.xul", "_blank", "chrome", switchWindowTest, framesetWindow);
}
else {
--- a/dom/tests/mochitest/chrome/window_focus_docnav.xul
+++ b/dom/tests/mochitest/chrome/window_focus_docnav.xul
@@ -54,24 +54,24 @@ function done()
{
var opener = window.opener;
window.close();
opener.wrappedJSObject.SimpleTest.finish();
}
function previous(expectedWindow, expectedElement, desc)
{
- synthesizeKey("VK_F6", { shiftKey: true });
+ synthesizeKey("KEY_F6", {shiftKey: true});
is(fm.focusedWindow, expectedWindow, desc);
is(fm.focusedElement, expectedElement, desc + " element");
}
function next(expectedWindow, expectedElement, desc)
{
- synthesizeKey("VK_F6", { });
+ synthesizeKey("KEY_F6");
is(fm.focusedWindow, expectedWindow, desc);
is(fm.focusedElement, expectedElement, desc + " element" + "::" + (fm.focusedElement ? fm.focusedElement.parentNode.id : "<none>"));
}
// This test runs through three cases. Document navigation forward and
// backward using the F6 key when no popups are open, with one popup open and
// with two popups open.
function runTests(panel, popupCount)
--- a/dom/tests/mochitest/general/test_bug1012662_common.js
+++ b/dom/tests/mochitest/general/test_bug1012662_common.js
@@ -267,30 +267,30 @@ function cutCopyAll(aDoCut, aDoCopy, aDo
function allMechanisms(aCb, aClipOverride, aNegateAll) {
function testStep(n) {
gTestN1 = n;
switch (n) {
case 0:
// Keyboard issued
cutCopyAll(function docut(aSucc) {
- synthesizeKey("X", {accelKey: true});
+ synthesizeKey("x", {accelKey: true});
}, function docopy(aSucc) {
- synthesizeKey("C", {accelKey: true});
+ synthesizeKey("c", {accelKey: true});
}, function done() { testStep(n + 1); }, false, aClipOverride, aNegateAll);
return;
case 1:
// Button issued
cutCopyAll(function docut(aSucc) {
document.addEventListener('keydown', execCut(aSucc));
- synthesizeKey("Q", {});
+ sendString("Q");
}, function docopy(aSucc) {
document.addEventListener('keydown', execCopy(aSucc));
- synthesizeKey("Q", {});
+ sendString("Q");
}, function done() { testStep(n + 1); }, false, aClipOverride, aNegateAll);
return;
case 2:
// Button issued
cutCopyAll(function doCut(aSucc) {
is(false, document.execCommand('cut'), "Can't directly execCommand not in a user callback");
}, function doCopy(aSucc) {
--- a/dom/tests/mochitest/general/test_bug1170911.html
+++ b/dom/tests/mochitest/general/test_bug1170911.html
@@ -25,17 +25,17 @@ const TEXTAREA_VALUE = TEXTAREA.value;
function doTest() {
is(document.queryCommandSupported("copy"), false,
"Copy support should have been disabled");
is(document.queryCommandSupported("cut"), false,
"Cut support should have been disabled");
document.addEventListener("keydown", tryCopy);
- synthesizeKey("Q", {});
+ sendString("Q");
}
function tryCopy(evt) {
evt.preventDefault();
document.removeEventListener("keydown", tryCopy);
TEXTAREA.setSelectionRange(0, TEXTAREA_VALUE.length);
TEXTAREA.focus();
@@ -46,17 +46,17 @@ function tryCopy(evt) {
"Copy should not be executed when dom.allow_cut_copy is off");
is(TEXTAREA.value, TEXTAREA_VALUE,
"Content in the textarea shouldn't be changed");
TEXTAREA.value = TEXTAREA_VALUE;
},
/* success fn */ SimpleTest.finish,
/* failure fn */ function () {
document.addEventListener("keydown", tryCut);
- synthesizeKey("Q", {});
+ sendString("Q");
},
/* flavor */ undefined,
/* timeout */ undefined,
/* expect failure */ true);
}
function tryCut(evt) {
evt.preventDefault();
--- a/dom/tests/mochitest/general/test_focus_scrollchildframe.html
+++ b/dom/tests/mochitest/general/test_focus_scrollchildframe.html
@@ -8,17 +8,17 @@
</head>
<body onload="doTest()">
<p id="display"></p>
<div id="content" style="display: none"></div>
<script>
function doTest() {
document.getElementById("button").focus();
is(window.scrollY, 0, "Scrolled position initially 0");
- synthesizeKey("VK_TAB", { }),
+ synthesizeKey("KEY_Tab"),
ok(window.scrollY > 200, "Scrolled child frame into view");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
</script>
<button id="button">B</button><br><iframe style="margin-top:10000px;height:400px"></iframe>
</body>
</html>
--- a/dom/tests/mochitest/general/test_focusrings.xul
+++ b/dom/tests/mochitest/general/test_focusrings.xul
@@ -81,17 +81,17 @@ function runTest()
ok(compareSnapshots(snapShot($("b1")), snapShot($("b2")), false)[0], "focus after mouse shows no ring");
}
synthesizeMouse($("b2"), 4, 4, { });
checkFocus($("b2"), !isMac, "appearance on button after mouse focus with :focus");
// after a key is pressed, the focus ring will always be visible
$("l2").focus();
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
checkFocus($("l3"), true, "appearance on list after tab focus");
if (isMac) {
SpecialPowers.pushPrefEnv({"set": [['accessibility.mouse_focuses_formcontrol', true]]}, testMacFocusesFormControl);
}
else {
SimpleTest.finish();
}
--- a/dom/tests/mochitest/pointerlock/file_escapeKey.html
+++ b/dom/tests/mochitest/pointerlock/file_escapeKey.html
@@ -40,17 +40,17 @@
div.requestPointerLock();
}
function lockedPointer(e) {
document.removeEventListener("pointerlockchange", lockedPointer);
is(document.pointerLockElement, div, "Pointer should have been locked on #div");
document.addEventListener("pointerlockchange", unlockedPointer);
addFullscreenChangeContinuation("exit", leavedFullscreen);
- SimpleTest.executeSoon(() => synthesizeKey("VK_ESCAPE", {}));
+ SimpleTest.executeSoon(() => synthesizeKey("KEY_Escape"));
}
var pointerUnlocked = false;
var exitedFullscreen = false;
function unlockedPointer() {
document.removeEventListener("pointerlockchange", unlockedPointer);
ok(!pointerUnlocked, "Shouldn't have unlocked pointer before");
--- a/editor/libeditor/tests/browser_bug527935.js
+++ b/editor/libeditor/tests/browser_bug527935.js
@@ -21,17 +21,17 @@ add_task(async function() {
window.loadPromise = new Promise(resolve => {
formTarget.onload = resolve;
});
initValue.focus();
initValue.value = "foo";
});
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
await ContentTask.spawn(aBrowser, {}, async function() {
var window = content.window.wrappedJSObject;
var document = window.document;
await window.loadPromise;
var newInput = document.createElement("input");
--- a/editor/libeditor/tests/test_backspace_vs.html
+++ b/editor/libeditor/tests/test_backspace_vs.html
@@ -47,34 +47,32 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForExplicitFinish();
addLoadEvent(runTest);
function test(edit, bsCount) {
edit.focus();
var sel = window.getSelection();
sel.collapse(edit.childNodes[0], edit.textContent.length - 1);
for (i = 0; i < bsCount; ++i) {
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
}
is(edit.textContent, "ab", "The backspace key should delete the characters correctly");
}
function testWithMove(edit, offset, bsCount) {
edit.focus();
var sel = window.getSelection();
sel.collapse(edit.childNodes[0], 0);
var i;
for (i = 0; i < offset; ++i) {
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKey("KEY_ArrowRight");
}
- for (i = 0; i < bsCount; ++i) {
- synthesizeKey("VK_BACK_SPACE", {});
- }
+ synthesizeKey("KEY_Backspace", {repeat: bsCount});
is(edit.textContent, "ab", "The backspace key should delete the characters correctly");
}
function runTest() {
/* test backspace-deletion of the middle character(s) */
test(document.getElementById("edit1"), 1);
test(document.getElementById("edit2"), 1);
test(document.getElementById("edit3"), 1);
--- a/editor/libeditor/tests/test_bug1094000.html
+++ b/editor/libeditor/tests/test_bug1094000.html
@@ -41,60 +41,60 @@ function runTests()
var editor6 = document.getElementById("editor6");
ok(editor1.getBoundingClientRect().height - editor0.getBoundingClientRect().height > 1,
"an editor having a <br> element and an empty editor shouldn't be same height");
ok(Math.abs(editor1.getBoundingClientRect().height - editor2.getBoundingClientRect().height) <= 1,
"an editor having only a <br> element and an editor having \"a\" should be same height");
editor2.focus();
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_Backspace");
is(editor2.innerHTML, "<br>",
"an editor which had \"a\" should have only <br> element after Backspace keypress");
ok(Math.abs(editor2.getBoundingClientRect().height - editor1.getBoundingClientRect().height) <= 1,
"an editor whose content was removed by Backspace key should have a place to put a caret");
editor3.focus();
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKey("KEY_Delete");
is(editor3.innerHTML, "<br>",
"an editor which had \"b\" should have only <br> element after Delete keypress");
ok(Math.abs(editor3.getBoundingClientRect().height - editor1.getBoundingClientRect().height) <= 1,
"an editor whose content was removed by Delete key should have a place to put a caret");
editor4.focus();
window.getSelection().selectAllChildren(editor4);
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(editor4.innerHTML, "<br>",
"an editor which had \"c\" should have only <br> element after removing selected text with Backspace key");
ok(Math.abs(editor4.getBoundingClientRect().height - editor1.getBoundingClientRect().height) <= 1,
"an editor whose content was selected and removed by Backspace key should have a place to put a caret");
editor5.focus();
window.getSelection().selectAllChildren(editor5);
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
is(editor5.innerHTML, "<br>",
"an editor which had \"d\" should have only <br> element after removing selected text with Delete key");
ok(Math.abs(editor5.getBoundingClientRect().height - editor1.getBoundingClientRect().height) <= 1,
"an editor whose content was selected and removed by Delete key should have a place to put a caret");
editor6.focus();
window.getSelection().selectAllChildren(editor6);
- synthesizeKey("x", { accelKey: true });
+ synthesizeKey("x", {accelKey: true});
is(editor6.innerHTML, "<br>",
"an editor which had \"e\" should have only <br> element after removing selected text by \"Cut\"");
ok(Math.abs(editor6.getBoundingClientRect().height - editor1.getBoundingClientRect().height) <= 1,
"an editor whose content was selected and removed by \"Cut\" should have a place to put a caret");
editor0.focus();
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(editor0.innerHTML, "",
"an empty editor should keep being empty even if Backspace key is pressed");
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
is(editor0.innerHTML, "",
"an empty editor should keep being empty even if Delete key is pressed");
SimpleTest.finish();
}
SimpleTest.waitForFocus(runTests);
--- a/editor/libeditor/tests/test_bug1100966.html
+++ b/editor/libeditor/tests/test_bug1100966.html
@@ -28,21 +28,21 @@ let {onSpellCheck} = SpecialPowers.Cu.im
/** Test for Bug 1100966 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("content");
div.focus();
synthesizeMouseAtCenter(div, {});
getSpellChecker().UpdateCurrentDictionary(() => {
- synthesizeKey(" ", {});
+ sendString(" ");
setTimeout(function() {
- synthesizeKey("a", {});
+ sendString("a");
setTimeout(function() {
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
onSpellCheck(div, function() {
var sel = getSpellCheckSelection();
is(sel.rangeCount, 2, "We should have two misspelled words");
is(String(sel.getRangeAt(0)), "fivee", "Correct misspelled word");
is(String(sel.getRangeAt(1)), "sixx", "Correct misspelled word");
SimpleTest.finish();
--- a/editor/libeditor/tests/test_bug1109465.html
+++ b/editor/libeditor/tests/test_bug1109465.html
@@ -23,24 +23,20 @@ https://bugzilla.mozilla.org/show_bug.cg
/** Test for Bug 1109465 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var t = document.querySelector("textarea");
t.focus();
// Type foo\nbar and place the caret at the end of the last line
- synthesizeKey("f", {});
- synthesizeKey("o", {});
- synthesizeKey("o", {});
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("b", {});
- synthesizeKey("a", {});
- synthesizeKey("r", {});
- synthesizeKey("VK_UP", {});
+ sendString("foo");
+ synthesizeKey("KEY_Enter");
+ sendString("bar");
+ synthesizeKey("KEY_ArrowUp");
is(t.selectionStart, 3, "Correct start of selection");
is(t.selectionEnd, 3, "Correct end of selection");
// Compose an IME string
synthesizeComposition({ type: "compositionstart" });
var composingString = "\u306B";
synthesizeCompositionChange(
{ "composition":
--- a/editor/libeditor/tests/test_bug1140105.html
+++ b/editor/libeditor/tests/test_bug1140105.html
@@ -21,17 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<script class="testbody" type="application/javascript">
/** Test for Bug 1140105 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("content");
div.focus();
synthesizeMouseAtCenter(div, {});
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
var sel = window.getSelection();
var selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be in text node");
is(selRange.endOffset, 9, "offset should be 9");
var firstHas = {};
var anyHas = {};
--- a/editor/libeditor/tests/test_bug1154791.html
+++ b/editor/libeditor/tests/test_bug1154791.html
@@ -26,23 +26,23 @@ let {onSpellCheck} = SpecialPowers.Cu.im
/** Test for Bug 1154791 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("content");
div.focus();
getSpellChecker().UpdateCurrentDictionary(() => {
synthesizeMouseAtCenter(div, {});
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKey("KEY_ArrowLeft");
setTimeout(function() {
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
setTimeout(function() {
- synthesizeKey(" ", {});
+ sendString(" ");
onSpellCheck(div, function() {
var sel = getSpellCheckSelection();
is(sel.rangeCount, 2, "We should have two misspelled words");
is(String(sel.getRangeAt(0)), "thiss", "Correct misspelled word");
is(String(sel.getRangeAt(1)), "onee", "Correct misspelled word");
SimpleTest.finish();
--- a/editor/libeditor/tests/test_bug1162952.html
+++ b/editor/libeditor/tests/test_bug1162952.html
@@ -28,16 +28,16 @@ document.addEventListener('keydown', fun
is(true, document.queryCommandEnabled('copy'));
});
// Otherwise, they should be disabled
is(false, document.queryCommandEnabled('cut'));
is(false, document.queryCommandEnabled('copy'));
// Fire a user callback
-synthesizeKey('A', {});
+sendString('A');
ok(userCallbackRun, "User callback should've been run");
</script>
</pre>
</body>
</html>
--- a/editor/libeditor/tests/test_bug1248128.html
+++ b/editor/libeditor/tests/test_bug1248128.html
@@ -29,17 +29,17 @@ https://bugzilla.mozilla.org/show_bug.cg
} catch (e) {
ok(true, "unable to perform kMoveLeft");
}
ok(outer.scrollTop == scroll,
"scroll is unchanged: got " + outer.scrollTop + ", expected " + scroll);
// Make sure cmd_moveLeft isn't failing for some unrelated reason
- synthesizeKey("a", {});
+ sendString("a");
is(input.selectionStart, 1, "selectionStart after typing");
SpecialPowers.doCommand(window, "cmd_moveLeft");
is(input.selectionStart, 0, "selectionStart after move left");
SimpleTest.finish();
});
</script>
</head>
--- a/editor/libeditor/tests/test_bug1250010.html
+++ b/editor/libeditor/tests/test_bug1250010.html
@@ -35,21 +35,21 @@ SimpleTest.waitForFocus(function() {
div.focus();
synthesizeMouseAtCenter(div, {});
var sel = window.getSelection();
var selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
is(selRange.endOffset, 10, "offset should be 10");
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("b", {});
- synthesizeKey("VK_UP", {});
- synthesizeKey("a", {});
+ synthesizeKey("KEY_Enter");
+ synthesizeKey("KEY_Enter");
+ sendString("b");
+ synthesizeKey("KEY_ArrowUp");
+ sendString("a");
is(div.innerHTML, "<p><b><font color=\"red\">1234567890</font></b></p>" +
"<p><b><font color=\"red\">a<br></font></b></p>" +
"<p><b><font color=\"red\">b<br></font></b></p>",
"unexpected HTML");
// Second test: Since we modified the code path that splits non-text nodes,
// test that this works, if the split node is not empty.
@@ -58,20 +58,20 @@ SimpleTest.waitForFocus(function() {
synthesizeMouseAtCenter(div, {});
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
is(selRange.endOffset, 3, "offset should be 3");
// Move behind the image and press enter, insert an "A".
// That should insert a new empty paragraph with the "A" after what we have.
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("A", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_Enter");
+ sendString("A");
// The resulting HTML is sadly less than optimal:
// A <br> gets inserted after the image and the "A" is followed by an empty <tt></tt>.
var newHTML = div.innerHTML;
var expectedHTML;
// Existing part with additional <br> inserted.
expectedHTML = "<p><tt>xyz</tt></p><p><tt><img src=\"" + getImageDataURI() + "\"><br></tt></p>" +
// New part caused by pressing enter after the image and typing an "A".
--- a/editor/libeditor/tests/test_bug1257363.html
+++ b/editor/libeditor/tests/test_bug1257363.html
@@ -33,64 +33,64 @@ SimpleTest.waitForFocus(function() {
synthesizeMouse(div, 100, 2, {}); /* click behind and down */
var sel = window.getSelection();
var selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
is(selRange.endOffset, 5, "offset should be 5");
// Return and backspace should take us to where we started.
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Enter");
+ synthesizeKey("KEY_Backspace");
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
is(selRange.endOffset, 5, "offset should be 5");
// Add an "a" to the end of the paragraph.
- synthesizeKey("a", {});
+ sendString("a");
// Return and forward delete should take us to the following line.
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Enter");
+ synthesizeKey("KEY_Delete");
// Add a "b" to the start.
- synthesizeKey("b", {});
+ sendString("b");
is(div.innerHTML, "<p style=\"color:red;\">12345a</p>b67",
"unexpected HTML");
// Let's repeat the whole thing, but a font tag instead of CSS.
// The behaviour is different since the font is carried over.
div = document.getElementById("backspace");
div.focus();
synthesizeMouse(div, 100, 2, {}); /* click behind and down */
sel = window.getSelection();
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
is(selRange.endOffset, 5, "offset should be 5");
// Return and backspace should take us to where we started.
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Enter");
+ synthesizeKey("KEY_Backspace");
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
is(selRange.endOffset, 5, "offset should be 5");
// Add an "a" to the end of the paragraph.
- synthesizeKey("a", {});
+ sendString("a");
// Return and forward delete should take us to the following line.
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Enter");
+ synthesizeKey("KEY_Delete");
// Add a "b" to the start.
- synthesizeKey("b", {});
+ sendString("b");
// Here we get a somewhat ugly result since the red sticks.
is(div.innerHTML, "<p><font color=\"red\">12345a</font></p><font color=\"red\">b</font>67",
"unexpected HTML");
// ***** Delete test *****
div = document.getElementById("deleteCSS");
div.focus();
@@ -98,81 +98,81 @@ SimpleTest.waitForFocus(function() {
var sel = window.getSelection();
var selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
is(selRange.endOffset, 1, "offset should be 1");
// left, enter should create a new empty paragraph before
// but leave the selection at the start of the existing paragraph.
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKey("KEY_Enter");
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the start of text node");
is(selRange.endOffset, 0, "offset should be 0");
is(selRange.endContainer.nodeValue, "x", "we should be in the text node with the x");
// Now moving up into the new empty paragraph.
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "P", "selection should be the new empty paragraph");
is(selRange.endOffset, 0, "offset should be 0");
// Forward delete should now take us to where we started.
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the start of text node");
is(selRange.endOffset, 0, "offset should be 0");
// Add an "a" to the start of the paragraph.
- synthesizeKey("a", {});
+ sendString("a");
is(div.innerHTML, "<p style=\"color:red;\">ax</p>",
"unexpected HTML");
// Let's repeat the whole thing, but a font tag instead of CSS.
div = document.getElementById("delete");
div.focus();
synthesizeMouse(div, 100, 2, {}); /* click behind and down */
var sel = window.getSelection();
var selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
is(selRange.endOffset, 1, "offset should be 1");
// left, enter should create a new empty paragraph before
// but leave the selection at the start of the existing paragraph.
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKey("KEY_Enter");
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the start of text node");
is(selRange.endOffset, 0, "offset should be 0");
is(selRange.endContainer.nodeValue, "y", "we should be in the text node with the y");
// Now moving up into the new empty paragraph.
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "FONT", "selection should be the font tag");
is(selRange.endOffset, 0, "offset should be 0");
is(selRange.endContainer.parentNode.nodeName, "P", "the parent of the font should be a paragraph");
// Forward delete should now take us to where we started.
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be at the start of text node");
is(selRange.endOffset, 0, "offset should be 0");
// Add an "a" to the start of the paragraph.
- synthesizeKey("a", {});
+ sendString("a");
is(div.innerHTML, "<p><font color=\"red\">ay</font></p>",
"unexpected HTML");
SimpleTest.finish();
});
--- a/editor/libeditor/tests/test_bug1258085.html
+++ b/editor/libeditor/tests/test_bug1258085.html
@@ -5,61 +5,61 @@
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<div contenteditable></div>
<script>
var div = document.querySelector("div");
function reset() {
div.innerHTML = "x<br> y";
div.focus();
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
}
function checks(msg) {
is(div.innerHTML, "x<br><br>",
msg + ": Should add a second <br> to prevent collapse of first");
is(div.childNodes.length, 3, msg + ": No empty text nodes allowed");
ok(getSelection().isCollapsed, msg + ": Selection must be collapsed");
is(getSelection().focusNode, div, msg + ": Focus must be in div");
is(getSelection().focusOffset, 2,
msg + ": Focus must be between the two <br>s");
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
// Put selection after the "y" and backspace
reset();
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_Backspace");
checks("Collapsed backspace");
// Now do the same with delete
reset();
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
checks("Collapsed delete");
// Forward selection
reset();
- synthesizeKey("VK_RIGHT", {shiftKey: true});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_ArrowRight", {shiftKey: true});
+ synthesizeKey("KEY_Backspace");
checks("Forward-selected backspace");
// Backward selection
reset();
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_LEFT", {shiftKey: true});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowLeft", {shiftKey: true});
+ synthesizeKey("KEY_Backspace");
checks("Backward-selected backspace");
// Make sure we're not deleting if the whitespace isn't actually collapsed
div.style.whiteSpace = "pre-wrap";
reset();
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_Backspace");
if (div.innerHTML, "x<br> ", "pre-wrap: Don't delete uncollapsed space");
ok(getSelection().isCollapsed, "pre-wrap: Selection must be collapsed");
is(getSelection().focusNode, div.lastChild,
"pre-wrap: Focus must be in final text node");
is(getSelection().focusOffset, 1, "pre-wrap: Focus must be at end of node");
SimpleTest.finish();
});
--- a/editor/libeditor/tests/test_bug1270235.html
+++ b/editor/libeditor/tests/test_bug1270235.html
@@ -32,15 +32,15 @@ SimpleTest.waitForFocus(()=>{
newRange.setEnd(node, 0);
let selection = document.getSelection();
selection.removeAllRanges();
selection.addRange(newRange);
ok(selection.isCollapsed, 'isCollapsed must be true');
// Don't crash by user input
- synthesizeKey("X", {});
+ sendString("X");
SimpleTest.finish();
});
</script>
</body>
</html>
--- a/editor/libeditor/tests/test_bug1314790.html
+++ b/editor/libeditor/tests/test_bug1314790.html
@@ -24,26 +24,18 @@ SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
let elm = document.getElementById("contenteditable1");
elm.focus();
window.getSelection().collapse(elm.childNodes[0], 0);
SpecialPowers.doCommand(window, "cmd_wordNext");
SpecialPowers.doCommand(window, "cmd_wordNext");
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("a", {});
- synthesizeKey("p", {});
- synthesizeKey("p", {});
- synthesizeKey("l", {});
- synthesizeKey("e", {});
- synthesizeKey(" ", {});
- synthesizeKey("p", {});
- synthesizeKey("e", {});
- synthesizeKey("n", {});
+ synthesizeKey("KEY_Enter");
+ sendString("apple pen");
is(elm.childNodes[0].textContent, "pen pineapple",
"'pen pineapple' is first elment");
is(elm.childNodes[1].textContent, "apple pen",
"'apple pen' is second elment");
SpecialPowers.doCommand(window, "cmd_deleteWordBackward");
SpecialPowers.doCommand(window, "cmd_deleteWordBackward");
--- a/editor/libeditor/tests/test_bug1315065.html
+++ b/editor/libeditor/tests/test_bug1315065.html
@@ -55,17 +55,17 @@ SimpleTest.waitForFocus(()=>{
}
}
for (var i = 0; i < 4; i++) {
const kDescription = i == 0 ? "Backspace from immediately after the last character" :
"Backspace from " + i + "th empty text node";
editor.focus();
initForBackspace(i);
- synthesizeKey("KEY_Backspace", {});
+ synthesizeKey("KEY_Backspace");
var p = document.getElementById("p");
ok(p, kDescription + ": <p> element shouldn't be removed by Backspace key press");
is(p.tagName.toLowerCase(), "p", kDescription + ": <p> element shouldn't be removed by Backspace key press");
// When Backspace key is pressed even in empty text nodes, Gecko should not remove empty text nodes for now
// because we should keep our traditional behavior (same as Edge) for backward compatibility as far as possible.
// In this case, Chromium removes all empty text nodes, but Edge doesn't remove any empty text nodes.
is(p.childNodes.length, 5, kDescription + ": <p> should have 5 children after pressing Backspace key");
is(p.childNodes.item(0).textContent, "ab", kDescription + ": 'c' should be removed by pressing Backspace key");
@@ -112,17 +112,17 @@ SimpleTest.waitForFocus(()=>{
}
}
for (var i = 0; i < 4; i++) {
const kDescription = i == 0 ? "Delete from immediately before the first character" :
"Delete from " + i + "th empty text node";
editor.focus();
initForDelete(i);
- synthesizeKey("KEY_Delete", {});
+ synthesizeKey("KEY_Delete");
var p = document.getElementById("p");
ok(p, kDescription + ": <p> element shouldn't be removed by Delete key press");
is(p.tagName.toLowerCase(), "p", kDescription + ": <p> element shouldn't be removed by Delete key press");
if (i == 0) {
// If Delete key is pressed in non-empty text node, only the text node should be modified.
// This is same behavior as Chromium, but different from Edge. Edge removes all empty text nodes in this case.
is(p.childNodes.length, 5, kDescription + ": <p> should have only 2 children after pressing Delete key (empty text nodes should be removed");
is(p.childNodes.item(0).textContent, "", kDescription + ": 1st empty text node should not be removed by pressing Delete key");
--- a/editor/libeditor/tests/test_bug1316302.html
+++ b/editor/libeditor/tests/test_bug1316302.html
@@ -26,25 +26,25 @@ SimpleTest.waitForFocus(()=>{
editor.focus();
// Try to remove the last character from the end of the <blockquote>
selection.collapse(blockquote, blockquote.childNodes.length);
var range = selection.getRangeAt(0);
ok(range.collapsed, "range should be collapsed at the end of <blockquote>");
is(range.startContainer, blockquote, "range should be collapsed in the <blockquote>");
is(range.startOffset, blockquote.childNodes.length, "range should be collapsed at the end");
- synthesizeKey("KEY_Backspace", {});
+ synthesizeKey("KEY_Backspace");
is(blockquote.innerHTML, "<p>ab</p>", "Pressing Backspace key at the end of <blockquote> should remove the last character in the <p>");
// Try to remove the first character from the start of the <blockquote>
selection.collapse(blockquote, 0);
range = selection.getRangeAt(0);
ok(range.collapsed, "range should be collapsed at the start of <blockquote>");
is(range.startContainer, blockquote, "range should be collapsed in the <blockquote>");
is(range.startOffset, 0, "range should be collapsed at the start");
- synthesizeKey("KEY_Delete", {});
+ synthesizeKey("KEY_Delete");
is(blockquote.innerHTML, "<p>b</p>", "Pressing Delete key at the start of <blockquote> should remove the first character in the <p>");
SimpleTest.finish();
});
</script>
</body>
</html>
--- a/editor/libeditor/tests/test_bug1318312.html
+++ b/editor/libeditor/tests/test_bug1318312.html
@@ -24,41 +24,41 @@ function runTests()
"outerEditor should have focus");
// Move cursor into the innerEditor with ArrowDown key. Then, focus shouldn't
// be moved to innerEditor from outerEditor.
// Note that Chrome moves focus in this case. However, we should do that
// at least for now because user can move focus with ArrowUp key even from
// innerEditor to outerEditor but we don't allow such navigation.
// FYI: Edge behaves same as us.
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
is(document.activeElement, outerEditor,
"outerEditor should still have focus because focus shouldn't be moved by moving caret");
is(document.getSelection().focusNode, document.getElementById("innerEditor").firstChild.firstChild,
"focus node of selection should be the text node in the innerEditor");
is(document.getSelection().focusOffset, 0,
"focus offset of selection should be 0");
- synthesizeKey("a", {});
+ sendString("a");
is(document.activeElement, outerEditor,
"outerEditor should still have focus because focus shouldn't be moved by typing a character");
is(document.getSelection().focusNode, document.getElementById("innerEditor").firstChild.firstChild,
"focus node of selection should be the text node in the innerEditor");
is(document.getSelection().focusOffset, 1,
"focus offset of selection should be 1");
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
is(document.activeElement, outerEditor,
"outerEditor should still have focus because focus shouldn't be moved by typing Enter");
is(document.getSelection().focusNode, document.getElementById("innerEditor").childNodes.item(1).firstChild,
"focus node of selection should be the text node in the second paragraph in the innerEditor");
is(document.getSelection().focusOffset, 0,
"focus offset of selection should be 0");
- synthesizeKey("KEY_Backspace", {});
+ synthesizeKey("KEY_Backspace");
is(document.activeElement, outerEditor,
"outerEditor should still have focus because focus shouldn't be moved by typing Backspace (removing the line breaker)");
is(document.getSelection().focusNode, document.getElementById("innerEditor").firstChild.firstChild,
"focus node of selection should be the text node in the innerEditor");
is(document.getSelection().focusOffset, 1,
"focus offset of selection should be 1");
synthesizeKey("KEY_ArrowLeft", {shiftKey: true});
@@ -68,25 +68,25 @@ function runTests()
"focus node of selection should be the text node in the innerEditor");
is(document.getSelection().focusOffset, 0,
"focus offset of selection should be 0");
is(document.getSelection().anchorNode, document.getElementById("innerEditor").firstChild.firstChild,
"anchor node of selection should be the text node in the innerEditor");
is(document.getSelection().anchorOffset, 1,
"anchor offset of selection should be 1");
- synthesizeKey("KEY_Delete", {});
+ synthesizeKey("KEY_Delete");
is(document.activeElement, outerEditor,
"outerEditor should still have focus because focus shouldn't be moved by typing Delete (removing the 'a')");
is(document.getSelection().focusNode, document.getElementById("innerEditor").firstChild.firstChild,
"focus node of selection should be the text node in the innerEditor");
is(document.getSelection().focusOffset, 0,
"focus offset of selection should be 0");
- synthesizeKey("KEY_ArrowUp", {});
+ synthesizeKey("KEY_ArrowUp");
is(document.activeElement, outerEditor,
"outerEditor should still have focus because focus shouldn't be moved by moving caret from innerEditor to outerEditor");
is(document.getSelection().focusNode, document.getElementById("outerEditor").firstChild.firstChild,
"focus node of selection should be the text node in the outerEditor");
is(document.getSelection().focusOffset, 0,
"focus offset of selection should be 0");
// However, clicking in innerEditor should move focus.
--- a/editor/libeditor/tests/test_bug1328023.html
+++ b/editor/libeditor/tests/test_bug1328023.html
@@ -20,45 +20,42 @@ https://bugzilla.mozilla.org/show_bug.cg
<pre id="test">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
let elm = document.getElementById("input1");
elm.focus();
- synthesizeKey("A", {});
- synthesizeKey("B", {});
+ sendString("AB");
is(elm.value, "AB", "AB is input.value now");
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(elm.value, "A", "A is input.value now");
synthesizeKey("Z", { accelKey: true });
is(elm.value, "AB", "AB is input.value now");
- synthesizeKey("C", {});
+ sendString("C");
is(elm.value, "ABC", "ABC is input.value now");
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
+ synthesizeKey("KEY_Backspace");
+ synthesizeKey("KEY_Backspace");
- synthesizeKey("A", {});
- synthesizeKey("B", {});
- synthesizeKey("C", {});
+ sendString("ABC");
is(elm.value, "ABC", "ABC is input.value now");
synthesizeKey("Z", { accelKey: true });
is(elm.value, "", "'' is input.value now");
synthesizeKey("Z", { accelKey: true, shiftKey: true });
is(elm.value, "ABC", "ABC is input.value now");
- synthesizeKey("D", {});
+ sendString("D");
is(elm.value, "ABCD", "ABCD is input.value now");
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>
--- a/editor/libeditor/tests/test_bug1330796.html
+++ b/editor/libeditor/tests/test_bug1330796.html
@@ -70,18 +70,18 @@ SimpleTest.waitForFocus(function() {
for (i = 0; i < tests.length; i++) {
theEdit.innerHTML = tests[i][0];
theEdit.focus();
var theText = theEdit.firstChild.firstChild;
// Position set at the beginning , middle and end of the text.
sel.collapse(theText, tests[i][1]);
- synthesizeKey("KEY_Enter", {});
- synthesizeKey("x", {});
+ synthesizeKey("KEY_Enter");
+ sendString("x");
is(theEdit.innerHTML, tests[i][2], "unexpected HTML for test " + i.toString());
}
SimpleTest.finish();
});
function makeMailEditor() {
--- a/editor/libeditor/tests/test_bug1352799.html
+++ b/editor/libeditor/tests/test_bug1352799.html
@@ -26,69 +26,55 @@ SimpleTest.waitForFocus(() => {
var input = document.getElementById("input");
var inputcontainer = document.getElementById('input-container');
input.setAttribute('maxlength', 2);
inputcontainer.style.display = 'block';
input.focus();
- synthesizeKey('1', {});
- synthesizeKey('2', {});
- synthesizeKey('3', {});
+ sendString("123");
is(input.value, '12', 'value should be 12 with maxlength = 2');
input.value = '';
inputcontainer.style.display = 'none';
window.setTimeout(() => {
input.setAttribute('maxlength', 4);
inputcontainer.style.display = 'block';
input.focus();
- synthesizeKey('4', {});
- synthesizeKey('5', {});
- synthesizeKey('6', {});
- synthesizeKey('7', {});
- synthesizeKey('8', {});
+ sendString("45678");
is(input.value, '4567', 'value should be 4567 with maxlength = 4');
inputcontainer.style.display = 'none';
window.setTimeout(() => {
input.setAttribute('maxlength', 2);
inputcontainer.style.display = 'block';
input.focus();
- synthesizeKey('1', {});
- synthesizeKey('2', {});
+ sendString("12");
todo_is(input.value, '45', 'value should be 45 with maxlength = 2');
input.value = '';
inputcontainer.style.display = 'none';
window.setTimeout(() => {
input.removeAttribute('maxlength');
inputcontainer.style.display = 'block';
input.focus();
- synthesizeKey('1', {});
- synthesizeKey('2', {});
- synthesizeKey('3', {});
- synthesizeKey('4', {});
- synthesizeKey('5', {});
- synthesizeKey('6', {});
- synthesizeKey('7', {});
- synthesizeKey('8', {});
+ sendString("12345678");
is(input.value, '12345678', 'value should be 12345678 without maxlength');
SimpleTest.finish();
}, 0);
}, 0);
}, 0);
});
--- a/editor/libeditor/tests/test_bug1361008.html
+++ b/editor/libeditor/tests/test_bug1361008.html
@@ -23,35 +23,33 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(() => {
document.execCommand("defaultparagraphseparator", false, "div")
let edit1 = document.getElementById("edit1");
edit1.focus();
let selection = window.getSelection();
// Insert text before BR element
selection.collapse(edit1, 0);
- synthesizeKey("A", {});
- synthesizeKey("B", {});
- synthesizeKey("VK_RETURN", {});
+ sendString("AB");
+ synthesizeKey("KEY_Enter");
// count <div> element into contenteidable
is(edit1.getElementsByTagName('div').length, 2,
"DIV element should be 2 children");
is(edit1.getElementsByTagName('div')[0].innerText,
"AB", "AB should be in 1st DIV element");
is(edit1.getElementsByTagName('div')[1].innerHTML,
"<br>", "BR element should be in 2nd DIV element");
document.execCommand("defaultparagraphseparator", false, "p")
let edit2 = document.getElementById("edit2");
edit2.focus();
selection.collapse(edit2, 0);
// Insert text before BR element
- synthesizeKey("A", {});
- synthesizeKey("B", {});
- synthesizeKey("VK_RETURN", {});
+ sendString("AB");
+ synthesizeKey("KEY_Enter");
is(edit2.getElementsByTagName('p').length, 2,
"P element should be 2 children");
is(edit2.getElementsByTagName('p')[0].innerText,
"AB", "AB should be in 1st P element");
is(edit2.getElementsByTagName('p')[1].innerHTML,
"<br>", "BR element should be into 2nd P element");
--- a/editor/libeditor/tests/test_bug1368544.html
+++ b/editor/libeditor/tests/test_bug1368544.html
@@ -31,58 +31,51 @@ SimpleTest.waitForFocus(() => {
SpecialPowers.Cu.import(
"resource://testing-common/AsyncSpellCheckTestHelper.jsm")
.onSpellCheck(textarea, () => {
spellChecker.UpdateCurrentDictionary(() => {
textarea.value = "ABC";
ok(editor.rootElement.hasChildNodes(),
"editor of textarea has child nodes");
- synthesizeKey("D", {});
+ sendString("D");
is(textarea.value, "ABCD", "D is last character");
ok(editor.rootElement.hasChildNodes(),
"editor of textarea has child nodes");
textarea.value = "";
ok(editor.rootElement.hasChildNodes(),
"editor of textarea has child node even if value is empty");
- synthesizeKey("A", {});
- synthesizeKey("A", {});
- synthesizeKey("A", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ sendString("AAA");
+ synthesizeKey("KEY_Backspace", {repeat: 3});
is(textarea.value, "", "value is empty");
ok(editor.rootElement.hasChildNodes(),
"editor of textarea has child node even if value is empty");
textarea.value = "ABC";
SpecialPowers.wrap(textarea).setUserInput("");
ok(editor.rootElement.hasChildNodes(),
"editor of textarea has child node even if value is empty");
textarea.value = "ABC";
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter", {repeat: 2});
textarea.value = "";
ok(editor.rootElement.hasChildNodes(),
"editor of textarea has child node even if value is empty");
- synthesizeKey("A", {});
- synthesizeKey("A", {});
- synthesizeKey("A", {});
+ sendString("AAA");
is(textarea.value, "AAA", "value is AAA");
textarea.addEventListener("keyup", (e) => {
if (e.key == "Enter") {
textarea.value = "";
ok(editor.rootElement.hasChildNodes(),
"editor of textarea has child node even if value is empty");
SimpleTest.finish();
}
});
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
});
});
});
</script>
</body>
</html>
--- a/editor/libeditor/tests/test_bug1385905.html
+++ b/editor/libeditor/tests/test_bug1385905.html
@@ -23,29 +23,29 @@ SimpleTest.waitForFocus(() => {
isnot(br.getAttribute("type"), "_moz",
"mozBR shouldn't be used with this test");
}
}
document.execCommand("defaultparagraphseparator", false, "div");
var editor = document.getElementById("editor");
// Click the left blank area of the first line to set cursor to the start of "contents".
synthesizeMouse(editor, 3, 10, {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
is(editor.innerHTML, "<div><br></div><div>contents</div>",
"Typing Enter at start of the <div> element should split the <div> element");
- synthesizeKey("KEY_ArrowUp", {});
- synthesizeKey("x", {});
+ synthesizeKey("KEY_ArrowUp");
+ sendString("x");
is(editor.innerHTML, "<div>x<br></div><div>contents</div>",
"Typing 'x' at the empty <div> element should just insert 'x' into the <div> element");
ensureNoMozBR();
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
is(editor.innerHTML, "<div>x</div><div><br></div><div>contents</div>",
"Typing Enter next to 'x' in the first <div> element should split the <div> element and inserts <br> element to a new <div> element");
ensureNoMozBR();
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
is(editor.innerHTML, "<div>x</div><div><br></div><div><br></div><div>contents</div>",
"Typing Enter in the empty <div> should split the <div> element and inserts <br> element to a new <div> element");
ensureNoMozBR();
SimpleTest.finish();
});
</script>
</body>
</html>
--- a/editor/libeditor/tests/test_bug1390562.html
+++ b/editor/libeditor/tests/test_bug1390562.html
@@ -32,33 +32,33 @@ SimpleTest.waitForFocus(function() {
// Collapse selection at the end of the first text node.
window.getSelection().collapse(editor.firstChild.firstChild, 3);
// Then, typing Enter should insert <br> for <div> container.
// This is necessary for backward compatibility. When we change default
// value of "defaultParagraphSeparator" to "div" or "p", it may be possible
// to remove this hack.
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
is(editor.innerHTML,
"<div>abc<br><br><br></div>def",
"Enter key press at end of a text node followed by a visible <br> shouldn't split <div> container when defaultParagraphSeparator is 'br'");
// Check also the case of <p> as container.
editor.innerHTML = "<p>abc<br><br></p>def";
// Collapse selection at the end of the first text node.
window.getSelection().collapse(editor.firstChild.firstChild, 3);
// Then, typing Enter should splitting <p> container and remove the visible
// <br> element next to the caret position.
// This is not consistent with <div> container, but this is better behavior
// and keep using this behavior.
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
is(editor.innerHTML,
"<p>abc</p><p><br></p>def",
"Enter key press at end of a text node followed by a visible <br> should split <p> container and remove the visible <br> when defaultParagraphSeparator is 'br'");
SimpleTest.finish();
});
</script>
--- a/editor/libeditor/tests/test_bug1394758.html
+++ b/editor/libeditor/tests/test_bug1394758.html
@@ -28,28 +28,28 @@ SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var editable = document.getElementById('editable');
var span = document.getElementById('span');
var beforeSpan = span.textContent;
editable.focus();
window.getSelection().collapse(span.nextSibling, 0);
- synthesizeKey("KEY_ArrowRight", {});
- synthesizeKey("KEY_ArrowRight", {});
- synthesizeKey("KEY_ArrowRight", {});
- synthesizeKey("KEY_Backspace", {});
- synthesizeKey("KEY_Backspace", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_Backspace");
+ synthesizeKey("KEY_Backspace");
is(span.textContent, beforeSpan,
"VK_BACK_SPACE should not modify non-editable area");
is(span.nextSibling.textContent.trim(), "rld",
"VK_BACK_SPACE should delete first 2 characters");
- synthesizeKey("KEY_Delete", {});
+ synthesizeKey("KEY_Delete");
is(span.textContent, beforeSpan,
"VK_DELETE should not modify non-editable area");
is(span.nextSibling.textContent.trim(), "ld",
"VK_DELETE should delete first character");
SimpleTest.finish();
});
--- a/editor/libeditor/tests/test_bug1397412.xul
+++ b/editor/libeditor/tests/test_bug1397412.xul
@@ -44,24 +44,24 @@ function runTest() {
doc.designMode = "on";
doc.defaultView.focus();
var selection = doc.defaultView.getSelection();
var body = doc.body;
// Test 1.
body.innerHTML = initialHTML1;
selection.collapse(body, 2);
- synthesizeKey("t", {});
+ sendString("t");
var actualHTML = body.innerHTML;
is(actualHTML, expectedHTML1, "'t' should be inserted between <br>s");
// Test 2.
body.innerHTML = initialHTML2;
selection.collapse(body, 2);
- synthesizeKey("t", {});
+ sendString("t");
actualHTML = body.innerHTML;
is(actualHTML, expectedHTML2, "'t' should be inserted between <br>s");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
]]>
--- a/editor/libeditor/tests/test_bug1399722.html
+++ b/editor/libeditor/tests/test_bug1399722.html
@@ -20,21 +20,19 @@ https://bugzilla.mozilla.org/show_bug.cg
<pre id="test">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
let elm = document.querySelector("input");
elm.focus();
- synthesizeKey("A", {});
- synthesizeKey("B", {});
- synthesizeKey("KEY_Enter", {});
- synthesizeKey("C", {});
- synthesizeKey("D", {});
+ sendString("AB");
+ synthesizeKey("KEY_Enter");
+ sendString("CD");
is(elm.value, "CD", "Can type into the textbox successfully after the onkeypress handler deleting the value");
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>
--- a/editor/libeditor/tests/test_bug318065.html
+++ b/editor/libeditor/tests/test_bug318065.html
@@ -48,29 +48,29 @@ https://bugzilla.mozilla.org/show_bug.cg
var input = document.getElementById("t1");
input.addEventListener("input", onInput);
var input2 = document.getElementById("t2");
input2.addEventListener("input", onInput);
input.focus();
// Tests 0 + 1: Input letter and delete it again
- synthesizeKey("A", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ sendString("A");
+ synthesizeKey("KEY_Backspace");
// Test 2: Undo deletion. Value of input should be "A"
synthesizeKey("Z", {accelKey: true});
// Test 3: Redo deletion. Value of input should be ""
synthesizeKey("Z", {accelKey: true, shiftKey: true});
input2.focus();
// Test 4: Input letter
- synthesizeKey("A", {});
+ sendString("A");
// Test 5: Undo typing. Value of input should be ""
synthesizeKey("Z", {accelKey: true});
// Test 6: Redo typing. Value of input should be "A"
synthesizeKey("Z", {accelKey: true, shiftKey: true});
});
</script>
--- a/editor/libeditor/tests/test_bug332636.html
+++ b/editor/libeditor/tests/test_bug332636.html
@@ -30,31 +30,31 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForExplicitFinish();
addLoadEvent(runTest);
function test(edit) {
edit.focus();
var sel = window.getSelection();
sel.collapse(edit.childNodes[0], edit.textContent.length - 1);
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(edit.textContent, "ab", "The backspace key should delete the UTF-16 surrogate pair correctly");
}
function testWithMove(edit, offset) {
edit.focus();
var sel = window.getSelection();
sel.collapse(edit.childNodes[0], 0);
var i;
for (i = 0; i < offset; ++i) {
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKey("KEY_ArrowRight");
}
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(edit.textContent, "ab", "The backspace key should delete the UTF-16 surrogate pair correctly");
}
function runTest() {
/* test backspace-deletion of the middle character */
test(document.getElementById("edit0"));
test(document.getElementById("edit1"));
test(document.getElementById("edit2"));
--- a/editor/libeditor/tests/test_bug414526.html
+++ b/editor/libeditor/tests/test_bug414526.html
@@ -75,89 +75,89 @@ function runTests()
var editor4 = document.getElementById("editor4");
var editor5 = document.getElementById("editor5");
/* TestCase #1:
* pressing backspace key at start should not change the content.
*/
editor2.focus();
moveCaretToStartOf(editor2);
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
is(container.innerHTML, kTestCase1,
"Pressing backspace key at start of editor2 changes the content");
reset();
editor3.focus();
moveCaretToStartOf(editor3);
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
is(container.innerHTML, kTestCase1,
"Pressing backspace key at start of editor3 changes the content");
reset();
editor4.focus();
moveCaretToStartOf(editor4);
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
is(container.innerHTML, kTestCase1,
"Pressing backspace key at start of editor4 changes the content");
reset();
editor5.focus();
moveCaretToStartOf(editor5);
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
is(container.innerHTML, kTestCase1,
"Pressing backspace key at start of editor5 changes the content");
reset();
/* TestCase #1:
* pressing delete key at end should not change the content.
*/
editor1.focus();
moveCaretToEndOf(editor1);
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
is(container.innerHTML, kTestCase1,
"Pressing delete key at end of editor1 changes the content");
reset();
editor2.focus();
moveCaretToEndOf(editor2);
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
is(container.innerHTML, kTestCase1,
"Pressing delete key at end of editor2 changes the content");
reset();
editor3.focus();
moveCaretToEndOf(editor3);
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
is(container.innerHTML, kTestCase1,
"Pressing delete key at end of editor3 changes the content");
reset();
editor4.focus();
moveCaretToEndOf(editor4);
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
is(container.innerHTML, kTestCase1,
"Pressing delete key at end of editor4 changes the content");
reset();
/* TestCase #1: cases when the caret is not on text node.
* - pressing delete key at start should remove the first character
* - pressing backspace key at end should remove the first character
* and the adjacent blocks should not be changed.
*/
editor3.focus();
moveCaretToStartOf(editor3);
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
is(container.innerHTML, kTestCase1_editor3_deleteAtStart,
"Pressing delete key at start of editor3 changes adjacent elements"
+ " and/or does not remove the first character.");
reset();
editor3.focus();
moveCaretToEndOf(editor3);
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
is(container.innerHTML, kTestCase1_editor3_backspaceAtEnd,
"Pressing backspace key at end of editor3 changes adjacent elements"
+ " and/or does not remove the last character.");
reset();
/* TestCase #2:
* two adjacent editable <span> in a table cell.
*/
@@ -165,72 +165,72 @@ function runTests()
"<span id=\"editor2\" contenteditable=\"true\">test</span></td></tr></tbody></table>";
container.innerHTML = kTestCase2;
editor1 = document.getElementById("editor1");
editor2 = document.getElementById("editor2");
editor2.focus();
moveCaretToStartOf(editor2);
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
is(container.innerHTML, kTestCase2,
"Pressing backspace key at the start of editor2 changes the content for kTestCase2");
reset();
editor1.focus();
moveCaretToEndOf(editor1);
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
is(container.innerHTML, kTestCase2,
"Pressing delete key at the end of editor1 changes the content for kTestCase2");
reset();
/* TestCase #3:
* editable <span> in two adjacent table cells.
*/
const kTestCase3 = "<table><tbody><tr><td><span id=\"editor1\" contenteditable=\"true\">test</span></td>" +
"<td><span id=\"editor2\" contenteditable=\"true\">test</span></td></tr></tbody></table>";
container.innerHTML = kTestCase3;
editor1 = document.getElementById("editor1");
editor2 = document.getElementById("editor2");
editor2.focus();
moveCaretToStartOf(editor2);
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
is(container.innerHTML, kTestCase3,
"Pressing backspace key at the start of editor2 changes the content for kTestCase3");
reset();
editor1.focus();
moveCaretToEndOf(editor1);
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
is(container.innerHTML, kTestCase3,
"Pressing delete key at the end of editor1 changes the content for kTestCase3");
reset();
/* TestCase #4:
* editable <div> in two adjacent table cells.
*/
const kTestCase4 = "<table><tbody><tr><td><div id=\"editor1\" contenteditable=\"true\">test</div></td>" +
"<td><div id=\"editor2\" contenteditable=\"true\">test</div></td></tr></tbody></table>";
container.innerHTML = kTestCase4;
editor1 = document.getElementById("editor1");
editor2 = document.getElementById("editor2");
editor2.focus();
moveCaretToStartOf(editor2);
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
is(container.innerHTML, kTestCase4,
"Pressing backspace key at the start of editor2 changes the content for kTestCase4");
reset();
editor1.focus();
moveCaretToEndOf(editor1);
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
is(container.innerHTML, kTestCase4,
"Pressing delete key at the end of editor1 changes the content for kTestCase4");
reset();
SimpleTest.finish();
}
</script>
--- a/editor/libeditor/tests/test_bug430392.html
+++ b/editor/libeditor/tests/test_bug430392.html
@@ -28,31 +28,31 @@ function test() {
// Each test is [desc, callback]. callback() is called and we check that the
// textContent didn't change. For expected failures, the format is [desc,
// callback, expectedValue], and the test will be marked as an expected fail
// if the textContent changes to expectedValue, and an unexpected fail if
// it's neither the original value nor expectedValue.
var tests = [["adding returns", () => {
getSelection().collapse(edit.firstChild, 0);
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_Enter");
+ synthesizeKey("KEY_Enter");
+ synthesizeKey("KEY_Backspace");
+ synthesizeKey("KEY_Backspace");
// For some reason this test fails if the separator is not "br"
}, () => document.queryCommandValue("defaultParagraphSeparator") == "br"
? undefined : " A; B ; C "],
["adding shift-returns", () => {
getSelection().collapse(edit.firstChild, 0);
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_RETURN", {shiftKey: true});
- synthesizeKey("VK_RETURN", {shiftKey: true});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_Enter", {shiftKey: true});
+ synthesizeKey("KEY_Enter", {shiftKey: true});
+ synthesizeKey("KEY_Backspace");
+ synthesizeKey("KEY_Backspace");
}, "A ; B ; C "]];
[
"insertorderedlist",
"insertunorderedlist",
["formatblock", "p"],
]
.forEach(item => {
var cmd = Array.isArray(item) ? item[0] : item;
--- a/editor/libeditor/tests/test_bug439808.html
+++ b/editor/libeditor/tests/test_bug439808.html
@@ -19,19 +19,19 @@ https://bugzilla.mozilla.org/show_bug.cg
<script type="application/javascript">
/** Test for Bug 439808 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var e = document.getElementById("e");
e.focus();
getSelection().collapse(e.firstChild, 1);
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
is(e.textContent, "test", "Delete key worked");
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(e.textContent, "est", "Backspace key worked");
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>
--- a/editor/libeditor/tests/test_bug449243.html
+++ b/editor/libeditor/tests/test_bug449243.html
@@ -50,17 +50,17 @@ function split(element, caretPos, nbKeyP
case CARET_END:
pos = len;
break;
}
sel.collapse(element.firstChild, pos);
// simulates a [Return] keypress
for (var i = 0; i < nbKeyPresses; i++)
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
}
function undo(nbKeyPresses) {
for (var i = 0; i < nbKeyPresses; i++)
document.execCommand("Undo", false, null);
}
function SameTypeAsPreviousSibling(element) {
--- a/editor/libeditor/tests/test_bug483651.html
+++ b/editor/libeditor/tests/test_bug483651.html
@@ -28,18 +28,18 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForExplicitFinish();
function doTest() {
var t1 = $("t1");
var editor = SpecialPowers.wrap(t1).editor;
ok(editor, "able to get editor for the element");
t1.focus();
- synthesizeKey("A", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ sendString("A");
+ synthesizeKey("KEY_Backspace");
try {
// Was the trailing br removed?
is(editor.documentIsEmpty, true, "trailing <br> correctly removed");
} catch (e) {
ok(false, "test failed with error "+e);
}
SimpleTest.finish();
--- a/editor/libeditor/tests/test_bug484181.html
+++ b/editor/libeditor/tests/test_bug484181.html
@@ -37,20 +37,17 @@ function getEditor() {
}
function append(str) {
var edit = document.getElementById("edit");
var editor = getEditor();
var sel = editor.selection;
sel.selectAllChildren(edit);
sel.collapseToEnd();
-
- for (var i = 0; i < str.length; ++i) {
- synthesizeKey(str[i], {});
- }
+ sendString(str);
}
function runTest() {
gMisspeltWords = ["haz", "cheezburger"];
var edit = document.getElementById("edit");
edit.focus();
SpecialPowers.Cu.import(
--- a/editor/libeditor/tests/test_bug514156.html
+++ b/editor/libeditor/tests/test_bug514156.html
@@ -22,27 +22,23 @@ https://bugzilla.mozilla.org/show_bug.cg
/** Test for Bug 514156 **/
SimpleTest.waitForExplicitFinish();
function test() {
var input1 = $("input1");
input1.focus();
- synthesizeKey("\u200e", { });
- synthesizeKey("\u05d0", { });
- synthesizeKey("\u05d1", { });
+ sendString("\u200e\u05d0\u05d1");
is(escape(input1.value), escape("\u200e\u05d0\u05d1"), "non-spacing character and direction change shouldn't change content");
var input2 = $("input2");
input2.focus();
- synthesizeKey("\u05b6", { });
- synthesizeKey("a", { });
- synthesizeKey("b", { });
- synthesizeKey("c", { });
+ sendString("\u05b6");
+ sendString("abc");
is(escape(input2.value), escape("\u05b6abc"), "non-spacing character and direction change shouldn't change content");
SimpleTest.finish();
}
</script>
</pre>
</body>
--- a/editor/libeditor/tests/test_bug537046.html
+++ b/editor/libeditor/tests/test_bug537046.html
@@ -31,18 +31,18 @@ addLoadEvent(function() {
src.textContent = ed.innerHTML;
});
src.addEventListener("DOMSubtreeModified", function() {
ed.innerHTML = ed.textContent;
});
// Simulate pressing Enter twice
ed.focus();
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
+ synthesizeKey("KEY_Enter");
ok(true, "Didn't crash!");
SimpleTest.finish();
});
</script>
</pre>
</body>
--- a/editor/libeditor/tests/test_bug550434.html
+++ b/editor/libeditor/tests/test_bug550434.html
@@ -24,17 +24,17 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var ed = document.getElementById("editor");
// Simulate click twice
synthesizeMouse(ed, 10, 10, {});
synthesizeMouse(ed, 50, 50, {});
setTimeout(function() {
- synthesizeKey("x", {});
+ sendString("x");
is(ed.innerHTML, "x", "Editor should work after being clicked twice");
SimpleTest.finish();
}, 0);
});
</script>
</pre>
--- a/editor/libeditor/tests/test_bug551704.html
+++ b/editor/libeditor/tests/test_bug551704.html
@@ -49,32 +49,29 @@ function testLineBreak(div, type, expect
function() {
SimpleTest.finish();
}
);
});
}
function typeABCDEF() {
- synthesizeKey("a", {});
+ sendString("a");
typeBCDEF_chars();
}
function typeBCDEF() {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
typeBCDEF_chars();
}
function typeBCDEF_chars() {
- synthesizeKey("b", {});
- synthesizeKey("c", {});
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("d", {});
- synthesizeKey("e", {});
- synthesizeKey("f", {});
+ sendString("bc");
+ synthesizeKey("KEY_Enter");
+ sendString("def");
}
/** Test for Bug 551704 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
document.execCommand("defaultParagraphSeparator", false, "div");
var preformatted = document.getElementById("preformatted");
--- a/editor/libeditor/tests/test_bug567213.html
+++ b/editor/libeditor/tests/test_bug567213.html
@@ -32,26 +32,26 @@ https://bugzilla.mozilla.org/show_bug.cg
var sel = window.getSelection();
// select the contents of the editable area
sel.removeAllRanges();
sel.selectAllChildren(target);
target.focus();
// press some key
- synthesizeKey("X", {});
+ sendString("X");
is(target.textContent, "X", "Text input should work (sanity check)");
// select the contents of the editable area again
sel.removeAllRanges();
sel.selectAllChildren(target);
thief.focus();
// press some key with the thief having focus
- synthesizeKey("Y", {});
+ sendString("Y");
is(target.textContent, "X", "Text entry should not work with another element focused");
SimpleTest.finish();
});
</script>
</pre>
</body>
--- a/editor/libeditor/tests/test_bug570144.html
+++ b/editor/libeditor/tests/test_bug570144.html
@@ -67,18 +67,18 @@ function try2split(list) {
editor.focus();
// put the caret at the end of the paragraph
var selection = window.getSelection();
if (editor.nodeName.toLowerCase() == "p")
selection.selectAllChildren(editor);
else
selection.selectAllChildren(editor.querySelector("p"));
selection.collapseToEnd();
- // simulate a [Return] keypress
- synthesizeKey("VK_RETURN", {});
+ // simulate a [Enter] keypress
+ synthesizeKey("KEY_Enter");
}
function testSection(element, context, shouldCreateLI, shouldCreateP) {
var nbLI = shouldCreateLI ? 2 : 1; // number of expected list items
var nbP = shouldCreateP ? 2 : 1; // number of expected paragraphs
function message(nodeName, dup) {
return context + ":[Return] should " + (dup ? "" : "not ")
--- a/editor/libeditor/tests/test_bug586662.html
+++ b/editor/libeditor/tests/test_bug586662.html
@@ -19,17 +19,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<pre id="test">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var t = document.querySelector("textarea");
t.focus();
- synthesizeKey("a", {});
+ sendString("a");
is(getComputedStyle(t, null).overflow, "hidden", "The event handler should be executed");
is(t.value, "a", "The key entry should result in a character being added to the field");
var win = window.open("file_bug586662.html", "_blank",
"width=600,height=600,scrollbars=yes");
SimpleTest.waitForFocus(function() {
// Make sure that focusing the textarea will cause the page to scroll
var ed = win.document.getElementById("editor");
--- a/editor/libeditor/tests/test_bug590554.html
+++ b/editor/libeditor/tests/test_bug590554.html
@@ -17,19 +17,19 @@ https://bugzilla.mozilla.org/show_bug.cg
/** Test for Bug 590554 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var t = document.querySelector("textarea");
t.focus();
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
is(t.value, "\n", "Pressing enter should work the first time");
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
is(t.value, "\n", "Pressing enter should not work the second time");
SimpleTest.finish();
});
</script>
<textarea maxlength="1"></textarea>
</body>
--- a/editor/libeditor/tests/test_bug592592.html
+++ b/editor/libeditor/tests/test_bug592592.html
@@ -25,45 +25,45 @@ SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var ed = document.getElementById("editor");
// Put the selection right after "a"
ed.focus();
window.getSelection().collapse(ed.firstChild, 1);
// Press space
- synthesizeKey(" ", {});
+ sendString(" ");
// Make sure we haven't added an nbsp
is(ed.innerHTML, "a b", "We should not be adding an for preformatted text");
// Remove the preformatted style
ed.removeAttribute("style");
// Reset the DOM
ed.innerHTML = "a b";
// Reset the selection
ed.focus();
window.getSelection().collapse(ed.firstChild, 1);
// Press space
- synthesizeKey(" ", {});
+ sendString(" ");
// Make sure that we have added an nbsp
is(ed.innerHTML, "a b", "We should add an for non-preformatted text");
ed = document.getElementById("editor2");
// Put the selection after the second space in the second editable field
ed.focus();
window.getSelection().collapse(ed.firstChild, 3);
// Press the back-space key
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
// Make sure that we've only deleted a single space
is(ed.innerHTML, "a b", "We should only be deleting a single space");
SimpleTest.finish();
});
</script>
--- a/editor/libeditor/tests/test_bug596333.html
+++ b/editor/libeditor/tests/test_bug596333.html
@@ -31,20 +31,17 @@ function getEditor() {
return SpecialPowers.wrap(document.getElementById("edit")).editor;
}
function append(str) {
var edit = document.getElementById("edit");
edit.focus();
edit.selectionStart = edit.selectionEnd = edit.value.length;
var editor = getEditor();
-
- for (var i = 0; i < str.length; ++i) {
- synthesizeKey(str[i], {});
- }
+ sendString(str);
}
function getLoadContext() {
return SpecialPowers.wrap(window)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsILoadContext);
}
--- a/editor/libeditor/tests/test_bug596506.html
+++ b/editor/libeditor/tests/test_bug596506.html
@@ -20,37 +20,32 @@ https://bugzilla.mozilla.org/show_bug.cg
/** Test for Bug 596506 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTest);
const kIsMac = navigator.platform.indexOf("Mac") == 0;
-function append(str) {
- for (var i = 0; i < str.length; ++i) {
- synthesizeKey(str[i], {});
- }
-}
function runTest() {
var edit = document.getElementById("edit");
edit.focus();
- append("First");
- synthesizeKey("VK_RETURN", {});
- append("Second");
- synthesizeKey("VK_UP", {});
- synthesizeKey("VK_UP", {});
+ sendString("First");
+ synthesizeKey("KEY_Enter", {});
+ sendString("Second");
+ synthesizeKey("KEY_ArrowUp", {});
+ synthesizeKey("KEY_ArrowUp", {});
if (kIsMac) {
- synthesizeKey("VK_RIGHT", {accelKey: true});
+ synthesizeKey("KEY_ArrowRight", {accelKey: true});
} else {
- synthesizeKey("VK_END", {});
+ synthesizeKey("KEY_End", {});
}
- append("ly");
+ sendString("ly");
is(edit.value, "Firstly\nSecond",
"Pressing end should position the cursor before the terminating newline");
SimpleTest.finish();
}
</script>
</pre>
--- a/editor/libeditor/tests/test_bug597331.html
+++ b/editor/libeditor/tests/test_bug597331.html
@@ -54,17 +54,17 @@ addLoadEvent(function() {
msg += "\nRESULT:\n" + result[2];
msg += "\nREFERENCE:\n" + result[1];
}
ok(result[0], msg);
SimpleTest.finish();
});
}, {once: true});
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
});
});
});
</script>
</pre>
</body>
</html>
--- a/editor/libeditor/tests/test_bug600570.html
+++ b/editor/libeditor/tests/test_bug600570.html
@@ -57,17 +57,17 @@ SimpleTest.waitForFocus(function() {
if (!res[0]) {
msg += "\nRESULT:\n" + res[2] + "\nREFERENCE:\n" + res[1];
}
ok(res[0], msg);
SimpleTest.finish();
}, 0);
}, {once: true});
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
synthesizeKey("V", {accelKey: true});
},
function() {
SimpleTest.finish();
}
);
});
});
--- a/editor/libeditor/tests/test_bug604532.html
+++ b/editor/libeditor/tests/test_bug604532.html
@@ -22,18 +22,18 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var i = document.querySelector("input");
i.focus();
i.value = "foo";
synthesizeKey("A", {accelKey: true});
is(i.selectionStart, 0, "Selection should start at 0 before appending");
is(i.selectionEnd, 3, "Selection should end at 3 before appending");
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("x", {});
+ synthesizeKey("KEY_ArrowRight");
+ sendString("x");
is(i.value, "foox", "The text should be appended correctly");
synthesizeKey("A", {accelKey: true});
is(i.selectionStart, 0, "Selection should start at 0 after appending");
is(i.selectionEnd, 4, "Selection should end at 4 after appending");
SimpleTest.finish();
});
</script>
--- a/editor/libeditor/tests/test_bug607584.html
+++ b/editor/libeditor/tests/test_bug607584.html
@@ -20,17 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
/** Test for Bug 607584 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var content = document.getElementById("content");
content.focus();
var sel = getSelection();
sel.collapse(document.getElementById("foo").firstChild, 5);
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
var paragraphs = content.querySelectorAll("p");
is(paragraphs.length, 2, "The paragraph should be split in two");
is(paragraphs[0].textContent, "Hello", "The first paragraph should have the correct content");
is(paragraphs[1].textContent, " world", "The second paragraph should have the correct content");
is(paragraphs[0].getAttribute("id"), "foo", "The id of the first paragraph should be retained");
is(paragraphs[1].hasAttribute("id"), false, "The second paragraph shouldn't have an ID");
SimpleTest.finish();
});
--- a/editor/libeditor/tests/test_bug611182.html
+++ b/editor/libeditor/tests/test_bug611182.html
@@ -60,17 +60,17 @@ SimpleTest.waitForFocus(function() {
var doc = iframe.contentDocument;
var win = iframe.contentWindow;
doc.body.setAttribute("spellcheck", "false");
iframe.focus();
var textNode = findTextNode(doc);
var sel = win.getSelection();
sel.collapse(textNode, 4);
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(textNode.textContent, "foo bar", "Backspace should work correctly");
var snapshot = snapshotWindow(win, false);
ok(compareSnapshots(snapshot, ref, true)[0], "No bogus node should exist in the document");
callback();
}, {once: true});
iframe.src = src;
--- a/editor/libeditor/tests/test_bug612447.html
+++ b/editor/libeditor/tests/test_bug612447.html
@@ -35,31 +35,31 @@ SimpleTest.waitForFocus(function() {
var i = document.querySelector("iframe");
var doc = i.contentDocument;
var win = i.contentWindow;
var b = doc.body;
doc.designMode = "on";
i.focus();
b.focus();
var beforeA = snapshotWindow(win, true);
- synthesizeKey("X", {});
+ sendString("X");
var beforeB = snapshotWindow(win, true);
is(b.textContent, "X", "Typing should work");
while (b.firstChild) {
b.firstChild.remove();
}
ok(editorCommandsEnabled(), "The editor commands should work");
i.style.display = "block";
document.clientWidth;
i.focus();
b.focus();
var afterA = snapshotWindow(win, true);
- synthesizeKey("X", {});
+ sendString("X");
var afterB = snapshotWindow(win, true);
is(b.textContent, "X", "Typing should work");
while (b.firstChild) {
b.firstChild.remove();
}
ok(editorCommandsEnabled(), "The editor commands should work");
ok(compareSnapshots(beforeA, afterA, true)[0], "The iframes should look the same before typing");
--- a/editor/libeditor/tests/test_bug625452.html
+++ b/editor/libeditor/tests/test_bug625452.html
@@ -42,17 +42,17 @@ addLoadEvent(function() {
// test redo
synthesizeKey("Z", {accelKey: true, shiftKey: true});
is(i.value, "bar", "Redo should work correctly");
is(inputCount, 3, "input event should be raised correctly");
// test delete
i.selectionStart = 0;
i.selectionEnd = 2;
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
is(i.value, "r", "Delete should work correctly");
is(inputCount, 4, "input event should be raised correctly");
// test DeleteSelection(eNone)
i.value = "retest"; // the "r" common prefix is crucial here
is(inputCount, 4, "input event should not have been raised");
// paste is tested in test_bug596001.html
--- a/editor/libeditor/tests/test_bug638596.html
+++ b/editor/libeditor/tests/test_bug638596.html
@@ -18,20 +18,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<pre id="test">
<script type="application/javascript">
/** Test for Bug 638596 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var i = document.querySelector("input");
i.focus();
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ sendString("test");
is(i.value, "test", "The correct value should be stored in the field");
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>
--- a/editor/libeditor/tests/test_bug641466.html
+++ b/editor/libeditor/tests/test_bug641466.html
@@ -21,20 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
/** Test for Bug 641466 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
function doTest(element) {
element.focus();
element.selectionStart = 4;
element.selectionEnd = 4;
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace", {repeat: 4});
ok(element.value, "", "4 backspaces should delete all of the characters in the " + element.localName);
}
doTest(document.querySelector("input"));
doTest(document.querySelector("textarea"));
SimpleTest.finish();
--- a/editor/libeditor/tests/test_bug668599.html
+++ b/editor/libeditor/tests/test_bug668599.html
@@ -41,30 +41,30 @@ function select(element) {
};
function runTests() {
var span = document.querySelector("#test1 span");
// editable <span> => the <span> *content* should be deleted
select(span);
span.focus();
- synthesizeKey("x", {});
+ sendString("x");
is(span.textContent, "x", "The <span> content should have been replaced by 'x'.");
// same thing, but using [Del] instead of typing some text
document.execCommand("Undo", false, null);
select(span);
span.focus();
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
is(span.textContent, "", "The <span> content should have been deleted.");
// <span> in editable block => the <span> *element* should be deleted
select(document.querySelector("#test2 span"));
document.querySelector("#test2 [contenteditable]").focus();
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
is(document.querySelector("#test2 span"), null,
"The <span> element should have been deleted.");
// done
SimpleTest.finish();
}
</script>
--- a/editor/libeditor/tests/test_bug674861.html
+++ b/editor/libeditor/tests/test_bug674861.html
@@ -100,18 +100,18 @@ function try2split(element, caretPos) {
sel.removeRange(range);
}
range = document.createRange();
range.setStart(element.firstChild, pos);
range.setEnd(element.firstChild, pos);
sel.addRange(range);
// simulates two [Return] keypresses
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
+ synthesizeKey("KEY_Enter");
}
function runTests() {
const test1 = document.getElementById("test1");
const test2 = document.getElementById("test2");
// -----------------------------------------------------------------------
// #test1: editable lists should NOT be splittable
--- a/editor/libeditor/tests/test_bug686203.html
+++ b/editor/libeditor/tests/test_bug686203.html
@@ -28,17 +28,17 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForFocus(function() {
var ce = document.getElementById("ce");
var input = document.getElementById("input");
ce.focus();
var eventDetails = { button : 2 };
synthesizeMouseAtCenter(input, eventDetails);
- synthesizeKey("Z", {});
+ sendString("Z");
/* check values */
is(input.value, "Z", "input correctly focused after right-click");
is(ce.textContent, "abc", "contenteditable correctly blurred after right-click on input");
SimpleTest.finish();
});
</script>
--- a/editor/libeditor/tests/test_bug740784.html
+++ b/editor/libeditor/tests/test_bug740784.html
@@ -25,19 +25,19 @@ https://bugzilla.mozilla.org/show_bug.cg
/** Test for Bug 740784 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var t1 = $("t1");
t1.focus();
- synthesizeKey("VK_END", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("Z", {accelKey: true});
+ synthesizeKey("KEY_End");
+ synthesizeKey("KEY_Backspace");
+ synthesizeKey("z", {accelKey: true});
// Was the former bogus node changed to a mozBR?
is(t1.value, "a", "trailing <br> correctly ignored");
SimpleTest.finish();
});
</script>
</pre>
--- a/editor/libeditor/tests/test_bug772796.html
+++ b/editor/libeditor/tests/test_bug772796.html
@@ -158,29 +158,29 @@ https://bugzilla.mozilla.org/show_bug.cg
/* Set up the selection. */
theEdit.innerHTML = "<div id=\"" + testName + "\">" + tests[i][0] + "</div>";
theDiv = document.getElementById(testName);
theDiv.focus();
sel.collapse(theDiv, 0);
synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */
/** First round: Forward delete. **/
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
is(theDiv.innerHTML, tests[i][1], "delete(collapsed): inner HTML for " + testName);
/* Set up the selection. */
theEdit.innerHTML = "<div id=\"" + testName + "\">" + tests[i][0] + "</div>";
theDiv = document.getElementById(testName);
theDiv.focus();
sel.collapse(theDiv, 0);
synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */
/** Second round: Backspace. **/
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_Backspace");
if (tests[i].length == 2) {
is(theDiv.innerHTML, tests[i][1], "backspace: inner HTML for " + testName);
} else {
todo_is(theDiv.innerHTML, tests[i][1], "backspace(should be): inner HTML for " + testName);
is(theDiv.innerHTML, tests[i][2], "backspace(currently is): inner HTML for " + testName);
}
/* Set up the selection. */
@@ -190,22 +190,22 @@ https://bugzilla.mozilla.org/show_bug.cg
sel.collapse(theDiv, 0);
synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */
/** Third round: Delete with non-collapsed selection. **/
if (i == 72) {
// This test doesn't work, since we can't select only one newline using the right arrow key.
continue;
}
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
/* Strangely enough we need to hit "right arrow" three times to select two characters. */
- synthesizeKey("VK_RIGHT", {shiftKey:true});
- synthesizeKey("VK_RIGHT", {shiftKey:true});
- synthesizeKey("VK_RIGHT", {shiftKey:true});
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_ArrowRight", {shiftKey:true});
+ synthesizeKey("KEY_ArrowRight", {shiftKey:true});
+ synthesizeKey("KEY_ArrowRight", {shiftKey:true});
+ synthesizeKey("KEY_Delete");
/* We always expect to the delete the "tf" in "testfoo". */
var expected = tests[i][1].replace("testfoo", "tesoo")
.replace("test<b>foo", "tes<b>oo")
.replace("test<span class=\"pre\">foo", "tes<span class=\"pre\">oo")
.replace("test<span class=\"pre\"><b>foo", "tes<span class=\"pre\"><b>oo");
is(theDiv.innerHTML, expected, "delete(non-collapsed): inner HTML for " + testName);
}
--- a/editor/libeditor/tests/test_bug790475.html
+++ b/editor/libeditor/tests/test_bug790475.html
@@ -52,17 +52,17 @@ function runTest() {
gMisspeltWords = [];
is(isSpellingCheckOk(), true, "Should not find any misspellings yet.");
var newTextNode = document.createTextNode("ing string");
edit.appendChild(newTextNode);
var editor = getEditor();
var sel = editor.selection;
sel.collapse(newTextNode, newTextNode.textContent.length);
- synthesizeKey("!", {});
+ sendString("!");
edit.blur();
SimpleTest.executeSoon(function() {
is(isSpellingCheckOk(), true, "Should not have found any misspellings. ");
SimpleTest.finish();
});
});
--- a/editor/libeditor/tests/test_bug795785.html
+++ b/editor/libeditor/tests/test_bug795785.html
@@ -46,58 +46,41 @@ function hitEventLoop(aFunc, aTimes)
function doKeyEventTest(aElement, aElementDescription, aCallback)
{
aElement.focus();
aElement.scrollTop = 0;
hitEventLoop(function () {
is(aElement.scrollTop, 0,
aElementDescription + "'s scrollTop isn't 0");
- synthesizeKey("VK_RETURN", { shiftKey: true });
- synthesizeKey("VK_RETURN", { shiftKey: true });
- synthesizeKey("VK_RETURN", { shiftKey: true });
- synthesizeKey("VK_RETURN", { shiftKey: true });
- synthesizeKey("VK_RETURN", { shiftKey: true });
- synthesizeKey("VK_RETURN", { shiftKey: true });
+ synthesizeKey("KEY_Enter", {shiftKey: true, repeat: 6});
hitEventLoop(function () {
isnot(aElement.scrollTop, 0,
aElementDescription + " was not scrolled by inserting line breaks");
var scrollTop = aElement.scrollTop;
- synthesizeKey("VK_UP", { });
- synthesizeKey("VK_UP", { });
- synthesizeKey("VK_UP", { });
- synthesizeKey("VK_UP", { });
- synthesizeKey("VK_UP", { });
+ synthesizeKey("KEY_ArrowUp", {repeat: 5});
hitEventLoop(function () {
isnot(aElement.scrollTop, scrollTop,
aElementDescription + " was not scrolled by up key events");
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown", {repeat: 5});
hitEventLoop(function () {
is(aElement.scrollTop, scrollTop,
aElementDescription + " was not scrolled by down key events");
var longWord = "aaaaaaaaaaaaaaaaaaaa";
sendString(longWord);
hitEventLoop(function () {
isnot(aElement.scrollLeft, 0,
aElementDescription + " was not scrolled by typing long word");
var scrollLeft = aElement.scrollLeft;
var i;
- for (i = 0; i < longWord.length; i++) {
- synthesizeKey("VK_LEFT", { });
- }
+ synthesizeKey("KEY_ArrowLeft", {repeat: longWord.length});
hitEventLoop(function () {
isnot(aElement.scrollLeft, scrollLeft,
aElementDescription + " was not scrolled by left key events");
- for (i = 0; i < longWord.length; i++) {
- synthesizeKey("VK_RIGHT", { });
- }
+ synthesizeKey("KEY_ArrowRight", {repeat: longWord.length});
hitEventLoop(function () {
is(aElement.scrollLeft, scrollLeft,
aElementDescription + " was not scrolled by right key events");
aCallback();
}, 20);
}, 20);
}, 20);
}, 20);
--- a/editor/libeditor/tests/test_bug850043.html
+++ b/editor/libeditor/tests/test_bug850043.html
@@ -28,37 +28,33 @@ SimpleTest.waitForFocus(() => {
let fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
getService(SpecialPowers.Ci.nsIFocusManager);
let element = document.getElementById("textarea");
element.setSelectionRange(element.value.length, element.value.length);
element.focus();
is(SpecialPowers.unwrap(fm.focusedElement), element, "failed to move focus");
- synthesizeKey("VK_END", { });
- synthesizeKey("a", { });
+ synthesizeKey("KEY_End");
+ sendString("a");
is(element.value, "b\u{9080}\u{e010f}\u{8fba}\u{e0101}a", "a isn't last character");
- synthesizeKey("VK_BACK_SPACE", { });
- synthesizeKey("VK_BACK_SPACE", { });
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace", {repeat: 3});
is(element.value, 'b', "cannot remove all IVS characters");
element = document.getElementById("edit");
element.focus();
is(SpecialPowers.unwrap(fm.focusedElement), element, "failed to move focus");
let sel = window.getSelection();
sel.collapse(element.childNodes[0], element.textContent.length);
- synthesizeKey("a", { });
+ sendString("a");
is(element.textContent, "b\u{9080}\u{e010f}\u{8fba}\u{e0101}a", "a isn't last character");
- synthesizeKey("VK_BACK_SPACE", { });
- synthesizeKey("VK_BACK_SPACE", { });
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace", {repeat: 3});
is(element.textContent, 'b', "cannot remove all IVS characters");
SimpleTest.finish();
});
</script>
</body>
</html>
--- a/editor/libeditor/tests/test_contenteditable_text_input_handling.html
+++ b/editor/libeditor/tests/test_contenteditable_text_input_handling.html
@@ -131,30 +131,26 @@ function runTests()
if (focusedElement) {
focusedElement.blur();
}
ok(!fm.focusedElement,
"Failed to blur at preparing tests" + when);
}
if (aFocus && aFocus._isFocusable) {
- synthesizeKey("A", { });
- synthesizeKey("B", { });
- synthesizeKey("C", { });
+ sendString("ABC");
checkValue(staticContent, "ABC");
checkValue(inputInStatic, "ABC");
checkValue(textareaInStatic, "ABC");
checkValue(editor, "ABC");
checkValue(inputInEditor, "ABC");
checkValue(textareaInEditor, "ABC");
if (aFocus._isEditable) {
- synthesizeKey("VK_BACK_SPACE", { });
- synthesizeKey("VK_BACK_SPACE", { });
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace", {repeat: 3});
checkValue(staticContent, "");
checkValue(inputInStatic, "");
checkValue(textareaInStatic, "");
checkValue(editor, "");
checkValue(inputInEditor, "");
checkValue(textareaInEditor, "");
}
}
@@ -297,17 +293,17 @@ function runTests()
checkValue(staticContent, "\u3089");
checkValue(inputInStatic, "\u3089");
checkValue(textareaInStatic, "\u3089");
checkValue(editor, "\u3089");
checkValue(inputInEditor, "\u3089");
checkValue(textareaInEditor, "\u3089");
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
checkValue(staticContent, "");
checkValue(inputInStatic, "");
checkValue(textareaInStatic, "");
checkValue(editor, "");
checkValue(inputInEditor, "");
checkValue(textareaInEditor, "");
}
--- a/editor/libeditor/tests/test_dom_input_event_on_texteditor.html
+++ b/editor/libeditor/tests/test_dom_input_event_on_texteditor.html
@@ -57,75 +57,75 @@ function runTests()
"differed by " + duration + "ms)");
}
inputEvent = aEvent;
};
aElement.addEventListener("input", handler, true);
inputEvent = null;
- synthesizeKey("a", { });
+ sendString("a");
is(aElement.value, "a", aDescription + "'a' key didn't change the value");
ok(inputEvent, aDescription + "input event wasn't fired by 'a' key");
ok(inputEvent.isTrusted, aDescription + "input event by 'a' key wasn't trusted event");
inputEvent = null;
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
is(aElement.value, "", aDescription + "BackSpace key didn't remove the value");
ok(inputEvent, aDescription + "input event wasn't fired by BackSpace key");
ok(inputEvent.isTrusted, aDescription + "input event by BackSpace key wasn't trusted event");
if (aIsTextarea) {
inputEvent = null;
- synthesizeKey("VK_RETURN", { });
+ synthesizeKey("KEY_Enter");
is(aElement.value, "\n", aDescription + "Enter key didn't change the value");
ok(inputEvent, aDescription + "input event wasn't fired by Enter key");
ok(inputEvent.isTrusted, aDescription + "input event by Enter key wasn't trusted event");
}
inputEvent = null;
aElement.value = "foo-bar";
is(aElement.value, "foo-bar", aDescription + "value wasn't set");
ok(!inputEvent, aDescription + "input event was fired by setting value");
inputEvent = null;
aElement.value = "";
is(aElement.value, "", aDescription + "value wasn't set (empty)");
ok(!inputEvent, aDescription + "input event was fired by setting empty value");
inputEvent = null;
- synthesizeKey(" ", { });
+ sendString(" ");
is(aElement.value, " ", aDescription + "Space key didn't change the value");
ok(inputEvent, aDescription + "input event wasn't fired by Space key");
ok(inputEvent.isTrusted, aDescription + "input event by Space key wasn't trusted event");
inputEvent = null;
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
is(aElement.value, " ", aDescription + "Delete key removed the value");
ok(!inputEvent, aDescription + "input event was fired by Delete key at the end");
inputEvent = null;
- synthesizeKey("VK_LEFT", { });
+ synthesizeKey("KEY_ArrowLeft");
is(aElement.value, " ", aDescription + "Left key removed the value");
ok(!inputEvent, aDescription + "input event was fired by Left key");
inputEvent = null;
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
is(aElement.value, "", aDescription + "Delete key didn't remove the value");
ok(inputEvent, aDescription + "input event wasn't fired by Delete key at the start");
ok(inputEvent.isTrusted, aDescription + "input event by Delete key wasn't trusted event");
inputEvent = null;
- synthesizeKey("z", { accelKey: true });
+ synthesizeKey("z", {accelKey: true});
is(aElement.value, " ", aDescription + "Accel+Z key didn't undo the value");
ok(inputEvent, aDescription + "input event wasn't fired by Undo");
ok(inputEvent.isTrusted, aDescription + "input event by Undo wasn't trusted event");
inputEvent = null;
- synthesizeKey("z", { accelKey: true, shiftKey: true });
+ synthesizeKey("Z", {accelKey: true, shiftKey: true});
is(aElement.value, "", aDescription + "Accel+Y key didn't redo the value");
ok(inputEvent, aDescription + "input event wasn't fired by Redo");
ok(inputEvent.isTrusted, aDescription + "input event by Redo wasn't trusted event");
aElement.removeEventListener("input", handler, true);
}
doTests(document.getElementById("input"), "<input type=\"text\">", false);
--- a/editor/libeditor/tests/test_htmleditor_keyevent_handling.html
+++ b/editor/libeditor/tests/test_htmleditor_keyevent_handling.html
@@ -128,483 +128,483 @@ function runTests()
aElement.focus();
is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "failed to move focus");
// Backspace key:
// If editor is readonly, it doesn't consume.
// If editor is editable, it consumes backspace and shift+backspace.
// Otherwise, editor doesn't consume the event.
reset("");
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
check(aDescription + "Backspace", true, true, true);
reset("");
- synthesizeKey("VK_BACK_SPACE", { shiftKey: true });
+ synthesizeKey("KEY_Backspace", {shiftKey: true});
check(aDescription + "Shift+Backspace", true, true, true);
reset("");
- synthesizeKey("VK_BACK_SPACE", { ctrlKey: true });
+ synthesizeKey("KEY_Backspace", {ctrlKey: true});
check(aDescription + "Ctrl+Backspace", true, true, aIsReadonly);
reset("");
- synthesizeKey("VK_BACK_SPACE", { altKey: true });
+ synthesizeKey("KEY_Backspace", {altKey: true});
check(aDescription + "Alt+Backspace", true, true, aIsReadonly || kIsMac);
reset("");
- synthesizeKey("VK_BACK_SPACE", { metaKey: true });
+ synthesizeKey("KEY_Backspace", {metaKey: true});
check(aDescription + "Meta+Backspace", true, true, aIsReadonly);
reset("");
- synthesizeKey("VK_BACK_SPACE", { osKey: true });
+ synthesizeKey("KEY_Backspace", {osKey: true});
check(aDescription + "OS+Backspace", true, true, aIsReadonly);
// Delete key:
// If editor is readonly, it doesn't consume.
// If editor is editable, delete is consumed.
// Otherwise, editor doesn't consume the event.
reset("");
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
check(aDescription + "Delete", true, true, !aIsReadonly || kIsMac);
reset("");
- synthesizeKey("VK_DELETE", { shiftKey: true });
+ synthesizeKey("KEY_Delete", {shiftKey: true});
check(aDescription + "Shift+Delete", true, true, kIsMac);
reset("");
- synthesizeKey("VK_DELETE", { ctrlKey: true });
+ synthesizeKey("KEY_Delete", {ctrlKey: true});
check(aDescription + "Ctrl+Delete", true, true, false);
reset("");
- synthesizeKey("VK_DELETE", { altKey: true });
+ synthesizeKey("KEY_Delete", {altKey: true});
check(aDescription + "Alt+Delete", true, true, kIsMac);
reset("");
- synthesizeKey("VK_DELETE", { metaKey: true });
+ synthesizeKey("KEY_Delete", {metaKey: true});
check(aDescription + "Meta+Delete", true, true, false);
reset("");
- synthesizeKey("VK_DELETE", { osKey: true });
+ synthesizeKey("KEY_Delete", {osKey: true});
check(aDescription + "OS+Delete", true, true, false);
// Return key:
// If editor is readonly, it doesn't consume.
// If editor is editable and not single line editor, it consumes Return
// and Shift+Return.
// Otherwise, editor doesn't consume the event.
reset("a");
- synthesizeKey("VK_RETURN", { });
+ synthesizeKey("KEY_Enter");
check(aDescription + "Return",
true, true, !aIsReadonly);
is(aElement.innerHTML, aIsReadonly ? "a" : "<div>a</div><br>",
aDescription + "Return");
reset("a");
- synthesizeKey("VK_RETURN", { shiftKey: true });
+ synthesizeKey("KEY_Enter", {shiftKey: true});
check(aDescription + "Shift+Return",
true, true, !aIsReadonly);
is(aElement.innerHTML, aIsReadonly ? "a" : "a<br><br>",
aDescription + "Shift+Return");
reset("a");
- synthesizeKey("VK_RETURN", { ctrlKey: true });
+ synthesizeKey("KEY_Enter", {ctrlKey: true});
check(aDescription + "Ctrl+Return", true, true, false);
is(aElement.innerHTML, "a", aDescription + "Ctrl+Return");
reset("a");
- synthesizeKey("VK_RETURN", { altKey: true });
+ synthesizeKey("KEY_Enter", {altKey: true});
check(aDescription + "Alt+Return", true, true, false);
is(aElement.innerHTML, "a", aDescription + "Alt+Return");
reset("a");
- synthesizeKey("VK_RETURN", { metaKey: true });
+ synthesizeKey("KEY_Enter", {metaKey: true});
check(aDescription + "Meta+Return", true, true, false);
is(aElement.innerHTML, "a", aDescription + "Meta+Return");
reset("a");
- synthesizeKey("VK_RETURN", { osKey: true });
+ synthesizeKey("KEY_Enter", {osKey: true});
check(aDescription + "OS+Return", true, true, false);
is(aElement.innerHTML, "a", aDescription + "OS+Return");
// Tab key:
// If editor is tabbable, editor doesn't consume all tab key events.
// Otherwise, editor consumes tab key event without any modifier keys.
reset("a");
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
check(aDescription + "Tab",
true, true, !aIsTabbable && !aIsReadonly);
is(aElement.innerHTML,
aIsTabbable || aIsReadonly ? "a" :
aIsPlaintext ? "a\t" : "a <br>",
aDescription + "Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Tab)");
reset("a");
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
check(aDescription + "Shift+Tab", true, true, false);
is(aElement.innerHTML, "a", aDescription + "Shift+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab)");
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
reset("a");
- synthesizeKey("VK_TAB", { ctrlKey: true });
+ synthesizeKey("KEY_Tab", {ctrlKey: true});
check(aDescription + "Ctrl+Tab", false, false, false);
is(aElement.innerHTML, "a", aDescription + "Ctrl+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Ctrl+Tab)");
reset("a");
- synthesizeKey("VK_TAB", { altKey: true });
+ synthesizeKey("KEY_Tab", {altKey: true});
check(aDescription + "Alt+Tab", true, true, false);
is(aElement.innerHTML, "a", aDescription + "Alt+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Alt+Tab)");
reset("a");
- synthesizeKey("VK_TAB", { metaKey: true });
+ synthesizeKey("KEY_Tab", {metaKey: true});
check(aDescription + "Meta+Tab", true, true, false);
is(aElement.innerHTML, "a", aDescription + "Meta+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Meta+Tab)");
reset("a");
- synthesizeKey("VK_TAB", { osKey: true });
+ synthesizeKey("KEY_Tab", {osKey: true});
check(aDescription + "OS+Tab", true, true, false);
is(aElement.innerHTML, "a", aDescription + "OS+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (OS+Tab)");
// Indent/Outdent tests:
// UL
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
check(aDescription + "Tab on UL",
true, true, !aIsTabbable && !aIsReadonly);
is(aElement.innerHTML,
aIsReadonly || aIsTabbable ?
"<ul><li id=\"target\">ul list item</li></ul>" :
aIsPlaintext ? "<ul><li id=\"target\">ul list item\t</li></ul>" :
"<ul><ul><li id=\"target\">ul list item</li></ul></ul>",
aDescription + "Tab on UL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Tab on UL)");
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
check(aDescription + "Shift+Tab after Tab on UL",
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
is(aElement.innerHTML,
aIsReadonly || aIsTabbable || (!aIsPlaintext) ?
"<ul><li id=\"target\">ul list item</li></ul>" :
"<ul><li id=\"target\">ul list item\t</li></ul>",
aDescription + "Shift+Tab after Tab on UL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab after Tab on UL)");
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
check(aDescription + "Shift+Tab on UL",
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
is(aElement.innerHTML,
aIsReadonly || aIsTabbable || aIsPlaintext ?
"<ul><li id=\"target\">ul list item</li></ul>" : "ul list item",
aDescription + "Shift+Tab on UL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab on UL)");
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
- synthesizeKey("VK_TAB", { ctrlKey: true });
+ synthesizeKey("KEY_Tab", {ctrlKey: true});
check(aDescription + "Ctrl+Tab on UL", false, false, false);
is(aElement.innerHTML, "<ul><li id=\"target\">ul list item</li></ul>",
aDescription + "Ctrl+Tab on UL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Ctrl+Tab on UL)");
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
- synthesizeKey("VK_TAB", { altKey: true });
+ synthesizeKey("KEY_Tab", {altKey: true});
check(aDescription + "Alt+Tab on UL", true, true, false);
is(aElement.innerHTML, "<ul><li id=\"target\">ul list item</li></ul>",
aDescription + "Alt+Tab on UL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Alt+Tab on UL)");
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
- synthesizeKey("VK_TAB", { metaKey: true });
+ synthesizeKey("KEY_Tab", {metaKey: true});
check(aDescription + "Meta+Tab on UL", true, true, false);
is(aElement.innerHTML, "<ul><li id=\"target\">ul list item</li></ul>",
aDescription + "Meta+Tab on UL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Meta+Tab on UL)");
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
- synthesizeKey("VK_TAB", { osKey: true });
+ synthesizeKey("KEY_Tab", {osKey: true});
check(aDescription + "OS+Tab on UL", true, true, false);
is(aElement.innerHTML, "<ul><li id=\"target\">ul list item</li></ul>",
aDescription + "OS+Tab on UL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (OS+Tab on UL)");
// OL
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
check(aDescription + "Tab on OL",
true, true, !aIsTabbable && !aIsReadonly);
is(aElement.innerHTML,
aIsReadonly || aIsTabbable ?
"<ol><li id=\"target\">ol list item</li></ol>" :
aIsPlaintext ? "<ol><li id=\"target\">ol list item\t</li></ol>" :
"<ol><ol><li id=\"target\">ol list item</li></ol></ol>",
aDescription + "Tab on OL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Tab on OL)");
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
check(aDescription + "Shift+Tab after Tab on OL",
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
is(aElement.innerHTML,
aIsReadonly || aIsTabbable || (!aIsPlaintext) ?
"<ol><li id=\"target\">ol list item</li></ol>" :
"<ol><li id=\"target\">ol list item\t</li></ol>",
aDescription + "Shift+Tab after Tab on OL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab after Tab on OL)");
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
check(aDescription + "Shift+Tab on OL",
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
is(aElement.innerHTML,
aIsReadonly || aIsTabbable || aIsPlaintext ?
"<ol><li id=\"target\">ol list item</li></ol>" : "ol list item",
aDescription + "Shfit+Tab on OL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab on OL)");
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
- synthesizeKey("VK_TAB", { ctrlKey: true });
+ synthesizeKey("KEY_Tab", {ctrlKey: true});
check(aDescription + "Ctrl+Tab on OL", false, false, false);
is(aElement.innerHTML, "<ol><li id=\"target\">ol list item</li></ol>",
aDescription + "Ctrl+Tab on OL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Ctrl+Tab on OL)");
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
- synthesizeKey("VK_TAB", { altKey: true });
+ synthesizeKey("KEY_Tab", {altKey: true});
check(aDescription + "Alt+Tab on OL", true, true, false);
is(aElement.innerHTML, "<ol><li id=\"target\">ol list item</li></ol>",
aDescription + "Alt+Tab on OL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Alt+Tab on OL)");
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
- synthesizeKey("VK_TAB", { metaKey: true });
+ synthesizeKey("KEY_Tab", {metaKey: true});
check(aDescription + "Meta+Tab on OL", true, true, false);
is(aElement.innerHTML, "<ol><li id=\"target\">ol list item</li></ol>",
aDescription + "Meta+Tab on OL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Meta+Tab on OL)");
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
- synthesizeKey("VK_TAB", { osKey: true });
+ synthesizeKey("KEY_Tab", {osKey: true});
check(aDescription + "OS+Tab on OL", true, true, false);
is(aElement.innerHTML, "<ol><li id=\"target\">ol list item</li></ol>",
aDescription + "OS+Tab on OL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (OS+Tab on OL)");
// TD
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
check(aDescription + "Tab on TD",
true, true, !aIsTabbable && !aIsReadonly);
is(aElement.innerHTML,
aIsTabbable || aIsReadonly ?
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>" :
aIsPlaintext ? "<table><tbody><tr><td id=\"target\">td\t</td></tr></tbody></table>" :
"<table><tbody><tr><td id=\"target\">td</td></tr><tr><td style=\"vertical-align: top;\"><br></td></tr></tbody></table>",
aDescription + "Tab on TD");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Tab on TD)");
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
check(aDescription + "Shift+Tab after Tab on TD",
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
is(aElement.innerHTML,
aIsTabbable || aIsReadonly ?
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>" :
aIsPlaintext ? "<table><tbody><tr><td id=\"target\">td\t</td></tr></tbody></table>" :
"<table><tbody><tr><td id=\"target\">td</td></tr><tr><td style=\"vertical-align: top;\"><br></td></tr></tbody></table>",
aDescription + "Shift+Tab after Tab on TD");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab after Tab on TD)");
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
check(aDescription + "Shift+Tab on TD", true, true, false);
is(aElement.innerHTML,
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>",
aDescription + "Shift+Tab on TD");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab on TD)");
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
- synthesizeKey("VK_TAB", { ctrlKey: true });
+ synthesizeKey("KEY_Tab", {ctrlKey: true});
check(aDescription + "Ctrl+Tab on TD", false, false, false);
is(aElement.innerHTML,
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>",
aDescription + "Ctrl+Tab on TD");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Ctrl+Tab on TD)");
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
- synthesizeKey("VK_TAB", { altKey: true });
+ synthesizeKey("KEY_Tab", {altKey: true});
check(aDescription + "Alt+Tab on TD", true, true, false);
is(aElement.innerHTML,
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>",
aDescription + "Alt+Tab on TD");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Alt+Tab on TD)");
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
- synthesizeKey("VK_TAB", { metaKey: true });
+ synthesizeKey("KEY_Tab", {metaKey: true});
check(aDescription + "Meta+Tab on TD", true, true, false);
is(aElement.innerHTML,
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>",
aDescription + "Meta+Tab on TD");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Meta+Tab on TD)");
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
- synthesizeKey("VK_TAB", { osKey: true });
+ synthesizeKey("KEY_Tab", {osKey: true});
check(aDescription + "OS+Tab on TD", true, true, false);
is(aElement.innerHTML,
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>",
aDescription + "OS+Tab on TD");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (OS+Tab on TD)");
// TH
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
check(aDescription + "Tab on TH",
true, true, !aIsTabbable && !aIsReadonly);
is(aElement.innerHTML,
aIsTabbable || aIsReadonly ?
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>" :
aIsPlaintext ? "<table><tbody><tr><th id=\"target\">th\t</th></tr></tbody></table>" :
"<table><tbody><tr><th id=\"target\">th</th></tr><tr><td style=\"vertical-align: top;\"><br></td></tr></tbody></table>",
aDescription + "Tab on TH");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Tab on TH)");
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
check(aDescription + "Shift+Tab after Tab on TH",
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
is(aElement.innerHTML,
aIsTabbable || aIsReadonly ?
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>" :
aIsPlaintext ? "<table><tbody><tr><th id=\"target\">th\t</th></tr></tbody></table>" :
"<table><tbody><tr><th id=\"target\">th</th></tr><tr><td style=\"vertical-align: top;\"><br></td></tr></tbody></table>",
aDescription + "Shift+Tab after Tab on TH");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab after Tab on TH)");
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
check(aDescription + "Shift+Tab on TH", true, true, false);
is(aElement.innerHTML,
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>",
aDescription + "Shift+Tab on TH");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab on TH)");
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
- synthesizeKey("VK_TAB", { ctrlKey: true });
+ synthesizeKey("KEY_Tab", {ctrlKey: true});
check(aDescription + "Ctrl+Tab on TH", false, false, false);
is(aElement.innerHTML,
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>",
aDescription + "Ctrl+Tab on TH");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Ctrl+Tab on TH)");
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
- synthesizeKey("VK_TAB", { altKey: true });
+ synthesizeKey("KEY_Tab", {altKey: true});
check(aDescription + "Alt+Tab on TH", true, true, false);
is(aElement.innerHTML,
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>",
aDescription + "Alt+Tab on TH");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Alt+Tab on TH)");
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
- synthesizeKey("VK_TAB", { metaKey: true });
+ synthesizeKey("KEY_Tab", {metaKey: true});
check(aDescription + "Meta+Tab on TH", true, true, false);
is(aElement.innerHTML,
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>",
aDescription + "Meta+Tab on TH");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Meta+Tab on TH)");
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
- synthesizeKey("VK_TAB", { osKey: true });
+ synthesizeKey("KEY_Tab", {osKey: true});
check(aDescription + "OS+Tab on TH", true, true, false);
is(aElement.innerHTML,
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>",
aDescription + "OS+Tab on TH");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (OS+Tab on TH)");
// Esc key:
// In all cases, esc key events are not consumed
reset("abc");
- synthesizeKey("VK_ESCAPE", { });
+ synthesizeKey("KEY_Escape");
check(aDescription + "Esc", true, true, false);
reset("abc");
- synthesizeKey("VK_ESCAPE", { shiftKey: true });
+ synthesizeKey("KEY_Escape", {shiftKey: true});
check(aDescription + "Shift+Esc", true, true, false);
reset("abc");
- synthesizeKey("VK_ESCAPE", { ctrlKey: true });
+ synthesizeKey("KEY_Escape", {ctrlKey: true});
check(aDescription + "Ctrl+Esc", true, true, false);
reset("abc");
- synthesizeKey("VK_ESCAPE", { altKey: true });
+ synthesizeKey("KEY_Escape", {altKey: true});
check(aDescription + "Alt+Esc", true, true, false);
reset("abc");
- synthesizeKey("VK_ESCAPE", { metaKey: true });
+ synthesizeKey("KEY_Escape", {metaKey: true});
check(aDescription + "Meta+Esc", true, true, false);
reset("abc");
- synthesizeKey("VK_ESCAPE", { osKey: true });
+ synthesizeKey("KEY_Escape", {osKey: true});
check(aDescription + "OS+Esc", true, true, false);
// typical typing tests:
reset("");
- synthesizeKey("M", { shiftKey: true });
+ sendString("M");
check(aDescription + "M", true, true, !aIsReadonly);
- synthesizeKey("o", { });
+ sendString("o");
check(aDescription + "o", true, true, !aIsReadonly);
- synthesizeKey("z", { });
+ sendString("z");
check(aDescription + "z", true, true, !aIsReadonly);
- synthesizeKey("i", { });
+ sendString("i");
check(aDescription + "i", true, true, !aIsReadonly);
- synthesizeKey("l", { });
+ sendString("l");
check(aDescription + "l", true, true, !aIsReadonly);
- synthesizeKey("l", { });
+ sendString("l");
check(aDescription + "l", true, true, !aIsReadonly);
- synthesizeKey("a", { });
+ sendString("a");
check(aDescription + "a", true, true, !aIsReadonly);
- synthesizeKey(" ", { });
+ sendString(" ");
check(aDescription + "' '", true, true, !aIsReadonly);
is(aElement.innerHTML,
aIsReadonly ? "" : aIsPlaintext ? "Mozilla " : "Mozilla <br>",
aDescription + "typed \"Mozilla \"");
}
doTest(htmlEditor, "contenteditable=\"true\"", false, true, false);
--- a/editor/libeditor/tests/test_inline_style_cache.html
+++ b/editor/libeditor/tests/test_inline_style_cache.html
@@ -26,251 +26,200 @@ SimpleTest.waitForFocus(function() {
var selection = window.getSelection();
// #01-01 Typing something after setting some styles should insert some nodes to insert text.
editor.innerHTML = "beforeafter";
selection.collapse(editor.firstChild, "before".length);
document.execCommand("bold");
document.execCommand("italic");
document.execCommand("strikethrough");
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ sendString("test");
is(editor.innerHTML, "before<strike><i><b>test</b></i></strike>after",
"#01-01 At typing something after setting some styles, should cause inserting some nodes to apply the style");
// #01-02 Typing something after removing some characters after setting some styles should work as without removing some character.
// XXX This behavior is different from Chromium.
editor.innerHTML = "beforeafter";
selection.collapse(editor.firstChild, "before".length);
document.execCommand("bold");
document.execCommand("italic");
document.execCommand("strikethrough");
- synthesizeKey("KEY_Delete", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Delete");
+ sendString("test");
is(editor.innerHTML, "before<strike><i><b>test</b></i></strike>fter",
"#01-02-1 At typing something after Delete after setting style, should cause inserting some nodes to apply the style");
editor.innerHTML = "beforeafter";
selection.collapse(editor.firstChild, "before".length);
document.execCommand("bold");
document.execCommand("italic");
document.execCommand("strikethrough");
- synthesizeKey("KEY_Backspace", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Backspace");
+ sendString("test");
is(editor.innerHTML, "befor<strike><i><b>test</b></i></strike>after",
"#01-02-2 At typing something after Backspace after setting style, should cause inserting some nodes to apply the style");
// #01-03 Typing Enter after setting some styles should not ignore the styles.
editor.innerHTML = "beforeafter";
selection.collapse(editor.firstChild, "before".length);
document.execCommand("bold");
document.execCommand("italic");
document.execCommand("strikethrough");
- synthesizeKey("KEY_Enter", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Enter");
+ sendString("test");
is(editor.innerHTML, "<div>before</div><div><strike><i><b>test</b></i></strike>after</div>",
"#01-03-1 Typing Enter after setting style should not ignore the styles");
editor.innerHTML = "<p>beforeafter</p>";
selection.collapse(editor.firstChild.firstChild, "before".length);
document.execCommand("bold");
document.execCommand("italic");
document.execCommand("strikethrough");
- synthesizeKey("KEY_Enter", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Enter");
+ sendString("test");
is(editor.innerHTML, "<p>before</p><p><strike><i><b>test</b></i></strike>after</p>",
"#01-03-2 Typing Enter after setting style should not ignore the styles");
// #02-01 Replacing text with typing some text after setting some styles should work as just inserting text.
// XXX Chromium works as expected.
editor.innerHTML = "beforeselectionafter";
selection.collapse(editor.firstChild, "before".length);
selection.extend(editor.firstChild, "beforeselection".length);
document.execCommand("bold");
document.execCommand("italic");
document.execCommand("strikethrough");
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ sendString("test");
// XXX <strike> is not handled correctly in this case.
todo_is(editor.innerHTML, "before<strike><i><b>test</b></i></strike>after",
"#02-01 At replacing \"selection\" after setting some styles, should keep the styles at inserting text");
// XXX For testing current (buggy) behavior for now.
is(editor.innerHTML, "before<i><b>test</b></i><strike><i><b></b></i></strike>after",
"#02-01 At replacing \"selection\" after setting some styles, should keep the styles");
// #02-02 Inserting text after removing selected text after setting some styles should not keep the styles.
// XXX Chromium keeps the style.
editor.innerHTML = "beforeselectionafter";
selection.collapse(editor.firstChild, "before".length);
selection.extend(editor.firstChild, "beforeselection".length);
document.execCommand("bold");
document.execCommand("italic");
document.execCommand("strikethrough");
- synthesizeKey("KEY_Backspace", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Backspace");
+ sendString("test");
is(editor.innerHTML, "beforetestafter",
"#02-02 After removing \"selection\" after setting some styles, should not keep the styles");
// #02-03 Inserting text after replacing selected text after setting some styles should keep the styles.
editor.innerHTML = "beforeselectionafter";
selection.collapse(editor.firstChild, "before".length);
selection.extend(editor.firstChild, "beforeselection".length);
document.execCommand("bold");
document.execCommand("italic");
document.execCommand("strikethrough");
- synthesizeKey("KEY_Enter", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Enter");
+ sendString("test");
// XXX <strike> is not handled correctly in this case.
todo_is(editor.innerHTML, "<div>before</div><div><strike><i><b>test</b></i></strike>after</div>",
"#02-03-1 Typing Enter after setting style to selected text should keep the styles");
// XXX For testing current (buggy) behavior for now.
is(editor.innerHTML, "<div>before</div><div><i><b>test</b></i>after</div>",
"#02-03-1 Typing Enter after setting style to selected text should keep the styles");
editor.innerHTML = "<p>beforeselectionafter</p>";
selection.collapse(editor.firstChild.firstChild, "before".length);
selection.extend(editor.firstChild.firstChild, "beforeselection".length);
document.execCommand("bold");
document.execCommand("italic");
document.execCommand("strikethrough");
- synthesizeKey("KEY_Enter", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Enter");
+ sendString("test");
is(editor.innerHTML, "<p>before</p><p><strike><i><b>test</b></i></strike>after</p>",
"#02-03-2 Typing Enter after setting style to selected text should keep the styles");
// #03-01 Replacing in <b style="font-weight: normal;"> shouldn't cause new <b>.
editor.innerHTML = "<b style=\"font-weight: normal;\">beforeselectionafter</b>";
selection.collapse(editor.firstChild.firstChild, "before".length);
selection.extend(editor.firstChild.firstChild, "beforeselection".length);
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ sendString("test");
is(editor.innerHTML, "<b style=\"font-weight: normal;\">beforetestafter</b>",
"#03-01 Replacing text in styled inline elements should respect the styles");
// #03-02 Typing something after removing selected text in <b style="font-weight: normal;"> shouldn't cause new <b>.
editor.innerHTML = "<b style=\"font-weight: normal;\">beforeselectionafter</b>";
selection.collapse(editor.firstChild.firstChild, "before".length);
selection.extend(editor.firstChild.firstChild, "beforeselection".length);
- synthesizeKey("KEY_Backspace", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Backspace");
+ sendString("test");
is(editor.innerHTML, "<b style=\"font-weight: normal;\">beforetestafter</b>",
"#03-02 Inserting text after removing text in styled inline elements should respect the styles");
// #03-03 Typing something after typing Enter at selected text in <b style="font-weight: normal;"> shouldn't cause new <b>.
editor.innerHTML = "<b style=\"font-weight: normal;\">beforeselectionafter</b>";
selection.collapse(editor.firstChild.firstChild, "before".length);
selection.extend(editor.firstChild.firstChild, "beforeselection".length);
- synthesizeKey("KEY_Enter", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Enter");
+ sendString("test");
is(editor.innerHTML, "<div><b style=\"font-weight: normal;\">before</b></div><div><b style=\"font-weight: normal;\">testafter</b></div>",
"#03-03-1 Inserting text after typing Enter at selected text in styled inline elements should respect the styles");
editor.innerHTML = "<p><b style=\"font-weight: normal;\">beforeselectionafter</b></p>";
selection.collapse(editor.firstChild.firstChild.firstChild, "before".length);
selection.extend(editor.firstChild.firstChild.firstChild, "beforeselection".length);
- synthesizeKey("KEY_Enter", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Enter");
+ sendString("test");
is(editor.innerHTML, "<p><b style=\"font-weight: normal;\">before</b></p><p><b style=\"font-weight: normal;\">testafter</b></p>",
"#03-03-2 Inserting text after typing Enter at selected text in styled inline elements should respect the styles");
// #04-01 Replacing in some styled inline elements shouldn't cause new same elements.
editor.innerHTML = "<strike style=\"text-decoration: none;\"><i style=\"font-style: normal;\"><b style=\"font-weight: normal;\">beforeselectionafter</b></i></strike>";
selection.collapse(editor.firstChild.firstChild.firstChild.firstChild, "before".length);
selection.extend(editor.firstChild.firstChild.firstChild.firstChild, "beforeselection".length);
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ sendString("test");
is(editor.innerHTML, "<strike style=\"text-decoration: none;\"><i style=\"font-style: normal;\"><b style=\"font-weight: normal;\">beforetestafter</b></i></strike>",
"#04-01 Replacing text in styled inline elements should respect the styles");
// #04-02 Typing something after removing selected text in some styled inline elements shouldn't cause new same elements.
editor.innerHTML = "<strike style=\"text-decoration: none;\"><i style=\"font-style: normal;\"><b style=\"font-weight: normal;\">beforeselectionafter</b>";
selection.collapse(editor.firstChild.firstChild.firstChild.firstChild, "before".length);
selection.extend(editor.firstChild.firstChild.firstChild.firstChild, "beforeselection".length);
- synthesizeKey("KEY_Backspace", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Backspace");
+ sendString("test");
is(editor.innerHTML, "<strike style=\"text-decoration: none;\"><i style=\"font-style: normal;\"><b style=\"font-weight: normal;\">beforetestafter</b></i></strike>",
"#04-02 Inserting text after removing text in styled inline elements should respect the styles");
// #04-03 Typing something after typing Enter at selected text in some styled inline elements shouldn't cause new same elements.
editor.innerHTML = "<strike style=\"text-decoration: none;\"><i style=\"font-style: normal;\"><b style=\"font-weight: normal;\">beforeselectionafter</b>";
selection.collapse(editor.firstChild.firstChild.firstChild.firstChild, "before".length);
selection.extend(editor.firstChild.firstChild.firstChild.firstChild, "beforeselection".length);
- synthesizeKey("KEY_Enter", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Enter");
+ sendString("test");
is(editor.innerHTML, "<div><strike style=\"text-decoration: none;\"><i style=\"font-style: normal;\"><b style=\"font-weight: normal;\">before</b></i></strike></div><div><strike style=\"text-decoration: none;\"><i style=\"font-style: normal;\"><b style=\"font-weight: normal;\">testafter</b></i></strike></div>",
"#04-03-1 Inserting text after typing Enter at selected text in styled inline elements should respect the styles");
editor.innerHTML = "<p><strike style=\"text-decoration: none;\"><i style=\"font-style: normal;\"><b style=\"font-weight: normal;\">beforeselectionafter</b></p>";
selection.collapse(editor.firstChild.firstChild.firstChild.firstChild.firstChild, "before".length);
selection.extend(editor.firstChild.firstChild.firstChild.firstChild.firstChild, "beforeselection".length);
- synthesizeKey("KEY_Enter", {});
- synthesizeKey("t", {});
- synthesizeKey("e", {});
- synthesizeKey("s", {});
- synthesizeKey("t", {});
+ synthesizeKey("KEY_Enter");
+ sendString("test");
is(editor.innerHTML, "<p><strike style=\"text-decoration: none;\"><i style=\"font-style: normal;\"><b style=\"font-weight: normal;\">before</b></i></strike></p><p><strike style=\"text-decoration: none;\"><i style=\"font-style: normal;\"><b style=\"font-weight: normal;\">testafter</b></i></strike></p>",
"#04-03-2 Inserting text after typing Enter at selected text in styled inline elements should respect the styles");
SimpleTest.finish();
});
</script>
</pre>
--- a/editor/libeditor/tests/test_texteditor_keyevent_handling.html
+++ b/editor/libeditor/tests/test_texteditor_keyevent_handling.html
@@ -114,234 +114,234 @@ function runTests()
is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "failed to move focus");
// Backspace key:
// If editor is readonly, it doesn't consume.
// If editor is editable, it consumes backspace and shift+backspace.
// Otherwise, editor doesn't consume the event but the native key
// bindings on nsTextControlFrame may consume it.
reset("");
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
check(aDescription + "Backspace", true, true, true);
reset("");
- synthesizeKey("VK_BACK_SPACE", { shiftKey: true });
+ synthesizeKey("KEY_Backspace", {shiftKey: true});
check(aDescription + "Shift+Backspace", true, true, true);
reset("");
- synthesizeKey("VK_BACK_SPACE", { ctrlKey: true });
+ synthesizeKey("KEY_Backspace", {ctrlKey: true});
// Win: cmd_deleteWordBackward
check(aDescription + "Ctrl+Backspace",
true, true, aIsReadonly || kIsWin);
reset("");
- synthesizeKey("VK_BACK_SPACE", { altKey: true });
+ synthesizeKey("KEY_Backspace", {altKey: true});
// Win: cmd_undo
// Mac: cmd_deleteWordBackward
check(aDescription + "Alt+Backspace",
true, true, aIsReadonly || kIsWin || kIsMac);
reset("");
- synthesizeKey("VK_BACK_SPACE", { metaKey: true });
+ synthesizeKey("KEY_Backspace", {metaKey: true});
check(aDescription + "Meta+Backspace", true, true, aIsReadonly);
reset("");
- synthesizeKey("VK_BACK_SPACE", { osKey: true });
+ synthesizeKey("KEY_Backspace", {osKey: true});
check(aDescription + "OS+Backspace", true, true, aIsReadonly);
// Delete key:
// If editor is readonly, it doesn't consume.
// If editor is editable, delete is consumed.
// Otherwise, editor doesn't consume the event but the native key
// bindings on nsTextControlFrame may consume it.
reset("");
- synthesizeKey("VK_DELETE", { });
+ synthesizeKey("KEY_Delete");
// Linux: native handler
// Mac: cmd_deleteCharForward
check(aDescription + "Delete",
true, true, !aIsReadonly || kIsLinux || kIsMac);
reset("");
// Win: cmd_cutOrDelete
// Linux: cmd_cut
// Mac: cmd_deleteCharForward
- synthesizeKey("VK_DELETE", { shiftKey: true });
+ synthesizeKey("KEY_Delete", {shiftKey: true});
check(aDescription + "Shift+Delete",
true, true, true);
reset("");
- synthesizeKey("VK_DELETE", { ctrlKey: true });
+ synthesizeKey("KEY_Delete", {ctrlKey: true});
// Win: cmd_deleteWordForward
// Linux: cmd_copy
check(aDescription + "Ctrl+Delete",
true, true, kIsWin || kIsLinux);
reset("");
- synthesizeKey("VK_DELETE", { altKey: true });
+ synthesizeKey("KEY_Delete", {altKey: true});
// Mac: cmd_deleteWordForward
check(aDescription + "Alt+Delete",
true, true, kIsMac);
reset("");
- synthesizeKey("VK_DELETE", { metaKey: true });
+ synthesizeKey("KEY_Delete", {metaKey: true});
// Linux: native handler consumed.
check(aDescription + "Meta+Delete",
true, true, kIsLinux);
reset("");
- synthesizeKey("VK_DELETE", { osKey: true });
+ synthesizeKey("KEY_Delete", {osKey: true});
check(aDescription + "OS+Delete",
true, true, false);
// XXX input.value returns "\n" when it's empty, so, we should use dummy
// value ("a") for the following tests.
// Return key:
// If editor is readonly, it doesn't consume.
// If editor is editable and not single line editor, it consumes Return
// and Shift+Return.
// Otherwise, editor doesn't consume the event.
reset("a");
- synthesizeKey("VK_RETURN", { });
+ synthesizeKey("KEY_Enter");
check(aDescription + "Return",
true, true, !aIsSingleLine && !aIsReadonly);
is(aElement.value, !aIsSingleLine && !aIsReadonly ? "a\n" : "a",
aDescription + "Return");
reset("a");
- synthesizeKey("VK_RETURN", { shiftKey: true });
+ synthesizeKey("KEY_Enter", {shiftKey: true});
check(aDescription + "Shift+Return",
true, true, !aIsSingleLine && !aIsReadonly);
is(aElement.value, !aIsSingleLine && !aIsReadonly ? "a\n" : "a",
aDescription + "Shift+Return");
reset("a");
- synthesizeKey("VK_RETURN", { ctrlKey: true });
+ synthesizeKey("KEY_Enter", {ctrlKey: true});
check(aDescription + "Ctrl+Return", true, true, false);
is(aElement.value, "a", aDescription + "Ctrl+Return");
reset("a");
- synthesizeKey("VK_RETURN", { altKey: true });
+ synthesizeKey("KEY_Enter", {altKey: true});
check(aDescription + "Alt+Return", true, true, false);
is(aElement.value, "a", aDescription + "Alt+Return");
reset("a");
- synthesizeKey("VK_RETURN", { metaKey: true });
+ synthesizeKey("KEY_Enter", {metaKey: true});
check(aDescription + "Meta+Return", true, true, false);
is(aElement.value, "a", aDescription + "Meta+Return");
reset("a");
- synthesizeKey("VK_RETURN", { osKey: true });
+ synthesizeKey("KEY_Enter", {osKey: true});
check(aDescription + "OS+Return", true, true, false);
is(aElement.value, "a", aDescription + "OS+Return");
// Tab key:
// If editor is tabbable, editor doesn't consume all tab key events.
// Otherwise, editor consumes tab key event without any modifier keys.
reset("a");
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
check(aDescription + "Tab",
true, true, !aIsTabbable && !aIsReadonly);
is(aElement.value, !aIsTabbable && !aIsReadonly ? "a\t" : "a",
aDescription + "Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Tab)");
// If the editor is not tabbable, make sure that it accepts tab characters
// even if it's empty.
if (!aIsTabbable && !aIsReadonly) {
reset("");
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab");
check(aDescription + "Tab on empty textarea",
true, true, !aIsReadonly);
is(aElement.value, "\t", aDescription + "Tab on empty textarea");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Tab on empty textarea");
}
reset("a");
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
check(aDescription + "Shift+Tab", true, true, false);
is(aElement.value, "a", aDescription + "Shift+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab)");
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
reset("a");
- synthesizeKey("VK_TAB", { ctrlKey: true });
+ synthesizeKey("KEY_Tab", {ctrlKey: true});
check(aDescription + "Ctrl+Tab", false, false, false);
is(aElement.value, "a", aDescription + "Ctrl+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Ctrl+Tab)");
reset("a");
- synthesizeKey("VK_TAB", { altKey: true });
+ synthesizeKey("KEY_Tab", {altKey: true});
check(aDescription + "Alt+Tab", true, true, false);
is(aElement.value, "a", aDescription + "Alt+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Alt+Tab)");
reset("a");
- synthesizeKey("VK_TAB", { metaKey: true });
+ synthesizeKey("KEY_Tab", {metaKey: true});
check(aDescription + "Meta+Tab", true, true, false);
is(aElement.value, "a", aDescription + "Meta+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Meta+Tab)");
reset("a");
- synthesizeKey("VK_TAB", { osKey: true });
+ synthesizeKey("KEY_Tab", {osKey: true});
check(aDescription + "OS+Tab", true, true, false);
is(aElement.value, "a", aDescription + "OS+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (OS+Tab)");
// Esc key:
// In all cases, esc key events are not consumed
reset("abc");
- synthesizeKey("VK_ESCAPE", { });
+ synthesizeKey("KEY_Escape");
check(aDescription + "Esc", true, true, false);
reset("abc");
- synthesizeKey("VK_ESCAPE", { shiftKey: true });
+ synthesizeKey("KEY_Escape", {shiftKey: true});
check(aDescription + "Shift+Esc", true, true, false);
reset("abc");
- synthesizeKey("VK_ESCAPE", { ctrlKey: true });
+ synthesizeKey("KEY_Escape", {ctrlKey: true});
check(aDescription + "Ctrl+Esc", true, true, false);
reset("abc");
- synthesizeKey("VK_ESCAPE", { altKey: true });
+ synthesizeKey("KEY_Escape", {altKey: true});
check(aDescription + "Alt+Esc", true, true, false);
reset("abc");
- synthesizeKey("VK_ESCAPE", { metaKey: true });
+ synthesizeKey("KEY_Escape", {metaKey: true});
check(aDescription + "Meta+Esc", true, true, false);
reset("abc");
- synthesizeKey("VK_ESCAPE", { osKey: true });
+ synthesizeKey("KEY_Escape", {osKey: true});
check(aDescription + "OS+Esc", true, true, false);
// typical typing tests:
reset("");
- synthesizeKey("M", { shiftKey: true });
+ sendString("M");
check(aDescription + "M", true, true, !aIsReadonly);
- synthesizeKey("o", { });
+ sendString("o");
check(aDescription + "o", true, true, !aIsReadonly);
- synthesizeKey("z", { });
+ sendString("z");
check(aDescription + "z", true, true, !aIsReadonly);
- synthesizeKey("i", { });
+ sendString("i");
check(aDescription + "i", true, true, !aIsReadonly);
- synthesizeKey("l", { });
+ sendString("l");
check(aDescription + "l", true, true, !aIsReadonly);
- synthesizeKey("l", { });
+ sendString("l");
check(aDescription + "l", true, true, !aIsReadonly);
- synthesizeKey("a", { });
+ sendString("a");
check(aDescription + "a", true, true, !aIsReadonly);
- synthesizeKey(" ", { });
+ sendString(" ");
check(aDescription + "' '", true, true, !aIsReadonly);
is(aElement.value, !aIsReadonly ? "Mozilla " : "",
aDescription + "typed \"Mozilla \"");
}
doTest(inputField, "<input type=\"text\">", true, false, true);
inputField.setAttribute("readonly", "readonly");
--- a/gfx/layers/apz/test/mochitest/helper_key_scroll.html
+++ b/gfx/layers/apz/test/mochitest/helper_key_scroll.html
@@ -31,51 +31,51 @@ https://bugzilla.mozilla.org/show_bug.cg
function runTests() {
// Sanity check
SimpleTest.is(checkHasAsyncKeyScrolled(false), false, "expected no async key scrolling before test");
// Send a key to initiate a page scroll to take us to the bottom of the
// page. This scroll is done synchronously because APZ doesn't have
// current focus state at page load.
window.addEventListener("scroll", waitForScrollBottom);
- window.synthesizeKey("VK_END", {});
+ window.synthesizeKey("KEY_End");
};
function waitForScrollBottom() {
if (window.scrollY < window.scrollYMax) {
return;
}
- SimpleTest.info("Reached final scroll position of sync VK_END scroll");
+ SimpleTest.info("Reached final scroll position of sync KEY_End scroll");
window.removeEventListener("scroll", waitForScrollBottom);
// Spin the refresh driver a few times, so that the AsyncScroll instance
// that was running the main-thread scroll animation finishes up and
// triggers any repaints that it needs to.
var utils = SpecialPowers.DOMWindowUtils;
for (var i = 0; i < 10; i++) {
utils.advanceTimeAndRefresh(50);
}
utils.restoreNormalRefresh();
// Wait for the APZ to reach a stable state as well, before dispatching
// the next key input or the default action won't occur.
waitForApzFlushedRepaints(function () {
- SimpleTest.is(checkHasAsyncKeyScrolled(false), false, "expected no async key scrolling before VK_HOME dispatch");
+ SimpleTest.is(checkHasAsyncKeyScrolled(false), false, "expected no async key scrolling before KEY_Home dispatch");
// This scroll should be asynchronous now that the focus state is up to date.
window.addEventListener("scroll", waitForScrollTop);
- window.synthesizeKey("VK_HOME", {});
+ window.synthesizeKey("KEY_Home");
});
};
function waitForScrollTop() {
if (window.scrollY > 0) {
return;
}
- SimpleTest.info("Reached final scroll position of async VK_HOME scroll");
+ SimpleTest.info("Reached final scroll position of async KEY_Home scroll");
window.removeEventListener("scroll", waitForScrollTop);
// Wait for APZ to settle and then check that async scrolling happened.
waitForApzFlushedRepaints(function () {
SimpleTest.is(checkHasAsyncKeyScrolled(true), true, "expected async key scrolling after test");
window.opener.finishTest();
});
};
--- a/layout/base/tests/bug1109968-1.html
+++ b/layout/base/tests/bug1109968-1.html
@@ -9,15 +9,15 @@
function start() {
div.focus();
}
function done() {
var sel = getSelection();
sel.collapse(div, 0);
// Press Right four times to set the caret right before "baz"
for (var i = 0; i < 5; ++i) {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
}
document.documentElement.removeAttribute("class");
}
</script>
</body>
</html>
--- a/layout/base/tests/bug1109968-2.html
+++ b/layout/base/tests/bug1109968-2.html
@@ -9,15 +9,15 @@
function start() {
div.focus();
}
function done() {
var sel = getSelection();
sel.collapse(div, 0);
// Press Right four times to set the caret right before "bar"
for (var i = 0; i < 6; ++i) {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
}
document.documentElement.removeAttribute("class");
}
</script>
</body>
</html>
--- a/layout/base/tests/bug1123067-1.html
+++ b/layout/base/tests/bug1123067-1.html
@@ -8,19 +8,19 @@
<script>
function click(id) {
var e = document.querySelector(id);
synthesizeMouse(e, 1, 1, {type: "mousedown"}, window);
synthesizeMouse(e, 1, 1, {type: "mouseup"}, window);
}
function test() {
for (var i = 0; i < 5; ++i) {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
}
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
document.documentElement.removeAttribute("class");
}
function runTests() {
click('#test1')
}
</script>
<style>
div { -moz-user-select:none; }
--- a/layout/base/tests/bug1123067-2.html
+++ b/layout/base/tests/bug1123067-2.html
@@ -3,19 +3,19 @@
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase #2 for bug 1123067</title>
<script>
function test() {
for (var i = 0; i < 5; ++i) {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
}
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
document.documentElement.removeAttribute("class");
}
function runTests() {
var e = document.querySelector('#test1');
e.focus();
}
</script>
<style>
--- a/layout/base/tests/bug1123067-3.html
+++ b/layout/base/tests/bug1123067-3.html
@@ -3,19 +3,19 @@
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase #2 for bug 1123067</title>
<script>
function test() {
for (var i = 0; i < 5; ++i) {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
}
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
document.documentElement.removeAttribute("class");
}
function runTests() {
document.designMode='on';
document.querySelector('div').focus();
document.body.offsetHeight;
setTimeout(test,0)
}
--- a/layout/base/tests/bug1123067-ref.html
+++ b/layout/base/tests/bug1123067-ref.html
@@ -3,19 +3,19 @@
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase for bug 1123067</title>
<script>
function test() {
for (var i = 0; i < 5; ++i) {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
}
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
document.documentElement.removeAttribute("class");
}
function runTests() {
var e = document.querySelector('#test1');
e.focus();
}
</script>
<style>
--- a/layout/base/tests/bug1237236-1-ref.html
+++ b/layout/base/tests/bug1237236-1-ref.html
@@ -2,17 +2,17 @@
<html class="reftest-wait">
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase #1 for bug 1237236</title>
<script>
function test1() {
- synthesizeKey("VK_DOWN", { }); // move caret to the second line
+ synthesizeKey("KEY_ArrowDown"); // move caret to the second line
// caret should now be at the start of the second line
document.body.offsetHeight;
setTimeout(function(){ document.documentElement.removeAttribute("class"); },0);
}
function runTests() {
document.querySelector('textarea').focus();
document.body.offsetHeight;
}
--- a/layout/base/tests/bug1237236-1.html
+++ b/layout/base/tests/bug1237236-1.html
@@ -2,18 +2,18 @@
<html class="reftest-wait">
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase #1 for bug 1237236</title>
<script>
function test1() {
- synthesizeKey("VK_DOWN", { shiftKey: true }); // select first line including the newline
- synthesizeKey("VK_RIGHT", { }); // collapse to the end of the selection
+ synthesizeKey("KEY_ArrowDown", {shiftKey: true}); // select first line including the newline
+ synthesizeKey("KEY_ArrowRight"); // collapse to the end of the selection
// caret should now be at the start of the second line
document.body.offsetHeight;
setTimeout(function(){ document.documentElement.removeAttribute("class"); },0);
}
function runTests() {
document.querySelector('textarea').focus();
document.body.offsetHeight;
}
--- a/layout/base/tests/bug1237236-2-ref.html
+++ b/layout/base/tests/bug1237236-2-ref.html
@@ -2,20 +2,17 @@
<html class="reftest-wait">
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase #2 for bug 1237236</title>
<script>
function test1() {
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("KEY_ArrowRight", {repeat: 4});
document.body.offsetHeight;
document.documentElement.removeAttribute("class");
}
function runTests() {
document.querySelector('pre').focus();
document.body.offsetHeight;
}
</script>
--- a/layout/base/tests/bug1258308-1-ref.html
+++ b/layout/base/tests/bug1258308-1-ref.html
@@ -2,18 +2,18 @@
<html class="reftest-wait">
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase #1 for bug 1258308</title>
<script>
function test1() {
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
// caret should now be at the start of the third line
document.body.offsetHeight;
setTimeout(function(){ document.documentElement.removeAttribute("class"); },0);
}
function runTests() {
document.querySelector('textarea').focus();
document.body.offsetHeight;
}
--- a/layout/base/tests/bug1258308-1.html
+++ b/layout/base/tests/bug1258308-1.html
@@ -3,25 +3,25 @@
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase #1 for bug 1258308</title>
<script>
function test1() {
const kIsMac = navigator.platform.indexOf("Mac") == 0;
- synthesizeKey("VK_DOWN", {}); // go to the second line
+ synthesizeKey("KEY_ArrowDown"); // go to the second line
// go to the end of the second line
if (kIsMac) {
- synthesizeKey("VK_RIGHT", {accelKey: true});
+ synthesizeKey("KEY_ArrowRight", {accelKey: true});
} else {
- synthesizeKey("VK_END", {});
+ synthesizeKey("KEY_End");
}
- synthesizeKey("VK_RIGHT", { shiftKey: true }); // select the newline
- synthesizeKey("VK_RIGHT", {}); // collapse to the end of the selection
+ synthesizeKey("KEY_ArrowRight", {shiftKey: true}); // select the newline
+ synthesizeKey("KEY_ArrowRight"); // collapse to the end of the selection
// caret should now be at the start of the third line
document.body.offsetHeight;
setTimeout(function(){ document.documentElement.removeAttribute("class"); },0);
}
function runTests() {
document.querySelector('textarea').focus();
document.body.offsetHeight;
}
--- a/layout/base/tests/bug1258308-2-ref.html
+++ b/layout/base/tests/bug1258308-2-ref.html
@@ -2,24 +2,17 @@
<html class="reftest-wait">
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase #2 for bug 1258308</title>
<script>
function test1() {
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("KEY_ArrowRight", {repeat: 8});
document.body.offsetHeight;
document.documentElement.removeAttribute("class");
}
function runTests() {
document.querySelector('pre').focus();
document.body.offsetHeight;
}
</script>
--- a/layout/base/tests/bug1259949-1-ref.html
+++ b/layout/base/tests/bug1259949-1-ref.html
@@ -2,17 +2,17 @@
<html class="reftest-wait">
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase #1 for bug 1259949</title>
<script>
function test1() {
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
// caret should now be at the start of the second line
document.body.offsetHeight;
setTimeout(function(){ document.documentElement.removeAttribute("class"); },0);
}
function runTests() {
document.querySelector('textarea').focus();
document.body.offsetHeight;
}
--- a/layout/base/tests/bug1259949-1.html
+++ b/layout/base/tests/bug1259949-1.html
@@ -2,21 +2,21 @@
<html class="reftest-wait">
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase #1 for bug 1259949</title>
<script>
function test1() {
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_RIGHT", {}); // caret is now between "c" and "d"
- synthesizeKey("VK_DOWN", {shiftKey: true}); // select "def\n"
- synthesizeKey("VK_RIGHT", {}); // collapse to the end of the selection
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight"); // caret is now between "c" and "d"
+ synthesizeKey("KEY_ArrowDown", {shiftKey: true}); // select "def\n"
+ synthesizeKey("KEY_ArrowRight"); // collapse to the end of the selection
// caret should now be at the start of the second line
document.body.offsetHeight;
setTimeout(function(){ document.documentElement.removeAttribute("class"); },0);
}
function runTests() {
document.querySelector('textarea').focus();
document.body.offsetHeight;
}
--- a/layout/base/tests/bug1259949-2-ref.html
+++ b/layout/base/tests/bug1259949-2-ref.html
@@ -2,23 +2,17 @@
<html class="reftest-wait">
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<meta charset="utf-8">
<title>Testcase #2 for bug 1259949</title>
<script>
function test1() {
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
- synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("KEY_ArrowRight", {repeat: 7});
document.body.offsetHeight;
document.documentElement.removeAttribute("class");
}
function runTests() {
document.querySelector('pre').focus();
document.body.offsetHeight;
}
</script>
--- a/layout/base/tests/bug1263288.html
+++ b/layout/base/tests/bug1263288.html
@@ -15,16 +15,16 @@ https://bugzilla.mozilla.org/show_bug.cg
function start() {
var sel = window.getSelection();
// Focus on editable block.
theDiv = document.getElementById("editable");
theDiv.focus();
sel.collapse(theDiv, 0);
synthesizeMouse(theDiv, 100, 2, {});
- synthesizeKey("VK_END", {});
+ synthesizeKey("KEY_End");
}
SimpleTest.waitForFocus(start);
</script>
</body>
</html>
--- a/layout/base/tests/bug1263357-1.html
+++ b/layout/base/tests/bug1263357-1.html
@@ -14,21 +14,21 @@ https://bugzilla.mozilla.org/show_bug.cg
function start() {
var sel = window.getSelection();
// Focus on editable block.
theDiv = document.getElementById("editable");
theDiv.focus();
sel.collapse(theDiv, 0);
if (navigator.platform.indexOf("Win") == 0) {
- synthesizeKey("VK_END", {});
+ synthesizeKey("KEY_End");
} else {
// End key doesn't work as expected on Mac and Linux.
sel.modify("move", "right", "lineboundary");
}
- synthesizeKey("VK_RETURN", {shiftKey: true});
+ synthesizeKey("KEY_Enter", {shiftKey: true});
}
SimpleTest.waitForFocus(start);
</script>
</body>
</html>
--- a/layout/base/tests/bug1263357-2.html
+++ b/layout/base/tests/bug1263357-2.html
@@ -14,21 +14,21 @@ https://bugzilla.mozilla.org/show_bug.cg
function start() {
var sel = window.getSelection();
// Focus on editable block.
theDiv = document.getElementById("editable");
theDiv.focus();
sel.collapse(theDiv, 0);
if (navigator.platform.indexOf("Win") == 0) {
- synthesizeKey("VK_END", {});
+ synthesizeKey("KEY_End");
} else {
// End key doesn't work as expected on Mac and Linux.
sel.modify("move", "right", "lineboundary");
}
- synthesizeKey("VK_RETURN", {shiftKey: true});
+ synthesizeKey("KEY_Enter", {shiftKey: true});
}
SimpleTest.waitForFocus(start);
</script>
</body>
</html>
--- a/layout/base/tests/bug1423331-2-ref.html
+++ b/layout/base/tests/bug1423331-2-ref.html
@@ -11,15 +11,13 @@
height: 100px;
}
</style>
<div id="editable" contenteditable></div>
<script>
SimpleTest.waitForFocus(function() {
let div = document.getElementById("editable");
div.focus();
- synthesizeKey("x", {});
- synthesizeKey("x", {});
- synthesizeKey("x", {});
+ sendString("xxx");
document.documentElement.className = "";
});
</script>
</html>
--- a/layout/base/tests/bug1423331-2.html
+++ b/layout/base/tests/bug1423331-2.html
@@ -15,15 +15,13 @@
}
</style>
<div id="editable" contenteditable></div>
<script>
SimpleTest.waitForFocus(function() {
let div = document.getElementById("editable");
synthesizeMouseAtCenter(div, {});
synthesizeMouseAtCenter(div, {});
- synthesizeKey("x", {});
- synthesizeKey("x", {});
- synthesizeKey("x", {});
+ sendString("xxx");
document.documentElement.className = "";
});
</script>
</html>
--- a/layout/base/tests/bug1423331-4.html
+++ b/layout/base/tests/bug1423331-4.html
@@ -15,15 +15,13 @@
}
</style>
<div id="editable" contenteditable></div>
<script>
SimpleTest.waitForFocus(function() {
let div = document.getElementById("editable");
synthesizeMouse(div, 2, 2, {});
synthesizeMouse(div, 2, 2, {});
- synthesizeKey("x", {});
- synthesizeKey("x", {});
- synthesizeKey("x", {});
+ sendString("xxx");
document.documentElement.className = "";
});
</script>
</html>
--- a/layout/base/tests/bug597519-1.html
+++ b/layout/base/tests/bug597519-1.html
@@ -2,15 +2,14 @@
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
</head>
<body>
<textarea maxlength="3" spellcheck="false" style="-moz-appearance: none"></textarea>
<script>
var t = document.querySelector("textarea");
t.focus();
- synthesizeKey("a", {});
- synthesizeKey("b", {});
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("c", {});
+ sendString("ab");
+ synthesizeKey("KEY_Enter");
+ sendString("c");
</script>
</body>
</html>
--- a/layout/base/tests/bug632215-1.html
+++ b/layout/base/tests/bug632215-1.html
@@ -12,18 +12,18 @@
var w = i.contentWindow;
var s = w.getSelection();
i.focus();
d.body.contentEditable = true;
d.body.contentEditable = false;
d.designMode = "off";
d.designMode = "on";
d.body.focus();
- synthesizeKey("x", {});
+ sendString("x");
s.collapse(d.body.firstChild, 1);
- synthesizeKey("x", {});
+ sendString("x");
setTimeout(function() {
document.documentElement.removeAttribute("class");
}, 0);
};
</script>
</body>
</html>
--- a/layout/base/tests/bug632215-2.html
+++ b/layout/base/tests/bug632215-2.html
@@ -11,18 +11,18 @@
var d = i.contentDocument;
var w = i.contentWindow;
var s = w.getSelection();
i.focus();
d.body.contentEditable = false;
d.designMode = "off";
d.designMode = "on";
d.body.focus();
- synthesizeKey("x", {});
+ sendString("x");
s.collapse(d.body.firstChild, 1);
- synthesizeKey("x", {});
+ sendString("x");
setTimeout(function() {
document.documentElement.removeAttribute("class");
}, 0);
};
</script>
</body>
</html>
--- a/layout/base/tests/bug633044-1.html
+++ b/layout/base/tests/bug633044-1.html
@@ -11,14 +11,14 @@
document.body.focus();
getSelection().collapse(document.body.firstChild, 0);
var range = window.getSelection().getRangeAt(0);
var el = document.createTextNode(" ");
range.insertNode(el);
el.remove();
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
}
</script>
</head>
<body style="white-space:pre-wrap;" contenteditable></body></html>
--- a/layout/base/tests/bug634406-1.html
+++ b/layout/base/tests/bug634406-1.html
@@ -2,15 +2,15 @@
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
</head>
<body>
<textarea spellcheck="false" style="-moz-appearance: none"></textarea>
<script>
var t = document.querySelector("textarea");
t.focus();
- synthesizeKey("a", {});
+ sendString("a");
synthesizeKey("A", {accelKey: true});
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("b", {});
+ synthesizeKey("KEY_ArrowRight");
+ sendString("b");
</script>
</body>
</html>
--- a/layout/base/tests/bug644428-1.html
+++ b/layout/base/tests/bug644428-1.html
@@ -6,14 +6,14 @@
<body onload="setupCaret()" spellcheck="false">
<div contenteditable>a<span>b</span>c </div>
<script>
function setupCaret() {
var div = document.querySelector("div");
div.focus();
var sel = window.getSelection();
sel.collapse(div, 3);
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
+ synthesizeKey("KEY_Backspace");
}
</script>
</body>
</html>
--- a/layout/base/tests/bug646382-1.html
+++ b/layout/base/tests/bug646382-1.html
@@ -6,17 +6,17 @@
<body onload="start()">
<textarea onfocus="typeIntoMe()" style="-moz-appearance: none"></textarea>
<script>
function start() {
document.querySelector("textarea").focus();
}
function typeIntoMe() {
setTimeout(function() {
- synthesizeKey("س", {});
- synthesizeKey("VK_DOWN", {});
- synthesizeKey("VK_DOWN", {});
+ sendString("س");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
document.documentElement.removeAttribute("class");
}, 0);
}
</script>
</body>
</html>
--- a/layout/base/tests/bug646382-2.html
+++ b/layout/base/tests/bug646382-2.html
@@ -5,17 +5,17 @@
<body onload="start()">
<textarea dir="rtl" onfocus="typeIntoMe()" style="-moz-appearance: none"></textarea>
<script>
function start() {
document.querySelector("textarea").focus();
}
function typeIntoMe() {
setTimeout(function() {
- synthesizeKey("s", {});
- synthesizeKey("VK_DOWN", {});
- synthesizeKey("VK_DOWN", {});
+ sendString("s");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
document.documentElement.removeAttribute("class");
}, 0);
}
</script>
</body>
</html>
--- a/layout/base/tests/bug664087-1-ref.html
+++ b/layout/base/tests/bug664087-1-ref.html
@@ -7,15 +7,15 @@
<textarea rows="3" onfocus="done()" spellcheck="false" style="-moz-appearance: none">אב
ג</textarea>
<script>
var textarea = document.querySelector("textarea");
function start() {
textarea.focus();
}
function done() {
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKey("KEY_ArrowLeft");
document.documentElement.removeAttribute("class");
}
</script>
</body>
</html>
--- a/layout/base/tests/bug664087-1.html
+++ b/layout/base/tests/bug664087-1.html
@@ -6,20 +6,20 @@
<body onload="start()">
<textarea rows="3" onfocus="typeIntoMe()" spellcheck="false" style="-moz-appearance: none"></textarea>
<script>
function start() {
document.querySelector("textarea").focus();
}
function typeIntoMe() {
setTimeout(function() {
- synthesizeKey("א", {});
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("ג", {});
- synthesizeKey("VK_UP", {});
- synthesizeKey("VK_END", {});
- synthesizeKey("ב", {});
+ sendString("א");
+ synthesizeKey("KEY_Enter");
+ sendString("ג");
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_End");
+ sendString("ב");
document.documentElement.removeAttribute("class");
}, 0);
}
</script>
</body>
</html>
--- a/layout/base/tests/bug664087-2-ref.html
+++ b/layout/base/tests/bug664087-2-ref.html
@@ -7,15 +7,15 @@
<textarea dir="rtl" onfocus="done()" spellcheck="false" style="-moz-appearance: none">ab
c</textarea>
<script>
var textarea = document.querySelector("textarea");
function start() {
textarea.focus();
}
function done() {
- synthesizeKey("VK_RIGHT", {});
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKey("KEY_ArrowRight");
document.documentElement.removeAttribute("class");
}
</script>
</body>
</html>
--- a/layout/base/tests/bug664087-2.html
+++ b/layout/base/tests/bug664087-2.html
@@ -6,20 +6,20 @@
<body onload="start()">
<textarea dir="rtl" onfocus="typeIntoMe()" spellcheck="false" style="-moz-appearance: none"></textarea>
<script>
function start() {
document.querySelector("textarea").focus();
}
function typeIntoMe() {
setTimeout(function() {
- synthesizeKey("a", {});
- synthesizeKey("VK_RETURN", {});
- synthesizeKey("c", {});
- synthesizeKey("VK_UP", {});
- synthesizeKey("VK_END", {});
- synthesizeKey("b", {});
+ sendString("a");
+ synthesizeKey("KEY_Enter");
+ sendString("c");
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_End");
+ sendString("b");
document.documentElement.removeAttribute("class");
}, 0);
}
</script>
</body>
</html>
--- a/layout/base/tests/bug682712-1.html
+++ b/layout/base/tests/bug682712-1.html
@@ -17,16 +17,16 @@
iframe.style.display = "";
document.body.clientWidth;
setTimeout(function() {
doc.body.focus();
// Now try to move the caret
win.getSelection().collapse(doc.body.firstChild, 0);
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
document.documentElement.removeAttribute("class");
}, 0);
}
</script>
</body>
</html>
--- a/layout/base/tests/bug746993-1.html
+++ b/layout/base/tests/bug746993-1.html
@@ -9,14 +9,14 @@
function start() {
var iframe = document.querySelector("iframe");
var win = iframe.contentWindow;
var doc = iframe.contentDocument;
iframe.focus();
doc.body.focus();
win.getSelection().collapse(doc.body, 0);
sendString("Here's some text.");
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
document.documentElement.removeAttribute("class");
}
</script>
</body>
</html>
--- a/layout/base/tests/bug989012-1.html
+++ b/layout/base/tests/bug989012-1.html
@@ -10,15 +10,15 @@
function start() {
div.focus();
}
function done() {
var sel = getSelection();
sel.collapse(div, 0);
// Press Right four times to set the caret right before "bar"
for (var i = 0; i < 4; ++i) {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
}
document.documentElement.removeAttribute("class");
}
</script>
</body>
</html>
--- a/layout/base/tests/bug989012-2.html
+++ b/layout/base/tests/bug989012-2.html
@@ -15,15 +15,15 @@
function start() {
div.focus();
}
function done() {
var sel = getSelection();
sel.collapse(div, 0);
// Press Right four times to set the caret right before "bar"
for (var i = 0; i < 4; ++i) {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
}
document.documentElement.removeAttribute("class");
}
</script>
</body>
</html>
--- a/layout/base/tests/bug989012-3.html
+++ b/layout/base/tests/bug989012-3.html
@@ -17,15 +17,15 @@
function start() {
div.focus();
}
function done() {
var sel = getSelection();
sel.collapse(div, 0);
// Press Right four times to set the caret right before "bar"
for (var i = 0; i < 4; ++i) {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
}
document.documentElement.removeAttribute("class");
}
</script>
</body>
</html>
--- a/layout/base/tests/chrome/test_bug551434.html
+++ b/layout/base/tests/chrome/test_bug551434.html
@@ -47,17 +47,17 @@ function runTest()
is($("i2").value, "a", "input 2 value");
// key events should however be retargeted when the focus changes to an
// element in the a content document from a chrome document.
$("i3").focus();
var childWinObj = frames[0].wrappedJSObject;
- synthesizeKey("b", {});
+ sendString("b");
is(gKeyDown3, 1, "keydown on input 3");
is(gKeyPress3, 1, "keypress on input 3");
is(gKeyUp3, 1, "keyup on input 3");
is(childWinObj.gKeyDownChild, 0, "keydown on input 4");
is(childWinObj.gKeyPressChild, 0, "keypress on input 4");
is(childWinObj.gKeyUpChild, 0, "keyup on input 4");
var i4 = frames[0].document.getElementById("i4");
@@ -66,17 +66,17 @@ function runTest()
is(document.activeElement, $("iframe"), "parent focus");
is(frames[0].document.activeElement, i4, "child focus");
// key events should also be retargeted when the focus changes to an
// element in a chrome document from a content document.
i4.addEventListener("keydown", () => $("i3").focus());
- synthesizeKey("c", {});
+ sendString("c");
is(gKeyDown3, 1, "keydown on input 3");
is(gKeyPress3, 1, "keypress on input 3");
is(gKeyUp3, 1, "keyup on input 3");
is(childWinObj.gKeyDownChild, 1, "keydown on input 4");
is(childWinObj.gKeyPressChild, 1, "keypress on input 4");
is(childWinObj.gKeyUpChild, 1, "keyup on input 4");
--- a/layout/base/tests/input-maxlength-invalid-change.html
+++ b/layout/base/tests/input-maxlength-invalid-change.html
@@ -8,17 +8,17 @@
* { box-shadow:none; background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var input = document.getElementById('input');
input.setSelectionRange(input.value.length, input.value.length)
input.focus();
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
input.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<input id="input" maxlength="2" value="fooo">
</body>
--- a/layout/base/tests/input-maxlength-ui-invalid-change.html
+++ b/layout/base/tests/input-maxlength-ui-invalid-change.html
@@ -8,17 +8,17 @@
* { box-shadow:none; background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var input = document.getElementById('input');
input.setSelectionRange(input.value.length, input.value.length)
input.focus();
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
input.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<input id="input" maxlength="2" value="fooo">
</body>
--- a/layout/base/tests/input-maxlength-ui-valid-change.html
+++ b/layout/base/tests/input-maxlength-ui-valid-change.html
@@ -8,20 +8,20 @@
* { background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var input = document.getElementById('input');
input.setSelectionRange(input.value.length, input.value.length)
input.focus();
- synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first
+ synthesizeKey("KEY_Backspace"); // so that it becomes invalid first
input.blur();
input.focus();
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
input.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<input id="input" maxlength="3" value="foooo">
</body>
--- a/layout/base/tests/input-maxlength-valid-change.html
+++ b/layout/base/tests/input-maxlength-valid-change.html
@@ -8,20 +8,20 @@
* { background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var input = document.getElementById('input');
input.setSelectionRange(input.value.length, input.value.length)
input.focus();
- synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first
+ synthesizeKey("KEY_Backspace"); // so that it becomes invalid first
input.blur();
input.focus();
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
input.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<input id="input" maxlength="3" value="foooo">
</body>
--- a/layout/base/tests/input-minlength-invalid-change.html
+++ b/layout/base/tests/input-minlength-invalid-change.html
@@ -8,17 +8,17 @@
* { box-shadow:none; background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var input = document.getElementById('input');
input.setSelectionRange(input.value.length, input.value.length)
input.focus();
- synthesizeKey('o', {});
+ sendString("o");
input.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<input id="input" minlength="4" value="fo">
</body>
--- a/layout/base/tests/input-minlength-ui-invalid-change.html
+++ b/layout/base/tests/input-minlength-ui-invalid-change.html
@@ -8,17 +8,17 @@
* { box-shadow:none; background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var input = document.getElementById('input');
input.setSelectionRange(input.value.length, input.value.length)
input.focus();
- synthesizeKey('o', {});
+ sendString("o");
input.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<input id="input" minlength="4" value="fo">
</body>
--- a/layout/base/tests/input-minlength-ui-valid-change.html
+++ b/layout/base/tests/input-minlength-ui-valid-change.html
@@ -8,20 +8,20 @@
* { background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var input = document.getElementById('input');
input.setSelectionRange(input.value.length, input.value.length)
input.focus();
- synthesizeKey('o', {}); // so that it becomes invalid first
+ sendString("o"); // so that it becomes invalid first
input.blur();
input.focus();
- synthesizeKey('o', {});
+ sendString("o");
input.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<input id="input" minlength="3" value="f">
</body>
--- a/layout/base/tests/input-minlength-valid-change.html
+++ b/layout/base/tests/input-minlength-valid-change.html
@@ -8,20 +8,20 @@
* { background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var input = document.getElementById('input');
input.setSelectionRange(input.value.length, input.value.length)
input.focus();
- synthesizeKey('o', {}); // so that it becomes invalid first
+ sendString("o"); // so that it becomes invalid first
input.blur();
input.focus();
- synthesizeKey('o', {});
+ sendString("o");
input.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<input id="input" minlength="3" value="f">
</body>
--- a/layout/base/tests/test_bug332655-1.html
+++ b/layout/base/tests/test_bug332655-1.html
@@ -24,31 +24,28 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForExplicitFinish();
function test() {
var textInput = $("testInput");
var s1, s2, s3, equal, str1, str2;
textInput.focus();
- synthesizeKey("a", { });
- synthesizeKey("b", { });
- synthesizeKey(" ", { });
- synthesizeKey("\u05d0", { });
- synthesizeKey("\u05d1", { });
+ sendString("ab ");
+ sendString("\u05d0\u05d1");
s1 = snapshotWindow(window);
- synthesizeKey(" ", { });
+ sendString(" ");
s2 = snapshotWindow(window);
[equal, str1, str2] = compareSnapshots(s1, s2, true);
ok(equal, "space after LTR + RTL shouldn't change direction: expected " +
str1 + " but got " + str2);
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
s3 = snapshotWindow(window);
[equal, str1, str2] = compareSnapshots(s1, s3, true);
ok(equal, "backspace should restore the status quo: expected " + str1 +
" but got " + str2);
SimpleTest.finish();
}
--- a/layout/base/tests/test_bug332655-2.html
+++ b/layout/base/tests/test_bug332655-2.html
@@ -19,54 +19,42 @@ https://bugzilla.mozilla.org/show_bug.cg
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 332655 **/
SimpleTest.waitForExplicitFinish();
-function repeatKey(key, repetitions) {
- for (var i = 0; i < 4; ++i) {
- synthesizeKey(key, {});
- }
-}
-
function test() {
var textInput = $("testInput");
var s1, s2, s3, equal, str1, str2;
textInput.focus();
- synthesizeKey("\u05d0", { });
- synthesizeKey("a", { });
- synthesizeKey("b", { });
- synthesizeKey(" ", { });
- synthesizeKey("\u05d1", { });
- synthesizeKey("\u05d2", { });
+ sendString("\u05d0");
+ sendString("ab ");
+ sendString("\u05d1\u05d2");
s1 = snapshotWindow(window);
// 4 LEFT to get to the beginning of the line: HOME doesn't work on OS X
- repeatKey("VK_LEFT", 4);
- synthesizeKey("VK_BACK_SPACE", { });
- synthesizeKey("\u05d0", { });
+ synthesizeKey("KEY_ArrowLeft", {repeat: 4});
+ synthesizeKey("KEY_Backspace");
+ sendString("\u05d0");
s2 = snapshotWindow(window);
[equal, str1, str2] = compareSnapshots(s1, s2, true);
ok(equal, "deleting and inserting RTL char at beginning of line shouldn't change: expected " +
str1 + " but got " + str2);
textInput.select();
- synthesizeKey("a", { });
- synthesizeKey("b", { });
- synthesizeKey(" ", { });
- synthesizeKey("\u05d1", { });
- synthesizeKey("\u05d2", { });
+ sendString("ab ");
+ sendString("\u05d1\u05d2");
// 4 LEFT to get to the beginning of the line: HOME doesn't work on OS X
- repeatKey("VK_LEFT", 4);
- synthesizeKey("\u05d0", { });
+ synthesizeKey("KEY_ArrowLeft", {repeat: 4});
+ sendString("\u05d0");
s3 = snapshotWindow(window);
[equal, str1, str2] = compareSnapshots(s1, s3, true);
ok(equal, "the order entering Bidi text shouldn't change rendering: expected " +
str1 + " but got " + str2);
SimpleTest.finish();
--- a/layout/base/tests/test_bug370436.html
+++ b/layout/base/tests/test_bug370436.html
@@ -40,35 +40,35 @@ function startTest()
ta.selectionStart = ta.selectionEnd = ta.value.length;
// Note: This test, intentionally or by accident, relies on sending button '0'
// with contextMenu, which triggers some key-equiv stuff in
// PresShell::AdjustContextMenuKeyEvent.
var mouseParams = { type: 'contextmenu', button: 0 };
/* Put cursor at start and middle of "sheep" */
- synthesizeKey("VK_UP", {})
+ synthesizeKey("KEY_ArrowUp")
synthesizeMouse(ta, 0, 0, mouseParams);
- synthesizeKey("VK_RIGHT", {})
+ synthesizeKey("KEY_ArrowRight")
synthesizeMouse(ta, 0, 0, mouseParams);
- synthesizeKey("VK_RIGHT", {})
+ synthesizeKey("KEY_ArrowRight")
synthesizeMouse(ta, 0, 0, mouseParams);
/* Put cursor at the end of "hello" */
- synthesizeKey("VK_UP", {})
+ synthesizeKey("KEY_ArrowUp")
synthesizeMouse(ta, 0, 0, mouseParams);
- synthesizeKey("VK_RIGHT", {})
- synthesizeKey("VK_RIGHT", {})
- synthesizeKey("VK_RIGHT", {})
+ synthesizeKey("KEY_ArrowRight")
+ synthesizeKey("KEY_ArrowRight")
+ synthesizeKey("KEY_ArrowRight")
synthesizeMouse(ta, 0, 0, mouseParams);
- synthesizeKey("VK_RIGHT", {})
+ synthesizeKey("KEY_ArrowRight")
synthesizeMouse(ta, 0, 0, mouseParams);
/* Put cursor on "welcome" */
- synthesizeKey("VK_UP", {})
+ synthesizeKey("KEY_ArrowUp")
synthesizeMouse(ta, 0, 0, mouseParams);
is(words.pop(), "welcome", "Word 1 selected correctly");
is(words.pop(), "world" , "Word 2 selected correctly");
is(words.pop(), "hello" , "Word 3 selected correctly");
is(words.pop(), "hello" , "Word 4 selected correctly");
is(words.pop(), "sheep" , "Word 5 selected correctly");
is(words.pop(), "sheep" , "Word 6 selected correctly");
--- a/layout/base/tests/test_bug423523.html
+++ b/layout/base/tests/test_bug423523.html
@@ -66,35 +66,35 @@ https://bugzilla.mozilla.org/show_bug.cg
function runtests() {
sendMouseClick();
window.getSelection().collapse(document.getElementById("div1").firstChild, 0);
ok(divIsFocused(), "Div should be focused [0].");
ok(divIsFocused(), "Div should be focused [1].");
ok(selectionOffsetIs(0), "Caret should be at offset 0");
- synthesizeKey("VK_LEFT", { });
+ synthesizeKey("KEY_ArrowLeft");
ok(divIsFocused(), "Div should be focused [2].");
ok(selectionOffsetIs(0), "Caret should be at offset 0");
- synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("KEY_ArrowRight");
ok(divIsFocused(), "Div should be focused [3].");
ok(selectionOffsetIs(1), "Caret should be at offset 1");
- synthesizeKey("VK_LEFT", { });
+ synthesizeKey("KEY_ArrowLeft");
ok(divIsFocused(), "Div should be focused [4].");
ok(selectionOffsetIs(0), "Caret should be at offset 0");
ok(divIsFocused(), "Div should be focused [5].");
ok(selectionOffsetIs(0), "Caret should be at offset 0");
sendMouseClick();
ok(divIsFocused(), "Div should be focused [6].");
ok(selectionOffsetIs(0), "Caret should be at offset 0");
- synthesizeKey("VK_LEFT", { });
+ synthesizeKey("KEY_ArrowLeft");
ok(divIsFocused(), "Div should be focused [7].");
ok(selectionOffsetIs(0), "Caret should be at offset 0");
SimpleTest.finish();
}
</script>
--- a/layout/base/tests/test_bug499538-1.html
+++ b/layout/base/tests/test_bug499538-1.html
@@ -23,33 +23,26 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForExplicitFinish();
function test() {
var textInput = $("testInput");
var s1, s2, s3, equal, str1, str2;
textInput.focus();
- synthesizeKey("a", { });
- synthesizeKey(" ", { });
- synthesizeKey("\u0639", { });
- synthesizeKey("\u063A", { });
- synthesizeKey(" ", { });
- synthesizeKey("b", { });
+ sendString("a ");
+ sendString("\u0639\u063A");
+ sendString(" b");
s1 = snapshotWindow(window);
textInput.select();
- synthesizeKey("a", { });
- synthesizeKey(" ", { });
- synthesizeKey(" ", { });
- synthesizeKey("b", { });
- synthesizeKey("VK_LEFT", { });
- synthesizeKey("VK_LEFT", { });
- synthesizeKey("\u0639", { });
- synthesizeKey("\u063A", { });
+ sendString("a b");
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKey("KEY_ArrowLeft");
+ sendString("\u0639\u063A");
s2 = snapshotWindow(window);
[equal, str1, str2] = compareSnapshots(s1, s2, true);
ok(equal, "Arabic text between English words not connected: expected " +
str1 + " but got " + str2);
SimpleTest.finish();
}
--- a/layout/base/tests/test_bug582181-1.html
+++ b/layout/base/tests/test_bug582181-1.html
@@ -27,28 +27,28 @@ SimpleTest.waitForExplicitFinish();
function test() {
var textInput = $("testInput");
var s1, s2, s3, equal, str1, str2;
s1 = snapshotWindow(window);
textInput.focus();
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_RETURN", { });
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
textInput.blur();
s2 = snapshotWindow(window);
[equal, str1, str2] = compareSnapshots(s1, s2, true);
ok(equal, "enter after text shouldn't change rendering: expected " +
str1 + " but got " + str2);
textInput.focus();
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
textInput.blur();
s3 = snapshotWindow(window);
[equal, str1, str2] = compareSnapshots(s1, s3, true);
ok(equal, "backspace shouldn't change rendering: expected " + str1 +
" but got " + str2);
SimpleTest.finish();
--- a/layout/base/tests/test_bug582181-2.html
+++ b/layout/base/tests/test_bug582181-2.html
@@ -29,29 +29,29 @@ SimpleTest.waitForExplicitFinish();
function test() {
var textInput = $("testInput");
var s1, s2, s3, equal, str1, str2;
s1 = snapshotWindow(window);
textInput.focus();
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Backspace");
textInput.blur();
s2 = snapshotWindow(window);
[unequal, str1, str2] = compareSnapshots(s1, s2, false);
ok(unequal, "backspace after text should change rendering: got " + str2);
textInput.focus();
- synthesizeKey(">", { });
+ sendString(">");
textInput.blur();
s3 = snapshotWindow(window);
[equal, str1, str2] = compareSnapshots(s1, s3, true);
ok(equal, "entering '>' should restore original rendering: expected " + str1 +
" but got " + str2);
SimpleTest.finish();
--- a/layout/base/tests/test_bug644768.html
+++ b/layout/base/tests/test_bug644768.html
@@ -36,21 +36,21 @@
function test() {
var textInput = $("testInput");
var s1, s2, equal, str1, str2;
textInput.focus();
s1 = snapshotWindow(window);
- synthesizeKey("VK_UP", { });
- synthesizeKey("VK_UP", { });
- synthesizeKey("VK_UP", { });
- synthesizeKey("VK_DELETE", { });
- synthesizeKey("VK_RETURN", { });
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_Delete");
+ synthesizeKey("KEY_Enter");
// Bug 1016184: Touch caret will hide due to key event.
s2 = snapshotWindow(window);
[equal, str1, str2] = compareSnapshots(s1, s2, true);
ok(equal, "newline before bidi text shouldn't change direction: expected " +
str1 + " but got " + str2);
SimpleTest.finish();
--- a/layout/base/tests/test_bug667512.html
+++ b/layout/base/tests/test_bug667512.html
@@ -20,18 +20,18 @@ function appendElements() {
window.getSelection().collapse(document.documentElement, 0);
var x=document.getElementById('a');
x.remove();
var x=document.getElementById('b');
x.remove();
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKey("KEY_ArrowRight");
ok(true, "Should not crash!");
SimpleTest.finish();
}
addLoadEvent(appendElements);
SimpleTest.waitForExplicitFinish();
--- a/layout/base/tests/test_scroll_snapping.html
+++ b/layout/base/tests/test_scroll_snapping.html
@@ -21,663 +21,663 @@ var testCases = [
"description" : "Proximity + Within proximity => Snaps to point (Right)",
"scrollSnapType" : "proximity",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "525px 500px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_RIGHT",
+ "key" : "KEY_ArrowRight",
"expectedX" : 525,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Proximity + Within proximity => Snaps to point (Left)",
"scrollSnapType" : "proximity",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "475px 500px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_LEFT",
+ "key" : "KEY_ArrowLeft",
"expectedX" : 475,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Proximity + Within proximity => Snaps to point (Up)",
"scrollSnapType" : "proximity",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "500px 475px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_UP",
+ "key" : "KEY_ArrowUp",
"expectedX" : 500,
"expectedY" : 475,
"notExpected" : false
},
{
"description" : "Proximity + Within proximity => Snaps to point (Down)",
"scrollSnapType" : "proximity",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "500px 525px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_DOWN",
+ "key" : "KEY_ArrowDown",
"expectedX" : 500,
"expectedY" : 525,
"notExpected" : false
},
{
"description" : "Proximity + Beyond proximity => Does not snap to point (Right)",
"scrollSnapType" : "proximity",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "700px 500px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_RIGHT",
+ "key" : "KEY_ArrowRight",
"expectedX" : 700,
"expectedY" : 500,
"notExpected" : true
},
{
"description" : "Proximity + Beyond proximity => Does not snap to point (Left)",
"scrollSnapType" : "proximity",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "300px 500px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_LEFT",
+ "key" : "KEY_ArrowLeft",
"expectedX" : 300,
"expectedY" : 500,
"notExpected" : true
},
{
"description" : "Proximity + Beyond proximity => Does not snap to point (Up)",
"scrollSnapType" : "proximity",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "500px 300px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_UP",
+ "key" : "KEY_ArrowUp",
"expectedX" : 500,
"expectedY" : 300,
"notExpected" : true
},
{
"description" : "Proximity + Beyond proximity => Does not snap to point (Down)",
"scrollSnapType" : "proximity",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "500px 700px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_DOWN",
+ "key" : "KEY_ArrowDown",
"expectedX" : 500,
"expectedY" : 700,
"notExpected" : true
},
{
"description" : "Mandatory + Beyond proximity => Snaps to point (Right)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "700px 500px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_RIGHT",
+ "key" : "KEY_ArrowRight",
"expectedX" : 700,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Mandatory + Beyond proximity => Snaps to point (Left)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "300px 500px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_LEFT",
+ "key" : "KEY_ArrowLeft",
"expectedX" : 300,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Mandatory + Beyond proximity => Snaps to point (Up)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "500px 300px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_UP",
+ "key" : "KEY_ArrowUp",
"expectedX" : 500,
"expectedY" : 300,
"notExpected" : false
},
{
"description" : "Mandatory + Beyond proximity => Snaps to point (Down)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "500px 700px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_DOWN",
+ "key" : "KEY_ArrowDown",
"expectedX" : 500,
"expectedY" : 700,
"notExpected" : false
},
{
"description" : "Mandatory + No snap points => Does not snap or scroll (Left)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "none",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_LEFT",
+ "key" : "KEY_ArrowLeft",
"expectedX" : 500,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Mandatory + No snap points => Does not snap or scroll (Right)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "none",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_RIGHT",
+ "key" : "KEY_ArrowRight",
"expectedX" : 500,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Mandatory + No snap points => Does not snap or scroll (Up)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "none",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_UP",
+ "key" : "KEY_ArrowUp",
"expectedX" : 500,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Mandatory + No snap points => Does not snap or scroll (Down)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "none",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_DOWN",
+ "key" : "KEY_ArrowDown",
"expectedX" : 500,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-y + scroll-snap-destination + Start of page + No snap point at start of page => Does not snap to top of page (Up)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "repeat(500px)",
"scrollSnapDestination" : "25px 25px",
"scrollSnapCoordinate" : "none",
"initialX" : 0,
"initialY" : 200,
- "key" : "VK_UP",
+ "key" : "KEY_ArrowUp",
"expectedX" : 0,
"expectedY" : 200,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-y + scroll-snap-destination + Start of page + No snap point at start of page => Does not snap to top of page (Page Up)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "repeat(500px)",
"scrollSnapDestination" : "25px 25px",
"scrollSnapCoordinate" : "none",
"initialX" : 0,
"initialY" : 200,
- "key" : "VK_PAGE_UP",
+ "key" : "KEY_PageUp",
"expectedX" : 0,
"expectedY" : 200,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-y + scroll-snap-destination + Start of page + No snap point at start of page => Snaps to highest snap point (Home)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "repeat(500px)",
"scrollSnapDestination" : "25px 25px",
"scrollSnapCoordinate" : "none",
"initialX" : 0,
"initialY" : 200,
- "key" : "VK_HOME",
+ "key" : "KEY_Home",
"expectedX" : 0,
"expectedY" : 475,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-x + scroll-snap-destination + Start of page + No snap point at start of page => Does not snap to left of page (Left)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "repeat(500px)",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "25px 25px",
"scrollSnapCoordinate" : "none",
"initialX" : 200,
"initialY" : 0,
- "key" : "VK_LEFT",
+ "key" : "KEY_ArrowLeft",
"expectedX" : 200,
"expectedY" : 0,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-y + negative scroll-snap-destination + End of page + No snap point at end of page => Does not snap to end of page (Down)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "repeat(500px)",
"scrollSnapDestination" : "-25px -25px",
"scrollSnapCoordinate" : "none",
"initialX" : 0,
"initialY" : 800,
- "key" : "VK_DOWN",
+ "key" : "KEY_ArrowDown",
"expectedX" : 0,
"expectedY" : 800,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-y + negative scroll-snap-destination + End of page + No snap point at end of page => Does not snap to end of page (Page Down)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "repeat(500px)",
"scrollSnapDestination" : "-25px -25px",
"scrollSnapCoordinate" : "none",
"initialX" : 0,
"initialY" : 800,
- "key" : "VK_PAGE_DOWN",
+ "key" : "KEY_PageDown",
"expectedX" : 0,
"expectedY" : 800,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-y + negative scroll-snap-destination + End of page + No snap point at end of page => Snaps to lowest snap point (End)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "repeat(500px)",
"scrollSnapDestination" : "-25px -25px",
"scrollSnapCoordinate" : "none",
"initialX" : 0,
"initialY" : 800,
- "key" : "VK_END",
+ "key" : "KEY_End",
"expectedX" : 0,
"expectedY" : 525,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-coordinate + No snap point at start of page => Does not snap to top of page (Home)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "500px 100px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_HOME",
+ "key" : "KEY_Home",
"expectedX" : 500,
"expectedY" : 100,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-coordinate + No snap point at end of page => Does not snap to end of page (End)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "500px 900px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_END",
+ "key" : "KEY_End",
"expectedX" : 500,
"expectedY" : 900,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-y greater than scrolling rect + positive non-zero scroll-snap-destination => No snap points, does not scroll or snap (Left)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "repeat(1500px)",
"scrollSnapDestination" : "25px 25px",
"scrollSnapCoordinate" : "none",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_LEFT",
+ "key" : "KEY_ArrowLeft",
"expectedX" : 500,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-y greater than scrolling rect + positive non-zero scroll-snap-destination => No snap points, does not scroll or snap (Right)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "repeat(1500px)",
"scrollSnapDestination" : "25px 25px",
"scrollSnapCoordinate" : "none",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_RIGHT",
+ "key" : "KEY_ArrowRight",
"expectedX" : 500,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-y greater than scrolling rect + positive non-zero scroll-snap-destination => No snap points, does not scroll or snap (Up)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "repeat(1500px)",
"scrollSnapDestination" : "25px 25px",
"scrollSnapCoordinate" : "none",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_UP",
+ "key" : "KEY_ArrowUp",
"expectedX" : 500,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-y greater than scrolling rect + positive non-zero scroll-snap-destination => No snap points, does not scroll or snap (Down)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "repeat(1500px)",
"scrollSnapDestination" : "25px 25px",
"scrollSnapCoordinate" : "none",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_DOWN",
+ "key" : "KEY_ArrowDown",
"expectedX" : 500,
"expectedY" : 500,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Right #1)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "repeat(200px)",
"scrollSnapPointsY" : "repeat(200px)",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "120px 120px, 220px 220px",
"initialX" : 0,
"initialY" : 0,
- "key" : "VK_RIGHT",
+ "key" : "KEY_ArrowRight",
"expectedX" : 120,
"expectedY" : 0,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Right #2)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "repeat(200px)",
"scrollSnapPointsY" : "repeat(200px)",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "120px 120px, 220px 220px",
"initialX" : 120,
"initialY" : 0,
- "key" : "VK_RIGHT",
+ "key" : "KEY_ArrowRight",
"expectedX" : 200,
"expectedY" : 0,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Right #3)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "repeat(200px)",
"scrollSnapPointsY" : "repeat(200px)",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "120px 120px, 220px 220px",
"initialX" : 200,
"initialY" : 0,
- "key" : "VK_RIGHT",
+ "key" : "KEY_ArrowRight",
"expectedX" : 220,
"expectedY" : 0,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Up #1)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "repeat(200px)",
"scrollSnapPointsY" : "repeat(200px)",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "120px 120px, 220px 220px",
"initialX" : 0,
"initialY" : 300,
- "key" : "VK_UP",
+ "key" : "KEY_ArrowUp",
"expectedX" : 0,
"expectedY" : 220,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Up #2)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "repeat(200px)",
"scrollSnapPointsY" : "repeat(200px)",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "120px 120px, 220px 220px",
"initialX" : 0,
"initialY" : 220,
- "key" : "VK_UP",
+ "key" : "KEY_ArrowUp",
"expectedX" : 0,
"expectedY" : 200,
"notExpected" : false
},
{
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Up #3)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "repeat(200px)",
"scrollSnapPointsY" : "repeat(200px)",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "120px 120px, 220px 220px",
"initialX" : 0,
"initialY" : 200,
- "key" : "VK_UP",
+ "key" : "KEY_ArrowUp",
"expectedX" : 0,
"expectedY" : 120,
"notExpected" : false
},
{
"description" : "Ensure that when paging down/up that the next snap point in the direction of the scroll is selected rather than a closer point in the opposite direction (page Down)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "600px 600px, 475px 475px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_PAGE_DOWN",
+ "key" : "KEY_PageDown",
"expectedX" : 500,
"expectedY" : 600,
"notExpected" : false
},
{
"description" : "Ensure that when paging down/up that the next snap point in the direction of the scroll is selected rather than a closer point in the opposite direction (Page Up)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "400px 400px, 525px 525px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_PAGE_UP",
+ "key" : "KEY_PageUp",
"expectedX" : 500,
"expectedY" : 400,
"notExpected" : false
},
{
"description" : "Ensure that when paging down/up that the farthest snap point before the destination is selected and prioritized over a snap point that is past the destination, even if the snap point past the destination is closer to the destination. Setup - two snap points between current position and destination and one snap point past the destination which is closer than any of the other points. Scrollable rect size is 500px. (Page Down)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "525px 525px, 550px 550px, 800px 800px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_PAGE_DOWN",
+ "key" : "KEY_PageDown",
"expectedX" : 500,
"expectedY" : 550,
"notExpected" : false
},
{
"description" : "Ensure that when paging down/up that the farthest snap point before the destination is selected and prioritized over a snap point that is past the destination, even if the snap point past the destination is closer to the destination. Setup - two snap points between current position and destination and one snap point past the destination which is closer than any of the other points. Scrollable rect size is 500px. (Page Up)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "475px 475px, 450px 450px, 200px 200px",
"initialX" : 500,
"initialY" : 500,
- "key" : "VK_PAGE_UP",
+ "key" : "KEY_PageUp",
"expectedX" : 500,
"expectedY" : 450,
"notExpected" : false
},
{
"description" : "Ensure that when paging down/up that the closest snap point past the destination is selected when no snap points exist between the starting position and the destination. Additionally, a snap point closer to the destination than the one past the snap point, but not in the scrolling direction, must not be selected. Setup - Two snap points beyond the destination and one snap point in the opposite direction of scrolling which is closest to the destination. Scrollable rect size is 500px. (Page Down)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "50px 50px, 800px 800px, 900px 900px",
"initialX" : 100,
"initialY" : 100,
- "key" : "VK_PAGE_DOWN",
+ "key" : "KEY_PageDown",
"expectedX" : 100,
"expectedY" : 800,
"notExpected" : false
},
{
"description" : "Ensure that when paging down/up that the closest snap point past the destination is selected when no snap points exist between the starting position and the destination. Additionally, a snap point closer to the destination than the one past the snap point, but not in the scrolling direction, must not be selected. Setup - Two snap points beyond the destination and one snap point in the opposite direction of scrolling which is closest to the destination. Scrollable rect size is 500px. (Page Up)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "950px 950px, 200px 200px, 100px 100px",
"initialX" : 900,
"initialY" : 900,
- "key" : "VK_PAGE_UP",
+ "key" : "KEY_PageUp",
"expectedX" : 900,
"expectedY" : 200,
"notExpected" : false
},
{
"description" : "Ensure that when scrolling by lines up,down,left,or right, that the closest snap point to the destination in the direction of travel is selected. Setup - Two snap points in the direction of travel and one in the opposite direction. Snap point in opposite direction is closest to the destination but must not be selected. (Down)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "50px 50px, 800px 800px, 900px 900px",
"initialX" : 100,
"initialY" : 100,
- "key" : "VK_PAGE_DOWN",
+ "key" : "KEY_PageDown",
"expectedX" : 100,
"expectedY" : 800,
"notExpected" : false
},
{
"description" : "Ensure that when scrolling by lines up,down,left,or right, that the closest snap point to the destination in the direction of travel is selected. Setup - Two snap points in the direction of travel and one in the opposite direction. Snap point in opposite direction is closest to the destination but must not be selected. (Up)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "950px 950px, 200px 200px, 100px 100px",
"initialX" : 900,
"initialY" : 900,
- "key" : "VK_PAGE_UP",
+ "key" : "KEY_PageUp",
"expectedX" : 900,
"expectedY" : 200,
"notExpected" : false
},
{
"description" : "Ensure that when scrolling by lines up,down,left,or right, that the closest snap point to the destination in the direction of travel is selected. Setup - Two snap points in the direction of travel and one in the opposite direction. Snap point in opposite direction is closest to the destination but must not be selected. (Left)",
"scrollSnapType" : "mandatory",
"scrollSnapPointsX" : "none",
"scrollSnapPointsY" : "none",
"scrollSnapDestination" : "0px 0px",
"scrollSnapCoordinate" : "950px 950px, 200px 200px, 100px 100px",
"initialX" : 900,
"initialY" : 900,
- "key" : "VK_LEFT",
+ "key" : "KEY_ArrowLeft",
"expectedX" : 200,
"expectedY" : 900,
"notExpected" : false
}
];
var step = 0;
var sc; // Scroll Container
@@ -710,17 +710,17 @@ function initTest() {
var testCase = testCases[step];
sc.style.scrollSnapType = testCase.scrollSnapType;
sc.style.scrollSnapPointsX = testCase.scrollSnapPointsX;
sc.style.scrollSnapPointsY = testCase.scrollSnapPointsY;
sc.style.scrollSnapDestination = testCase.scrollSnapDestination;
sd.style.scrollSnapCoordinate = testCase.scrollSnapCoordinate;
sc.scrollTo(testCase.initialX, testCase.initialY);
sc.focus();
- synthesizeKey(testCase.key, {});
+ synthesizeKey(testCase.key);
stopFrameCount = 0;
lastScrollTop = sc.scrollTop;
lastScrollLeft = sc.scrollLeft;
window.requestAnimationFrame(waitForScrollStop);
}
--- a/layout/base/tests/textarea-maxlength-invalid-change.html
+++ b/layout/base/tests/textarea-maxlength-invalid-change.html
@@ -8,17 +8,17 @@
* { box-shadow:none; background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var textarea = document.getElementById('textarea');
textarea.setSelectionRange(textarea.value.length, textarea.value.length)
textarea.focus();
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
textarea.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<textarea id="textarea" maxlength="2">fooo</textarea>
</body>
--- a/layout/base/tests/textarea-maxlength-ui-invalid-change.html
+++ b/layout/base/tests/textarea-maxlength-ui-invalid-change.html
@@ -8,17 +8,17 @@
* { box-shadow:none; background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var textarea = document.getElementById('textarea');
textarea.setSelectionRange(textarea.value.length, textarea.value.length)
textarea.focus();
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
textarea.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<textarea id="textarea" maxlength="2">fooo</textarea>
</body>
--- a/layout/base/tests/textarea-maxlength-ui-valid-change.html
+++ b/layout/base/tests/textarea-maxlength-ui-valid-change.html
@@ -8,20 +8,20 @@
* { background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var textarea = document.getElementById('textarea');
textarea.setSelectionRange(textarea.value.length, textarea.value.length)
textarea.focus();
- synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first
+ synthesizeKey("KEY_Backspace"); // so that it becomes invalid first
textarea.blur();
textarea.focus();
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
textarea.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<textarea id="textarea" maxlength="3">foooo</textarea>
</body>
--- a/layout/base/tests/textarea-maxlength-valid-change.html
+++ b/layout/base/tests/textarea-maxlength-valid-change.html
@@ -8,20 +8,20 @@
* { background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var textarea = document.getElementById('textarea');
textarea.setSelectionRange(textarea.value.length, textarea.value.length)
textarea.focus();
- synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first
+ synthesizeKey("KEY_Backspace"); // so that it becomes invalid first
textarea.blur();
textarea.focus();
- synthesizeKey('VK_BACK_SPACE', {});
+ synthesizeKey("KEY_Backspace");
textarea.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<textarea id="textarea" maxlength="3">foooo</textarea>
</body>
--- a/layout/base/tests/textarea-minlength-invalid-change.html
+++ b/layout/base/tests/textarea-minlength-invalid-change.html
@@ -8,17 +8,17 @@
* { box-shadow:none; background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var textarea = document.getElementById('textarea');
textarea.setSelectionRange(textarea.value.length, textarea.value.length)
textarea.focus();
- synthesizeKey('o', {});
+ sendString("o");
textarea.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<textarea id="textarea" minlength="4">fo</textarea>
</body>
--- a/layout/base/tests/textarea-minlength-ui-invalid-change.html
+++ b/layout/base/tests/textarea-minlength-ui-invalid-change.html
@@ -8,17 +8,17 @@
* { box-shadow:none; background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var textarea = document.getElementById('textarea');
textarea.setSelectionRange(textarea.value.length, textarea.value.length)
textarea.focus();
- synthesizeKey('o', {});
+ sendString("o");
textarea.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<textarea id="textarea" minlength="4">fo</textarea>
</body>
--- a/layout/base/tests/textarea-minlength-ui-valid-change.html
+++ b/layout/base/tests/textarea-minlength-ui-valid-change.html
@@ -8,20 +8,20 @@
* { background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var textarea = document.getElementById('textarea');
textarea.setSelectionRange(textarea.value.length, textarea.value.length)
textarea.focus();
- synthesizeKey('o', {}); // so that it becomes invalid first
+ sendString("o"); // so that it becomes invalid first
textarea.blur();
textarea.focus();
- synthesizeKey('o', {});
+ sendString("o");
textarea.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<textarea id="textarea" minlength="3">f</textarea>
</body>
--- a/layout/base/tests/textarea-minlength-valid-change.html
+++ b/layout/base/tests/textarea-minlength-valid-change.html
@@ -8,20 +8,20 @@
* { background-color:white; }
</style>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script>
function runTest() {
var textarea = document.getElementById('textarea');
textarea.setSelectionRange(textarea.value.length, textarea.value.length)
textarea.focus();
- synthesizeKey('o', {}); // so that it becomes invalid first
+ sendString("o"); // so that it becomes invalid first
textarea.blur();
textarea.focus();
- synthesizeKey('o', {});
+ sendString("o");
textarea.blur(); // to hide the caret
document.documentElement.className='';
}
</script>
</head>
<body onload="runTest()">
<textarea id="textarea" minlength="3">f</textarea>
</body>
--- a/layout/forms/test/test_bug1305282.html
+++ b/layout/forms/test/test_bug1305282.html
@@ -28,23 +28,23 @@ var select = document.getElementsByTagNa
select.addEventListener("change", function(aEvent) {
is(select.selectedIndex, 1, "'b a r' option is selected");
SimpleTest.finish();
}, {once: true});
select.addEventListener("focus", function() {
SimpleTest.executeSoon(function () {
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
SimpleTest.executeSoon(function () {
- synthesizeKey('b', {});
+ sendString("b");
SimpleTest.executeSoon(function () {
- synthesizeKey(' ', {});
+ sendString(" ");
SimpleTest.executeSoon(function () {
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
});
});
});
});
}, {once: true});
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
--- a/layout/forms/test/test_bug1327129.html
+++ b/layout/forms/test/test_bug1327129.html
@@ -176,102 +176,102 @@ function runTests()
});
//
// Test DOWN key on a <select> with no selected options.
//
const listboxes = Array.from(document.querySelectorAll('select[size="3"]'));
listboxes.forEach((elem) => {
elem.focus();
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(""+elem.selectedIndex,
elem.getAttribute('firstNonDisabledIndex'),
elem.id + ": DOWN selected first non-disabled option");
});
const comboboxes = Array.from(document.querySelectorAll('select[size="1"]'));
// Mac shows the drop-down menu for DOWN, so skip this test there.
if (!kIsMac) {
comboboxes.forEach((elem) => {
elem.focus();
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
is(""+elem.selectedIndex,
elem.getAttribute('firstNonDisabledIndex'),
elem.id + ": DOWN selected first non-disabled option");
});
}
all.forEach((elem) => {
elem.selectedIndex = -1;
elem.blur();
});
//
// Test SHIFT+DOWN on a <select> with no selected options.
//
listboxes.forEach((elem) => {
elem.focus();
- synthesizeKey("VK_DOWN", {shiftKey:true});
+ synthesizeKey("KEY_ArrowDown", {shiftKey:true});
is(""+elem.selectedIndex,
elem.getAttribute('firstNonDisabledIndex'),
elem.id + ": SHIFT+DOWN selected first non-disabled option");
});
// Mac shows the drop-down menu for SHIFT+DOWN, so skip this test there.
if (!kIsMac) {
comboboxes.forEach((elem) => {
elem.focus();
- synthesizeKey("VK_DOWN", {shiftKey:true});
+ synthesizeKey("KEY_ArrowDown", {shiftKey:true});
is(""+elem.selectedIndex,
elem.getAttribute('firstNonDisabledIndex'),
elem.id + ": SHIFT+DOWN selected first non-disabled option");
});
}
all.forEach((elem) => {
elem.selectedIndex = -1;
elem.blur();
});
//
// Test CTRL+DOWN on a <select> with no selected options.
//
listboxes.forEach((elem) => {
elem.focus();
- synthesizeKey("VK_DOWN", {ctrlKey:true});
+ synthesizeKey("KEY_ArrowDown", {ctrlKey:true});
if (!elem.multiple)
is(""+elem.selectedIndex,
elem.getAttribute('firstNonDisabledIndex'),
elem.id + ": CTRL+DOWN selected first non-disabled option");
else
is(elem.selectedIndex, -1, elem.id + ": CTRL+DOWN did NOT select first any option");
});
// Mac shows the drop-down menu for CTRL+DOWN, so skip this test there.
if (!kIsMac) {
comboboxes.forEach((elem) => {
elem.focus();
- synthesizeKey("VK_DOWN", {ctrlKey:true});
+ synthesizeKey("KEY_ArrowDown", {ctrlKey:true});
is(""+elem.selectedIndex,
elem.getAttribute('firstNonDisabledIndex'),
elem.id + ": CTRL+DOWN selected first non-disabled option");
});
}
all.forEach((elem) => {
elem.selectedIndex = -1;
elem.blur();
});
//
// Test SPACE on a <select> with no selected options.
//
listboxes.forEach((elem) => {
elem.focus();
- synthesizeKey(" ", {});
+ sendString(" ");
is(""+elem.selectedIndex,
elem.getAttribute('firstNonDisabledIndex'),
elem.id + ": SPACE selected first non-disabled option");
});
// All platforms shows the drop-down menu for SPACE so skip testing that
// on the comboboxes.
@@ -326,27 +326,27 @@ function runTests()
elem.blur();
});
//
// Test CTRL+SHIFT+DOWN on a <select> with no selected options.
//
listboxes.forEach((elem) => {
elem.focus();
- synthesizeKey("VK_DOWN", {ctrlKey:true, shiftKey:true});
+ synthesizeKey("KEY_ArrowDown", {ctrlKey:true, shiftKey:true});
is(""+elem.selectedIndex,
elem.getAttribute('firstNonDisabledIndex'),
elem.id + ": CTRL+SHIFT+DOWN selected first non-disabled option");
});
// Mac shows the drop-down menu for CTRL+SHIFT+DOWN, so skip this test there.
if (!kIsMac) {
comboboxes.forEach((elem) => {
elem.focus();
- synthesizeKey("VK_DOWN", {ctrlKey:true, shiftKey:true});
+ synthesizeKey("KEY_ArrowDown", {ctrlKey:true, shiftKey:true});
is(""+elem.selectedIndex,
elem.getAttribute('firstNonDisabledIndex'),
elem.id + ": CTRL+SHIFT+DOWN selected first non-disabled option");
});
}
all.forEach((elem) => {
elem.selectedIndex = -1;
--- a/layout/forms/test/test_bug346043.html
+++ b/layout/forms/test/test_bug346043.html
@@ -16,25 +16,25 @@ https://bugzilla.mozilla.org/show_bug.cg
is(select.selectedIndex, index, "Selected index is broken");
// Open the select dropdown.
//
// Using Alt+Down (instead of a click) seems necessary to make subsequent
// mouse events work with the dropdown itself, instead of the window below
// it.
select.focus();
- synthesizeKey("VK_DOWN", {altKey: true});
+ synthesizeKey("KEY_ArrowDown", {altKey: true});
var options = select.getElementsByTagName("option");
synthesizeMouseAtCenter(options[1],
{type: "mousemove", clickCount: 0});
// Close the select dropdown.
if (useEscape)
- synthesizeKey("VK_ESCAPE", {}); // Tests a different code path.
+ synthesizeKey("KEY_Escape"); // Tests a different code path.
select.blur();
is(select.selectedIndex, index, "Selected index shouldn't change");
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
test(document.getElementById("test-unselected"), -1, true);
test(document.getElementById("test-unselected"), -1, false);
--- a/layout/forms/test/test_bug411236.html
+++ b/layout/forms/test/test_bug411236.html
@@ -25,17 +25,17 @@ https://bugzilla.mozilla.org/show_bug.cg
window.oTarget = null;
window.fileInputGotClick = false;
function test() {
// Try to find the 'Browse...' using tabbing.
var i = 0;
while (!window.oTarget && i < 100) {
++i;
- synthesizeKey("KEY_Tab", {});
+ synthesizeKey("KEY_Tab");
}
if (i >= 100) {
ok(false, "Couldn't find an input element!");
SimpleTest.finish();
return;
}
--- a/layout/forms/test/test_bug534785.html
+++ b/layout/forms/test/test_bug534785.html
@@ -27,27 +27,27 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var i = document.querySelector("input");
i.addEventListener("focus", function() {
is(i.value, "test", "Sanity check");
is(document.activeElement, i, "Should be focused before frame reconstruction");
- synthesizeKey("1", {});
+ sendString("1");
is(i.value, "1test", "Can accept keyboard events before frame reconstruction");
// force frame reconstruction
i.style.display = "none";
document.offsetHeight;
i.style.display = "";
document.offsetHeight;
is(document.activeElement, i, "Should be focused after frame reconstruction");
- synthesizeKey("2", {});
+ sendString("2");
is(i.value, "12test", "Can accept keyboard events after frame reconstruction");
// Make sure reframing happens gracefully
var reframeDiv = document.getElementById("reframe");
var textAreaWithoutValue = reframeDiv.querySelectorAll("textarea")[0];
var textAreaWithValue = reframeDiv.querySelectorAll("textarea")[1];
var inputWithoutValue = reframeDiv.querySelectorAll("input")[0];
var inputWithValue = reframeDiv.querySelectorAll("input")[1];
--- a/layout/forms/test/test_bug571352.html
+++ b/layout/forms/test/test_bug571352.html
@@ -28,20 +28,20 @@ SimpleTest.waitForFocus(function test()
}
function option(index) {
return $('display').firstChild.childNodes[index];
}
function remove(index) {
var sel = $('display').firstChild;
sel.removeChild(sel.childNodes[index]);
}
- function up() { synthesizeKey("VK_UP", {}); }
- function shiftUp() { synthesizeKey("VK_UP", {shiftKey:true}); }
- function down() { synthesizeKey("VK_DOWN", {}); }
- function shiftDown() { synthesizeKey("VK_DOWN", {shiftKey:true}); }
+ function up() { synthesizeKey("KEY_ArrowUp"); }
+ function shiftUp() { synthesizeKey("KEY_ArrowUp", {shiftKey:true}); }
+ function down() { synthesizeKey("KEY_ArrowDown"); }
+ function shiftDown() { synthesizeKey("KEY_ArrowDown", {shiftKey:true}); }
function mouseEvent(index,event) {
synthesizeMouse(option(index), 5, 5, event);
}
const click = {};
const shiftClick = {shiftKey:true};
const CtrlClick = {CtrlKey:true};
createList();
--- a/layout/forms/test/test_bug672810.html
+++ b/layout/forms/test/test_bug672810.html
@@ -25,36 +25,36 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var sel = document.getElementsByTagName('select');
sel[0].addEventListener('focus', function() {
s = sel[0];
s.removeEventListener('focus', arguments.callee);
- synthesizeKey('VK_DOWN', {});
+ synthesizeKey('KEY_ArrowDown');
is(s.selectedIndex,0, s.id + ": initial DOWN selects first option");
- synthesizeKey('VK_DOWN', {ctrlKey: true});
+ synthesizeKey('KEY_ArrowDown', {ctrlKey: true});
is(s.selectedIndex,0, s.id + ": first option is still selected");
ok(!s[1].selected,s.id + ": CTRL+DOWN did not select 2nd option");
- synthesizeKey('VK_DOWN', {ctrlKey: true});
- synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
+ synthesizeKey('KEY_ArrowDown', {ctrlKey: true});
+ synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true});
is(s.selectedIndex,0, s.id + ": first option is still selected");
ok(!s[1].selected,s.id + ": 2nd option is still unselected");
ok(s[2].selected,s.id + ": 3rd option is selected");
ok(s[3].selected,s.id + ": 4th option is selected");
ok(!s[4].selected,s.id + ": 5th option is unselected");
- synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
+ synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true});
is(s.selectedIndex,0, s.id + ": first option is still selected");
ok(!s[1].selected,s.id + ": 2nd option is still unselected");
ok(s[2].selected,s.id + ": 3rd option is still selected");
ok(s[3].selected,s.id + ": 4th option is still selected");
ok(s[4].selected,s.id + ": 5th option is selected");
ok(!s[5].selected,s.id + ": 6th option is unselected");
- synthesizeKey('VK_UP', {ctrlKey: true, shiftKey: true});
+ synthesizeKey('KEY_ArrowUp', {ctrlKey: true, shiftKey: true});
is(s.selectedIndex,0, s.id + ": first option is still selected");
ok(!s[1].selected,s.id + ": 2nd option is still unselected");
ok(s[2].selected,s.id + ": 3rd option is still selected");
ok(s[3].selected,s.id + ": 4th option is still selected");
ok(s[4].selected,s.id + ": 5th option is still selected");
ok(!s[5].selected,s.id + ": 6th option is still unselected");
synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
is(s.selectedIndex,0, s.id + ": first option is still selected");
@@ -70,41 +70,41 @@ SimpleTest.waitForFocus(function() {
ok(s[3].selected,s.id + ": 4th option is selected");
ok(s[4].selected,s.id + ": 5th option is still selected");
ok(!s[5].selected,s.id + ": 6th option is still unselected");
setTimeout(function(){sel[1].focus()},0);
});
sel[1].addEventListener('focus', function() {
s = sel[1];
s.removeEventListener('focus', arguments.callee);
- synthesizeKey('VK_DOWN', {});
+ synthesizeKey('KEY_ArrowDown');
is(s.selectedIndex,0, s.id + ": initial DOWN selects first option");
- synthesizeKey('VK_DOWN', {ctrlKey: true});
+ synthesizeKey('KEY_ArrowDown', {ctrlKey: true});
is(s.selectedIndex,1, s.id + ": 2nd option is selected");
ok(!s[0].selected,s.id + ": CTRL+DOWN deselected first option");
- synthesizeKey('VK_DOWN', {ctrlKey: true});
- synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
+ synthesizeKey('KEY_ArrowDown', {ctrlKey: true});
+ synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true});
is(s.selectedIndex,3, s.id + ": 4th option is selected");
ok(!s[1].selected,s.id + ": CTRL+SHIFT+DOWN deselected 2nd option");
synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
is(s.selectedIndex,3, s.id + ": 4th option is still selected");
synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
is(s.selectedIndex,3, s.id + ": 4th option is still selected");
setTimeout(function(){sel[2].focus()},0);
});
sel[2].addEventListener('focus', function() {
if (!navigator.platform.includes("Mac")) {
s = sel[2];
s.removeEventListener('focus', arguments.callee);
- synthesizeKey('VK_DOWN', {});
+ synthesizeKey('KEY_ArrowDown');
is(s.selectedIndex,1, s.id + ": initial DOWN selects 2nd option");
- synthesizeKey('VK_DOWN', {ctrlKey: true});
+ synthesizeKey('KEY_ArrowDown', {ctrlKey: true});
is(s.selectedIndex,2, s.id + ": 3rd option is selected");
ok(!s[1].selected,s.id + ": CTRL+DOWN deselected 2nd option");
- synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
+ synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true});
is(s.selectedIndex,3, s.id + ": 4th option is selected");
ok(!s[2].selected,s.id + ": CTRL+SHIFT+DOWN deselected 3rd option");
synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
is(s.selectedIndex,3, s.id + ": 4th option is still selected");
synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
is(s.selectedIndex,3, s.id + ": 4th option is still selected");
} else {
todo(false, "Make this test work on OSX");
--- a/layout/forms/test/test_bug903715.html
+++ b/layout/forms/test/test_bug903715.html
@@ -53,29 +53,29 @@ function runTests()
input.focus();
input.select();
});
select.focus();
select.addEventListener("popupshowing", function (aEvent) {
setTimeout(function () {
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
select.addEventListener("popuphiding", function (aEvent) {
setTimeout(function () {
// Enter key should cause closing the dropdown of the select element
// and keypress event shouldn't be fired on the input element because
// which shouldn't cause sumbmitting the form contents.
ok(true, "Test passes if there is no error");
SimpleTest.finish();
}, 100);
});
// Close dropdown.
- synthesizeKey("VK_RETURN", { });
+ synthesizeKey("KEY_Enter");
}, 100);
});
// Open dropdown.
- synthesizeKey("VK_DOWN", { altKey: true });
+ synthesizeKey("KEY_ArrowDown", { altKey: true });
}
</script>
</body>
</html>
--- a/layout/forms/test/test_bug935876.html
+++ b/layout/forms/test/test_bug935876.html
@@ -122,76 +122,76 @@ function runTests()
SpecialPowers.addSystemEventListener(listbox, "keydown", onkeydownInSystemEventGroup, false);
listbox.focus();
[ false, true ].forEach(function (consume) {
doPreventDefault = consume;
for (var i = 0; i < listbox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
check(true, false, "DownArrow key on listbox #" + i);
}
for (var i = 0; i < listbox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowUp", {});
+ synthesizeKey("KEY_ArrowUp");
check(true, false, "'ArrowUp' key on listbox #" + i);
}
for (var i = 0; i < listbox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowRight", {});
+ synthesizeKey("KEY_ArrowRight");
check(true, false, "'ArrowRight' key on listbox #" + i);
}
for (var i = 0; i < listbox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowLeft");
check(true, false, "'ArrowLeft' key on listbox #" + i);
}
for (var i = 0; i < 4; i++) {
reset()
- synthesizeKey("KEY_PageDown", {});
+ synthesizeKey("KEY_PageDown");
check(true, false, "'PageDown' key on listbox #" + i);
}
for (var i = 0; i < 4; i++) {
reset()
- synthesizeKey("KEY_PageUp", {});
+ synthesizeKey("KEY_PageUp");
check(true, false, "'PageUp' key on listbox #" + i);
}
for (var i = 0; i < 2; i++) {
reset()
- synthesizeKey("KEY_End", {});
+ synthesizeKey("KEY_End");
check(true, false, "'End' key on listbox #" + i);
}
for (var i = 0; i < 2; i++) {
reset()
- synthesizeKey("KEY_Home", {});
+ synthesizeKey("KEY_Home");
check(true, false, "'Home' key on listbox #" + i);
}
reset()
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
check(false, true, "'Enter' key on listbox");
reset()
- synthesizeKey("KEY_Escape", {});
+ synthesizeKey("KEY_Escape");
check(false, false, "'Escape' key on listbox");
reset()
- synthesizeKey("KEY_F4", {});
+ synthesizeKey("KEY_F4");
check(false, false, "F4 key on listbox");
reset()
- synthesizeKey("a", {});
+ sendString("a");
check(false, true, "'A' key on listbox");
});
listbox.removeEventListener("keydown", onKeydown);
listbox.removeEventListener("keypress", onKeypress);
SpecialPowers.removeSystemEventListener(listbox, "keydown", onkeydownInSystemEventGroup, false);
@@ -202,76 +202,76 @@ function runTests()
SpecialPowers.addSystemEventListener(multipleListbox, "keydown", onkeydownInSystemEventGroup, false);
multipleListbox.focus();
[ false, true ].forEach(function (consume) {
doPreventDefault = consume;
for (var i = 0; i < multipleListbox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
check(true, false, "'ArrowDown' key on multiple listbox #" + i);
}
for (var i = 0; i < multipleListbox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowUp", {});
+ synthesizeKey("KEY_ArrowUp");
check(true, false, "'ArrowUp' key on multiple listbox #" + i);
}
for (var i = 0; i < multipleListbox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowRight", {});
+ synthesizeKey("KEY_ArrowRight");
check(true, false, "'ArrowRight' key on multiple listbox #" + i);
}
for (var i = 0; i < multipleListbox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowLeft");
check(true, false, "'ArrowLeft' key on multiple listbox #" + i);
}
for (var i = 0; i < 4; i++) {
reset()
- synthesizeKey("KEY_PageDown", {});
+ synthesizeKey("KEY_PageDown");
check(true, false, "'PageDown' key on multiple listbox #" + i);
}
for (var i = 0; i < 4; i++) {
reset()
- synthesizeKey("KEY_PageUp", {});
+ synthesizeKey("KEY_PageUp");
check(true, false, "'PageUp' key on multiple listbox #" + i);
}
for (var i = 0; i < 2; i++) {
reset()
- synthesizeKey("KEY_End", {});
+ synthesizeKey("KEY_End");
check(true, false, "'End' key on multiple listbox #" + i);
}
for (var i = 0; i < 2; i++) {
reset()
- synthesizeKey("KEY_Home", {});
+ synthesizeKey("KEY_Home");
check(true, false, "'Home' key on multiple listbox #" + i);
}
reset()
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
check(true, true, "'Enter' key on multiple listbox");
reset()
- synthesizeKey("KEY_Escape", {});
+ synthesizeKey("KEY_Escape");
check(false, false, "'Escape' key on multiple listbox");
reset()
- synthesizeKey("KEY_F4", {});
+ synthesizeKey("KEY_F4");
check(false, false, "'F4' key on multiple listbox");
reset()
- synthesizeKey("a", {});
+ sendString("a");
check(false, true, "'A' key on multiple listbox");
});
multipleListbox.removeEventListener("keydown", onKeydown);
multipleListbox.removeEventListener("keypress", onKeypress);
SpecialPowers.removeSystemEventListener(multipleListbox, "keydown", onkeydownInSystemEventGroup, false);
@@ -283,81 +283,81 @@ function runTests()
combobox.focus();
[ false, true ].forEach(function (consume) {
doPreventDefault = consume;
if (!kIsMac) {
for (var i = 0; i < combobox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
check(true, false, "'ArrowDown' key on combobox #" + i);
}
for (var i = 0; i < combobox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowUp", {});
+ synthesizeKey("KEY_ArrowUp");
check(true, false, "'ArrowUp' key on combobox #" + i);
}
} else {
todo(false, "Make this test work on OSX");
}
for (var i = 0; i < combobox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowRight", {});
+ synthesizeKey("KEY_ArrowRight");
check(true, false, "'ArrowRight' key on combobox #" + i);
}
for (var i = 0; i < combobox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowLeft");
check(true, false, "'ArrowLeft' key on combobox #" + i);
}
for (var i = 0; i < 4; i++) {
reset()
- synthesizeKey("KEY_PageDown", {});
+ synthesizeKey("KEY_PageDown");
check(true, false, "'PageDown' key on combobox #" + i);
}
for (var i = 0; i < 4; i++) {
reset()
- synthesizeKey("KEY_PageUp", {});
+ synthesizeKey("KEY_PageUp");
check(true, false, "'PageUp' key on combobox #" + i);
}
for (var i = 0; i < 2; i++) {
reset()
- synthesizeKey("KEY_End", {});
+ synthesizeKey("KEY_End");
check(true, false, "'End' key on combobox #" + i);
}
for (var i = 0; i < 2; i++) {
reset()
- synthesizeKey("KEY_Home", {});
+ synthesizeKey("KEY_Home");
check(true, false, "'Home' key on combobox #" + i);
}
reset()
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
check(false, true, "'Enter' key on combobox");
reset()
- synthesizeKey("KEY_Escape", {});
+ synthesizeKey("KEY_Escape");
check(true, false, "'Escape' key on combobox");
if (!kIsWin) {
reset()
- synthesizeKey("KEY_F4", {});
+ synthesizeKey("KEY_F4");
check(false, false, "'F4' key on combobox");
}
reset()
- synthesizeKey("a", {});
+ sendString("a");
check(false, true, "'A' key on combobox");
});
function finish()
{
combobox.removeEventListener("keydown", onKeydown);
combobox.removeEventListener("keypress", onKeypress);
SpecialPowers.removeSystemEventListener(combobox, "keydown", onkeydownInSystemEventGroup, false);
@@ -377,95 +377,95 @@ function runTests()
testOpenDropDown(function () {
reset()
synthesizeKey("KEY_ArrowDown", {altKey: true});
}, function () {
check(true, false, "Alt + DownArrow key on combobox at opening dropdown");
for (var i = 0; i < combobox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
check(true, false, "'ArrowDown' key on combobox during dropdown open #" + i);
}
for (var i = 0; i < combobox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowUp", {});
+ synthesizeKey("KEY_ArrowUp");
check(true, false, "'ArrowUp' key on combobox during dropdown open #" + i);
}
for (var i = 0; i < combobox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowRight", {});
+ synthesizeKey("KEY_ArrowRight");
check(true, false, "'ArrowRight' key on combobox during dropdown open #" + i);
}
for (var i = 0; i < combobox.options.length + 1; i++) {
reset()
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowLeft");
check(true, false, "'ArrowLeft' key on combobox during dropdown open #" + i);
}
for (var i = 0; i < 4; i++) {
reset()
- synthesizeKey("KEY_PageDown", {});
+ synthesizeKey("KEY_PageDown");
check(true, false, "'PageDown' key on combobox during dropdown open #" + i);
}
for (var i = 0; i < 4; i++) {
reset()
- synthesizeKey("KEY_PageUp", {});
+ synthesizeKey("KEY_PageUp");
check(true, false, "'PageUp' key on combobox during dropdown open #" + i);
}
for (var i = 0; i < 2; i++) {
reset()
- synthesizeKey("KEY_End", {});
+ synthesizeKey("KEY_End");
check(true, false, "'End' key on combobox during dropdown open #" + i);
}
for (var i = 0; i < 2; i++) {
reset()
- synthesizeKey("KEY_Home", {});
+ synthesizeKey("KEY_Home");
check(true, false, "'Home' key on combobox during dropdown open #" + i);
}
testCloseDropDown(function () {
reset()
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
}, function () {
testOpenDropDown(function () {
check(true, true, "'Enter' key on combobox at closing dropdown");
synthesizeKey("KEY_ArrowUp", {altKey: true});
}, function () {
check(true, false, "'Alt' + 'ArrowUp' key on combobox at opening dropdown");
testCloseDropDown(function () {
reset()
- synthesizeKey("KEY_Escape", {});
+ synthesizeKey("KEY_Escape");
}, function () {
check(true, false, "'Escape' key on combobox at closing dropdown");
// F4 key opens/closes dropdown only on Windows. So, other platforms
// don't need to do anymore.
if (!kIsWin) {
aCallback();
return;
}
testOpenDropDown(function () {
reset()
- synthesizeKey("KEY_F4", {});
+ synthesizeKey("KEY_F4");
}, function () {
check(true, false, "'F4' key on combobox at opening dropdown on Windows");
testCloseDropDown(function () {
reset()
- synthesizeKey("KEY_F4", {});
+ synthesizeKey("KEY_F4");
}, function () {
check(true, false, "'F4' key on combobox at closing dropdown on Windows");
aCallback();
return;
});
});
});
--- a/layout/forms/test/test_listcontrol_search.html
+++ b/layout/forms/test/test_listcontrol_search.html
@@ -13,17 +13,17 @@ https://bugzilla.mozilla.org/show_bug.cg
/** This test will focus a select element and press a key that matches the
first non-space character of an entry. **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var select = document.getElementsByTagName('select')[0];
select.focus();
- synthesizeKey('a', {});
+ sendString('a');
is(select.options[0].selected, false, "the first option isn't selected");
is(select.options[1].selected, true, "the second option is selected");
select.blur();
SimpleTest.finish();
});
--- a/layout/generic/test/test_bug240933.html
+++ b/layout/generic/test/test_bug240933.html
@@ -33,28 +33,28 @@ https://bugzilla.mozilla.org/show_bug.cg
synthesizeMouse(t, t.clientWidth / 2, 5, {}, window);
is(t.selectionStart, 3, "The selection should be set before the newline");
is(t.selectionEnd, 3, "The selection should be set before the newline");
t = document.getElementById("ta");
t.focus();
t.selectionStart = t.selectionEnd = t.value.length;
var val = t.value;
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
is(t.value, val + "\n", "Pressing enter right after focusing the textarea should work");
t = document.getElementById("tb");
t.focus();
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
is(t.value, "\n", "Pressing enter for the first time should work");
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
is(t.value, "\n\n", "Pressing enter for the second time should work");
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(t.value, "\n", "Pressing backspace for the first time should work");
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(t.value, "", "Pressing backspace for the second time should work");
SimpleTest.finish();
});
</script>
</pre>
<textarea id="t" rows="10" cols="10">abc
--- a/layout/generic/test/test_bug288789.html
+++ b/layout/generic/test/test_bug288789.html
@@ -38,22 +38,22 @@ function test() {
var textarea = $("ta");
function collapse(offset) {
textarea.selectionStart = offset;
textarea.selectionEnd = offset;
}
function testRight(offset) {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
is(textarea.selectionStart, offset, "Right movement broken");
}
function testLeft(offset) {
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
is(textarea.selectionStart, offset, "Left movement broken");
}
textarea.focus();
collapse(0);
ok(true, "Testing forward movement in RTL mode");
for (var i = 0; i < textarea.textContent.length; ++i) {
if (i == 0) {
--- a/layout/generic/test/test_bug404872.html
+++ b/layout/generic/test/test_bug404872.html
@@ -21,18 +21,18 @@ https://bugzilla.mozilla.org/show_bug.cg
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/* Focus, press key down twice, and make sure we successfully selected the second item. */
$('a').focus();
-synthesizeKey("VK_DOWN", {});
-synthesizeKey("VK_DOWN", {});
+synthesizeKey("KEY_ArrowDown");
+synthesizeKey("KEY_ArrowDown");
is($("a").value, "value2", "value2 should be selected!");
</script>
</pre>
</body>
</html>
--- a/layout/generic/test/test_bug424627.html
+++ b/layout/generic/test/test_bug424627.html
@@ -23,17 +23,17 @@ enough text</textarea></td></tr></table>
/** Test for Bug 424627 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var t = document.querySelector("textarea")
t.focus();
var originalValue = t.value;
synthesizeMouse(t, 10, 30, {accelKey: true});
- synthesizeKey("x", {});
+ sendString("x");
t = document.querySelector("textarea")
ok(t, "The text area should not be removed from the document");
isnot(t.value, originalValue, "Its value should be modified");
SimpleTest.finish();
});
</script>
</pre>
--- a/layout/generic/test/test_bug448860.html
+++ b/layout/generic/test/test_bug448860.html
@@ -37,21 +37,17 @@ https://bugzilla.mozilla.org/show_bug.cg
/** Test for Bug 448860 **/
function mapChange(mapNo){
$('innermapBox').style.display = 'none';
}
function focusarea() {
- synthesizeKey("VK_TAB", {});
- synthesizeKey("VK_TAB", {});
- synthesizeKey("VK_TAB", {});
- synthesizeKey("VK_TAB", {});
- synthesizeKey("VK_TAB", {});
+ synthesizeKey("KEY_Tab", {repeat: 5});
ok(true, "we did not crash");
SimpleTest.finish();
}
function delayed_focusarea() {
setTimeout(focusarea,100);
}
SimpleTest.waitForExplicitFinish();
--- a/layout/generic/test/test_bug468167.html
+++ b/layout/generic/test/test_bug468167.html
@@ -37,17 +37,17 @@ function runTests()
ta.value = s;
is(ta.scrollTop, 0, "scrolled to top after adding content");
ta.scrollTop = 9999; // scroll down as far as we can
isnot(ta.scrollTop, 0, "scrolled down after scrolling down");
ta.setSelectionRange(0, 99); // 33 lines out of 40
// Send a backspace key event to delete the selection
- synthesizeKey("VK_BACK_SPACE", { });
+ synthesizeKey("KEY_Backspace");
is(ta.scrollTop, 0, "scrolled to top after deleting selection");
SimpleTest.finish();
}
</script>
</pre>
--- a/layout/generic/test/test_bug597333.html
+++ b/layout/generic/test/test_bug597333.html
@@ -17,17 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<pre id="test">
<script>
function runTests() {
var t = document.getElementById("a");
t.focus();
setTimeout(function() {
- synthesizeKey('VK_RIGHT', {});
+ synthesizeKey('KEY_ArrowRight');
ok(true, "The browser did not crash!");
SimpleTest.finish();
}, 0);
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTests);
--- a/layout/generic/test/test_bug632379.xul
+++ b/layout/generic/test/test_bug632379.xul
@@ -174,18 +174,18 @@ var count=0;
function snapshot(elem)
{
todo(false, "snapshot() called");
pos[count] = elem.getBoundingClientRect().top;
++count;
if (count <= 1) {
// close the submenu and open the bottom submenu
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("9", {});
+ synthesizeKey("KEY_ArrowLeft");
+ sendString("9");
} else {
if (!navigator.platform.includes("Mac")) {
is(pos[1], pos[0], "Popup should open in the same place when the menu is scrolled");
} else {
todo(false, "This test fails on Mac since it was ported to chrome: Bug 668716.");
}
todo(false, "Test finished");
gFinished = true;
@@ -200,17 +200,17 @@ function doTest() {
}
function openSubmenu()
{
if (!gFinished) {
todo(false, "openSubmenu() called");
}
// open a submenu in the middle
- synthesizeKey("5", {});
+ sendString("5");
}
SimpleTest.waitForExplicitFinish();
todo(false, "Wait for focus");
SimpleTest.waitForFocus(doTest);
]]></script>
</window>
--- a/layout/generic/test/test_bug756984.html
+++ b/layout/generic/test/test_bug756984.html
@@ -81,56 +81,51 @@ https://bugzilla.mozilla.org/show_bug.cg
theDiv.focus();
var originalHTML = theDiv.innerHTML;
sel.collapse(theDiv, 0);
synthesizeMouse(theDiv, 100, 2, {});
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be in text node (1)");
is(selRange.endOffset, 10, "offset should be 10");
- synthesizeKey("X", {});
+ sendString("X");
// 2) Down arrow to the end of the second line, add "Y".
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be in text node (2)");
is(selRange.endOffset, 3, "offset should be 3");
- synthesizeKey("Y", {});
+ sendString("Y");
// 3) Right arrow and end key to the end of the third line, add "Z".
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
if (navigator.platform.indexOf("Win") == 0) {
- synthesizeKey("VK_END", {});
+ synthesizeKey("KEY_End");
} else {
// End key doesn't work as expected on Mac and Linux.
sel.modify("move", "right", "lineboundary");
}
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be in text node (3)");
is(selRange.endOffset, 12, "offset should be 12");
- synthesizeKey("Z", {});
+ sendString("Z");
// 4) Up arrow to the end of the second line, add "T".
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be in text node (4)");
is(selRange.endOffset, 4, "offset should be 4");
- synthesizeKey("T", {});
+ sendString("T");
// 5) Left arrow six times to the end of the first line, add "A".
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft", {repeat: 6});
selRange = sel.getRangeAt(0);
is(selRange.endContainer.nodeName, "#text", "selection should be in text node (5)");
is(selRange.endOffset, 11, "offset should be 11");
- synthesizeKey("A", {});
+ sendString("A");
// Check the resulting HTML. First prepare what we expect.
originalHTML = originalHTML.replace(/1234567890/, "1234567890XA");
originalHTML = originalHTML.replace(/abc/, "abcYT");
originalHTML = originalHTML.replace(/defghijklmno/, "defghijklmnoZ");
var newHTML = theDiv.innerHTML;
is(newHTML, originalHTML, "unexpected HTML");
}
--- a/layout/generic/test/test_bug784410.html
+++ b/layout/generic/test/test_bug784410.html
@@ -64,17 +64,17 @@ function doneTest() {
if (wheelAndPaintDone && step == 3) {
SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
SimpleTest.finish();
}
}
function test() {
sel.collapse(inner.firstChild, 2);
- synthesizeKey("VK_PAGE_DOWN", {});
+ synthesizeKey("KEY_PageDown");
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({"set":[[smoothScrollPref, false]]}, test);
});
</script>
</pre>
--- a/layout/generic/test/test_bug791616.html
+++ b/layout/generic/test/test_bug791616.html
@@ -38,17 +38,17 @@ SimpleTest.waitForFocus(function() {
});
function runTest() {
is(target.getBoundingClientRect().top, targetY, "Target should not have scrolled due to waitForFocus");
t.focus();
is(target.getBoundingClientRect().top, targetY, "Target should not have scrolled due to focus change");
// Move the caret to scroll it into view
sel.collapse(target.firstChild, 2);
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
// Delay until next repaint in case stuff is asynchronous. Also
// take a trip through the event loop.
setTimeout(function() {
window.requestAnimationFrame(function() {
is(sel.anchorNode, target.firstChild, "Should have selected 'target' text node");
is(sel.anchorOffset, 1, "Selection should have moved left one character");
// We should not have needed to scroll the caret into view
--- a/layout/generic/test/test_bug904810.html
+++ b/layout/generic/test/test_bug904810.html
@@ -30,74 +30,74 @@ SimpleTest.waitForExplicitFinish();
// We intermittently trigger two "Wrong parent style context" assertions
// on B2G emulator builds (bug XXXXXXX). The two frames that get incorrect
// style context parents are scroll bar parts in the <textarea>.
SimpleTest.expectAssertions(0, 2);
SimpleTest.waitForFocus(function test() {
function shiftLeft(i) {
for ( ; i > 0; --i)
- synthesizeKey("VK_LEFT", {shiftKey:true});
+ synthesizeKey("KEY_ArrowLeft", {shiftKey:true});
}
function shiftRight(i) {
for ( ; i > 0; --i)
- synthesizeKey("VK_RIGHT", {shiftKey:true});
+ synthesizeKey("KEY_ArrowRight", {shiftKey:true});
}
const isWindows = /WINNT/.test(SpecialPowers.OS);
var textarea = document.getElementById('textarea904810');
textarea.focus();
- // Testing VK_DOWN with forward selection
+ // Testing KEY_ArrowDown with forward selection
textarea.selectionStart = 1;
textarea.selectionEnd = 1;
shiftRight(7);
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
if (isWindows) {
is(textarea.selectionStart, 19, "caret moved to next line below selection end");
is(textarea.selectionEnd, 19, "caret moved to next line below selection end");
} else {
is(textarea.selectionStart, 8, "caret moved to visual end of selection");
is(textarea.selectionEnd, 8, "caret moved to visual end of selection");
}
- // Testing VK_DOWN with backward selection
+ // Testing KEY_ArrowDown with backward selection
textarea.selectionStart = 8;
textarea.selectionEnd = 8;
shiftLeft(7);
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
if (isWindows) {
is(textarea.selectionStart, 12, "caret moved to next line below selection start");
is(textarea.selectionEnd, 12, "caret moved to next line below selection start");
} else {
is(textarea.selectionStart, 8, "caret moved to visual end of selection");
is(textarea.selectionEnd, 8, "caret moved to visual end of selection");
}
- // Testing VK_UP with forward selection
+ // Testing KEY_ArrowUp with forward selection
textarea.selectionStart = 12;
textarea.selectionEnd = 12;
shiftRight(7);
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
var result = textarea.selectionEnd
if (isWindows) {
is(textarea.selectionStart, 8, "caret moved to previous line above selection end");
is(textarea.selectionEnd, 8, "caret moved to previous line above selection end");
} else {
is(textarea.selectionStart, 12, "caret moved to visual start of selection");
is(textarea.selectionEnd, 12, "caret moved to visual start of selection");
}
- // Testing VK_UP with backward selection
+ // Testing KEY_ArrowUp with backward selection
textarea.selectionStart = 19;
textarea.selectionEnd = 19;
shiftLeft(7);
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
var result = textarea.selectionEnd
if (isWindows) {
is(textarea.selectionStart, 1, "caret moved to previous line above selection start");
is(textarea.selectionEnd, 1, "caret moved to previous line above selection start");
} else {
is(textarea.selectionStart, 12, "caret moved to visual start of selection");
is(textarea.selectionEnd, 12, "caret moved to visual start of selection");
}
--- a/layout/generic/test/test_bug970363.html
+++ b/layout/generic/test/test_bug970363.html
@@ -29,21 +29,21 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForFocus(function() {
var t = document.getElementById("t");
var editablediv = document.getElementById("editablediv");
var sel = window.getSelection();
editablediv.focus();
sel.collapse(t, 0);
// Move past the 'S' char.
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
// Move across the span.
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
// Insert an 'I' to show when IP currently is.
- synthesizeKey("I", {});
+ sendString("I");
is(t.textContent, "SreadonlyIE", "the 'I' char should be inserted between 'readonly' and 'E'");
SimpleTest.finish();
});
</script>
</pre>
--- a/layout/generic/test/test_movement_by_characters.html
+++ b/layout/generic/test/test_movement_by_characters.html
@@ -29,23 +29,23 @@ function focusing() {
setTimeout(test, 0);
}
function test() {
var sel = window.getSelection();
var editor = document.getElementById("editor");
function testRight(node, offset) {
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
is(sel.anchorNode, node, "Right movement broken in " + editor.innerHTML);
is(sel.anchorOffset, offset, "Right movement broken in " + editor.innerHTML);
}
function testLeft(node, offset) {
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
is(sel.anchorNode, node, "Left movement broken in " + editor.innerHTML);
is(sel.anchorOffset, offset, "Left movement broken in " + editor.innerHTML);
}
editor.innerHTML = "H K";
sel.collapse(editor.firstChild, 0);
testRight(editor.firstChild, 1);
testRight(editor.firstChild, 2);
--- a/layout/style/test/chrome/test_display_mode.html
+++ b/layout/style/test/chrome/test_display_mode.html
@@ -59,24 +59,24 @@ add_task(async function() {
shouldApply("all and (display-mode: browser)");
shouldNotApply("all and (display-mode: fullscreen)");
shouldNotApply("all and (display-mode: standalone)");
shouldNotApply("all and (display-mode: minimal-ui)");
// Test entering the OS's fullscreen mode.
var fullScreenEntered = waitOneEvent(win, "sizemodechange");
- synthesizeKey("VK_F11", {});
+ synthesizeKey("KEY_F11");
await fullScreenEntered;
// Wait for the next tick to apply media feature changes. See bug 1430380.
await promiseNextTick();
shouldApply("all and (display-mode: fullscreen)");
shouldNotApply("all and (display-mode: browser)");
var fullScreenExited = waitOneEvent(win, "sizemodechange");
- synthesizeKey("VK_F11", {});
+ synthesizeKey("KEY_F11");
await fullScreenExited;
// Wait for the next tick to apply media feature changes. See bug 1430380.
await promiseNextTick();
shouldNotApply("all and (display-mode: fullscreen)");
shouldApply("all and (display-mode: browser)");
// Test entering fullscreen through document requestFullScreen.
fullScreenEntered = waitOneEvent(document, "mozfullscreenchange");
--- a/layout/style/test/chrome/test_display_mode_reflow.html
+++ b/layout/style/test/chrome/test_display_mode_reflow.html
@@ -38,24 +38,24 @@ add_task(async function() {
var bodyComputedStyled = subdoc.defaultView.getComputedStyle(subdoc.body);
var win = Services.wm.getMostRecentWindow("navigator:browser");
var secondDiv = subdoc.getElementById("b");
var offsetTop = secondDiv.offsetTop;
// Test entering the OS's fullscreen mode.
var fullScreenEntered = waitOneEvent(win, "sizemodechange");
- synthesizeKey("VK_F11", {});
+ synthesizeKey("KEY_F11");
await fullScreenEntered;
// Wait for the next tick to apply media feature changes. See bug 1430380.
await promiseNextTick();
ok(offsetTop !== secondDiv.offsetTop, "offset top changes");
var fullScreenExited = waitOneEvent(win, "sizemodechange");
- synthesizeKey("VK_F11", {});
+ synthesizeKey("KEY_F11");
await fullScreenExited;
// Wait for the next tick to apply media feature changes. See bug 1430380.
await promiseNextTick();
ok(offsetTop === secondDiv.offsetTop, "offset top returns to original value");
offsetTop = secondDiv.offsetTop;
// Test entering fullscreen through document requestFullScreen.
--- a/layout/style/test/test_flexbox_focus_order.html
+++ b/layout/style/test/test_flexbox_focus_order.html
@@ -55,17 +55,17 @@ function doTest() {
// First, we focus something just before the flex container:
document.getElementById('beforeContainer').focus();
is(document.activeElement, document.getElementById('beforeContainer'),
"explicitly-focused link should gain focus");
// And then we advance focus across the focusable things in the flex container
// and check that we traverse them in the expected order:
for (let expectedId of gExpectedFocusedIds) {
- synthesizeKey("KEY_Tab", {});
+ synthesizeKey("KEY_Tab");
is(document.activeElement, document.getElementById(expectedId),
"expecting element '#" + expectedId + "' to be focused");
}
SimpleTest.finish();
}
// Before we start, we have to bump Mac to make its 'tab'-key focus behavior
--- a/layout/xul/test/browser_bug1163304.js
+++ b/layout/xul/test/browser_bug1163304.js
@@ -14,22 +14,22 @@ function test() {
setTimeout(function () {
is(DOMWindowUtils.IMEStatus, DOMWindowUtils.IME_STATUS_ENABLED,
"IME should be available even when the popup of searchbar is open");
searchPopup.addEventListener("popuphidden", function (aEvent) {
setTimeout(function () {
is(DOMWindowUtils.IMEStatus, DOMWindowUtils.IME_STATUS_DISABLED,
"IME should not be available when menubar is active");
// Inactivate the menubar (and restore the focus to the searchbar
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
is(DOMWindowUtils.IMEStatus, DOMWindowUtils.IME_STATUS_ENABLED,
"IME should be available after focus is back to the searchbar");
Services.prefs.clearUserPref("browser.search.widget.inNavBar");
finish();
}, 0);
}, {once: true});
// Activate the menubar, then, the popup should be closed
- EventUtils.synthesizeKey("VK_ALT", {});
+ EventUtils.synthesizeKey("KEY_Alt");
}, 0);
}, {once: true});
// Open popup of the searchbar
- EventUtils.synthesizeKey("VK_F4", {});
+ EventUtils.synthesizeKey("KEY_F4");
}
--- a/testing/mochitest/tests/Harness_sanity/test_sanity.html
+++ b/testing/mochitest/tests/Harness_sanity/test_sanity.html
@@ -28,23 +28,23 @@ isnot(0, false, "0 must not be false");
isnot(0, true, "0 must not be true");
isnot("", 0, "Empty string must not be 0");
isnot("1", 1, "Numeric string must not equal the number");
isnot("", null, "Empty string must not be null");
isnot(undefined, null, "Undefined must not be null");
var press1 = false;
$("testKeyEvent1").focus();
-synthesizeKey("x", {});
+sendString("x");
is($("testKeyEvent1").value, "x", "synthesizeKey should work");
is(press1, true, "synthesizeKey should dispatch keyPress");
var press2 = false;
$("testKeyEvent2").focus();
-synthesizeKey("x", {});
+sendString("x");
is($("testKeyEvent2").value, "", "synthesizeKey should respect keydown preventDefault");
is(press2, false, "synthesizeKey should not dispatch keyPress with default prevented");
var press3 = false;
$("testKeyEvent3").focus();
sendChar("x")
is($("testKeyEvent3").value, "x", "sendChar should work");
is(press3, true, "sendChar should dispatch keyPress");
--- a/testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html
+++ b/testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html
@@ -107,17 +107,17 @@ function starttest() {
* toolkit/content/tests/chrome/test_mousescroll.xul
*/
synthesizeWheel($("scrollB"), 5, 5, {'deltaY': 10.0, deltaMode: WheelEvent.DOM_DELTA_LINE});
/* test synthesizeKey* */
check = false;
$("testKeyEvent").addEventListener("keypress", function() { check = true; });
$("testKeyEvent").focus();
- synthesizeKey("a", {});
+ sendString("a");
is($("testKeyEvent").value, "a", "synthesizeKey should work");
is(check, true, "synthesizeKey should dispatch keyPress");
$("testKeyEvent").value = "";
check = false;
synthesizeKeyExpectEvent("a", {}, $("testKeyEvent"), "keypress");
is($("testKeyEvent").value, "a", "synthesizeKey should work");
is(check, true, "synthesizeKey should dispatch keyPress");
--- a/toolkit/components/passwordmgr/test/browser/browser_formless_submit_chrome.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_formless_submit_chrome.js
@@ -34,27 +34,27 @@ add_task(async function setup() {
add_task(async function test_urlbar_new_URL() {
await withTestPage(async function(aBrowser) {
gURLBar.value = "";
let focusPromise = BrowserTestUtils.waitForEvent(gURLBar, "focus");
gURLBar.focus();
await focusPromise;
info("focused");
EventUtils.sendString("http://mochi.test:8888/");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
await BrowserTestUtils.browserLoaded(aBrowser, false, "http://mochi.test:8888/");
});
});
add_task(async function test_urlbar_fragment_enter() {
await withTestPage(function(aBrowser) {
gURLBar.focus();
- EventUtils.synthesizeKey("VK_RIGHT", {});
+ EventUtils.synthesizeKey("KEY_ArrowRight");
EventUtils.sendString("#fragment");
- EventUtils.synthesizeKey("VK_RETURN", {});
+ EventUtils.synthesizeKey("KEY_Enter");
});
});
add_task(async function test_backButton_forwardButton() {
await withTestPage(async function(aBrowser) {
// Load a new page in the tab so we can test going back
aBrowser.loadURI("https://example.com" + DIRECTORY_PATH + "formless_basic.html?second");
await BrowserTestUtils.browserLoaded(aBrowser, false,
@@ -122,12 +122,12 @@ add_task(async function test_back_keyboa
// Load a new page in the tab so we can test going back
aBrowser.loadURI("https://example.com" + DIRECTORY_PATH + "formless_basic.html?second");
await BrowserTestUtils.browserLoaded(aBrowser, false,
"https://example.com" + DIRECTORY_PATH +
"formless_basic.html?second");
await fillTestPage(aBrowser);
let backPromise = BrowserTestUtils.browserStopped(aBrowser);
- EventUtils.synthesizeKey("VK_BACK_SPACE", {});
+ EventUtils.synthesizeKey("KEY_Backspace");
await backPromise;
});
});
--- a/toolkit/components/passwordmgr/test/browser/browser_notifications_2.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_notifications_2.js
@@ -31,18 +31,18 @@ add_task(async function test_empty_passw
await promiseShown;
let notificationElement = PopupNotifications.panel.childNodes[0];
let passwordTextbox = notificationElement.querySelector("#password-notification-password");
let toggleCheckbox = notificationElement.querySelector("#password-notification-visibilityToggle");
// Synthesize input to empty the field
passwordTextbox.focus();
- await EventUtils.synthesizeKey("VK_RIGHT", {});
- await EventUtils.synthesizeKey("VK_BACK_SPACE", {});
+ await EventUtils.synthesizeKey("KEY_ArrowRight");
+ await EventUtils.synthesizeKey("KEY_Backspace");
let mainActionButton = notificationElement.button;
Assert.ok(mainActionButton.disabled, "Main action button is disabled");
// Makes sure submiting an empty password throws an error
Assert.throws(notificationElement.button.doCommand(),
"Can't add a login with a null or empty password.",
"Should fail for an empty password");
--- a/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_4.html
+++ b/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_4.html
@@ -16,23 +16,23 @@
<input id="user" name="user" type="text">
<input id="pass" name="pass" type="password">
<button type='submit'>Submit</button>
</form>
<script>
function startAutocomplete() {
userField.focus();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
setTimeout(submitForm, 100);
}
function submitForm() {
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
setTimeout(function() { form.submit(); }, 100);
}
var form = document.getElementById("form");
var userField = document.getElementById("user");
window.addEventListener("message", () => { startAutocomplete(); });
--- a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html
@@ -92,101 +92,101 @@ add_task(async function setup() {
add_task(async function test_empty_first_entry() {
// Make sure initial form is empty.
checkACForm("", "");
// Trigger autocomplete popup
restoreForm();
let popupState = await getPopupState();
is(popupState.open, false, "Check popup is initially closed");
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
let results = await shownPromise;
popupState = await getPopupState();
is(popupState.selectedIndex, -1, "Check no entries are selected");
checkArrayValues(results, ["name", "name1", "name2"], "initial");
// Check first entry
let index0Promise = notifySelectedIndex(0);
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
await index0Promise;
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("name", "pass");
});
add_task(async function test_empty_second_entry() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("name1", "pass1");
});
add_task(async function test_search() {
restoreForm();
let shownPromise = promiseACShown();
// We need to blur for the autocomplete controller to notice the forced value below.
uname.blur();
uname.value = "name";
uname.focus();
sendChar("1");
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
let results = await shownPromise;
checkArrayValues(results, ["name1"], "check result deduping for 'name1'");
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("name1", "pass1");
let popupState = await getPopupState();
is(popupState.open, false, "Check popup is now closed");
});
add_task(async function test_delete_first_entry() {
restoreForm();
uname.focus();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
await shownPromise;
let index0Promise = notifySelectedIndex(0);
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
await index0Promise;
let deletionPromise = promiseStorageChanged(["removeLogin"]);
// On OS X, shift-backspace and shift-delete work, just delete does not.
// On Win/Linux, shift-backspace does not work, delete and shift-delete do.
synthesizeKey("KEY_Delete", {shiftKey: true});
await deletionPromise;
checkACForm("", "");
let results = await notifyMenuChanged(2, "name1");
checkArrayValues(results, ["name1", "name2"], "two should remain after deleting the first");
let popupState = await getPopupState();
is(popupState.open, true, "Check popup stays open after deleting");
- synthesizeKey("KEY_Escape", {});
+ synthesizeKey("KEY_Escape");
popupState = await getPopupState();
is(popupState.open, false, "Check popup closed upon ESC");
});
add_task(async function test_delete_duplicate_entry() {
restoreForm();
uname.focus();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
await shownPromise;
let index0Promise = notifySelectedIndex(0);
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
await index0Promise;
let deletionPromise = promiseStorageChanged(["removeLogin"]);
// On OS X, shift-backspace and shift-delete work, just delete does not.
// On Win/Linux, shift-backspace does not work, delete and shift-delete do.
synthesizeKey("KEY_Delete", {shiftKey: true});
await deletionPromise;
checkACForm("", "");
@@ -198,17 +198,17 @@ add_task(async function test_delete_dupl
// Two menu items should remain as the HTTPS login should have been deleted but
// the HTTP would remain.
let results = await notifyMenuChanged(1, "name2");
checkArrayValues(results, ["name2"], "one should remain after deleting the HTTPS name1");
let popupState = await getPopupState();
is(popupState.open, true, "Check popup stays open after deleting");
- synthesizeKey("KEY_Escape", {});
+ synthesizeKey("KEY_Escape");
popupState = await getPopupState();
is(popupState.open, false, "Check popup closed upon ESC");
});
</script>
</pre>
</body>
</html>
--- a/toolkit/components/passwordmgr/test/mochitest/test_autofocus_js.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_autofocus_js.html
@@ -57,18 +57,18 @@ add_task(async function setup() {
iframeDoc = iframe.contentDocument;
SimpleTest.requestFlakyTimeout("Giving a chance for the unexpected popupshown to occur");
});
add_task(async function test_initial_focus() {
let results = await notifyMenuChanged(2, "name");
checkArrayValues(results, ["name", "name1"], "Two results");
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
is(iframeDoc.getElementById("form-basic-password").value, "pass", "Check first password filled");
let popupState = await getPopupState();
is(popupState.open, false, "Check popup is now closed");
});
// This depends on the filling from the previous test.
add_task(async function test_not_reopened_if_filled() {
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
@@ -223,214 +223,214 @@ add_task(async function test_form1_initi
is(popupState.open, false, "Check popup is initially closed");
});
add_task(async function test_form1_menuitems() {
await SimpleTest.promiseFocus(window);
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
let results = await shownPromise;
let popupState = await getPopupState();
is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
let expectedMenuItems = ["tempuser1",
"testuser2",
"testuser3",
"zzzuser4"];
checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
checkACForm("", ""); // value shouldn't update just by selecting
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await spinEventLoop(); // let focus happen
checkACForm("", "");
});
add_task(async function test_form1_first_entry() {
await SimpleTest.promiseFocus(window);
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
let popupState = await getPopupState();
is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
- synthesizeKey("KEY_ArrowDown", {}); // first
+ synthesizeKey("KEY_ArrowDown"); // first
checkACForm("", ""); // value shouldn't update just by selecting
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("tempuser1", "temppass1");
});
add_task(async function test_form1_second_entry() {
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_third_entry() {
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_ArrowDown", {}); // third
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_ArrowDown"); // third
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser3", "testpass3");
});
add_task(async function test_form1_fourth_entry() {
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_ArrowDown", {}); // third
- synthesizeKey("KEY_ArrowDown", {}); // fourth
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_ArrowDown"); // third
+ synthesizeKey("KEY_ArrowDown"); // fourth
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_wraparound_first_entry() {
// Trigger autocomplete popup
restoreForm();
await spinEventLoop(); // let focus happen
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_ArrowDown", {}); // third
- synthesizeKey("KEY_ArrowDown", {}); // fourth
- synthesizeKey("KEY_ArrowDown", {}); // deselects
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_ArrowDown"); // third
+ synthesizeKey("KEY_ArrowDown"); // fourth
+ synthesizeKey("KEY_ArrowDown"); // deselects
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("tempuser1", "temppass1");
});
add_task(async function test_form1_wraparound_up_last_entry() {
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowUp", {}); // last (fourth)
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowUp"); // last (fourth)
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_wraparound_down_up_up() {
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // select first entry
- synthesizeKey("KEY_ArrowUp", {}); // selects nothing!
- synthesizeKey("KEY_ArrowUp", {}); // select last entry
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // select first entry
+ synthesizeKey("KEY_ArrowUp"); // selects nothing!
+ synthesizeKey("KEY_ArrowUp"); // select last entry
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_wraparound_up_last() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowUp", {}); // deselects
- synthesizeKey("KEY_ArrowUp", {}); // last entry
- synthesizeKey("KEY_ArrowUp", {});
- synthesizeKey("KEY_ArrowUp", {});
- synthesizeKey("KEY_ArrowUp", {}); // first entry
- synthesizeKey("KEY_ArrowUp", {}); // deselects
- synthesizeKey("KEY_ArrowUp", {}); // last entry
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowUp"); // deselects
+ synthesizeKey("KEY_ArrowUp"); // last entry
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_ArrowUp"); // first entry
+ synthesizeKey("KEY_ArrowUp"); // deselects
+ synthesizeKey("KEY_ArrowUp"); // last entry
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_fill_username_without_autofill_right() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Set first entry w/o triggering autocomplete
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowRight", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowRight");
await spinEventLoop();
checkACForm("tempuser1", ""); // empty password
});
add_task(async function test_form1_fill_username_without_autofill_left() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Set first entry w/o triggering autocomplete
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowLeft");
checkACForm("tempuser1", ""); // empty password
});
add_task(async function test_form1_pageup_first() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Check first entry (page up)
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_PageUp", {}); // first
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_PageUp"); // first
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("tempuser1", "temppass1");
});
add_task(async function test_form1_pagedown_last() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
/* test 13 */
// Check last entry (page down)
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_PageDown", {}); // last
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_PageDown"); // last
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_untrusted_event() {
restoreForm();
await spinEventLoop();
@@ -440,131 +440,131 @@ add_task(async function test_form1_untru
sendFakeAutocompleteEvent(uname);
await spinEventLoop();
checkACForm("zzzuser4", "");
});
add_task(async function test_form1_delete() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// XXX tried sending character "t" before/during dropdown to test
// filtering, but had no luck. Seemed like the character was getting lost.
// Setting uname.value didn't seem to work either. This works with a human
// driver, so I'm not sure what's up.
// Delete the first entry (of 4), "tempuser1"
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
var numLogins;
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 5, "Correct number of logins before deleting one");
let countChangedPromise = notifyMenuChanged(3);
var deletionPromise = promiseStorageChanged(["removeLogin"]);
// On OS X, shift-backspace and shift-delete work, just delete does not.
// On Win/Linux, shift-backspace does not work, delete and shift-delete do.
synthesizeKey("KEY_Delete", {shiftKey: true});
await deletionPromise;
checkACForm("", "");
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 4, "Correct number of logins after deleting one");
await countChangedPromise;
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_first_after_deletion() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Check the new first entry (of 3)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_delete_second() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Delete the second entry (of 3), "testuser3"
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
synthesizeKey("KEY_Delete", {shiftKey: true});
checkACForm("", "");
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 3, "Correct number of logins after deleting one");
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_first_after_deletion2() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Check the new first entry (of 2)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_delete_last() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
/* test 54 */
// Delete the last entry (of 2), "zzzuser4"
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
synthesizeKey("KEY_Delete", {shiftKey: true});
checkACForm("", "");
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 2, "Correct number of logins after deleting one");
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_first_after_3_deletions() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Check the only remaining entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_check_only_entry_remaining() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
/* test 56 */
// Delete the only remaining entry, "testuser2"
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
synthesizeKey("KEY_Delete", {shiftKey: true});
checkACForm("", "");
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 1, "Correct number of logins after deleting one");
// remove the login that's not shown in the list.
setupScript.sendSyncMessage("removeLogin", "login0");
});
@@ -573,91 +573,91 @@ add_task(async function test_form1_check
add_task(async function test_form2() {
// Turn our attention to form2
uname = $_(2, "uname");
pword = $_(2, "pword");
checkACForm("singleuser5", "singlepass5");
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("singleuser5", "singlepass5");
});
add_task(async function test_form3() {
uname = $_(3, "uname");
pword = $_(3, "pword");
checkACForm("singleuser5", "singlepass5");
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("singleuser5", "singlepass5");
});
add_task(async function test_form4() {
uname = $_(4, "uname");
pword = $_(4, "pword");
checkACForm("singleuser5", "singlepass5");
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("singleuser5", "singlepass5");
});
add_task(async function test_form5() {
uname = $_(5, "uname");
pword = $_(5, "pword");
checkACForm("singleuser5", "singlepass5");
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("singleuser5", "singlepass5");
});
add_task(async function test_form6() {
// (this is a control, w/o autocomplete=off, to ensure the login
// that was being suppressed would have been filled in otherwise)
uname = $_(6, "uname");
pword = $_(6, "pword");
checkACForm("singleuser5", "singlepass5");
});
add_task(async function test_form6_changeUsername() {
// Test that the password field remains filled in after changing
// the username.
uname.focus();
- synthesizeKey("KEY_ArrowRight", {});
+ synthesizeKey("KEY_ArrowRight");
synthesizeKey("X", {shiftKey: true});
// Trigger the 'blur' event on uname
pword.focus();
await spinEventLoop();
checkACForm("singleuser5X", "singlepass5");
setupScript.sendSyncMessage("removeLogin", "login5");
});
@@ -679,23 +679,23 @@ add_task(async function test_form7() {
// automatically, removing it makes it more likely that we'll catch a
// future regression with form filling here.
setupScript.sendSyncMessage("removeLogin", "login6B");
});
add_task(async function test_form7_2() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
// The form changes, so we expect the old username field to get the
// selected autocomplete value, but neither the new username field nor
// the password field should have any values filled in.
await spinEventLoop();
checkACForm("form7user1", "");
is($_(7, "uname2").value, "", "Verifying empty uname2");
restoreForm(); // clear field, so reloading test doesn't fail
@@ -731,64 +731,64 @@ add_task(async function test_form9_filte
pword = $_(9, "pword");
uname.focus();
let shownPromise = promiseACShown();
sendString("form9userAB");
await shownPromise;
checkACForm("form9userAB", "");
uname.focus();
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowLeft");
shownPromise = promiseACShown();
synthesizeKey("A", {shiftKey: true});
let results = await shownPromise;
checkACForm("form9userAAB", "");
checkArrayValues(results, ["form9userAAB"], "Check dropdown is updated after inserting 'A'");
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("form9userAAB", "form9pass");
});
add_task(async function test_form9_autocomplete_cache() {
// Note that this addLogin call will only be seen by the autocomplete
// attempt for the synthesizeKey if we do not successfully cache the
// autocomplete results.
setupScript.sendSyncMessage("addLogin", "login8C");
uname.focus();
let promise0 = notifyMenuChanged(0);
- synthesizeKey("z", {});
+ sendString("z");
await promise0;
let popupState = await getPopupState();
is(popupState.open, false, "Check popup shouldn't open");
// check that empty results are cached - bug 496466
promise0 = notifyMenuChanged(0);
- synthesizeKey("z", {});
+ sendString("z");
await promise0;
popupState = await getPopupState();
is(popupState.open, false, "Check popup stays closed due to cached empty result");
});
add_task(async function test_form11_formless() {
// Test form-less autocomplete
uname = $_(11, "uname");
pword = $_(11, "pword");
restoreForm();
checkACForm("", "");
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Trigger autocomplete
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
let processedPromise = promiseFormsProcessed();
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await processedPromise;
checkACForm("testuser", "testpass");
});
add_task(async function test_form11_open_on_trusted_focus() {
uname = $_(11, "uname");
pword = $_(11, "pword");
uname.value = "";
@@ -803,19 +803,19 @@ add_task(async function test_form11_open
ok(e.isTrusted, "Ensure event is trusted");
resolve();
});
});
const shownPromise = promiseACShown();
synthesizeMouseAtCenter(uname, {});
await firePrivEventPromise;
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
const processedPromise = promiseFormsProcessed();
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await processedPromise;
checkACForm("testuser", "testpass");
});
add_task(async function test_form12_recipes() {
await loadRecipes({
siteRecipes: [{
"hosts": ["mochi.test:8888"],
@@ -829,31 +829,31 @@ add_task(async function test_form12_reci
// First test DOMAutocomplete
// Switch the password field to type=password so _fillForm marks the username
// field for autocomplete.
pword.type = "password";
await promiseFormsProcessed();
restoreForm();
checkACForm("", "");
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser10", "testpass10");
// Now test recipes with blur on the username field.
restoreForm();
checkACForm("", "");
uname.value = "testuser10";
checkACForm("testuser10", "");
- synthesizeKey("KEY_Tab", {});
+ synthesizeKey("KEY_Tab");
await promiseFormsProcessed();
checkACForm("testuser10", "testpass10");
await resetRecipes();
});
</script>
</pre>
</body>
</html>
--- a/toolkit/components/passwordmgr/test/mochitest/test_case_differences.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_case_differences.html
@@ -81,66 +81,66 @@ add_task(async function test_empty_first
/* test 1 */
// Make sure initial form is empty.
checkACForm("", "");
// Trigger autocomplete popup
restoreForm();
let popupState = await getPopupState();
is(popupState.open, false, "Check popup is initially closed");
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
let results = await shownPromise;
popupState = await getPopupState();
is(popupState.selectedIndex, -1, "Check no entries are selected");
checkArrayValues(results, ["name", "Name", "USER"], "initial");
// Check first entry
let index0Promise = notifySelectedIndex(0);
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
await index0Promise;
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("name", "pass");
});
add_task(async function test_empty_second_entry() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("Name", "Pass");
});
add_task(async function test_empty_third_entry() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_ArrowDown", {}); // third
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_ArrowDown"); // third
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("USER", "PASS");
});
add_task(async function test_preserve_matching_username_case() {
restoreForm();
uname.value = "user";
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Check that we don't clobber user-entered text when tabbing away
// (even with no autocomplete entry selected)
- synthesizeKey("KEY_Tab", {});
+ synthesizeKey("KEY_Tab");
await promiseFormsProcessed();
checkACForm("user", "PASS");
});
</script>
</pre>
</body>
</html>
--- a/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html
@@ -222,226 +222,226 @@ add_task(async function test_form1_initi
is(popupState.open, false, "Check popup is initially closed");
});
add_task(async function test_form1_warning_entry() {
await SimpleTest.promiseFocus(window);
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
let results = await shownPromise;
let popupState = await getPopupState();
is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
let expectedMenuItems = ["This connection is not secure. Logins entered here could be compromised. Learn More",
"tempuser1",
"testuser2",
"testuser3",
"zzzuser4"];
checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
- synthesizeKey("KEY_ArrowDown", {}); // select insecure warning
+ synthesizeKey("KEY_ArrowDown"); // select insecure warning
checkACForm("", ""); // value shouldn't update just by selecting
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await spinEventLoop(); // let focus happen
checkACForm("", "");
});
add_task(async function test_form1_first_entry() {
await SimpleTest.promiseFocus(window);
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
let popupState = await getPopupState();
is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
- synthesizeKey("KEY_ArrowDown", {}); // first
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // first
checkACForm("", ""); // value shouldn't update just by selecting
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("tempuser1", "temppass1");
});
add_task(async function test_form1_second_entry() {
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_third_entry() {
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_ArrowDown", {}); // third
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_ArrowDown"); // third
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser3", "testpass3");
});
add_task(async function test_form1_fourth_entry() {
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_ArrowDown", {}); // third
- synthesizeKey("KEY_ArrowDown", {}); // fourth
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_ArrowDown"); // third
+ synthesizeKey("KEY_ArrowDown"); // fourth
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_wraparound_first_entry() {
// Trigger autocomplete popup
restoreForm();
await spinEventLoop(); // let focus happen
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_ArrowDown", {}); // third
- synthesizeKey("KEY_ArrowDown", {}); // fourth
- synthesizeKey("KEY_ArrowDown", {}); // deselects
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_ArrowDown"); // third
+ synthesizeKey("KEY_ArrowDown"); // fourth
+ synthesizeKey("KEY_ArrowDown"); // deselects
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("tempuser1", "temppass1");
});
add_task(async function test_form1_wraparound_up_last_entry() {
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowUp", {}); // last (fourth)
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowUp"); // last (fourth)
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_wraparound_down_up_up() {
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // select first entry
- synthesizeKey("KEY_ArrowUp", {}); // selects nothing!
- synthesizeKey("KEY_ArrowUp", {}); // select last entry
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // select first entry
+ synthesizeKey("KEY_ArrowUp"); // selects nothing!
+ synthesizeKey("KEY_ArrowUp"); // select last entry
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_wraparound_up_last() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowUp", {}); // deselects
- synthesizeKey("KEY_ArrowUp", {}); // last entry
- synthesizeKey("KEY_ArrowUp", {});
- synthesizeKey("KEY_ArrowUp", {});
- synthesizeKey("KEY_ArrowUp", {}); // skip insecure warning
- synthesizeKey("KEY_ArrowUp", {}); // first entry
- synthesizeKey("KEY_ArrowUp", {}); // deselects
- synthesizeKey("KEY_ArrowUp", {}); // last entry
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowUp"); // deselects
+ synthesizeKey("KEY_ArrowUp"); // last entry
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_ArrowUp"); // skip insecure warning
+ synthesizeKey("KEY_ArrowUp"); // first entry
+ synthesizeKey("KEY_ArrowUp"); // deselects
+ synthesizeKey("KEY_ArrowUp"); // last entry
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_fill_username_without_autofill_right() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Set first entry w/o triggering autocomplete
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowRight", {});
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowRight");
await spinEventLoop();
checkACForm("tempuser1", ""); // empty password
});
add_task(async function test_form1_fill_username_without_autofill_left() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Set first entry w/o triggering autocomplete
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowLeft");
checkACForm("tempuser1", ""); // empty password
});
add_task(async function test_form1_pageup_first() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// Check first entry (page up)
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // second
- synthesizeKey("KEY_PageUp", {}); // first
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_ArrowDown"); // second
+ synthesizeKey("KEY_PageUp"); // first
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("tempuser1", "temppass1");
});
add_task(async function test_form1_pagedown_last() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// test 13
// Check last entry (page down)
- synthesizeKey("KEY_ArrowDown", {}); // first
- synthesizeKey("KEY_PageDown", {}); // last
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // first
+ synthesizeKey("KEY_PageDown"); // last
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_untrusted_event() {
restoreForm();
await spinEventLoop();
@@ -451,138 +451,138 @@ add_task(async function test_form1_untru
sendFakeAutocompleteEvent(uname);
await spinEventLoop();
checkACForm("zzzuser4", "");
});
add_task(async function test_form1_delete() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
// XXX tried sending character "t" before/during dropdown to test
// filtering, but had no luck. Seemed like the character was getting lost.
// Setting uname.value didn't seem to work either. This works with a human
// driver, so I'm not sure what's up.
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// Delete the first entry (of 4), "tempuser1"
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
var numLogins;
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 5, "Correct number of logins before deleting one");
let countChangedPromise = notifyMenuChanged(4);
var deletionPromise = promiseStorageChanged(["removeLogin"]);
// On OS X, shift-backspace and shift-delete work, just delete does not.
// On Win/Linux, shift-backspace does not work, delete and shift-delete do.
synthesizeKey("KEY_Delete", {shiftKey: true});
await deletionPromise;
checkACForm("", "");
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 4, "Correct number of logins after deleting one");
await countChangedPromise;
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_first_after_deletion() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// Check the new first entry (of 3)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_delete_second() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// Delete the second entry (of 3), "testuser3"
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
synthesizeKey("KEY_Delete", {shiftKey: true});
checkACForm("", "");
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 3, "Correct number of logins after deleting one");
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("zzzuser4", "zzzpass4");
});
add_task(async function test_form1_first_after_deletion2() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// Check the new first entry (of 2)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_delete_last() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// test 54
// Delete the last entry (of 2), "zzzuser4"
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
synthesizeKey("KEY_Delete", {shiftKey: true});
checkACForm("", "");
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 2, "Correct number of logins after deleting one");
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_first_after_3_deletions() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// Check the only remaining entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(async function test_form1_check_only_entry_remaining() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// test 56
// Delete the only remaining entry, "testuser2"
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
synthesizeKey("KEY_Delete", {shiftKey: true});
checkACForm("", "");
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 1, "Correct number of logins after deleting one");
// remove the login that's not shown in the list.
setupScript.sendSyncMessage("removeLogin", "login0");
});
@@ -591,95 +591,95 @@ add_task(async function test_form1_check
add_task(async function test_form2() {
// Turn our attention to form2
uname = $_(2, "uname");
pword = $_(2, "pword");
checkACForm("singleuser5", "singlepass5");
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("singleuser5", "singlepass5");
});
add_task(async function test_form3() {
uname = $_(3, "uname");
pword = $_(3, "pword");
checkACForm("singleuser5", "singlepass5");
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("singleuser5", "singlepass5");
});
add_task(async function test_form4() {
uname = $_(4, "uname");
pword = $_(4, "pword");
checkACForm("singleuser5", "singlepass5");
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("singleuser5", "singlepass5");
});
add_task(async function test_form5() {
uname = $_(5, "uname");
pword = $_(5, "pword");
checkACForm("singleuser5", "singlepass5");
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("singleuser5", "singlepass5");
});
add_task(async function test_form6() {
// (this is a control, w/o autocomplete=off, to ensure the login
// that was being suppressed would have been filled in otherwise)
uname = $_(6, "uname");
pword = $_(6, "pword");
checkACForm("singleuser5", "singlepass5");
});
add_task(async function test_form6_changeUsername() {
// Test that the password field remains filled in after changing
// the username.
uname.focus();
- synthesizeKey("KEY_ArrowRight", {});
+ synthesizeKey("KEY_ArrowRight");
synthesizeKey("X", {shiftKey: true});
// Trigger the 'blur' event on uname
pword.focus();
await spinEventLoop();
checkACForm("singleuser5X", "singlepass5");
setupScript.sendSyncMessage("removeLogin", "login5");
});
@@ -701,24 +701,24 @@ add_task(async function test_form7() {
// automatically, removing it makes it more likely that we'll catch a
// future regression with form filling here.
setupScript.sendSyncMessage("removeLogin", "login6B");
});
add_task(async function test_form7_2() {
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
// The form changes, so we expect the old username field to get the
// selected autocomplete value, but neither the new username field nor
// the password field should have any values filled in.
await spinEventLoop();
checkACForm("form7user1", "");
is($_(7, "uname2").value, "", "Verifying empty uname2");
restoreForm(); // clear field, so reloading test doesn't fail
@@ -754,48 +754,48 @@ add_task(async function test_form9_filte
pword = $_(9, "pword");
uname.focus();
let shownPromise = promiseACShown();
sendString("form9userAB");
await shownPromise;
checkACForm("form9userAB", "");
uname.focus();
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowLeft");
shownPromise = promiseACShown();
synthesizeKey("A", {shiftKey: true});
let results = await shownPromise;
checkACForm("form9userAAB", "");
checkArrayValues(results, ["This connection is not secure. Logins entered here could be compromised. Learn More", "form9userAAB"],
"Check dropdown is updated after inserting 'A'");
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("form9userAAB", "form9pass");
});
add_task(async function test_form9_autocomplete_cache() {
// Note that this addLogin call will only be seen by the autocomplete
// attempt for the synthesizeKey if we do not successfully cache the
// autocomplete results.
setupScript.sendSyncMessage("addLogin", "login8C");
uname.focus();
let promise0 = notifyMenuChanged(1);
let shownPromise = promiseACShown();
- synthesizeKey("z", {});
+ sendString("z");
await promise0;
await shownPromise;
let popupState = await getPopupState();
is(popupState.open, true, "Check popup should open");
// check that empty results are cached - bug 496466
promise0 = notifyMenuChanged(1);
- synthesizeKey("z", {});
+ sendString("z");
await promise0;
popupState = await getPopupState();
is(popupState.open, true, "Check popup stays opened due to cached empty result");
});
add_task(async function test_form11_recipes() {
await loadRecipes({
siteRecipes: [{
@@ -810,52 +810,52 @@ add_task(async function test_form11_reci
// First test DOMAutocomplete
// Switch the password field to type=password so _fillForm marks the username
// field for autocomplete.
pword.type = "password";
await promiseFormsProcessed();
restoreForm();
checkACForm("", "");
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await promiseFormsProcessed();
checkACForm("testuser10", "testpass10");
// Now test recipes with blur on the username field.
restoreForm();
checkACForm("", "");
uname.value = "testuser10";
checkACForm("testuser10", "");
- synthesizeKey("KEY_Tab", {});
+ synthesizeKey("KEY_Tab");
await promiseFormsProcessed();
checkACForm("testuser10", "testpass10");
await resetRecipes();
});
add_task(async function test_form12_formless() {
// Test form-less autocomplete
uname = $_(12, "uname");
pword = $_(12, "pword");
restoreForm();
checkACForm("", "");
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
- synthesizeKey("KEY_ArrowDown", {}); // skip insecure warning
+ synthesizeKey("KEY_ArrowDown"); // skip insecure warning
// Trigger autocomplete
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkACForm("", ""); // value shouldn't update
let processedPromise = promiseFormsProcessed();
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await processedPromise;
checkACForm("testuser", "testpass");
});
</script>
</pre>
</body>
</html>
--- a/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_no_saved_login.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_no_saved_login.html
@@ -77,26 +77,26 @@ add_task(async function test_form1_initi
is(popupState.open, false, "Check popup is initially closed");
});
add_task(async function test_form1_warning_entry() {
await SimpleTest.promiseFocus(window);
// Trigger autocomplete popup
restoreForm();
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
await shownPromise;
let popupState = await getPopupState();
is(popupState.open, true, "Check popup is opened");
is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
- synthesizeKey("KEY_ArrowDown", {}); // select insecure warning
+ synthesizeKey("KEY_ArrowDown"); // select insecure warning
checkACForm("", ""); // value shouldn't update just by selecting
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await spinEventLoop(); // let focus happen
checkACForm("", "");
});
</script>
</pre>
</body>
</html>
--- a/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html
@@ -165,131 +165,131 @@ add_task(async function test_form1_initi
add_task(async function test_form2_password_readonly() {
await SpecialPowers.pushPrefEnv({"set": [
["security.insecure_field_warning.contextual.enabled", true],
["signon.autofillForms.http", true]
]});
await reinitializeForm(2);
// Trigger autocomplete popup
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
let popupState = await getPopupState();
is(popupState.open, false, "Check popup is closed for a readonly field.");
});
add_task(async function test_form3_password_disabled() {
await SpecialPowers.pushPrefEnv({"set": [
["security.insecure_field_warning.contextual.enabled", true],
["signon.autofillForms.http", true]
]});
await reinitializeForm(3);
// Trigger autocomplete popup
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
let popupState = await getPopupState();
is(popupState.open, false, "Check popup is closed for a disabled field.");
});
add_task(async function test_form1_enabledInsecureFieldWarning_enabledInsecureAutoFillForm() {
await SpecialPowers.pushPrefEnv({"set": [
["security.insecure_field_warning.contextual.enabled", true],
["signon.autofillForms.http", true]
]});
await reinitializeForm(1);
// Trigger autocomplete popup
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
let results = await shownPromise;
let popupState = await getPopupState();
is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
let expectedMenuItems = ["This connection is not secure. Logins entered here could be compromised. Learn More",
"No username (" + DATE_NOW_STRING + ")",
"tempuser1",
"testuser2",
"testuser3",
"zzzuser4"];
checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
- synthesizeKey("KEY_ArrowDown", {}); // select insecure warning
+ synthesizeKey("KEY_ArrowDown"); // select insecure warning
checkACFormPasswordField(""); // value shouldn't update just by selecting
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await spinEventLoop(); // let focus happen
checkACFormPasswordField("");
});
add_task(async function test_form1_disabledInsecureFieldWarning_enabledInsecureAutoFillForm() {
await SpecialPowers.pushPrefEnv({"set": [
["security.insecure_field_warning.contextual.enabled", false],
["signon.autofillForms.http", true]
]});
await reinitializeForm(1);
// Trigger autocomplete popup
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
let results = await shownPromise;
let popupState = await getPopupState();
is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
let expectedMenuItems = ["No username (" + DATE_NOW_STRING + ")",
"tempuser1",
"testuser2",
"testuser3",
"zzzuser4"];
checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
- synthesizeKey("KEY_ArrowDown", {}); // select first item
+ synthesizeKey("KEY_ArrowDown"); // select first item
checkACFormPasswordField(""); // value shouldn't update just by selecting
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await spinEventLoop(); // let focus happen
checkACFormPasswordField("user0pass");
});
add_task(async function test_form1_enabledInsecureFieldWarning_disabledInsecureAutoFillForm() {
await SpecialPowers.pushPrefEnv({"set": [
["security.insecure_field_warning.contextual.enabled", true],
["signon.autofillForms.http", false]
]});
await reinitializeForm(1);
// Trigger autocomplete popup
let shownPromise = promiseACShown();
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
let results = await shownPromise;
let popupState = await getPopupState();
is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
let expectedMenuItems = ["This connection is not secure. Logins entered here could be compromised. Learn More",
"No username (" + DATE_NOW_STRING + ")",
"tempuser1",
"testuser2",
"testuser3",
"zzzuser4"];
checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
- synthesizeKey("KEY_ArrowDown", {}); // select insecure warning
+ synthesizeKey("KEY_ArrowDown"); // select insecure warning
checkACFormPasswordField(""); // value shouldn't update just by selecting
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
await spinEventLoop(); // let focus happen
checkACFormPasswordField("");
});
add_task(async function test_form1_disabledInsecureFieldWarning_disabledInsecureAutoFillForm() {
await SpecialPowers.pushPrefEnv({"set": [
["security.insecure_field_warning.contextual.enabled", false],
["signon.autofillForms.http", false]
]});
await reinitializeForm(1);
// Trigger autocomplete popup
- synthesizeKey("KEY_ArrowDown", {}); // open
+ synthesizeKey("KEY_ArrowDown"); // open
let popupState = await getPopupState();
is(popupState.open, false, "Check popup is closed with no AutoFillForms.");
});
</script>
</pre>
</body>
</html>
--- a/toolkit/components/satchel/test/test_bug_511615.html
+++ b/toolkit/components/satchel/test/test_bug_511615.html
@@ -159,31 +159,31 @@ add_task(async function test_untrusted_e
]) {
// We must wait for the entire timeout for each individual test, because the
// next event in the list might prevent the popup from opening.
await expectPopupDoesNotOpen(triggerFn);
}
// A privileged key press will actually open the popup.
let popupShown = waitForNextPopup();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
await popupShown;
// The selected autocomplete item should not change from untrusted events.
for (let triggerFn of [
() => doKeyUnprivileged("down"),
() => doKeyUnprivileged("page_down"),
]) {
triggerFn();
await checkSelectedIndexAfterResponseTime(-1);
}
// A privileged key press will actually change the selected index.
let indexChanged = new Promise(resolve => notifySelectedIndex(0, resolve));
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
await indexChanged;
// The selected autocomplete item should not change and it should not be
// possible to use it from untrusted events.
for (let triggerFn of [
() => doKeyUnprivileged("down"),
() => doKeyUnprivileged("page_down"),
() => doKeyUnprivileged("right"),
--- a/toolkit/components/satchel/test/test_datalist_with_caching.html
+++ b/toolkit/components/satchel/test/test_datalist_with_caching.html
@@ -98,39 +98,39 @@ function checkMenuEntries(expectedValues
for (let i = 0; i < expectedValues.length; i++) {
is(actualValues[i], expectedValues[i], testNum + " Checking menu entry #" + i);
}
}
async function runTests() {
testNum++;
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
await expectPopup();
checkMenuEntries(["Sec", "First", "Second", "Secomundo"]);
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("Sec");
testNum++;
restoreForm();
sendString("Sec");
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
await expectPopup();
testNum++;
checkMenuEntries(["Sec", "Second", "Secomundo"]);
sendString("o");
await waitForMenuChange(2);
testNum++;
checkMenuEntries(["Second", "Secomundo"]);
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("Second");
SimpleTest.finish();
}
function startTest() {
setupFormHistory(runTests);
}
--- a/toolkit/components/satchel/test/test_form_autocomplete.html
+++ b/toolkit/components/satchel/test/test_form_autocomplete.html
@@ -246,196 +246,196 @@ function runTest() { // eslint-disable-l
switch (testNum) {
case 1:
// Make sure initial form is empty.
checkForm("");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 2:
checkMenuEntries(["value1", "value2", "value3", "value4"], testNum);
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkForm(""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
checkForm("value1");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 3:
// Check second entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("value2");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 4:
// Check third entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("value3");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 5:
// Check fourth entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("value4");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 6:
// Check first entry (wraparound)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {}); // deselects
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown"); // deselects
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("value1");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 7:
// Check the last entry via arrow-up
- synthesizeKey("KEY_ArrowUp", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_Enter");
checkForm("value4");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 8:
// Check the last entry via arrow-up
- synthesizeKey("KEY_ArrowDown", {}); // select first entry
- synthesizeKey("KEY_ArrowUp", {}); // selects nothing!
- synthesizeKey("KEY_ArrowUp", {}); // select last entry
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown"); // select first entry
+ synthesizeKey("KEY_ArrowUp"); // selects nothing!
+ synthesizeKey("KEY_ArrowUp"); // select last entry
+ synthesizeKey("KEY_Enter");
checkForm("value4");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 9:
// Check the last entry via arrow-up (wraparound)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowUp", {}); // deselects
- synthesizeKey("KEY_ArrowUp", {}); // last entry
- synthesizeKey("KEY_ArrowUp", {});
- synthesizeKey("KEY_ArrowUp", {});
- synthesizeKey("KEY_ArrowUp", {}); // first entry
- synthesizeKey("KEY_ArrowUp", {}); // deselects
- synthesizeKey("KEY_ArrowUp", {}); // last entry
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowUp"); // deselects
+ synthesizeKey("KEY_ArrowUp"); // last entry
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKey("KEY_ArrowUp"); // first entry
+ synthesizeKey("KEY_ArrowUp"); // deselects
+ synthesizeKey("KEY_ArrowUp"); // last entry
+ synthesizeKey("KEY_Enter");
checkForm("value4");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 10:
// Set first entry w/o triggering autocomplete
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowRight", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowRight");
checkForm("value1");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 11:
// Set first entry w/o triggering autocomplete
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowLeft");
checkForm("value1");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 12:
// Check first entry (page up)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_PageUp", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_PageUp");
+ synthesizeKey("KEY_Enter");
checkForm("value1");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 13:
// Check last entry (page down)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_PageDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_PageDown");
+ synthesizeKey("KEY_Enter");
checkForm("value4");
// Trigger autocomplete popup
testNum = 49;
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
/* Test removing entries from the dropdown */
case 50:
checkMenuEntries(["value1", "value2", "value3", "value4"], testNum);
// Delete the first entry (of 4)
setForm("value");
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
// On OS X, shift-backspace and shift-delete work, just delete does not.
// On Win/Linux, shift-backspace does not work, delete and shift-delete do.
if (SpecialPowers.OS == "Darwin") {
synthesizeKey("KEY_Backspace", {shiftKey: true});
} else {
synthesizeKey("KEY_Delete", {shiftKey: true});
}
@@ -450,121 +450,121 @@ function runTest() { // eslint-disable-l
countEntries("field1", "value1",
function(num) {
ok(!num, testNum + " checking that f1/v1 was deleted");
runTest();
});
break;
case 52:
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
checkForm("value2");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 53:
checkMenuEntries(["value2", "value3", "value4"], testNum);
// Check the new first entry (of 3)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("value2");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 54:
// Delete the second entry (of 3)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
synthesizeKey("KEY_Delete", {shiftKey: true});
waitForMenuChange(2);
break;
case 55:
checkForm("");
countEntries("field1", "value3",
function(num) {
ok(!num, testNum + " checking that f1/v3 was deleted");
runTest();
});
break;
case 56:
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
checkForm("value4");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 57:
checkMenuEntries(["value2", "value4"], testNum);
// Check the new first entry (of 2)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("value2");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 58:
// Delete the last entry (of 2)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
synthesizeKey("KEY_Delete", {shiftKey: true});
checkForm("");
waitForMenuChange(1);
break;
case 59:
countEntries("field1", "value4",
function(num) {
ok(!num, testNum + " checking that f1/v4 was deleted");
runTest();
});
break;
case 60:
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
checkForm("value2");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 61:
checkMenuEntries(["value2"], testNum);
// Check the new first entry (of 1)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("value2");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 62:
// Delete the only remaining entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
synthesizeKey("KEY_Delete", {shiftKey: true});
waitForMenuChange(0);
break;
case 63:
checkForm("");
countEntries("field1", "value2",
function(num) {
@@ -574,54 +574,54 @@ function runTest() { // eslint-disable-l
break;
case 64:
// Look at form 2, trigger autocomplete popup
input = $_(2, "field2");
testNum = 99;
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
/* Test entries with autocomplete=off */
case 100:
// Select first entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("value1");
// Look at form 3, try to trigger autocomplete popup
input = $_(3, "field2");
restoreForm();
// Sometimes, this will fail if scrollTo(0, 0) is called, so that doesn't
// happen here. Fortunately, a different input is used from the last test,
// so a scroll should still occur.
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
waitForScroll();
break;
case 101:
// Ensure there's no autocomplete dropdown (autocomplete=off is present)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("");
// Look at form 4, try to trigger autocomplete popup
input = $_(4, "field2");
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
waitForMenuChange(0);
break;
case 102:
// Ensure there's no autocomplete dropdown (autocomplete=off is present)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("");
// Look at form 5, try to trigger autocomplete popup
input = $_(5, "field3");
restoreForm();
testNum = 199;
expectPopup();
input.focus();
@@ -641,51 +641,51 @@ function runTest() { // eslint-disable-l
checkMenuEntries(["aa", "aaz", "aa\xe6"], testNum);
input.focus();
sendChar("\xc6");
waitForMenuChange(1);
break;
case 202:
checkMenuEntries(["aa\xe6"], testNum);
- synthesizeKey("KEY_Backspace", {});
+ synthesizeKey("KEY_Backspace");
waitForMenuChange(3);
break;
case 203:
checkMenuEntries(["aa", "aaz", "aa\xe6"], testNum);
- synthesizeKey("KEY_Backspace", {});
+ synthesizeKey("KEY_Backspace");
waitForMenuChange(5);
break;
case 204:
checkMenuEntries(["a", "aa", "aaz", "aa\xe6", "az"], testNum);
input.focus();
sendChar("z");
waitForMenuChange(2);
break;
case 205:
checkMenuEntries(["az", "aaz"], testNum);
input.focus();
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowLeft");
expectPopup();
// Check case-insensitivity.
sendChar("A");
break;
case 206:
checkMenuEntries(["aaz"], testNum);
addEntry("field3", "aazq");
break;
case 207:
// check that results were cached
input.focus();
- synthesizeKey("KEY_ArrowRight", {});
+ synthesizeKey("KEY_ArrowRight");
sendChar("q");
waitForMenuChange(0);
break;
case 208:
// check that results were cached
checkMenuEntries([], testNum);
addEntry("field3", "aazqq");
@@ -696,17 +696,17 @@ function runTest() { // eslint-disable-l
window.scrollTo(0, 0);
sendChar("q");
waitForMenuChange(0);
break;
case 210:
// check that empty results were cached - bug 496466
checkMenuEntries([], testNum);
- synthesizeKey("KEY_Escape", {});
+ synthesizeKey("KEY_Escape");
// Look at form 6, try to trigger autocomplete popup
input = $_(6, "field4");
restoreForm();
testNum = 249;
expectPopup();
input.focus();
sendChar("a");
@@ -749,17 +749,17 @@ function runTest() { // eslint-disable-l
waitForMenuChange(2);
break;
case 254:
// check multi-word substring matches
checkMenuEntries(["bc d\xe6", "aba\xe6"]);
input.focus();
expectPopup();
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowLeft");
sendChar("d");
break;
case 255:
// check inserting in multi-word searches
checkMenuEntries(["bc d\xe6"], testNum);
input.focus();
sendChar("z");
@@ -769,142 +769,142 @@ function runTest() { // eslint-disable-l
case 256:
checkMenuEntries([], testNum);
// Look at form 7, try to trigger autocomplete popup
input = $_(7, "field5");
testNum = 299;
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 300:
checkMenuEntries(["1", "12", "123", "1234"], testNum);
input.maxLength = 4;
expectPopup();
- synthesizeKey("KEY_Escape", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_Escape");
+ synthesizeKey("KEY_ArrowDown");
break;
case 301:
checkMenuEntries(["1", "12", "123", "1234"], testNum);
input.maxLength = 3;
expectPopup();
- synthesizeKey("KEY_Escape", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_Escape");
+ synthesizeKey("KEY_ArrowDown");
break;
case 302:
checkMenuEntries(["1", "12", "123"], testNum);
input.maxLength = 2;
expectPopup();
- synthesizeKey("KEY_Escape", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_Escape");
+ synthesizeKey("KEY_ArrowDown");
break;
case 303:
checkMenuEntries(["1", "12"], testNum);
input.maxLength = 1;
expectPopup();
- synthesizeKey("KEY_Escape", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_Escape");
+ synthesizeKey("KEY_ArrowDown");
break;
case 304:
checkMenuEntries(["1"], testNum);
input.maxLength = 0;
- synthesizeKey("KEY_Escape", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_Escape");
+ synthesizeKey("KEY_ArrowDown");
waitForMenuChange(0);
break;
case 305:
checkMenuEntries([], testNum);
input.maxLength = 4;
// now again with a character typed
input.focus();
sendChar("1");
expectPopup();
- synthesizeKey("KEY_Escape", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_Escape");
+ synthesizeKey("KEY_ArrowDown");
break;
case 306:
checkMenuEntries(["1", "12", "123", "1234"], testNum);
input.maxLength = 3;
expectPopup();
- synthesizeKey("KEY_Escape", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_Escape");
+ synthesizeKey("KEY_ArrowDown");
break;
case 307:
checkMenuEntries(["1", "12", "123"], testNum);
input.maxLength = 2;
expectPopup();
- synthesizeKey("KEY_Escape", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_Escape");
+ synthesizeKey("KEY_ArrowDown");
break;
case 308:
checkMenuEntries(["1", "12"], testNum);
input.maxLength = 1;
expectPopup();
- synthesizeKey("KEY_Escape", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_Escape");
+ synthesizeKey("KEY_ArrowDown");
break;
case 309:
checkMenuEntries(["1"], testNum);
input.maxLength = 0;
- synthesizeKey("KEY_Escape", {});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_Escape");
+ synthesizeKey("KEY_ArrowDown");
waitForMenuChange(0);
break;
case 310:
checkMenuEntries([], testNum);
input = $_(8, "field6");
testNum = 399;
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 400:
case 401:
case 402:
case 403:
checkMenuEntries(["value"], testNum);
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("value");
if (testNum == 400) {
input = $_(9, "field7");
} else if (testNum == 401) {
input = $_(10, "field8");
} else if (testNum == 402) {
input = $_(11, "field9");
} else if (testNum == 403) {
todo(false, "Fix input type=number");
input = $_(12, "field10");
}
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 404:
checkMenuEntries(["42"], testNum);
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("42");
input = $_(14, "field11");
restoreForm();
waitForMenuChange(0);
break;
case 405:
@@ -919,108 +919,108 @@ function runTest() { // eslint-disable-l
case 406:
checkMenuEntries([]); // type=time with it's own control frame does not
// have a drop down menu for now
checkForm("");
input = $_(16, "field13");
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
waitForMenuChange(0);
break;
case 407:
checkMenuEntries([]); // type=range does not have a drop down menu
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("30"); // default (midway between minimum (0) and maximum (64)) - step
input = $_(17, "field14");
restoreForm();
waitForMenuChange(0);
break;
case 408:
checkMenuEntries([]); // type=color does not have a drop down menu
checkForm("#000000"); // default color value
input = $_(18, "field15");
restoreForm();
expectPopup();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 409:
checkMenuEntries(["2016-08"]);
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("2016-08");
input = $_(19, "field16");
restoreForm();
expectPopup();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 410:
checkMenuEntries(["2016-W32"]);
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("2016-W32");
input = $_(20, "field17");
restoreForm();
expectPopup();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 411:
checkMenuEntries(["2016-10-21T10:10"]);
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("2016-10-21T10:10");
addEntry("field1", "value1");
break;
case 412:
input = $_(1, "field1");
// Go to test 500.
testNum = 499;
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
// Check that the input event is fired.
case 500:
input.addEventListener("input", function(event) {
ok(true, testNum + " oninput should have been received");
ok(event.bubbles, testNum + " input event should bubble");
ok(event.cancelable, testNum + " input event should be cancelable");
}, {once: true});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkForm("");
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
checkForm("value1");
testNum = 599;
setTimeout(runTest, 100);
break;
case 600:
// check we don't show autocomplete for searchbar-history
input = $_(13, "searchbar-history");
// Trigger autocomplete popup
checkForm("");
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
waitForMenuChange(0);
break;
case 601:
checkMenuEntries([], testNum);
input.blur();
SimpleTest.finish();
return;
--- a/toolkit/components/satchel/test/test_form_autocomplete_with_list.html
+++ b/toolkit/components/satchel/test/test_form_autocomplete_with_list.html
@@ -111,260 +111,260 @@ function runTest() {
switch (testNum) {
case 1:
// Make sure initial form is empty.
checkForm("");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 2:
checkMenuEntries(["historyvalue", "PASS1", "PASS2", "final"], testNum);
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkForm(""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
checkForm("historyvalue");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 3:
// Check second entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("Google");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 4:
// Check third entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("Reddit");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 5:
// Check fourth entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("final");
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 6:
// Delete the first entry (of 3)
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
synthesizeKey("KEY_Delete", {shiftKey: true});
waitForMenuChange(3);
break;
case 7:
checkForm("");
countEntries("field1", "historyvalue",
function(num) {
ok(!num, testNum + " checking that form history value was deleted");
runTest();
});
break;
case 8:
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
checkForm("Google");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 9:
// Test deletion
checkMenuEntries(["PASS1", "PASS2", "final"], testNum);
// Check the new first entry (of 3)
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("Google");
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 10:
// Test autocompletion of datalists with cached results.
sendString("PAS");
waitForMenuChange(2);
break;
case 11:
// Continuation of test 10
sendString("S1");
waitForMenuChange(1);
break;
case 12:
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("Google");
// Trigger autocomplete popup
// Look at form 3, try to trigger autocomplete popup
input.value = "";
input = $_(3, "field2");
testNum = 99;
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 100:
checkMenuEntries(["PASS1", "PASS2", "final"], testNum);
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkForm(""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
checkForm("Google");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 101:
// Check second entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("Reddit");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 102:
// Check third entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("final");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 103:
checkMenuEntries(["PASS1", "PASS2", "final"], testNum);
// Check first entry
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkForm(""); // value shouldn't update
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
checkForm("Google");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 104:
// Check second entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("Reddit");
// Trigger autocomplete popup
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 105:
// Check third entry
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("final");
testNum = 199;
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
// Test dynamic updates.
// For some reasons, when there is an update of the list, the selection is
// lost so we need to go down like if we were at the beginning of the list
// again.
case 200:
// Removing the second element while on the first then going down and
// push enter. Value should be one from the third suggesion.
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
datalist = document.getElementById("suggest");
let toRemove = datalist.children[1];
datalist.removeChild(toRemove);
SimpleTest.executeSoon(function() {
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("final");
// Restore the element.
datalist.insertBefore(toRemove, datalist.children[1]);
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
});
break;
case 201:
// Adding an attribute after the first one while on the first then going
// down and push enter. Value should be the on from the new suggestion.
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
datalist = document.getElementById("suggest");
let added = new Option("Foo");
datalist.insertBefore(added, datalist.children[1]);
waitForMenuChange(4);
break;
case 202:
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("Foo");
// Remove the element.
datalist = document.getElementById("suggest");
datalist.removeChild(datalist.children[1]);
waitForMenuChange(0);
break;
@@ -373,18 +373,18 @@ function runTest() {
restoreForm();
datalist = document.getElementById("suggest");
prevValue = datalist.children[0].value;
datalist.children[0].value = "foo";
expectPopup();
break;
case 204:
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("foo");
datalist = document.getElementById("suggest");
datalist.children[0].value = prevValue;
waitForMenuChange(0);
break;
case 205:
@@ -393,93 +393,92 @@ function runTest() {
datalist = document.getElementById("suggest");
prevValue = datalist.children[0].getAttribute("value");
datalist.children[0].removeAttribute("value");
datalist.children[0].textContent = "foobar";
expectPopup();
break;
case 206:
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("foobar");
datalist = document.getElementById("suggest");
datalist.children[0].setAttribute("value", prevValue);
testNum = 299;
waitForMenuChange(0);
break;
// Tests for filtering (or not).
case 300:
// Filters with first letter of the word.
restoreForm();
- synthesizeKey("f", {});
+ sendString("f");
expectPopup();
break;
case 301:
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("final");
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 302:
// Filter with a letter in the middle of the word.
- synthesizeKey("i", {});
- synthesizeKey("n", {});
+ sendString("in");
waitForMenuChange(1);
break;
case 303:
// Continuation of test 302.
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("final");
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 304:
// Filter is disabled with mozNoFilter.
input.setAttribute("mozNoFilter", "true");
- synthesizeKey("f", {});
+ sendString("f");
waitForMenuChange(3); // no change
break;
case 305:
// Continuation of test 304.
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
checkForm("Google");
input.removeAttribute("mozNoFilter");
testNum = 399;
expectPopup();
restoreForm();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
break;
case 400:
// Check that the input event is fired.
input.addEventListener("input", function(event) {
ok(true, "oninput should have been received");
ok(event.bubbles, "input event should bubble");
ok(event.cancelable, "input event should be cancelable");
checkForm("Google");
input.blur();
SimpleTest.finish();
}, {once: true});
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
checkForm("");
- synthesizeKey("KEY_Enter", {});
+ synthesizeKey("KEY_Enter");
break;
default:
ok(false, "Unexpected invocation of test #" + testNum);
SimpleTest.finish();
}
}
--- a/toolkit/components/satchel/test/test_password_autocomplete.html
+++ b/toolkit/components/satchel/test/test_password_autocomplete.html
@@ -102,22 +102,21 @@ add_task(async function test_initialize(
add_task(async function test_secure_noFormHistoryOrWarning() {
let input = $_(1, "field1");
// The autocomplete popup should not open under any circumstances on
// type=password with password manager disabled.
for (let triggerFn of [
() => input.focus(),
() => input.click(),
- () => synthesizeKey("KEY_ArrowDown", {}),
- () => synthesizeKey("KEY_PageDown", {}),
- () => synthesizeKey("KEY_Enter", {}),
- () => synthesizeKey("v", {}),
- () => synthesizeKey(" ", {}),
- () => synthesizeKey("KEY_Backspace", {}),
+ () => synthesizeKey("KEY_ArrowDown"),
+ () => synthesizeKey("KEY_PageDown"),
+ () => synthesizeKey("KEY_Enter"),
+ () => sendString("v "),
+ () => synthesizeKey("KEY_Backspace"),
]) {
ok(true, "Testing: " + triggerFn.toString());
// We must wait for the entire timeout for each individual test, because the
// next event in the list might prevent the popup from opening.
await expectPopupDoesNotOpen(triggerFn);
}
// Close the popup.
--- a/toolkit/components/satchel/test/test_popup_direction.html
+++ b/toolkit/components/satchel/test/test_popup_direction.html
@@ -41,17 +41,17 @@ add_task(async function test_popup_direc
{ op: "add", fieldname: "field1", value: "value2" },
], resolve));
for (let direction of ["ltr", "rtl"]) {
document.getElementById("content").style.direction = direction;
let popupShown = waitForNextPopup();
input.focus();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
await popupShown;
let popupState = await new Promise(resolve => getPopupState(resolve));
is(popupState.direction, direction, "Direction should match.");
// Close the popup.
input.blur();
}
--- a/toolkit/components/satchel/test/test_popup_enter_event.html
+++ b/toolkit/components/satchel/test/test_popup_enter_event.html
@@ -47,19 +47,19 @@ function handleEnter(evt) {
is(input.value, expectedValue, "Check input value when enter is pressed the 2nd time");
info("form should submit with the default handler");
} else {
ok(false, "RETURN keypress shouldn't have been received when a popup item is selected");
}
}
function popupShownListener(evt) {
- synthesizeKey("KEY_ArrowDown", {});
- synthesizeKey("KEY_Enter", {}); // select the first entry in the popup
- synthesizeKey("KEY_Enter", {}); // try to submit the form with the filled value
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter"); // select the first entry in the popup
+ synthesizeKey("KEY_Enter"); // try to submit the form with the filled value
}
function runTest() {
input.addEventListener("keypress", handleEnter, true);
form.addEventListener("submit", function submitCallback(evt) {
is(input.value, expectedValue, "Check input value in the submit handler");
evt.preventDefault();
@@ -69,17 +69,17 @@ function runTest() {
SimpleTest.finish();
});
// Focus the input before adjusting.value so that the caret goes to the end
// (since OS X doesn't show the dropdown otherwise).
input.focus();
input.value = "value";
input.focus();
- synthesizeKey("KEY_ArrowDown", {});
+ synthesizeKey("KEY_ArrowDown");
}
function startTest() {
setupFormHistory(function() {
runTest();
});
}
--- a/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js
+++ b/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js
@@ -153,17 +153,17 @@ body > div > div {width: 1000px;height:
// previous frame, no scrolling may actually occur during that frame.
// After 100ms's worth of frames, timeCompensation will be 1, making it
// more likely that the accumulated scroll in autoscrollLoop will be >= 1,
// although it also depends on acceleration, which here in this test
// should be > 1 due to how it synthesizes mouse events below.
} while (timeCompensation < 5);
// Close the autoscroll popup by synthesizing Esc.
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("KEY_Escape");
let scrollVert = test.expected & expectScrollVert;
let scrollHori = test.expected & expectScrollHori;
await ContentTask.spawn(gBrowser.selectedBrowser,
{ scrollVert,
scrollHori,
elemid: test.elem,
checkWindow: test.testwindow },
--- a/toolkit/content/tests/chrome/findbar_window.xul
+++ b/toolkit/content/tests/chrome/findbar_window.xul
@@ -511,17 +511,17 @@
await enterStringIntoFindField(searchStr);
await promiseExpectRangeCount(0);
highlightButton.click();
ok(highlightButton.checked, "testFindWithHighlight: Highlight All should be checked.");
await promiseHighlightFinished();
await promiseExpectRangeCount(3);
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
await promiseExpectRangeCount(0);
// Regression test for bug 1316513.
highlightButton.click();
ok(!highlightButton.checked, "testFindWithHighlight - 1316513: Highlight All should be unchecked.");
await enterStringIntoFindField(searchStr);
highlightButton.click();
@@ -530,17 +530,17 @@
await promiseExpectRangeCount(3);
let promise = BrowserTestUtils.browserLoaded(gBrowser);
gBrowser.reload();
await promise;
ok(highlightButton.checked, "testFindWithHighlight - 1316513: Highlight All " +
"should still be checked after a reload.");
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
await promiseHighlightFinished();
await promiseExpectRangeCount(3);
// Uncheck at test end to not interfere with other test functions that are
// run after this one.
highlightButton.click();
}
--- a/toolkit/content/tests/chrome/popup_trigger.js
+++ b/toolkit/content/tests/chrome/popup_trigger.js
@@ -77,98 +77,98 @@ var popupTests = [
compareEdge(gTrigger, gMenuPopup, "after_start", 0, 0, testname);
}
},
{
// check that pressing cursor down while there is no selection
// highlights the first item
testname: "cursor down no selection",
events: [ "DOMMenuItemActive item1" ],
- test() { synthesizeKey("VK_DOWN", { }); },
+ test() { synthesizeKey("KEY_ArrowDown"); },
result(testname) { checkActive(gMenuPopup, "item1", testname); }
},
{
// check that pressing cursor up wraps and highlights the last item
testname: "cursor up wrap",
events() {
// No wrapping on menus on Mac
return platformIsMac() ? [] : [ "DOMMenuItemInactive item1", "DOMMenuItemActive last" ];
},
- test() { synthesizeKey("VK_UP", { }); },
+ test() { synthesizeKey("KEY_ArrowUp"); },
result(testname) {
checkActive(gMenuPopup, platformIsMac() ? "item1" : "last", testname);
}
},
{
// check that pressing cursor down wraps and highlights the first item
testname: "cursor down wrap",
condition() { return !platformIsMac(); },
events: ["DOMMenuItemInactive last", "DOMMenuItemActive item1" ],
- test() { synthesizeKey("VK_DOWN", { }); },
+ test() { synthesizeKey("KEY_ArrowDown"); },
result(testname) { checkActive(gMenuPopup, "item1", testname); }
},
{
// check that pressing cursor down highlights the second item
testname: "cursor down",
events: [ "DOMMenuItemInactive item1", "DOMMenuItemActive item2" ],
- test() { synthesizeKey("VK_DOWN", { }); },
+ test() { synthesizeKey("KEY_ArrowDown"); },
result(testname) { checkActive(gMenuPopup, "item2", testname); }
},
{
// check that pressing cursor up highlights the second item
testname: "cursor up",
events: [ "DOMMenuItemInactive item2", "DOMMenuItemActive item1" ],
- test() { synthesizeKey("VK_UP", { }); },
+ test() { synthesizeKey("KEY_ArrowUp"); },
result(testname) { checkActive(gMenuPopup, "item1", testname); }
},
{
// cursor left should not do anything
testname: "cursor left",
- test() { synthesizeKey("VK_LEFT", { }); },
+ test() { synthesizeKey("KEY_ArrowLeft"); },
result(testname) { checkActive(gMenuPopup, "item1", testname); }
},
{
// cursor right should not do anything
testname: "cursor right",
- test() { synthesizeKey("VK_RIGHT", { }); },
+ test() { synthesizeKey("KEY_ArrowRight"); },
result(testname) { checkActive(gMenuPopup, "item1", testname); }
},
{
// check cursor down when a disabled item exists in the menu
testname: "cursor down disabled",
events() {
// On Windows, disabled items are included when navigating, but on
// other platforms, disabled items are skipped over
if (navigator.platform.indexOf("Win") == 0) {
return [ "DOMMenuItemInactive item1", "DOMMenuItemActive item2" ];
}
return [ "DOMMenuItemInactive item1", "DOMMenuItemActive amenu" ];
},
test() {
document.getElementById("item2").disabled = true;
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
}
},
{
// check cursor up when a disabled item exists in the menu
testname: "cursor up disabled",
events() {
if (navigator.platform.indexOf("Win") == 0) {
return [ "DOMMenuItemInactive item2", "DOMMenuItemActive amenu",
"DOMMenuItemInactive amenu", "DOMMenuItemActive item2",
"DOMMenuItemInactive item2", "DOMMenuItemActive item1" ];
}
return [ "DOMMenuItemInactive amenu", "DOMMenuItemActive item1" ];
},
test() {
if (navigator.platform.indexOf("Win") == 0)
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_UP", { });
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_ArrowUp");
if (navigator.platform.indexOf("Win") == 0)
- synthesizeKey("VK_UP", { });
+ synthesizeKey("KEY_ArrowUp");
}
},
{
testname: "mouse click outside",
events: [ "popuphiding thepopup", "popuphidden thepopup",
"DOMMenuItemInactive item1", "DOMMenuInactive thepopup" ],
test() {
gMenuPopup.hidePopup();
@@ -351,17 +351,17 @@ var popupTests = [
compareEdge(gTrigger, gMenuPopup, "end_after", 0, 0, testname);
}
},
{
testname: "close popup with escape",
events: [ "popuphiding thepopup", "popuphidden thepopup",
"DOMMenuInactive thepopup", ],
test(testname, step) {
- synthesizeKey("VK_ESCAPE", { });
+ synthesizeKey("KEY_Escape");
checkClosed("trigger", testname);
}
},
{
// check that offsets may be supplied to the openPopup method
testname: "open popup anchored with offsets",
events: [ "popupshowing thepopup", "popupshown thepopup" ],
autohide: "thepopup",
@@ -475,17 +475,17 @@ var popupTests = [
// the menuitem with the M accesskey overrides the earlier menuitem that
// begins with M.
testname: "menuitem accelerator",
events: [ "DOMMenuItemActive amenu", "DOMMenuItemInactive amenu",
"DOMMenuInactive thepopup",
"command amenu", "popuphiding thepopup", "popuphidden thepopup",
"DOMMenuItemInactive amenu"
],
- test() { synthesizeKey("M", { }); },
+ test() { sendString("M"); },
result(testname) { checkClosed("trigger", testname); }
},
{
testname: "open context popup at screen",
events: [ "popupshowing thepopup 0010", "popupshown thepopup" ],
test(testname, step) {
gExpectedTriggerNode = gCachedEvent.target;
gMenuPopup.openPopupAtScreen(gScreenX + 8, gScreenY + 16, true, gCachedEvent);
@@ -521,82 +521,82 @@ var popupTests = [
}
},
{
// pressing a letter that doesn't correspond to an accelerator, but does
// correspond to the first letter in a menu's label. The menu should not
// close because there is more than one item corresponding to that letter
testname: "menuitem with non accelerator",
events: [ "DOMMenuItemActive one" ],
- test() { synthesizeKey("O", { }); },
+ test() { sendString("O"); },
result(testname) {
checkOpen("trigger", testname);
checkActive(gMenuPopup, "one", testname);
}
},
{
// pressing the letter again should select the next one that starts with
// that letter
testname: "menuitem with non accelerator again",
events: [ "DOMMenuItemInactive one", "DOMMenuItemActive submenu" ],
- test() { synthesizeKey("O", { }); },
+ test() { sendString("O"); },
result(testname) {
// 'submenu' is a menu but it should not be open
checkOpen("trigger", testname);
checkClosed("submenu", testname);
checkActive(gMenuPopup, "submenu", testname);
}
},
{
// open the submenu with the cursor right key
testname: "open submenu with cursor right",
events: [ "popupshowing submenupopup", "DOMMenuItemActive submenuitem",
"popupshown submenupopup" ],
- test() { synthesizeKey("VK_RIGHT", { }); },
+ test() { synthesizeKey("KEY_ArrowRight"); },
result(testname) {
checkOpen("trigger", testname);
checkOpen("submenu", testname);
checkActive(gMenuPopup, "submenu", testname);
checkActive(document.getElementById("submenupopup"), "submenuitem", testname);
}
},
{
// close the submenu with the cursor left key
testname: "close submenu with cursor left",
events: [ "popuphiding submenupopup", "popuphidden submenupopup",
"DOMMenuItemInactive submenuitem", "DOMMenuInactive submenupopup",
"DOMMenuItemActive submenu" ],
- test() { synthesizeKey("VK_LEFT", { }); },
+ test() { synthesizeKey("KEY_ArrowLeft"); },
result(testname) {
checkOpen("trigger", testname);
checkClosed("submenu", testname);
checkActive(gMenuPopup, "submenu", testname);
checkActive(document.getElementById("submenupopup"), "", testname);
}
},
{
// open the submenu with the enter key
testname: "open submenu with enter",
events: [ "popupshowing submenupopup", "DOMMenuItemActive submenuitem",
"popupshown submenupopup" ],
- test() { synthesizeKey("VK_RETURN", { }); },
+ test() { synthesizeKey("KEY_Enter"); },
result(testname) {
checkOpen("trigger", testname);
checkOpen("submenu", testname);
checkActive(gMenuPopup, "submenu", testname);
checkActive(document.getElementById("submenupopup"), "submenuitem", testname);
}
},
{
// close the submenu with the escape key
testname: "close submenu with escape",
events: [ "popuphiding submenupopup", "popuphidden submenupopup",
"DOMMenuItemInactive submenuitem", "DOMMenuInactive submenupopup",
"DOMMenuItemActive submenu" ],
- test() { synthesizeKey("VK_ESCAPE", { }); },
+ test() { synthesizeKey("KEY_Escape"); },
result(testname) {
checkOpen("trigger", testname);
checkClosed("submenu", testname);
checkActive(gMenuPopup, "submenu", testname);
checkActive(document.getElementById("submenupopup"), "", testname);
}
},
{
@@ -607,41 +607,41 @@ var popupTests = [
events() {
if (navigator.platform.indexOf("Win") == 0) {
return [ "DOMMenuItemInactive submenu", "DOMMenuItemActive other",
"DOMMenuItemInactive other", "DOMMenuItemActive item1" ];
}
return [ "DOMMenuItemInactive submenu", "DOMMenuItemActive last",
"DOMMenuItemInactive last", "DOMMenuItemActive item1" ];
},
- test() { synthesizeKey("O", { }); synthesizeKey("F", { }); },
+ test() { sendString("OF"); },
result(testname) {
checkActive(gMenuPopup, "item1", testname);
}
},
{
// pressing a letter that doesn't correspond to an accelerator nor the
// first letter of a menu. This should have no effect.
testname: "menuitem with keypress no accelerator found",
- test() { synthesizeKey("G", { }); },
+ test() { sendString("G"); },
result(testname) {
checkOpen("trigger", testname);
checkActive(gMenuPopup, "item1", testname);
}
},
{
// when only one menuitem starting with that letter exists, it should be
// selected and the menu closed
testname: "menuitem with non accelerator single",
events: [ "DOMMenuItemInactive item1", "DOMMenuItemActive amenu",
"DOMMenuItemInactive amenu", "DOMMenuInactive thepopup",
"command amenu", "popuphiding thepopup", "popuphidden thepopup",
"DOMMenuItemInactive amenu",
],
- test() { synthesizeKey("M", { }); },
+ test() { sendString("M"); },
result(testname) {
checkClosed("trigger", testname);
checkActive(gMenuPopup, "", testname);
}
},
{
testname: "open context popup at screen with all modifiers set",
events: [ "popupshowing thepopup 1111", "popupshown thepopup" ],
@@ -750,71 +750,71 @@ var popupTests = [
},
{
testname: "focus and cursor down on trigger",
condition() { return gIsMenu; },
events: [ "popupshowing thepopup", "popupshown thepopup" ],
autohide: "thepopup",
test(testname, step) {
gTrigger.focus();
- synthesizeKey("VK_DOWN", { altKey: !platformIsMac() });
+ synthesizeKey("KEY_ArrowDown", {altKey: !platformIsMac()});
},
result(testname, step) {
checkOpen("trigger", testname);
checkActive(gMenuPopup, "", testname);
}
},
{
testname: "focus and cursor up on trigger",
condition() { return gIsMenu; },
events: [ "popupshowing thepopup", "popupshown thepopup" ],
test(testname, step) {
gTrigger.focus();
- synthesizeKey("VK_UP", { altKey: !platformIsMac() });
+ synthesizeKey("KEY_ArrowUp", {altKey: !platformIsMac()});
},
result(testname, step) {
checkOpen("trigger", testname);
checkActive(gMenuPopup, "", testname);
}
},
{
testname: "select and enter on menuitem",
condition() { return gIsMenu; },
events: [ "DOMMenuItemActive item1", "DOMMenuItemInactive item1",
"DOMMenuInactive thepopup", "command item1",
"popuphiding thepopup", "popuphidden thepopup",
"DOMMenuItemInactive item1" ],
test(testname, step) {
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_RETURN", { });
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
},
result(testname, step) { checkClosed("trigger", testname); }
},
{
testname: "focus trigger and key to open",
condition() { return gIsMenu; },
events: [ "popupshowing thepopup", "popupshown thepopup" ],
autohide: "thepopup",
test(testname, step) {
gTrigger.focus();
- synthesizeKey(platformIsMac() ? " " : "VK_F4", { });
+ synthesizeKey(platformIsMac() ? " " : "KEY_F4");
},
result(testname, step) {
checkOpen("trigger", testname);
checkActive(gMenuPopup, "", testname);
}
},
{
// the menu should only open when the meta or alt key is not pressed
testname: "focus trigger and key wrong modifier",
condition() { return gIsMenu; },
test(testname, step) {
gTrigger.focus();
if (platformIsMac())
- synthesizeKey("VK_F4", { altKey: true });
+ synthesizeKey("KEY_F4", {altKey: true});
else
synthesizeKey("", { metaKey: true });
},
result(testname, step) {
checkClosed("trigger", testname);
}
},
{
--- a/toolkit/content/tests/chrome/test_arrowpanel.xul
+++ b/toolkit/content/tests/chrome/test_arrowpanel.xul
@@ -196,17 +196,17 @@ function* nextTest()
// Check that the transition occurs for an arrow panel with animate="true"
window.addEventListener("transitionend", transitionEnded, false);
$("animatepanel").openPopup($("topleft"), "after_start", 0, 0, false, false, null, "start");
is($("animatepanel").state, "showing", "state is showing");
yield;
window.removeEventListener("transitionend", transitionEnded, false);
- synthesizeKey("VK_ESCAPE", { });
+ synthesizeKey("KEY_Escape");
ok(!animatedPopupHidden, "animated popup not hidden yet");
yield;
}
SimpleTest.finish()
}
function setScale(win, scale)
--- a/toolkit/content/tests/chrome/test_autocomplete2.xul
+++ b/toolkit/content/tests/chrome/test_autocomplete2.xul
@@ -122,17 +122,17 @@ function check() {
// Toggle this value, so we can re-use the one function.
returnResult = !returnResult;
// blur the field to ensure that the popup is closed and that the previous
// search has stopped, then start a new search.
autocomplete.blur();
autocomplete.focus();
- synthesizeKey("r", {});
+ sendString("r");
}
function checkResult() {
var autocomplete = $("autocomplete");
var style = window.getComputedStyle(autocomplete);
if (returnResult) {
// Result was returned, so there should not be a nomatch attribute
--- a/toolkit/content/tests/chrome/test_autocomplete3.xul
+++ b/toolkit/content/tests/chrome/test_autocomplete3.xul
@@ -124,17 +124,17 @@ function startTest() {
}
function checkNext() {
var autocomplete = $("autocomplete");
autocomplete.completeDefaultIndex = tests[currentTest].completeDefaultIndex;
autocomplete.focus();
- synthesizeKey(tests[currentTest].key, {});
+ synthesizeKey(tests[currentTest].key);
}
function checkResult() {
var autocomplete = $("autocomplete");
var style = window.getComputedStyle(autocomplete);
is(autocomplete.value, tests[currentTest].result,
"Test " + currentTest + ": autocomplete.value should equal '" +
@@ -149,21 +149,21 @@ function checkResult() {
tests[currentTest].end);
++currentTest;
if (currentTest < tests.length)
setTimeout(checkNext, 0);
else {
// TODO (bug 494809): Autocomplete-in-the-middle should take in count RTL
- // and complete on VK_RIGHT or VK_LEFT based on that. It should also revert
+ // and complete on KEY_ArrowRight or KEY_ArrowLeft based on that. It should also revert
// what user has typed to far if he moves in the opposite direction.
if (!autocomplete.value.includes(">>")) {
// Test result if user accepts autocomplete suggestion.
- synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("KEY_ArrowRight");
is(autocomplete.value, "Result",
"Test complete: autocomplete.value should equal 'Result'");
is(autocomplete.selectionStart, 6,
"Test complete: autocomplete selection should start at 6");
is(autocomplete.selectionEnd, 6,
"Test complete: autocomplete selection should end at 6");
}
--- a/toolkit/content/tests/chrome/test_autocomplete4.xul
+++ b/toolkit/content/tests/chrome/test_autocomplete4.xul
@@ -91,84 +91,84 @@ SimpleTest.waitForExplicitFinish();
setTimeout(nextTest, 0);
var currentTest = null;
// Note the entries for these tests (key) are incremental.
const tests = [
{
desc: "HOME key remove selection",
- key: "VK_HOME",
+ key: "KEY_Home",
removeSelection: true,
result: "re",
start: 0, end: 0
},
{
desc: "LEFT key remove selection",
- key: "VK_LEFT",
+ key: "KEY_ArrowLeft",
removeSelection: true,
result: "re",
start: 1, end: 1
},
{ desc: "RIGHT key remove selection",
- key: "VK_RIGHT",
+ key: "KEY_ArrowRight",
removeSelection: true,
result: "re",
start: 2, end: 2
},
{ desc: "ENTER key remove selection",
- key: "VK_RETURN",
+ key: "KEY_Enter",
removeSelection: true,
result: "re",
start: 2, end: 2
},
{
desc: "HOME key",
- key: "VK_HOME",
+ key: "KEY_Home",
removeSelection: false,
result: "Result",
start: 0, end: 0
},
{
desc: "LEFT key",
- key: "VK_LEFT",
+ key: "KEY_ArrowLeft",
removeSelection: false,
result: "Result",
start: 5, end: 5
},
{ desc: "RIGHT key",
- key: "VK_RIGHT",
+ key: "KEY_ArrowRight",
removeSelection: false,
result: "Result",
start: 6, end: 6
},
{ desc: "RETURN key",
- key: "VK_RETURN",
+ key: "KEY_Enter",
removeSelection: false,
result: "Result",
start: 6, end: 6
},
{ desc: "TAB key should confirm suggestion when forcecomplete is set",
- key: "VK_TAB",
+ key: "KEY_Tab",
removeSelection: false,
forceComplete: true,
result: "Result",
start: 6, end: 6
},
{ desc: "RIGHT key complete from middle",
- key: "VK_RIGHT",
+ key: "KEY_ArrowRight",
forceComplete: true,
completeFromMiddle: true,
result: "Result",
start: 6, end: 6
},
{
desc: "RIGHT key w/ minResultsForPopup=2",
- key: "VK_RIGHT",
+ key: "KEY_ArrowRight",
removeSelection: false,
minResultsForPopup: 2,
result: "Result",
start: 6, end: 6
},
];
function nextTest() {
@@ -182,48 +182,46 @@ function nextTest() {
return;
}
var autocomplete = $("autocomplete");
autocomplete.value = "";
currentTest = tests.shift();
// HOME key works differently on Mac, so we skip tests using it.
- if (currentTest.key == "VK_HOME" && navigator.platform.includes("Mac"))
+ if (currentTest.key == "KEY_Home" && navigator.platform.includes("Mac"))
nextTest();
else
setTimeout(runCurrentTest, 0);
}
function runCurrentTest() {
var autocomplete = $("autocomplete");
if ("minResultsForPopup" in currentTest)
autocomplete.setAttribute("minresultsforpopup", currentTest.minResultsForPopup)
else
autocomplete.removeAttribute("minresultsforpopup");
autocomplete.focus();
if (!currentTest.completeFromMiddle) {
- synthesizeKey("r", {});
- synthesizeKey("e", {});
+ sendString("re");
}
else {
- synthesizeKey("l", {});
- synthesizeKey("t", {});
+ sendString("lt");
}
}
function searchComplete() {
var autocomplete = $("autocomplete");
autocomplete.setAttribute("forcecomplete", currentTest.forceComplete ? true : false);
if (currentTest.completeFromMiddle) {
if (!currentTest.forceComplete) {
- synthesizeKey(currentTest.key, {});
+ synthesizeKey(currentTest.key);
}
else if (!/ >> /.test(autocomplete.value)) {
// At this point we should have a value like "lt >> Result" showing.
throw new Error("Expected an middle-completed value, got " + autocomplete.value);
}
// For forceComplete a blur should cause a value from the results to get
// completed to. E.g. "lt >> Result" will turn into "Result".
@@ -235,20 +233,20 @@ function searchComplete() {
}
is(autocomplete.value, "result",
"Test '" + currentTest.desc + "': autocomplete.value should equal 'result'");
if (autocomplete.selectionStart == 2) { // Finished inserting "re" string.
if (currentTest.removeSelection) {
// remove current selection
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
}
- synthesizeKey(currentTest.key, {});
+ synthesizeKey(currentTest.key);
checkResult();
}
}
function checkResult() {
var autocomplete = $("autocomplete");
--- a/toolkit/content/tests/chrome/test_autocomplete5.xul
+++ b/toolkit/content/tests/chrome/test_autocomplete5.xul
@@ -84,53 +84,53 @@ setTimeout(startTest, 0);
function startTest() {
let autocomplete = $("autocomplete");
// blur the field to ensure that the popup is closed and that the previous
// search has stopped, then start a new search.
autocomplete.blur();
autocomplete.focus();
- synthesizeKey("r", {});
+ sendString("r");
}
let hasTextEntered = false;
let hasSearchBegun = false;
function checkSearchBegin() {
hasSearchBegun = true;
}
let test = 0;
function checkSearchCompleted() {
is(hasSearchBegun, true, "onsearchbegin handler has been correctly called.");
if (test == 0) {
hasSearchBegun = false;
- synthesizeKey("VK_RETURN", { });
+ synthesizeKey("KEY_Enter");
} else if (test == 1) {
hasSearchBegun = false;
- synthesizeKey("VK_ESCAPE", { });
+ synthesizeKey("KEY_Escape");
} else {
throw "checkSearchCompleted should only be called twice.";
}
}
function checkTextEntered() {
is(test, 0, "checkTextEntered should be reached from first test.");
is(hasSearchBegun, false, "onsearchbegin handler should not be called on text revert.");
// fire second test
test++;
let autocomplete = $("autocomplete");
autocomplete.textValue = "";
autocomplete.blur();
autocomplete.focus();
- synthesizeKey("r", {});
+ sendString("r");
}
function checkTextReverted() {
is(test, 1, "checkTextReverted should be the second test reached.");
is(hasSearchBegun, false, "onsearchbegin handler should not be called on text revert.");
setTimeout(function() {
// Unregister the factory so that we don't get in the way of other tests
--- a/toolkit/content/tests/chrome/test_autocomplete_emphasis.xul
+++ b/toolkit/content/tests/chrome/test_autocomplete_emphasis.xul
@@ -128,17 +128,17 @@ function nextTest() {
// search has stopped, then start a new search.
let autocomplete = $("richautocomplete");
autocomplete.blur();
autocomplete.focus();
currentTest = testcases[test];
resultText = currentTest.result;
autocomplete.value = currentTest.search;
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
}
function checkSearchCompleted() {
let autocomplete = $("richautocomplete");
let result = autocomplete.popup.richlistbox.firstChild;
for (let attribute of [result._titleText, result._urlText]) {
is(attribute.childNodes.length, currentTest.emphasis.length,
--- a/toolkit/content/tests/chrome/test_autocomplete_placehold_last_complete.xul
+++ b/toolkit/content/tests/chrome/test_autocomplete_placehold_last_complete.xul
@@ -123,164 +123,163 @@ function runTest() {
autoCompleteSimple.registerFactory();
gAutoComplete = $("autocomplete");
gAutoComplete.focus();
// Return the search results synchronous, which also makes the completion
// happen synchronous.
autoCompleteSimple.searchAsync = false;
- synthesizeKey("r", {});
+ sendString("r");
is(gAutoComplete.value, "result", "Value should be autocompleted immediately");
- synthesizeKey("e", {});
+ sendString("e");
is(gAutoComplete.value, "result", "Value should be autocompleted immediately");
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
is(gAutoComplete.value, "re", "Deletion should not complete value");
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(gAutoComplete.value, "r", "Backspace should not complete value");
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
is(gAutoComplete.value, "r", "Value should stay same when navigating with cursor");
runAsyncTest();
}
function* asyncTestGenerator() {
- synthesizeKey("r", {});
- synthesizeKey("e", {});
+ sendString("re");
is(gAutoComplete.value, "re", "Value should not be autocompleted immediately");
// Calling |yield undefined| makes this generator function wait until
// |asyncTest.next();| is called. This happens from within the
// |autoCompleteSimple.startSearch()| function once the simulated async
// search has finished.
// Therefore, the effect of the |yield undefined;| here (and the ones) below
// is to wait until the async search result comes back.
yield undefined;
is(gAutoComplete.value, "result", "Value should be autocompleted");
// Test if typing the `s` character completes directly based on the last
// completion
- synthesizeKey("s", {});
+ sendString("s");
is(gAutoComplete.value, "result", "Value should be completed immediately");
yield undefined;
is(gAutoComplete.value, "result", "Value should be autocompleted to same value");
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
is(gAutoComplete.value, "res", "Deletion should not complete value");
// No |yield undefined| needed here as no completion is triggered by the deletion.
is(gAutoComplete.value, "res", "Still no complete value after deletion");
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(gAutoComplete.value, "re", "Backspace should not complete value");
yield undefined;
is(gAutoComplete.value, "re", "Value after search due to backspace should stay the same"); (3)
// Typing a character that is not like the previous match. In this case, the
// completion cannot happen directly and therefore the value will be completed
// only after the search has finished.
- synthesizeKey("t", {});
+ sendString("t");
is(gAutoComplete.value, "ret", "Value should not be autocompleted immediately");
yield undefined;
is(gAutoComplete.value, "retire", "Value should be autocompleted");
- synthesizeKey("i", {});
+ sendString("i");
is(gAutoComplete.value, "retire", "Value should be autocompleted immediately");
yield undefined;
is(gAutoComplete.value, "retire", "Value should be autocompleted to the same value");
// Setup the scene to test how the completion behaves once the placeholder
// completion and the result from the search do not agree with each other.
gAutoComplete.value = 'r';
// Need to type two characters as the input was reset and the autocomplete
// controller things, ther user hit the backspace button, in which case
// no completion is performed. But as a completion is desired, another
// character `t` is typed afterwards.
- synthesizeKey("e", {});
+ sendString("e");
yield undefined;
- synthesizeKey("t", {});
+ sendString("t");
is(gAutoComplete.value, "ret", "Value should not be autocompleted");
yield undefined;
is(gAutoComplete.value, "retire", "Value should be autocompleted");
// The placeholder string is now set to "retire". Changing the completion
// string to "retirement" and see what the completion will turn out like.
autoCompleteSimpleResult.retireCompletion = "Retirement";
- synthesizeKey("i", {});
+ sendString("i");
is(gAutoComplete.value, "retire", "Value should be autocompleted based on placeholder");
yield undefined;
is(gAutoComplete.value, "retirement", "Value should be autocompleted based on search result");
// Change the search result to `Retire` again and see if the new result is
// complited.
autoCompleteSimpleResult.retireCompletion = "Retire";
- synthesizeKey("r", {});
+ sendString("r");
is(gAutoComplete.value, "retirement", "Value should be autocompleted based on placeholder");
yield undefined;
is(gAutoComplete.value, "retire", "Value should be autocompleted based on search result");
// Complete the value
gAutoComplete.value = 're';
- synthesizeKey("t", {});
+ sendString("t");
yield undefined;
- synthesizeKey("i", {});
+ sendString("i");
is(gAutoComplete.value, "reti", "Value should not be autocompleted");
yield undefined;
is(gAutoComplete.value, "retire", "Value should be autocompleted");
// Remove the selected text "re" (1) and the "et" (2). Afterwards, add it again (3).
// This should not cause the completion to kick in.
- synthesizeKey("VK_DELETE", {}); // (1)
+ synthesizeKey("KEY_Delete"); // (1)
is(gAutoComplete.value, "reti", "Value should not complete after deletion");
gAutoComplete.selectionStart = 1;
gAutoComplete.selectionEnd = 3;
- synthesizeKey("VK_DELETE", {}); // (2)
+ synthesizeKey("KEY_Delete"); // (2)
is(gAutoComplete.value, "ri", "Value should stay unchanged after removing character in the middle");
yield undefined;
- synthesizeKey("e", {}); // (3.1)
+ sendString("e"); // (3.1)
is(gAutoComplete.value, "rei", "Inserting a character in the middle should not complete the value");
yield undefined;
- synthesizeKey("t", {}); // (3.2)
+ sendString("t"); // (3.2)
is(gAutoComplete.value, "reti", "Inserting a character in the middle should not complete the value");
yield undefined;
// Adding a new character at the end should not cause the completion to happen again
// as the completion failed before.
gAutoComplete.selectionStart = 4;
gAutoComplete.selectionEnd = 4;
- synthesizeKey("r", {});
+ sendString("r");
is(gAutoComplete.value, "retir", "Value should not be autocompleted immediately");
yield undefined;
is(gAutoComplete.value, "retire", "Value should be autocompleted");
finishTest();
yield undefined;
--- a/toolkit/content/tests/chrome/test_autocomplete_with_composition_on_input.html
+++ b/toolkit/content/tests/chrome/test_autocomplete_with_composition_on_input.html
@@ -30,17 +30,17 @@ function runTests() {
var originalFormFillTimeout = formFillController.timeout;
SpecialPowers.attachFormFillControllerTo(window);
var target = document.getElementById("input");
// Register a word to the form history.
target.focus();
target.value = "Mozilla";
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
target.value = "";
new nsDoTestsForAutoCompleteWithComposition(
"Testing on HTML input (asynchronously search)",
window, target, formFillController.controller, is,
function() { return target.value; },
function() {
target.setAttribute("timeout", 0);
--- a/toolkit/content/tests/chrome/test_bug418874.xul
+++ b/toolkit/content/tests/chrome/test_bug418874.xul
@@ -53,19 +53,17 @@
is(t2CanUndo.value, true,
"undo correctly enabled when placeholder explicitly changed through property");
SimpleTest.finish();
}
function setTextboxValue(textbox, value) {
textbox.focus();
- for (var i = 0; i < value.length; ++i) {
- synthesizeKey(value.charAt(i), {});
- }
+ sendString(value);
textbox.blur();
}
SimpleTest.waitForFocus(doTest);
]]></script>
</window>
--- a/toolkit/content/tests/chrome/test_bug792324.xul
+++ b/toolkit/content/tests/chrome/test_bug792324.xul
@@ -49,17 +49,17 @@ function checkAccessKeyOnPanel(panelid,
panel.addEventListener("popupshown", function onpopupshown() {
panel.removeEventListener("popupshown", onpopupshown);
panel.firstChild.focus();
after_click = function(event) {
is(event.target.id, buttonid, "Accesskey was directed to the button '" + buttonid + "'");
panel.hidePopup();
cb();
}
- synthesizeKey("X", {});
+ sendString("X");
});
panel.openPopup(null, "", 100, 100, false, false);
}
function test() {
checkAccessKeyOnPanel("panel-1", "button-1", function() {
checkAccessKeyOnPanel("panel-2", "button-2", function() {
SimpleTest.finish();
--- a/toolkit/content/tests/chrome/test_button.xul
+++ b/toolkit/content/tests/chrome/test_button.xul
@@ -36,29 +36,29 @@ function test_button()
$("one").focus();
synthesizeKeyExpectEvent("VK_SPACE", { }, $("one"), "command", "key press");
$("two").disabled = true;
synthesizeMouseExpectEvent($("two"), 2, 2, {}, $("two"), "!command", "button press command when disabled");
synthesizeMouseExpectEvent($("two"), 2, 2, {}, $("two"), "click", "button press click when disabled");
if (!navigator.platform.includes("Mac")) {
$("one").focus();
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
is(document.activeElement, $("three"), "key cursor down on button");
- synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("KEY_ArrowRight");
is(document.activeElement, $("four"), "key cursor right on button");
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
is(document.activeElement, $("four"), "key cursor down on menu button");
$("five").focus();
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
is(document.activeElement, $("five"), "key cursor down on panel button");
$("three").focus();
- synthesizeKey("VK_UP", { });
+ synthesizeKey("KEY_ArrowUp");
is(document.activeElement, $("one"), "key cursor up on button");
}
$("two").focus();
ok(document.activeElement != $("two"), "focus disabled button");
SimpleTest.finish();
}
--- a/toolkit/content/tests/chrome/test_closemenu_attribute.xul
+++ b/toolkit/content/tests/chrome/test_closemenu_attribute.xul
@@ -43,18 +43,18 @@ function nextTest()
if (gModes[gMode] == "none")
$("l2").open = true;
else
$("menu").open = true;
}
function executeMenuItem()
{
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_RETURN", { });
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
// after a couple of seconds, end the test, as the 'none' closemenu value
// should not hide any popups
if (gModes[gMode] == "none")
setTimeout(function() { $("menu").open = false; }, 2000);
}
function popupHidden(event)
{
--- a/toolkit/content/tests/chrome/test_colorpicker_popup.xul
+++ b/toolkit/content/tests/chrome/test_colorpicker_popup.xul
@@ -52,39 +52,39 @@ function popupShown()
switch (phase) {
case "mouse click":
synthesizeMouse(gCp, 2, 2, { });
break;
case "showPopup":
gCp.hidePopup();
break;
case "key left":
- synthesizeKey("VK_LEFT", { });
- synthesizeKeyExpectEvent("VK_RETURN", { });
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKeyExpectEvent("KEY_Enter");
is(gCp.color, "#C0C0C0", "key left while open");
break;
case "key right":
- synthesizeKey("VK_RIGHT", { });
- synthesizeKeyExpectEvent("VK_SPACE", { });
+ synthesizeKey("KEY_ArrowRight");
+ synthesizeKeyExpectEvent("VK_SPACE");
is(gCp.color, "#FF0000", "key right while open");
break;
case "key up":
- synthesizeKey("VK_UP", { });
- synthesizeKeyExpectEvent("VK_RETURN", { });
+ synthesizeKey("KEY_ArrowUp");
+ synthesizeKeyExpectEvent("KEY_Enter");
is(gCp.color, "#FF6666", "key up while open");
break;
case "key down":
- synthesizeKey("VK_DOWN", { });
- synthesizeKeyExpectEvent("VK_SPACE", { });
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKeyExpectEvent(" ");
is(gCp.color, "#FF0000", "key down while open");
break;
default:
synthesizeMouse(gCp, 2, 2, { });
// this breaks on the Mac, so disable for now
-// synthesizeKey("VK_ESCAPE", { });
+// synthesizeKey("KEY_Escape");
break;
}
}
function popupHiding()
{
var phase = phases[gTestPhase];
if (phase == "showPopup")
@@ -111,29 +111,29 @@ function goNext()
switch (phase) {
case "mouse click":
synthesizeMouse(gCp, 2, 2, { });
break;
case "showPopup":
gCp.showPopup();
break;
case "key left":
- synthesizeKey("VK_LEFT", { });
+ synthesizeKey("KEY_ArrowLeft");
break;
case "key right":
- synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("KEY_ArrowRight");
break;
case "key down":
- synthesizeKey("VK_UP", { });
+ synthesizeKey("KEY_ArrowUp");
break;
case "key up":
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
break;
case "key space":
- synthesizeKey("VK_SPACE", { });
+ sendString(" ");
break;
}
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/content/tests/chrome/test_dialogfocus.xul
+++ b/toolkit/content/tests/chrome/test_dialogfocus.xul
@@ -37,17 +37,17 @@ let extraDialog = "data:application/vnd.
"<button id='nonbutton' noinitialfocus='true'/></dialog>";
var step = 0;
var fullKeyboardAccess = false;
function startTest()
{
var testButton = document.getElementById("test");
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
fullKeyboardAccess = (document.activeElement == testButton);
info("We " + (fullKeyboardAccess ? "have" : "don't have") + " full keyboard access");
runTest();
}
function runTest()
{
step++;
--- a/toolkit/content/tests/chrome/test_focus_anons.xul
+++ b/toolkit/content/tests/chrome/test_focus_anons.xul
@@ -53,47 +53,47 @@ function runTests()
gExpectedFocus = $("textbox").inputField;
$("textbox").focus();
gExpectedBlur = gExpectedFocus;
gExpectedFocus = document.getAnonymousNodes($("scale"))[0];
$("scale").focus();
var accessKeyDetails = (navigator.platform.includes("Mac")) ?
- { altKey: true, ctrlKey : true } :
- { altKey : true, shiftKey: true };
+ {altKey: true, ctrlKey: true} :
+ {altKey: true, shiftKey: true};
gExpectedBlur = document.getAnonymousNodes($("scale"))[0];
gExpectedFocus = $("menulist").inputField;
synthesizeKey("a", accessKeyDetails);
gExpectedBlur = gExpectedFocus;
gExpectedFocus = $("textbox").inputField;
synthesizeKey("b", accessKeyDetails);
gExpectedBlur = gExpectedFocus;
gExpectedFocus = document.getAnonymousNodes($("scale"))[0];
synthesizeKey("c", accessKeyDetails);
if (!navigator.platform.includes("Mac")) {
gExpectedBlur = gExpectedFocus;
gExpectedFocus = $("textbox").inputField;
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
gExpectedBlur = gExpectedFocus;
gExpectedFocus = $("menulist").inputField;
- synthesizeKey("VK_TAB", { shiftKey: true });
+ synthesizeKey("KEY_Tab", {shiftKey: true});
gExpectedBlur = gExpectedFocus;
gExpectedFocus = $("textbox").inputField;
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
gExpectedBlur = gExpectedFocus;
gExpectedFocus = document.getAnonymousNodes($("scale"))[0];
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
is(gBlurs, 9, "correct number of blurs");
is(gFocuses, 10, "correct number of focuses");
}
else {
is(gBlurs, 5, "correct number of blurs");
is(gFocuses, 6, "correct number of focuses");
}
--- a/toolkit/content/tests/chrome/test_menulist_keynav.xul
+++ b/toolkit/content/tests/chrome/test_menulist_keynav.xul
@@ -46,50 +46,50 @@ var ismac = (navigator.platform.indexOf(
function runTests()
{
list.focus();
// on Mac, up and cursor keys open the menu, but on other platforms, the
// cursor keys navigate between items without opening the menu
if (!ismac) {
expectCommandEvent = true;
- keyCheck(list, "VK_DOWN", 2, 1, "cursor down");
- keyCheck(list, "VK_DOWN", 3, 1, "cursor down skip disabled");
- keyCheck(list, "VK_UP", 2, 1, "cursor up skip disabled");
- keyCheck(list, "VK_UP", 1, 1, "cursor up");
+ keyCheck(list, "KEY_ArrowDown", 2, 1, "cursor down");
+ keyCheck(list, "KEY_ArrowDown", 3, 1, "cursor down skip disabled");
+ keyCheck(list, "KEY_ArrowUp", 2, 1, "cursor up skip disabled");
+ keyCheck(list, "KEY_ArrowUp", 1, 1, "cursor up");
// On Windows, wrapping doesn't occur.
- keyCheck(list, "VK_UP", iswin ? 1 : 4, 1, "cursor up wrap");
+ keyCheck(list, "KEY_ArrowUp", iswin ? 1 : 4, 1, "cursor up wrap");
list.selectedIndex = 4;
list.menuBoxObject.activeChild = list.selectedItem;
- keyCheck(list, "VK_DOWN", iswin ? 4 : 1, 4, "cursor down wrap");
+ keyCheck(list, "KEY_ArrowDown", iswin ? 4 : 1, 4, "cursor down wrap");
list.selectedIndex = 0;
list.menuBoxObject.activeChild = list.selectedItem;
}
// check that attempting to open the menulist does not change the selection
- synthesizeKey("VK_DOWN", { altKey: !ismac });
+ synthesizeKey("KEY_ArrowDown", {altKey: !ismac});
is(list.selectedItem, $("i1"), "open menulist down selectedItem");
- synthesizeKey("VK_UP", { altKey: !ismac });
+ synthesizeKey("KEY_ArrowUp", {altKey: !ismac});
is(list.selectedItem, $("i1"), "open menulist up selectedItem");
list.selectedItem = $("i1");
pressLetter();
}
function pressLetter()
{
// A command event should be fired only if the menulist is closed, or on Windows,
// where items are selected immediately.
expectCommandEvent = !gOpenPhase || iswin;
- synthesizeKey("G", { });
+ sendString("G");
is(list.selectedItem, $("i1"), "letter pressed not found selectedItem");
keyCheck(list, "T", 2, 1, "letter pressed");
if (!gOpenPhase) {
SpecialPowers.setIntPref("ui.menu.incremental_search.timeout", 0); // prevent to timeout
keyCheck(list, "T", 2, 1, "same letter pressed");
SpecialPowers.clearUserPref("ui.menu.incremental_search.timeout");
@@ -139,18 +139,18 @@ function differentPressed()
}
function tabAndScroll()
{
list = $("list");
if (!ismac) {
$("button1").focus();
- synthesizeKeyExpectEvent("VK_TAB", { }, list, "focus", "focus to menulist");
- synthesizeKeyExpectEvent("VK_TAB", { }, $("button2"), "focus", "focus to button");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, list, "focus", "focus to menulist");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("button2"), "focus", "focus to button");
is(document.activeElement, $("button2"), "tab from menulist focused button");
}
// now make sure that using a key scrolls the menu correctly
for (let i = 0; i < 65; i++) {
list.appendItem("Item" + i, "item" + i);
}
@@ -172,17 +172,17 @@ function tabAndScroll()
var originalPosition = item.getBoundingClientRect().top;
list.menuBoxObject.activeChild = item;
ok(item.getBoundingClientRect().top < originalPosition,
"position of item 1: " + item.getBoundingClientRect().top + " -> " + originalPosition);
originalPosition = item.getBoundingClientRect().top;
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
is(item.getBoundingClientRect().top, originalPosition - rowdiff, "position of item 10");
list.open = false;
checkEnter();
}
function keyCheck(list, key, index, defaultindex, testname)
@@ -204,30 +204,30 @@ function checkModifiers(event)
gModifiers++;
}
function checkEnter()
{
list.addEventListener("popuphidden", checkEnterWithModifiers, false);
list.addEventListener("command", checkModifiers, false);
list.open = true;
- synthesizeKey("VK_RETURN", { });
+ synthesizeKey("KEY_Enter");
}
function checkEnterWithModifiers()
{
is(gModifiers, 1, "modifiers checked when not set");
ok(!list.open, "list closed on enter press");
list.removeEventListener("popuphidden", checkEnterWithModifiers, false);
list.addEventListener("popuphidden", verifyPopupOnClose, false);
list.open = true;
- synthesizeKey("VK_RETURN", { shiftKey: true, ctrlKey: true, altKey: true, metaKey: true });
+ synthesizeKey("KEY_Enter", {shiftKey: true, ctrlKey: true, altKey: true, metaKey: true});
}
function verifyPopupOnClose()
{
is(gModifiers, 2, "modifiers checked when set");
ok(!list.open, "list closed on enter press with modifiers");
list.removeEventListener("popuphidden", verifyPopupOnClose, false);
@@ -241,39 +241,39 @@ function checkCursorNavigation()
{
var commandEventsCount = 0;
list.addEventListener("command", event => {
is(event.target, list.selectedItem, "command event fired on selected item");
commandEventsCount++;
}, false);
is(list.selectedIndex, 1, "selectedIndex before cursor down");
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
is(list.selectedIndex, iswin ? 2 : 1, "selectedIndex after cursor down");
is(commandEventsCount, iswin ? 1 : 0, "selectedIndex after cursor down command event");
is(list.menupopup.state, "open", "cursor down popup state");
- synthesizeKey("VK_PAGE_DOWN", { });
+ synthesizeKey("KEY_PageDown");
is(list.selectedIndex, iswin ? 3 : 1, "selectedIndex after page down");
is(commandEventsCount, iswin ? 2 : 0, "selectedIndex after page down command event");
is(list.menupopup.state, "open", "page down popup state");
// Check whether cursor up and down wraps.
list.selectedIndex = 0;
list.menuBoxObject.activeChild = list.selectedItem;
- synthesizeKey("VK_UP", { });
+ synthesizeKey("KEY_ArrowUp");
is(list.menuBoxObject.activeChild,
document.getElementById(iswin || ismac ? "b1" : "b4"), "cursor up wrap while open");
list.selectedIndex = 3;
list.menuBoxObject.activeChild = list.selectedItem;
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
is(list.menuBoxObject.activeChild,
document.getElementById(iswin || ismac ? "b4" : "b1"), "cursor down wrap while open");
- synthesizeKey("VK_UP", { altKey: true });
+ synthesizeKey("KEY_ArrowUp", {altKey: true});
is(list.open, ismac, "alt+up closes popup");
if (ismac) {
list.open = false;
}
SimpleTest.finish();
}
--- a/toolkit/content/tests/chrome/test_panelfrommenu.xul
+++ b/toolkit/content/tests/chrome/test_panelfrommenu.xul
@@ -60,18 +60,18 @@ function runTests()
is($("hiddenpanel").state, "closed", "hidden popup is closed");
var menu = $("menu");
menu.open = true;
}
function menuOpened()
{
- synthesizeKey("VK_DOWN", { });
- synthesizeKey("VK_RETURN", { });
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
}
function menuClosed()
{
// the panel will be open at this point, but the popupshown event
// still needs to fire
is($("panel").state, "showing", "panel is open after menu hide");
is($("menu").firstChild.state, "closed", "menu is closed after menu hide");
@@ -83,27 +83,27 @@ function panelOpened()
is($("menu").firstChild.state, "closed", "menu is closed");
$("panel").hidePopup();
}
function panelOnButtonOpened(panel)
{
is(panel.state, 'open', 'button panel is open');
is(document.activeElement, document.documentElement, "focus blurred on panel from button open");
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
is(document.activeElement, document.documentElement, "focus not modified on cursor down from button");
panel.firstChild.doCommand()
}
function panelOnToolbarbuttonOpened(panel)
{
is(panel.state, 'open', 'toolbarbutton panel is open');
is(document.activeElement, document.documentElement, "focus blurred on panel from toolbarbutton open");
panel.firstChild.focus();
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
is(document.activeElement, panel.firstChild.inputField, "focus not modified on cursor down from toolbarbutton");
panel.parentNode.open = false;
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/content/tests/chrome/test_popup_keys.xul
+++ b/toolkit/content/tests/chrome/test_popup_keys.xul
@@ -53,33 +53,33 @@ function runTests()
popup.enableKeyboardNavigator(true);
is(popup.hasAttribute("ignorekeys"), false, "keys enabled");
let popupShownPromise = waitForEvent(popup, "popupshown");
popup.openPopup(null, "after_start");
await popupShownPromise;
let popupHiddenPromise = waitForEvent(popup, "popuphidden");
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
await popupHiddenPromise;
is(gKeyPressCount, 0, "keypresses with ignorekeys='false'");
gIgnoreKeys = true;
popup.setAttribute("ignorekeys", "true");
// clear this first to avoid confusion
gIgnoreAttrChange = true;
$("i1").removeAttribute("_moz-menuactive")
gIgnoreAttrChange = false;
popupShownPromise = waitForEvent(popup, "popupshown");
popup.openPopup(null, "after_start");
await popupShownPromise;
- synthesizeKey("VK_DOWN", { });
+ synthesizeKey("KEY_ArrowDown");
await new Promise(resolve => setTimeout(() => resolve(), 1000));
popupHiddenPromise = waitForEvent(popup, "popuphidden");
popup.hidePopup();
await popupHiddenPromise;
is(gKeyPressCount, 1, "keypresses with ignorekeys='true'");
@@ -89,17 +89,17 @@ function runTests()
$("i1").removeAttribute("_moz-menuactive")
gIgnoreAttrChange = false;
popupShownPromise = waitForEvent(popup, "popupshown");
popup.openPopup(null, "after_start");
await popupShownPromise;
// When ignorekeys="shortcuts", T should be handled but accel+T should propagate.
- synthesizeKey("t", { });
+ sendString("t");
is(gKeyPressCount, 1, "keypresses after t pressed with ignorekeys='shortcuts'");
synthesizeKey("t", { accelKey: true });
is(gKeyPressCount, 2, "keypresses after accel+t pressed with ignorekeys='shortcuts'");
popupHiddenPromise = waitForEvent(popup, "popuphidden");
popup.hidePopup();
await popupHiddenPromise;
--- a/toolkit/content/tests/chrome/test_tabindex.xul
+++ b/toolkit/content/tests/chrome/test_tabindex.xul
@@ -100,17 +100,17 @@ function runTests()
else {
is(event.target.getAttribute(attrcompare), "t" + t, "tab " + t + " to " + event.target.localName)
if (event.target.localName != "textbox")
gTestsOccurred++;
}
}, true);
for (t = 1; t <= gTestCount; t++)
- synthesizeKey("VK_TAB", { });
+ synthesizeKey("KEY_Tab");
is(gTestsOccurred, gTestCount, "test count");
SimpleTest.finish();
}
SimpleTest.waitForFocus(runTests);
]]>
--- a/toolkit/content/tests/chrome/test_textbox_number.xul
+++ b/toolkit/content/tests/chrome/test_textbox_number.xul
@@ -93,40 +93,40 @@ function doTests() {
// check read only state
n1.readOnly = true;
n1.min = -10;
n1.max = 15;
n1.value = 12;
n1.inputField.focus();
// no events should fire and no changes should occur when the field is read only
- synthesizeKeyExpectEvent("VK_UP", { }, n1, "!change", "key up read only");
+ synthesizeKeyExpectEvent("KEY_ArrowUp", {}, n1, "!change", "key up read only");
is(n1.value, "12", "key up read only value");
- synthesizeKeyExpectEvent("VK_DOWN", { }, n1, "!change", "key down read only");
+ synthesizeKeyExpectEvent("KEY_ArrowDown", {}, n1, "!change", "key down read only");
is(n1.value, "12", "key down read only value");
n1.readOnly = false;
var n9 = $("n9");
is(n9.value, "0", "initial value");
n9.select();
- synthesizeKey("4", {});
+ sendString("4");
is(inputEventCount, 1, "input event count");
is(inputEventValue, "4", "input value");
is(n9.value, "4", "updated value");
- synthesizeKey("2", {});
+ sendString("2");
is(inputEventCount, 2, "input event count");
is(inputEventValue, "42", "input value");
is(n9.value, "42", "updated value");
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(inputEventCount, 3, "input event count");
is(inputEventValue, "4", "input value");
is(n9.value, "4", "updated value");
synthesizeKey("A", {accelKey: true});
- synthesizeKey("VK_DELETE", {});
+ synthesizeKey("KEY_Delete");
is(inputEventCount, 4, "input event count");
is(inputEventValue, "0", "input value");
is(n9.value, "0", "updated value");
SimpleTest.finish();
}
var inputEventCount = 0;
--- a/toolkit/content/tests/chrome/test_textbox_search.xul
+++ b/toolkit/content/tests/chrome/test_textbox_search.xul
@@ -71,62 +71,62 @@ function doTests() {
textbox.value = "foo";
gExpectedValue = "";
iconClick(clearIcon);
is(textbox.value, "", "clicking the clear icon clears the textbox");
ok(gExpectedValue == null, "search triggered when clearing the textbox with the clear icon");
textbox.value = "foo";
gExpectedValue = "";
- synthesizeKey("VK_ESCAPE", {});
+ synthesizeKey("KEY_Escape");
is(textbox.value, "", "escape key clears the textbox");
ok(gExpectedValue == null, "search triggered when clearing the textbox with the escape key");
textbox.value = "bar";
gExpectedValue = "bar";
textbox.doCommand();
ok(gExpectedValue == null, "search triggered with doCommand");
gExpectedValue = "bar";
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
ok(gExpectedValue == null, "search triggered with enter key");
textbox.value = "";
textbox.searchButton = true;
is(textbox.getAttribute("searchbutton"), "true", "searchbutton attribute set on the textbox");
is(searchIcon.getAttribute("searchbutton"), "true", "searchbutton attribute inherited to the search icon");
textbox.value = "foo";
is(icons.selectedPanel, searchIcon, "search icon displayed in search button mode if there's a value");
gExpectedValue = "foo";
iconClick(searchIcon);
ok(gExpectedValue == null, "search triggered when clicking the search icon in search button mode");
is(icons.selectedPanel, clearIcon, "clear icon displayed in search button mode after submitting");
- synthesizeKey("o", {});
+ sendString("o");
is(icons.selectedPanel, searchIcon, "search icon displayed in search button mode when typing a key");
gExpectedValue = "fooo";
iconClick(searchIcon); // display the clear icon (tested above)
textbox.value = "foo";
is(icons.selectedPanel, searchIcon, "search icon displayed in search button mode when the value is changed");
gExpectedValue = "foo";
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
ok(gExpectedValue == null, "search triggered with enter key in search button mode");
is(icons.selectedPanel, clearIcon, "clear icon displayed in search button mode after submitting with enter key");
textbox.value = "x";
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
is(icons.selectedPanel, searchIcon, "search icon displayed in search button mode when deleting the value with the backspace key");
gExpectedValue = "";
- synthesizeKey("VK_RETURN", {});
+ synthesizeKey("KEY_Enter");
ok(gExpectedValue == null, "search triggered with enter key in search button mode");
is(icons.selectedPanel, searchIcon, "search icon displayed in search button mode after submitting an empty string");
textbox.readOnly = true;
gExpectedValue = "foo";
textbox.value = "foo";
iconClick(searchIcon);
ok(gExpectedValue == null, "search triggered when clicking the search icon in search button mode while the textbox is read-only");
@@ -147,18 +147,17 @@ function doTests() {
textbox.searchButton = false;
ok(!textbox.hasAttribute("searchbutton"), "searchbutton attribute removed from the textbox");
ok(!searchIcon.hasAttribute("searchbutton"), "searchbutton attribute removed from the search icon");
gLastTest = true;
gExpectedValue = "123";
textbox.value = "1";
- synthesizeKey("2", {});
- synthesizeKey("3", {});
+ sendString("23");
}
function doSearch(aValue) {
is(aValue, gExpectedValue, "search triggered with expected value");
gExpectedValue = null;
if (gLastTest)
SimpleTest.finish();
}
--- a/toolkit/content/tests/chrome/window_panel_focus.xul
+++ b/toolkit/content/tests/chrome/window_panel_focus.xul
@@ -36,54 +36,54 @@
var gButtonBlur = 0;
function showPanel()
{
// click on the document so that the window has focus
synthesizeMouse(document.documentElement, 1, 1, { });
// focus the button
- synthesizeKeyExpectEvent("VK_TAB", { }, $("b1"), "focus", "button focus");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("b1"), "focus", "button focus");
// tabbing again should skip the popup
- synthesizeKeyExpectEvent("VK_TAB", { }, $("b2"), "focus", "popup skipped in focus navigation");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("b2"), "focus", "popup skipped in focus navigation");
$("panel").openPopup(null, "", 10, 10, false, false);
}
function panelShown()
{
// the focus on the button should have been removed when the popup was opened
is(gButtonBlur, 1, "focus removed when popup opened");
// press tab numerous times to cycle through the buttons. The t2 button will
// be blurred twice, so gButtonBlur will be 3 afterwards.
- synthesizeKeyExpectEvent("VK_TAB", { }, $("t2"), "focus", "tabindex 1");
- synthesizeKeyExpectEvent("VK_TAB", { }, $("t6"), "focus", "tabindex 2");
- synthesizeKeyExpectEvent("VK_TAB", { }, $("t3"), "focus", "tabindex 3");
- synthesizeKeyExpectEvent("VK_TAB", { }, $("t8"), "focus", "tabindex 4");
- synthesizeKeyExpectEvent("VK_TAB", { }, $("t1"), "focus", "tabindex 5");
- synthesizeKeyExpectEvent("VK_TAB", { }, $("t4"), "focus", "tabindex 6");
- synthesizeKeyExpectEvent("VK_TAB", { }, $("t5"), "focus", "tabindex 7");
- synthesizeKeyExpectEvent("VK_TAB", { }, $("t7"), "focus", "tabindex 8");
- synthesizeKeyExpectEvent("VK_TAB", { }, $("t9"), "focus", "tabindex 9");
- synthesizeKeyExpectEvent("VK_TAB", { }, $("t2"), "focus", "tabindex 10");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("t2"), "focus", "tabindex 1");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("t6"), "focus", "tabindex 2");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("t3"), "focus", "tabindex 3");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("t8"), "focus", "tabindex 4");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("t1"), "focus", "tabindex 5");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("t4"), "focus", "tabindex 6");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("t5"), "focus", "tabindex 7");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("t7"), "focus", "tabindex 8");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("t9"), "focus", "tabindex 9");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("t2"), "focus", "tabindex 10");
- synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t9"), "focus", "back tabindex 1");
- synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t7"), "focus", "back tabindex 2");
- synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t5"), "focus", "back tabindex 3");
- synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t4"), "focus", "back tabindex 4");
- synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t1"), "focus", "back tabindex 5");
- synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t8"), "focus", "back tabindex 6");
- synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t3"), "focus", "back tabindex 7");
- synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t6"), "focus", "back tabindex 8");
- synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t2"), "focus", "back tabindex 9");
+ synthesizeKeyExpectEvent("KEY_Tab", {shiftKey: true}, $("t9"), "focus", "back tabindex 1");
+ synthesizeKeyExpectEvent("KEY_Tab", {shiftKey: true}, $("t7"), "focus", "back tabindex 2");
+ synthesizeKeyExpectEvent("KEY_Tab", {shiftKey: true}, $("t5"), "focus", "back tabindex 3");
+ synthesizeKeyExpectEvent("KEY_Tab", {shiftKey: true}, $("t4"), "focus", "back tabindex 4");
+ synthesizeKeyExpectEvent("KEY_Tab", {shiftKey: true}, $("t1"), "focus", "back tabindex 5");
+ synthesizeKeyExpectEvent("KEY_Tab", {shiftKey: true}, $("t8"), "focus", "back tabindex 6");
+ synthesizeKeyExpectEvent("KEY_Tab", {shiftKey: true}, $("t3"), "focus", "back tabindex 7");
+ synthesizeKeyExpectEvent("KEY_Tab", {shiftKey: true}, $("t6"), "focus", "back tabindex 8");
+ synthesizeKeyExpectEvent("KEY_Tab", {shiftKey: true}, $("t2"), "focus", "back tabindex 9");
is(gButtonBlur, 3, "blur events fired within popup");
- synthesizeKey("VK_ESCAPE", { });
+ synthesizeKey("KEY_Escape");
}
function ok(condition, message) {
window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
}
function is(left, right, message) {
window.opener.wrappedJSObject.SimpleTest.is(left, right, message);
@@ -91,26 +91,26 @@ function is(left, right, message) {
function panelHidden()
{
// closing the popup should have blurred the focused element
is(gButtonBlur, 4, "focus removed when popup closed");
// now that the panel is hidden, pressing tab should focus the elements in
// the main window again
- synthesizeKeyExpectEvent("VK_TAB", { }, $("b1"), "focus", "focus after popup closed");
+ synthesizeKeyExpectEvent("KEY_Tab", {}, $("b1"), "focus", "focus after popup closed");
$("noautofocusPanel").openPopup(null, "", 10, 10, false, false);
}
function noautofocusPanelShown()
{
// with noautofocus="true", the focus should not be removed when the panel is
// opened, so key events should still be fired at the checkbox.
- synthesizeKeyExpectEvent("VK_SPACE", { }, $("b1"), "command", "noautofocus");
+ synthesizeKeyExpectEvent(" ", {}, $("b1"), "command", "noautofocus");
$("noautofocusPanel").hidePopup();
}
function noautofocusPanelHidden()
{
window.close();
window.opener.wrappedJSObject.SimpleTest.finish();
}
--- a/toolkit/content/tests/chrome/window_tooltip.xul
+++ b/toolkit/content/tests/chrome/window_tooltip.xul
@@ -276,20 +276,20 @@ var popupTests = [
synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
disableNonTestMouse(false);
},
},
{
testname: "close tooltip with modifiers",
test: function() {
// Press all of the modifiers; the tooltip should remain open on all platforms.
- synthesizeKey("VK_SHIFT", {});
- synthesizeKey("VK_CONTROL", {});
- synthesizeKey("VK_ALT", {});
- synthesizeKey("VK_META", {});
+ synthesizeKey("KEY_Shift");
+ synthesizeKey("KEY_Control");
+ synthesizeKey("KEY_Alt");
+ synthesizeKey("KEY_Alt");
},
result: function() {
is(document.getElementById("thetooltip").state, "open", "tooltip still open after modifiers pressed")
}
},
{
testname: "close tooltip with key",
events: function() {
@@ -297,17 +297,17 @@ var popupTests = [
return [];
}
else {
return [ "popuphiding thetooltip", "popuphidden thetooltip",
"DOMMenuInactive thetooltip" ];
}
},
test: function() {
- synthesizeKey("a", {});
+ sendString("a");
},
result: function() {
let expectedState = (navigator.platform.indexOf("Win") > -1) ? "open" : "closed";
is(document.getElementById("thetooltip").state, expectedState, "tooltip closed after key pressed")
}
},
{
testname: "close tooltip with hidePopup again",
--- a/toolkit/content/tests/mochitest/test_autocomplete_change_after_focus.html
+++ b/toolkit/content/tests/mochitest/test_autocomplete_change_after_focus.html
@@ -83,19 +83,19 @@ https://bugzilla.mozilla.org/show_bug.cg
});
field.focus();
await promiseFieldFocus;
await promisePopupShown;
- sendKey("DOWN");
- sendKey("RETURN");
- sendKey("RETURN");
+ synthesizeKey("KEY_ArrowDown");
+ synthesizeKey("KEY_Enter");
+ synthesizeKey("KEY_Enter");
await handleEnterPromise;
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=998893">Mozilla Bug 998893</a>
<p id="display"><input id="field1" value="Default text"></p>
--- a/toolkit/content/tests/mochitest/test_bug1407085.html
+++ b/toolkit/content/tests/mochitest/test_bug1407085.html
@@ -20,17 +20,17 @@ SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTests);
function runTests() {
let input = document.getElementById("input");
input.focus();
input.addEventListener("keydown", () => {
input.value = "new value";
}, { once: true });
- synthesizeKey("KEY_Escape", {});
+ synthesizeKey("KEY_Escape");
is(input.value, "new value",
"New <input> value changed by an Escape key event listener shouldn't be " +
"overwritten by original value even if Escape key is pressed");
SimpleTest.finish();
}
</script>
</pre>
--- a/toolkit/content/tests/widgets/test_contextmenu_menugroup.xul
+++ b/toolkit/content/tests/widgets/test_contextmenu_menugroup.xul
@@ -32,63 +32,63 @@ ok(gMenuPopup, "Got the reference to the
var popupTests = [
{
testname: "one-down-key",
condition: function() { return (!navigator.platform.includes("Mac")); },
events: [ "popupshowing context", "popupshown context", "DOMMenuItemActive a" ],
test: function () {
synthesizeMouse($("popuparea"), 4, 4, {});
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
},
result: function (testname) {
checkActive(gMenuPopup, "a", testname);
}
},
{
testname: "two-down-keys",
condition: function() { return (!navigator.platform.includes("Mac")); },
events: [ "DOMMenuItemInactive a", "DOMMenuItemActive b" ],
- test: () => synthesizeKey("VK_DOWN", {}),
+ test: () => synthesizeKey("KEY_ArrowDown"),
result: function (testname) {
checkActive(gMenuPopup, "b", testname);
}
},
{
testname: "three-down-keys",
condition: function() { return (!navigator.platform.includes("Mac")); },
events: [ "DOMMenuItemInactive b", "DOMMenuItemActive c" ],
- test: () => synthesizeKey("VK_DOWN", {}),
+ test: () => synthesizeKey("KEY_ArrowDown"),
result: function (testname) {
checkActive(gMenuPopup, "c", testname);
}
},
{
testname: "three-down-keys-one-up-key",
condition: function() { return (!navigator.platform.includes("Mac")); },
events: [ "DOMMenuItemInactive c", "DOMMenuItemActive b" ],
- test: () => synthesizeKey("VK_UP", {}),
+ test: () => synthesizeKey("KEY_ArrowUp"),
result: function (testname) {
checkActive(gMenuPopup, "b", testname);
}
},
{
testname: "three-down-keys-two-up-keys",
condition: function() { return (!navigator.platform.includes("Mac")); },
events: [ "DOMMenuItemInactive b", "DOMMenuItemActive a" ],
- test: () => synthesizeKey("VK_UP", {}),
+ test: () => synthesizeKey("KEY_ArrowUp"),
result: function (testname) {
checkActive(gMenuPopup, "a", testname);
}
},
{
testname: "three-down-keys-three-up-key",
condition: function() { return (!navigator.platform.includes("Mac")); },
events: [ "DOMMenuItemInactive a", "DOMMenuItemActive c" ],
- test: () => synthesizeKey("VK_UP", {}),
+ test: () => synthesizeKey("KEY_ArrowUp"),
result: function (testname) {
checkActive(gMenuPopup, "c", testname);
}
},
];
SimpleTest.waitForFocus(function runTest() {
startPopupTests(popupTests);
--- a/toolkit/content/tests/widgets/test_videocontrols.html
+++ b/toolkit/content/tests/widgets/test_videocontrols.html
@@ -264,40 +264,40 @@ add_task(async function click_slider() {
is(video.volume, 0.1, "Volume should be set.");
ok(!video.muted, "Video is not muted.");
});
// See bug 694696.
add_task(async function change_volume() {
video.focus();
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
await waitForEvent("volumechange");
is(video.volume, 0, "Volume should be 0.");
ok(!video.muted, "Video is not muted.");
ok(await isMuteButtonMuted(), "Mute button says it's muted");
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
await waitForEvent("volumechange");
is(video.volume, 0.1, "Volume is increased.");
ok(!video.muted, "Video is not muted.");
ok(!(await isMuteButtonMuted()), "Mute button says it's not muted");
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
await waitForEvent("volumechange");
is(video.volume, 0, "Volume should be 0.");
ok(!video.muted, "Video is not muted.");
ok(await isMuteButtonMuted(), "Mute button says it's muted");
synthesizeMouse(video, muteButtonCenterX, muteButtonCenterY, {});
await waitForEvent("volumechange");
is(video.volume, 0.5, "Volume should be 0.5.");
ok(!video.muted, "Video is not muted.");
- synthesizeKey("VK_UP", {});
+ synthesizeKey("KEY_ArrowUp");
await waitForEvent("volumechange");
is(video.volume, 0.6, "Volume should be 0.6.");
ok(!video.muted, "Video is not muted.");
synthesizeMouse(video, muteButtonCenterX, muteButtonCenterY, {});
await waitForEvent("volumechange");
is(video.volume, 0.6, "Volume should be 0.6.");
ok(video.muted, "Video is muted.");
@@ -309,35 +309,35 @@ add_task(async function change_volume()
ok(!video.muted, "Video is not muted.");
ok(!(await isMuteButtonMuted()), "Mute button says it's not muted");
synthesizeMouse(video, fullscreenButtonCenterX, fullscreenButtonCenterY, {});
await waitForEvent("mozfullscreenchange");
is(video.volume, 0.6, "Volume should still be 0.6");
await isVolumeSliderShowingCorrectVolume(video.volume);
- synthesizeKey("VK_ESCAPE", {});
+ synthesizeKey("KEY_Escape");
await waitForEvent("mozfullscreenchange");
is(video.volume, 0.6, "Volume should still be 0.6");
await isVolumeSliderShowingCorrectVolume(video.volume);
forceReframe();
video.focus();
- synthesizeKey("VK_DOWN", {});
+ synthesizeKey("KEY_ArrowDown");
await waitForEvent("volumechange");
is(video.volume, 0.5, "Volume should be decreased by 0.1");
await isVolumeSliderShowingCorrectVolume(video.volume);
});
add_task(async function whitespace_pause_video() {
synthesizeMouse(video, playButtonCenterX, playButtonCenterY, {});
await waitForEvent("play");
video.focus();
- synthesizeKey(" ", {});
+ sendString(" ");
await waitForEvent("pause");
synthesizeMouse(video, playButtonCenterX, playButtonCenterY, {});
await waitForEvent("play");
});
/*
* Bug 1352724: Click and hold on timeline should pause video immediately.
--- a/toolkit/content/tests/widgets/test_videocontrols_keyhandler.html
+++ b/toolkit/content/tests/widgets/test_videocontrols_keyhandler.html
@@ -36,32 +36,32 @@
tests.push(done => {
video.addEventListener("play", done, { once: true });
synthesizeMouseAtCenter(playButton, {});
}, done => {
video.addEventListener("seeked", done, { once: true });
synthesizeMouseAtCenter(scrubber, {});
}, done => {
let counter = 0;
- let keyCodes = ["VK_DOWN", "VK_DOWN", "VK_UP", "VK_DOWN", "VK_UP", "VK_UP"];
+ let keys = ["KEY_ArrowDown", "KEY_ArrowDown", "KEY_ArrowUp", "KEY_ArrowDown", "KEY_ArrowUp", "KEY_ArrowUp"];
video.addEventListener("seeked", () => ok(false, "should not trigger seeked event"));
video.addEventListener("volumechange", () => {
- if (++counter === keyCodes.length) {
+ if (++counter === keys.length) {
ok(true, "change volume by up/down arrow key without trigger 'seeked' event");
done();
}
- if (counter > keyCodes.length) {
+ if (counter > keys.length) {
ok(false, "trigger too much volumechange events");
}
});
- for (let keyCode of keyCodes) {
- synthesizeKey(keyCode, {});
+ for (let key of keys) {
+ synthesizeKey(key);
}
});
tests.push(SimpleTest.finish);
window.addEventListener("load", executeTests);
</script>
</pre>
--- a/toolkit/content/tests/widgets/window_menubar.xul
+++ b/toolkit/content/tests/widgets/window_menubar.xul
@@ -125,45 +125,45 @@ var popupTests = [
is(document.getElementById("filemenu").openedWithKey, false, testname + " openedWithKey");
}
},
{
// check that pressing cursor down while there is no selection
// highlights the first item
testname: "cursor down no selection",
events: [ "DOMMenuItemActive item1" ],
- test: function() { sendKey("DOWN"); },
+ test: function() { synthesizeKey("KEY_ArrowDown"); },
result: function(testname) { checkActive(gFilePopup, "item1", testname); }
},
{
// check that pressing cursor up wraps and highlights the last item
testname: "cursor up wrap",
events: [ "DOMMenuItemInactive item1", "DOMMenuItemActive item3" ],
- test: function() { sendKey("UP"); },
+ test: function() { synthesizeKey("KEY_ArrowUp"); },
result: function(testname) { checkActive(gFilePopup, "item3", testname); }
},
{
// check that pressing cursor down wraps and highlights the first item
testname: "cursor down wrap",
events: [ "DOMMenuItemInactive item3", "DOMMenuItemActive item1" ],
- test: function() { sendKey("DOWN"); },
+ test: function() { synthesizeKey("KEY_ArrowDown"); },
result: function(testname) { checkActive(gFilePopup, "item1", testname); }
},
{
// check that pressing cursor down highlights the second item
testname: "cursor down",
events: [ "DOMMenuItemInactive item1", "DOMMenuItemActive item2" ],
- test: function() { sendKey("DOWN"); },
+ test: function() { synthesizeKey("KEY_ArrowDown"); },
result: function(testname) { checkActive(gFilePopup, "item2", testname); }
},
{
// check that pressing cursor up highlights the second item
testname: "cursor up",
events: [ "DOMMenuItemInactive item2", "DOMMenuItemActive item1" ],
- test: function() { sendKey("UP"); },
+ test: function() { synthesizeKey("KEY_ArrowUp"); },
result: function(testname) { checkActive(gFilePopup, "item1", testname); }
},
{
// cursor right should skip the disabled menu and move to the edit menu
testname: "cursor right skip disabled",
events: function() {
var elist = [
@@ -182,17 +182,17 @@ var popupTests = [
// On Windows, don't skip disabled items.
if (navigator.platform.indexOf("Win") == 0)
elist.push("DOMMenuItemActive cut");
else
elist.push("DOMMenuItemActive copy");
elist.push("popupshown editpopup");
return elist;
},
- test: function() { sendKey("RIGHT"); },
+ test: function() { synthesizeKey("KEY_ArrowRight"); },
result: function(testname) {
var expected = (navigator.platform.indexOf("Win") == 0) ? "cut" : "copy";
checkActive(document.getElementById("editpopup"), expected, testname);
checkClosed("filemenu", testname);
checkOpen("editmenu", testname);
is(document.getElementById("editmenu").openedWithKey, false, testname + " openedWithKey");
}
},
@@ -208,17 +208,17 @@ var popupTests = [
"DOMMenuItemInactive editmenu", "DOMMenuItemInactive editmenu" ];
else
return [ "DOMMenuItemInactive copy", "DOMMenuInactive editpopup",
"DOMMenuBarInactive menubar",
"DOMMenuItemInactive editmenu", "DOMMenuItemInactive editmenu",
"command copy", "popuphiding editpopup", "popuphidden editpopup",
"DOMMenuItemInactive copy" ];
},
- test: function() { sendKey("RETURN"); },
+ test: function() { synthesizeKey("KEY_Enter"); },
result: function(testname) {
checkClosed("editmenu", testname);
is(document.getElementById("editmenu").openedWithKey, false, testname + " openedWithKey");
}
},
{
// pressing Alt + a key should open the corresponding menu
testname: "open with accelerator",
@@ -239,17 +239,17 @@ var popupTests = [
events: function() {
// on Windows, the disabled 'navigation' item can stll be highlihted
if (navigator.platform.indexOf("Win") == 0)
return [ "popupshowing toolbarpopup", "DOMMenuItemActive navigation",
"popupshown toolbarpopup" ];
else
return [ "popupshowing toolbarpopup", "popupshown toolbarpopup" ];
},
- test: function() { sendKey("RIGHT"); },
+ test: function() { synthesizeKey("KEY_ArrowRight"); },
result: function(testname) {
checkOpen("viewmenu", testname);
checkOpen("toolbar", testname);
}
},
{
// close the submenu with the cursor left key
testname: "close submenu with cursor left",
@@ -258,34 +258,34 @@ var popupTests = [
return [ "popuphiding toolbarpopup", "popuphidden toolbarpopup",
"DOMMenuItemInactive navigation", "DOMMenuInactive toolbarpopup",
"DOMMenuItemActive toolbar" ];
else
return [ "popuphiding toolbarpopup", "popuphidden toolbarpopup",
"DOMMenuInactive toolbarpopup",
"DOMMenuItemActive toolbar" ];
},
- test: function() { sendKey("LEFT"); },
+ test: function() { synthesizeKey("KEY_ArrowLeft"); },
result: function(testname) {
checkOpen("viewmenu", testname);
checkClosed("toolbar", testname);
}
},
{
// open the submenu with the enter key
testname: "open submenu with enter",
events: function() {
// on Windows, the disabled 'navigation' item can stll be highlighted
if (navigator.platform.indexOf("Win") == 0)
return [ "popupshowing toolbarpopup", "DOMMenuItemActive navigation",
"popupshown toolbarpopup" ];
else
return [ "popupshowing toolbarpopup", "popupshown toolbarpopup" ];
},
- test: function() { sendKey("RETURN"); },
+ test: function() { synthesizeKey("KEY_Enter"); },
result: function(testname) {
checkOpen("viewmenu", testname);
checkOpen("toolbar", testname);
},
},
{
// close the submenu with the escape key
testname: "close submenu with escape",
@@ -294,17 +294,17 @@ var popupTests = [
return [ "popuphiding toolbarpopup", "popuphidden toolbarpopup",
"DOMMenuItemInactive navigation", "DOMMenuInactive toolbarpopup",
"DOMMenuItemActive toolbar" ];
else
return [ "popuphiding toolbarpopup", "popuphidden toolbarpopup",
"DOMMenuInactive toolbarpopup",
"DOMMenuItemActive toolbar" ];
},
- test: function() { sendKey("ESCAPE"); },
+ test: function() { synthesizeKey("KEY_Escape"); },
result: function(testname) {
checkOpen("viewmenu", testname);
checkClosed("toolbar", testname);
},
},
{
// open the submenu with the enter key again
testname: "open submenu with enter again",
@@ -312,115 +312,115 @@ var popupTests = [
events: function() {
// on Windows, the disabled 'navigation' item can stll be highlighted
if (navigator.platform.indexOf("Win") == 0)
return [ "popupshowing toolbarpopup", "DOMMenuItemActive navigation",
"popupshown toolbarpopup" ];
else
return [ "popupshowing toolbarpopup", "popupshown toolbarpopup" ];
},
- test: function() { sendKey("RETURN"); },
+ test: function() { synthesizeKey("KEY_Enter"); },
result: function(testname) {
checkOpen("viewmenu", testname);
checkOpen("toolbar", testname);
},
},
{
// while a submenu is open, switch to the next toplevel menu with the cursor right key
testname: "while a submenu is open, switch to the next menu with the cursor right",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "DOMMenuItemInactive viewmenu", "DOMMenuItemActive helpmenu",
"popuphiding toolbarpopup", "popuphidden toolbarpopup",
"popuphiding viewpopup", "popuphidden viewpopup",
"popupshowing helppopup", "DOMMenuItemInactive navigation",
"DOMMenuInactive toolbarpopup", "DOMMenuItemInactive toolbar",
"DOMMenuInactive viewpopup", "DOMMenuItemActive contents",
"popupshown helppopup" ],
- test: function() { sendKey("RIGHT"); },
+ test: function() { synthesizeKey("KEY_ArrowRight"); },
result: function(testname) {
checkOpen("helpmenu", testname);
checkClosed("toolbar", testname);
checkClosed("viewmenu", testname);
}
},
{
// close the main menu with the escape key
testname: "close menubar menu with escape",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "popuphiding helppopup", "popuphidden helppopup",
"DOMMenuItemInactive contents", "DOMMenuInactive helppopup",
"DOMMenuBarInactive menubar", "DOMMenuItemInactive helpmenu" ],
- test: function() { sendKey("ESCAPE"); },
+ test: function() { synthesizeKey("KEY_Escape"); },
result: function(testname) { checkClosed("viewmenu", testname); },
},
{
// close the main menu with the escape key
testname: "close menubar menu with escape",
condition: function() { return (navigator.platform.indexOf("Win") != 0) },
events: [ "popuphiding viewpopup", "popuphidden viewpopup",
"DOMMenuItemInactive toolbar", "DOMMenuInactive viewpopup",
"DOMMenuBarInactive menubar",
"DOMMenuItemInactive viewmenu" ],
- test: function() { sendKey("ESCAPE"); },
+ test: function() { synthesizeKey("KEY_Escape"); },
result: function(testname) { checkClosed("viewmenu", testname); },
},
{
// Pressing Alt should highlight the first menu but not open it,
// but it should be ignored if the alt keydown event is consumed.
testname: "alt shouldn't activate menubar if keydown event is consumed",
test: function() {
document.addEventListener("keydown", function (aEvent) {
document.removeEventListener("keydown", arguments.callee, true);
aEvent.preventDefault();
}, true);
- sendKey("ALT");
+ synthesizeKey("KEY_Alt");
},
result: function(testname) {
ok(!document.getElementById("filemenu").openedWithKey, testname);
checkClosed("filemenu", testname);
},
},
{
// Pressing Alt should highlight the first menu but not open it,
// but it should be ignored if the alt keyup event is consumed.
testname: "alt shouldn't activate menubar if keyup event is consumed",
test: function() {
document.addEventListener("keyup", function (aEvent) {
document.removeEventListener("keyup", arguments.callee, true);
aEvent.preventDefault();
}, true);
- sendKey("ALT");
+ synthesizeKey("KEY_Alt");
},
result: function(testname) {
ok(!document.getElementById("filemenu").openedWithKey, testname);
checkClosed("filemenu", testname);
},
},
{
// Pressing Alt should highlight the first menu but not open it.
testname: "alt to activate menubar",
events: [ "DOMMenuBarActive menubar", "DOMMenuItemActive filemenu" ],
- test: function() { sendKey("ALT"); },
+ test: function() { synthesizeKey("KEY_Alt"); },
result: function(testname) {
is(document.getElementById("filemenu").openedWithKey, true, testname + " openedWithKey");
checkClosed("filemenu", testname);
},
},
{
// pressing cursor left should select the previous menu but not open it
testname: "cursor left on active menubar",
events: [ "DOMMenuItemInactive filemenu", "DOMMenuItemActive helpmenu" ],
- test: function() { sendKey("LEFT"); },
+ test: function() { synthesizeKey("KEY_ArrowLeft"); },
result: function(testname) { checkClosed("helpmenu", testname); },
},
{
// pressing cursor right should select the previous menu but not open it
testname: "cursor right on active menubar",
events: [ "DOMMenuItemInactive helpmenu", "DOMMenuItemActive filemenu" ],
- test: function() { sendKey("RIGHT"); },
+ test: function() { synthesizeKey("KEY_ArrowRight"); },
result: function(testname) { checkClosed("filemenu", testname); },
},
{
// pressing a character should act as an accelerator and open the menu
testname: "accelerator on active menubar",
events: [ "popupshowing helppopup",
"DOMMenuItemInactive filemenu", "DOMMenuItemActive helpmenu",
"DOMMenuItemActive contents", "popupshown helppopup" ],
@@ -429,24 +429,24 @@ var popupTests = [
checkOpen("helpmenu", testname);
is(document.getElementById("helpmenu").openedWithKey, true, testname + " openedWithKey");
},
},
{
// check that pressing cursor up skips non menuitems
testname: "cursor up wrap",
events: [ "DOMMenuItemInactive contents", "DOMMenuItemActive about" ],
- test: function() { sendKey("UP"); },
+ test: function() { synthesizeKey("KEY_ArrowUp"); },
result: function(testname) { }
},
{
// check that pressing cursor down skips non menuitems
testname: "cursor down wrap",
events: [ "DOMMenuItemInactive about", "DOMMenuItemActive contents" ],
- test: function() { sendKey("DOWN"); },
+ test: function() { synthesizeKey("KEY_ArrowDown"); },
result: function(testname) { }
},
{
// check that pressing a menuitem's accelerator selects it
testname: "menuitem accelerator",
events: [ "DOMMenuItemInactive contents", "DOMMenuItemActive amenu",
"DOMMenuItemInactive amenu", "DOMMenuInactive helppopup",
"DOMMenuBarInactive menubar", "DOMMenuItemInactive helpmenu",
@@ -456,17 +456,17 @@ var popupTests = [
],
test: function() { sendChar("m"); },
result: function(testname) { checkClosed("helpmenu", testname); }
},
{
// pressing F10 should highlight the first menu. On Linux, the menu is opened.
testname: "F10 to activate menubar",
events: pressF10Events(),
- test: function() { sendKey("F10"); },
+ test: function() { synthesizeKey("KEY_F10"); },
result: function(testname) {
is(document.getElementById("filemenu").openedWithKey, true, testname + " openedWithKey");
if (navigator.platform.includes("Linux"))
checkOpen("filemenu", testname);
else
checkClosed("filemenu", testname);
},
},
@@ -484,17 +484,17 @@ var popupTests = [
"DOMMenuInactive filepopup",
"popupshown helppopup" ] :
[ "popupshowing helppopup", "DOMMenuItemInactive filemenu",
"DOMMenuItemActive helpmenu",
// This is in a different order than the
// "accelerator on active menubar" because menus opened from a
// shortcut key are fired asynchronously
"DOMMenuItemActive contents", "popupshown helppopup" ],
- test: function() { sendKey("LEFT"); sendKey("DOWN"); },
+ test: function() { synthesizeKey("KEY_ArrowLeft"); synthesizeKey("KEY_ArrowDown"); },
result: function(testname) {
is(document.getElementById("helpmenu").openedWithKey, true, testname + " openedWithKey");
}
},
{
// pressing a letter that doesn't correspond to an accelerator. The menu
// should not close because there is more than one item corresponding to
// that letter
@@ -546,17 +546,17 @@ var popupTests = [
test: function() { sendChar("t"); },
result: function(testname) { checkClosed("helpmenu", testname); }
},
{
// pressing F10 should highlight the first menu but not open it
testname: "F10 to activate menubar again",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "DOMMenuBarActive menubar", "DOMMenuItemActive filemenu" ],
- test: function() { sendKey("F10"); },
+ test: function() { synthesizeKey("KEY_F10"); },
result: function(testname) { checkClosed("filemenu", testname); },
},
{
// pressing an accelerator for a disabled item should deactivate the menubar
testname: "accelerator for disabled menu",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "DOMMenuItemInactive filemenu", "DOMMenuBarInactive menubar" ],
test: function() { sendChar("s"); },
@@ -637,76 +637,76 @@ var popupTests = [
},
result: function (testname) {
checkClosed("editmenu", testname);
}
},
{
testname: "F10 to activate menubar for tab deactivation",
events: pressF10Events(),
- test: function() { sendKey("F10"); },
+ test: function() { synthesizeKey("KEY_F10"); },
},
{
testname: "Deactivate menubar with tab key",
events: closeAfterF10Events(true),
- test: function() { sendKey("TAB"); },
+ test: function() { synthesizeKey("KEY_Tab"); },
result: function(testname) {
is(document.getElementById("filemenu").openedWithKey, false, testname + " openedWithKey");
}
},
{
testname: "F10 to activate menubar for escape deactivation",
events: pressF10Events(),
- test: function() { sendKey("F10"); },
+ test: function() { synthesizeKey("KEY_F10"); },
},
{
testname: "Deactivate menubar with escape key",
events: closeAfterF10Events(false),
- test: function() { sendKey("ESCAPE"); },
+ test: function() { synthesizeKey("KEY_Escape"); },
result: function(testname) {
is(document.getElementById("filemenu").openedWithKey, false, testname + " openedWithKey");
}
},
{
testname: "F10 to activate menubar for f10 deactivation",
events: pressF10Events(),
- test: function() { sendKey("F10"); },
+ test: function() { synthesizeKey("KEY_F10"); },
},
{
testname: "Deactivate menubar with f10 key",
events: closeAfterF10Events(true),
- test: function() { sendKey("F10"); },
+ test: function() { synthesizeKey("KEY_F10"); },
result: function(testname) {
is(document.getElementById("filemenu").openedWithKey, false, testname + " openedWithKey");
}
},
{
testname: "F10 to activate menubar for alt deactivation",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "DOMMenuBarActive menubar", "DOMMenuItemActive filemenu" ],
- test: function() { sendKey("F10"); },
+ test: function() { synthesizeKey("KEY_F10"); },
},
{
testname: "Deactivate menubar with alt key",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "DOMMenuBarInactive menubar", "DOMMenuItemInactive filemenu" ],
- test: function() { sendKey("ALT"); },
+ test: function() { synthesizeKey("KEY_Alt"); },
result: function(testname) {
is(document.getElementById("filemenu").openedWithKey, false, testname + " openedWithKey");
}
},
{
testname: "Don't activate menubar with mousedown during alt key auto-repeat",
test: function() {
- synthesizeKey("VK_ALT", { type: "keydown" });
+ synthesizeKey("KEY_Alt", {type: "keydown"});
synthesizeMouse(document.getElementById("menubar"), 8, -30, { type: "mousedown", altKey: true });
- synthesizeKey("VK_ALT", { type: "keydown" });
+ synthesizeKey("KEY_Alt", {type: "keydown"});
synthesizeMouse(document.getElementById("menubar"), 8, -30, { type: "mouseup", altKey: true });
- synthesizeKey("VK_ALT", { type: "keydown" });
- synthesizeKey("VK_ALT", { type: "keyup" });
+ synthesizeKey("KEY_Alt", {type: "keydown"});
+ synthesizeKey("KEY_Alt", {type: "keyup"});
},
result: function (testname) {
checkActive(document.getElementById("menubar"), "", testname);
}
},
{
testname: "Open menu and press alt key by itself - open menu",
@@ -720,17 +720,17 @@ var popupTests = [
},
{
testname: "Open menu and press alt key by itself - close menu",
events: [ "popuphiding filepopup", "popuphidden filepopup",
"DOMMenuItemInactive item1", "DOMMenuInactive filepopup",
"DOMMenuBarInactive menubar", "DOMMenuItemInactive filemenu",
"DOMMenuItemInactive filemenu" ],
test: function() {
- synthesizeKey("VK_ALT", { });
+ synthesizeKey("KEY_Alt");
},
result: function (testname) {
checkClosed("filemenu", testname);
}
},
// Fllowing 4 tests are a test of bug 616797, don't insert any new tests
// between them.
@@ -738,19 +738,19 @@ var popupTests = [
testname: "Open file menu by accelerator",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: function() {
return [ "DOMMenuBarActive menubar", "popupshowing filepopup",
"DOMMenuItemActive filemenu", "DOMMenuItemActive item1",
"popupshown filepopup" ];
},
test: function() {
- synthesizeKey("VK_ALT", { type: "keydown" });
- synthesizeKey("F", { altKey: true });
- synthesizeKey("VK_ALT", { type: "keyup" });
+ synthesizeKey("KEY_Alt", {type: "keydown"});
+ synthesizeKey("f", {altKey: true});
+ synthesizeKey("KEY_Alt", {type: "keyup"});
}
},
{
testname: "Close file menu by click at outside of popup menu",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: function() {
return [ "popuphiding filepopup", "popuphidden filepopup",
"DOMMenuItemInactive item1", "DOMMenuInactive filepopup",
@@ -764,53 +764,53 @@ var popupTests = [
},
{
testname: "Alt keydown set focus the menubar",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: function() {
return [ "DOMMenuBarActive menubar", "DOMMenuItemActive filemenu" ];
},
test: function() {
- sendKey("ALT");
+ synthesizeKey("KEY_Alt");
},
result: function (testname) {
checkClosed("filemenu", testname);
}
},
{
testname: "unset focus the menubar",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: function() {
return [ "DOMMenuBarInactive menubar", "DOMMenuItemInactive filemenu" ];
},
test: function() {
- sendKey("ALT");
+ synthesizeKey("KEY_Alt");
}
},
// bug 625151
{
testname: "Alt key state before deactivating the window shouldn't prevent " +
"next Alt key handling",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: function() {
return [ "DOMMenuBarActive menubar", "DOMMenuItemActive filemenu" ];
},
test: function() {
- synthesizeKey("VK_ALT", { type: "keydown" });
- synthesizeKey("VK_TAB", { type: "keydown" }); // cancels the Alt key
+ synthesizeKey("KEY_Alt", {type: "keydown"});
+ synthesizeKey("KEY_Tab", {type: "keydown"}); // cancels the Alt key
var thisWindow = window;
var newWindow =
window.open("data:text/html,", "_blank", "width=100,height=100");
newWindow.addEventListener("focus", function () {
newWindow.removeEventListener("focus", arguments.callee, false);
thisWindow.addEventListener("focus", function () {
thisWindow.removeEventListener("focus", arguments.callee, false);
setTimeout(function () {
- sendKey("ALT", thisWindow);
+ synthesizeKey("KEY_Alt", {}, thisWindow);
}, 0);
}, false);
newWindow.close();
thisWindow.focus();
}, false);
}
}
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
@@ -90,21 +90,21 @@ function end_test() {
finish();
}
function go_back() {
gBrowser.goBack();
}
function go_back_backspace() {
- EventUtils.synthesizeKey("VK_BACK_SPACE", {});
+ EventUtils.synthesizeKey("KEY_Backspace");
}
function go_forward_backspace() {
- EventUtils.synthesizeKey("VK_BACK_SPACE", {shiftKey: true});
+ EventUtils.synthesizeKey("KEY_Backspace", {shiftKey: true});
}
function go_forward() {
gBrowser.goForward();
}
function check_state(canGoBack, canGoForward) {
is(gBrowser.canGoBack, canGoBack, "canGoBack should be correct");
--- a/toolkit/mozapps/extensions/test/browser/browser_file_xpi_no_process_switch.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_file_xpi_no_process_switch.js
@@ -50,17 +50,17 @@ async function testOpenedAndDraggedXPI(a
return Services.appinfo.processID;
});
// No process switch for XPI file:// URI in the urlbar.
let promiseNotification = promiseInstallNotification(aBrowser);
let urlbar = document.getElementById("urlbar");
urlbar.value = fileurl1.spec;
urlbar.focus();
- EventUtils.synthesizeKey("KEY_Enter", {});
+ EventUtils.synthesizeKey("KEY_Enter");
await promiseNotification;
await CheckBrowserInPid(aBrowser, browserPid,
"Check that browser has not switched process.");
// No process switch for XPI file:// URI dragged to tab.
let tab = gBrowser.getTabForBrowser(aBrowser);
promiseNotification = promiseInstallNotification(aBrowser);
let effect = EventUtils.synthesizeDrop(tab, tab,
--- a/widget/tests/test_input_events_on_deactive_window.xul
+++ b/widget/tests/test_input_events_on_deactive_window.xul
@@ -132,25 +132,25 @@ function startTests()
"compositionend event is (not) handled: " + aDescription);
is(compositionupdateHandled, aUpdate,
"compositionupdate event is (not) handled: " + aDescription);
is(inputHandled, aInput,
"input event is (not) handled: " + aDescription);
}
clear();
- synthesizeKey("a", { type: "keydown" });
+ synthesizeKey("a", {type: "keydown"});
checkKeyEvents(true, true, false, true, "a keydown and a keypress");
is(textarea.value, "a", "textarea value isn't 'a'");
clear();
- synthesizeKey("a", { type: "keyup" });
+ synthesizeKey("a", {type: "keyup"});
checkKeyEvents(false, false, true, false, "a keyup");
clear();
- synthesizeKey("VK_BACK_SPACE", {});
- checkKeyEvents(true, true, true, true, "VK_BACK_SPACE key events");
+ synthesizeKey("KEY_Backspace");
+ checkKeyEvents(true, true, true, true, "KEY_Backspace key events");
is(textarea.value, "", "textarea value isn't empty");
// IME events
clear();
// input first character
synthesizeCompositionChange(
{ "composition":
{ "string": "\u3089",
--- a/widget/tests/window_composition_text_querycontent.xul
+++ b/widget/tests/window_composition_text_querycontent.xul
@@ -409,48 +409,19 @@ function runUndoRedoTest()
]
},
"caret": { "start": 1, "length": 0 }
});
// commit
synthesizeComposition({ type: "compositioncommitasis" });
- synthesizeKey(" ", {});
- synthesizeKey("m", {});
- synthesizeKey("e", {});
- synthesizeKey("a", {});
- synthesizeKey("n", {});
- synthesizeKey("t", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("s", {});
- synthesizeKey(" ", {});
- synthesizeKey("\"", {});
- synthesizeKey("c", {});
- synthesizeKey("a", {});
- synthesizeKey("t", {});
- synthesizeKey("-", {});
- synthesizeKey("g", {});
- synthesizeKey("i", {});
- synthesizeKey("r", {});
- synthesizeKey("l", {});
- synthesizeKey("\"", {});
- synthesizeKey(".", {});
- synthesizeKey(" ", {});
- synthesizeKey("VK_SHIFT", { type: "keydown" });
- synthesizeKey("S", { shiftKey: true });
- synthesizeKey("VK_SHIFT", { type: "keyup" });
- synthesizeKey("h", {});
- synthesizeKey("e", {});
- synthesizeKey(" ", {});
- synthesizeKey("i", {});
- synthesizeKey("s", {});
- synthesizeKey(" ", {});
- synthesizeKey("a", {});
- synthesizeKey(" ", {});
+ sendString(" meant");
+ synthesizeKey("KEY_Backspace");
+ synthesizeKey("s \"cat-girl\". She is a ");
// input raw characters
synthesizeCompositionChange(
{ "composition":
{ "string": "\u3088",
"clauses":
[
{ "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
@@ -502,28 +473,17 @@ function runUndoRedoTest()
]
},
"caret": { "start": 2, "length": 0 }
});
// commit
synthesizeComposition({ type: "compositioncommitasis" });
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace", {repeat: 12});
var i = 0;
if (!checkContent("\u732B\u5A18 means \"cat-girl\".",
"runUndoRedoTest", "#" + ++i) ||
!checkSelection(20, "", "runUndoRedoTest", "#" + i)) {
return;
}
@@ -1598,17 +1558,17 @@ function runCompositionTest()
if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700",
"runCompositionTest", "#4-6") ||
!checkSelection(5, "", "runCompositionTest", "#4-6")) {
return;
}
// testing whether the empty composition string deletes selected string.
- synthesizeKey("VK_LEFT", { shiftKey: true });
+ synthesizeKey("KEY_ArrowLeft", {shiftKey: true});
synthesizeCompositionChange(
{ "composition":
{ "string": "",
"clauses":
[
{ "length": 0, "attr": 0 }
]
@@ -1624,17 +1584,17 @@ function runCompositionTest()
synthesizeComposition({ type: "compositioncommit", data: "\u9AD8" });
if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u9AD8",
"runCompositionTest", "#4-9") ||
!checkSelection(5, "", "runCompositionTest", "#4-9")) {
return;
}
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("KEY_Backspace");
if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
"runCompositionTest", "#4-11") ||
!checkSelection(4, "", "runCompositionTest", "#4-11")) {
return;
}
// bug 23558, ancient Japanese IMEs on Window may send empty text event
// twice at canceling composition.
@@ -1936,17 +1896,17 @@ function runCompositionEventTest()
is(inputEventCounts["input"], 3,
kDescription + "input hasn't been handled by input #3");
is(inputEventData["input"], "\u3089\u30FC",
kDescription + "value of input element wasn't modified (input) #3");
// select the second character, then, data of composition start should be
// the selected character.
initResults();
- synthesizeKey("VK_LEFT", { shiftKey: true });
+ synthesizeKey("KEY_ArrowLeft", {shiftKey: true});
synthesizeCompositionChange(
{ "composition":
{ "string": "\u3089",
"clauses":
[
{ "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
]
@@ -5828,43 +5788,43 @@ function runIsComposingTest()
textarea.focus();
textarea.value = "";
// XXX These cases shouldn't occur in actual native key events because we
// don't dispatch key events while composition (bug 354358).
SpecialPowers.setBoolPref("dom.keyboardevent.dispatch_during_composition", true);
description = "events before dispatching compositionstart";
- synthesizeKey("VK_LEFT", {});
+ synthesizeKey("KEY_ArrowLeft");
description = "events after dispatching compositionchange";
synthesizeCompositionChange(
{ "composition":
{ "string": "\u3042",
"clauses":
[
{ "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
]
},
"caret": { "start": 1, "length": 0 },
"key": { key: "a", code: "KeyA", keyCode: KeyboardEvent.DOM_VK_A },
});
// Although, firing keypress event during composition is a bug.
- synthesizeKey("VK_INSERT", {});
+ synthesizeKey("KEY_Insert");
description = "events for committing composition string";
synthesizeComposition({ type: "compositioncommitasis",
key: { key: "KEY_Enter", code: "Enter", type: "keydown" } });
// input event will be fired by synthesizing compositionend event.
// Then, its isComposing should be false.
description = "events after dispatching compositioncommitasis";
- synthesizeKey("VK_RETURN", { type: "keyup" });
+ synthesizeKey("KEY_Enter", {type: "keyup"});
SpecialPowers.clearUserPref("dom.keyboardevent.dispatch_during_composition");
textarea.removeEventListener("keydown", eventHandler, true);
textarea.removeEventListener("keypress", eventHandler, true);
textarea.removeEventListener("keyup", eventHandler, true);
textarea.removeEventListener("input", eventHandler, true);
textarea.removeEventListener("compositionstart", onComposition, true);
@@ -7062,18 +7022,18 @@ function* runEditorReframeTests()
synthesizeComposition({ type: "compositioncommitasis" });
},
check: function () {
is(getValue(aEditor), "ABCdef", description + "Commit 'def' without convert");
},
},
{ test: function () {
// Select "Cd"
- synthesizeKey("KEY_ArrowLeft", {});
- synthesizeKey("KEY_ArrowLeft", {});
+ synthesizeKey("KEY_ArrowLeft");
+ synthesizeKey("KEY_ArrowLeft");
synthesizeKey("KEY_Shift", {type: "keydown", shiftKey: true});
synthesizeKey("KEY_ArrowLeft", {shiftKey: true});
synthesizeKey("KEY_ArrowLeft", {shiftKey: true});
synthesizeKey("KEY_Shift", {type: "keyup"});
},
check: function () {
},
},