Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Errors
- This test gets skipped with pattern: debug
- This test failed 5 times in the preceding 30 days. quicksearch this test
- Manifest: browser/components/urlbar/tests/browser-newtab/browser.toml
/* Any copyright is dedicated to the Public Domain.
// Escape walks the newtab address bar back out: it closes the view, reverts
// what was typed, then hands focus back to the page around it.
"use strict";
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.suggest.searches", false]],
});
});
add_task(async function escapeWalksBackOut() {
let tab = await NewtabSearchbarTestUtils.openNewTabPage();
// One task, so each Escape and the state it leaves behind stay in the process
// holding the bar.
await NewtabSearchbarTestUtils.spawn(
tab.linkedBrowser,
[TEST_VALUE],
async value => {
let utils = NewtabSearchbarContentTestUtils;
await utils.promiseAutocompleteResultPopup({ window: content, value });
let escape = () => EventUtils.synthesizeKey("KEY_Escape", {}, content);
let waitFor = (predicate, msg) =>
ContentTaskUtils.waitForCondition(
() => predicate(utils.getState(content)),
msg
);
escape();
await waitFor(state => !state.viewOpen, "the view closes");
let state = utils.getState(content);
Assert.ok(!state.viewVisible, "the view stops being painted");
Assert.equal(state.value, value, "the value is still there");
Assert.ok(state.focused, "the bar keeps focus");
escape();
await waitFor(s => !s.value, "the value reverts");
Assert.ok(utils.getState(content).focused, "the bar still keeps focus");
escape();
await waitFor(s => !s.focused, "focus goes back to the page");
}
);
BrowserTestUtils.removeTab(tab);
});