Bug 1590216: Test for a EVENT_TEXT_CARET_MOVED when text is selected in the URL bar of a new window. r=Jamie

Differential Revision: https://phabricator.services.mozilla.com/D56781

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Morgan Reschenberg 2020-02-04 11:25:01 +00:00
Родитель fa1647cd96
Коммит 6d7530b618
2 изменённых файлов: 59 добавлений и 0 удалений

Просмотреть файл

@ -13,3 +13,4 @@ skip-if = e10s
[browser_test_focus_dialog.js]
[browser_test_focus_urlbar.js]
[browser_test_A11yUtils_announce.js]
[browser_test_selection_urlbar.js]

Просмотреть файл

@ -0,0 +1,58 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from ../../mochitest/role.js */
loadScripts({ name: "role.js", dir: MOCHITESTS_DIR });
XPCOMUtils.defineLazyModuleGetters(this, {
BrowserTestUtils: "resource://testing-common/BrowserTestUtils.jsm",
PlacesTestUtils: "resource://testing-common/PlacesTestUtils.jsm",
UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.jsm",
});
// Check that the URL bar manages accessibility
// selection notifications appropriately on startup (new window).
async function runTests() {
let focused = waitForEvent(
EVENT_FOCUS,
event => event.accessible.role == ROLE_ENTRY
);
info("Creating new window");
let newWin = await BrowserTestUtils.openNewBrowserWindow();
await PlacesTestUtils.addVisits("http://addons.mozilla.org");
registerCleanupFunction(async function() {
await BrowserTestUtils.closeWindow(newWin);
await PlacesUtils.history.clear();
});
info("Focusing window");
newWin.focus();
await focused;
// Ensure the URL bar is ready for a new URL to be typed.
// Sometimes, when this test runs, the existing text isn't selected when the
// URL bar is focused. Pressing escape twice ensures that the popup is
// closed and that the existing text is selected.
EventUtils.synthesizeKey("KEY_Escape", {}, newWin);
EventUtils.synthesizeKey("KEY_Escape", {}, newWin);
let caretMoved = waitForEvent(
EVENT_TEXT_CARET_MOVED,
event => event.accessible.role == ROLE_ENTRY
);
info("Autofilling after typing `a` in new window URL bar.");
EventUtils.synthesizeKey("a", {}, newWin);
await UrlbarTestUtils.promiseSearchComplete(newWin);
Assert.equal(
newWin.gURLBar.inputField.value,
"addons.mozilla.org/",
"autofilled value as expected"
);
info("Ensuring caret moved on text selection");
await caretMoved;
}
addAccessibleTask(``, runTests);