Bug 1803681 - Show the search term if returning to a tab contains a blank value - r=adw
Differential Revision: https://phabricator.services.mozilla.com/D163730
This commit is contained in:
@@ -337,7 +337,11 @@ export class UrlbarInput {
|
||||
dueToSessionRestore = false,
|
||||
dontShowSearchTerms = false
|
||||
) {
|
||||
if (!dontShowSearchTerms && this.window.gBrowser.userTypedValue == null) {
|
||||
if (
|
||||
!dontShowSearchTerms &&
|
||||
(this.window.gBrowser.userTypedValue == null ||
|
||||
this.window.gBrowser.userTypedValue == "")
|
||||
) {
|
||||
this.window.gBrowser.selectedBrowser.showingSearchTerms = false;
|
||||
if (lazy.UrlbarPrefs.isPersistedSearchTermsEnabled()) {
|
||||
let term = lazy.UrlbarSearchUtils.getSearchTermIfDefaultSerpUri(
|
||||
|
||||
@@ -135,3 +135,25 @@ add_task(async function user_overwrites_search_term() {
|
||||
BrowserTestUtils.removeTab(tab1);
|
||||
BrowserTestUtils.removeTab(tab2);
|
||||
});
|
||||
|
||||
// If a user clears the URL bar, and goes to a different tab,
|
||||
// the original tab should show the search term again.
|
||||
add_task(async function user_overwrites_search_term() {
|
||||
let { tab: tab1 } = await searchWithTab(SEARCH_STRING);
|
||||
|
||||
gURLBar.focus();
|
||||
gURLBar.select();
|
||||
EventUtils.sendKey("delete");
|
||||
|
||||
Assert.equal(gURLBar.value, "", "Empty string should be in url bar.");
|
||||
|
||||
// Open a new tab, switch back to the first and check
|
||||
// the blank string is replaced with the search string.
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab1);
|
||||
|
||||
assertSearchStringIsInUrlbar(SEARCH_STRING);
|
||||
|
||||
BrowserTestUtils.removeTab(tab1);
|
||||
BrowserTestUtils.removeTab(tab2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user