mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-10 05:08:36 +02:00
* Always update the `_searchModesByBrowser` map when entering/exiting search mode, not only for non-selected browsers, so that search mode can be saved and restored properly per tab. * Rename `setSearchMode` to `_updateSearchModeUI` and make it only update the UI. * Add a new `setSearchMode` method that takes a browser and updates the map. * Add `getSearchMode` so that SessionStore can get the search mode for a given browser. * Add a `searchMode` getter and setter for convenience. They call `getSearchMode` and `setSearchMode` with the selected browser. Differential Revision: https://phabricator.services.mozilla.com/D91910
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
/**
|
|
* This test makes sure that the urlbar's search mode is correctly preserved.
|
|
*/
|
|
|
|
XPCOMUtils.defineLazyModuleGetters(this, {
|
|
UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.jsm",
|
|
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
|
|
});
|
|
|
|
UrlbarTestUtils.init(this);
|
|
|
|
add_task(async function test() {
|
|
await SpecialPowers.pushPrefEnv({
|
|
set: [
|
|
["browser.urlbar.update2", true],
|
|
["browser.urlbar.update2.localOneOffs", true],
|
|
["browser.urlbar.update2.oneOffsRefresh", true],
|
|
],
|
|
});
|
|
|
|
// Open the urlbar view and enter search mode.
|
|
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
|
window,
|
|
value: "test",
|
|
});
|
|
await UrlbarTestUtils.enterSearchMode(window, {
|
|
source: UrlbarUtils.RESULT_SOURCE.HISTORY,
|
|
});
|
|
|
|
// The search mode should be in the tab state.
|
|
let state = JSON.parse(ss.getTabState(gBrowser.selectedTab));
|
|
Assert.ok(
|
|
"searchMode" in state,
|
|
"state.searchMode is present after entering search mode"
|
|
);
|
|
Assert.deepEqual(
|
|
state.searchMode,
|
|
{
|
|
source: UrlbarUtils.RESULT_SOURCE.HISTORY,
|
|
entry: "oneoff",
|
|
isPreview: false,
|
|
},
|
|
"state.searchMode is correct"
|
|
);
|
|
|
|
// Exit search mode.
|
|
await UrlbarTestUtils.exitSearchMode(window);
|
|
|
|
// The search mode should not be in the tab state.
|
|
let newState = JSON.parse(ss.getTabState(gBrowser.selectedTab));
|
|
Assert.ok(
|
|
!newState.searchMode,
|
|
"state.searchMode is not present after exiting search mode"
|
|
);
|
|
|
|
await UrlbarTestUtils.promisePopupClose(window);
|
|
});
|