gecko-dev/toolkit/components/satchel/test/browser/browser_close_tab.js
Kris Maglione 94e3b0bd8d Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
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
2019-12-13 20:36:16 +00:00

46 lines
1.4 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">`;
// Open a dummy tab.
await BrowserTestUtils.withNewTab({ gBrowser, url }, async function(
browser
) {});
await BrowserTestUtils.withNewTab({ gBrowser, url }, async function(browser) {
const { autoCompletePopup } = browser;
const mockHistory = [{ op: "add", fieldname: "field1", value: "value1" }];
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 TestUtils.waitForCondition(() => {
return autoCompletePopup.popupOpen;
});
gBrowser.removeCurrentTab();
await TestUtils.waitForCondition(() => {
return !autoCompletePopup.popupOpen;
});
Assert.ok(!autoCompletePopup.popupOpen, "Ensure the popup is closed.");
});
});