mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-07 19:59:18 +02:00
This is generally pretty straightforward, and rewrites nearly all calls. It skips the ones that it can detect using frame script globals like `sendAsyncMessage`, though. Differential Revision: https://phabricator.services.mozilla.com/D53740 --HG-- extra : moz-landing-system : lando
68 lines
2.3 KiB
JavaScript
68 lines
2.3 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
const { FormHistory } = ChromeUtils.import(
|
|
"resource://gre/modules/FormHistory.jsm"
|
|
);
|
|
|
|
add_task(async function test() {
|
|
const url = `data:text/html,<input type="text" name="field1">`;
|
|
await BrowserTestUtils.withNewTab({ gBrowser, url }, async function(browser) {
|
|
const {
|
|
autoCompletePopup,
|
|
autoCompletePopup: { richlistbox: itemsBox },
|
|
} = browser;
|
|
const mockHistory = [
|
|
{ op: "add", fieldname: "field1", value: "value1" },
|
|
{ op: "add", fieldname: "field1", value: "value2" },
|
|
{ op: "add", fieldname: "field1", value: "value3" },
|
|
{ op: "add", fieldname: "field1", value: "value4" },
|
|
];
|
|
|
|
await new Promise(resolve =>
|
|
FormHistory.update([{ op: "remove" }, ...mockHistory], {
|
|
handleCompletion: resolve,
|
|
})
|
|
);
|
|
await SpecialPowers.spawn(browser, [], async function() {
|
|
const input = content.document.querySelector("input");
|
|
|
|
input.focus();
|
|
});
|
|
|
|
// show popup
|
|
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
|
|
await BrowserTestUtils.waitForCondition(() => {
|
|
return autoCompletePopup.popupOpen;
|
|
});
|
|
const listItemElems = itemsBox.querySelectorAll(
|
|
".autocomplete-richlistitem"
|
|
);
|
|
is(listItemElems.length, mockHistory.length, "ensure result length");
|
|
is(autoCompletePopup.mousedOverIndex, -1, "mousedOverIndex should be -1");
|
|
|
|
// navigate to the first item
|
|
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
|
|
is(autoCompletePopup.selectedIndex, 0, "selectedIndex should be 0");
|
|
|
|
// mouseover the second item
|
|
EventUtils.synthesizeMouseAtCenter(listItemElems[1], { type: "mouseover" });
|
|
await BrowserTestUtils.waitForCondition(() => {
|
|
return (autoCompletePopup.mousedOverIndex = 1);
|
|
});
|
|
ok(true, "mousedOverIndex changed");
|
|
is(
|
|
autoCompletePopup.selectedIndex,
|
|
0,
|
|
"selectedIndex should not be changed by mouseover"
|
|
);
|
|
|
|
// close popup
|
|
await SpecialPowers.spawn(browser, [], async function() {
|
|
const input = content.document.querySelector("input");
|
|
|
|
input.blur();
|
|
});
|
|
});
|
|
});
|