1
0
Fork 0
firefox/toolkit/components/satchel/test/browser/browser_close_tab.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

43 lines
1.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.importESModule(
"resource://gre/modules/FormHistory.sys.mjs"
);
add_task(async function test() {
const url = `data:text/html,<input type="text" name="field1">`;
// Open a dummy tab.
await BrowserTestUtils.withNewTab({ gBrowser, url }, async function () {});
await BrowserTestUtils.withNewTab(
{ gBrowser, url },
async function (browser) {
const { autoCompletePopup } = browser;
const mockHistory = [{ op: "add", fieldname: "field1", value: "value1" }];
await FormHistory.update([{ op: "remove" }, ...mockHistory]);
await SpecialPowers.spawn(browser, [], async function () {
const input = content.document.querySelector("input");
input.focus();
});
// show popup
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
await TestUtils.waitForCondition(() => {
return autoCompletePopup.popupOpen;
});
gBrowser.removeCurrentTab();
await TestUtils.waitForCondition(() => {
return !autoCompletePopup.popupOpen;
});
Assert.ok(!autoCompletePopup.popupOpen, "Ensure the popup is closed.");
}
);
});