Bug 1265208: Restore url if the value of inputed bar that had been inputting is empty upon switching tab. r=adw

Differential Revision: https://phabricator.services.mozilla.com/D118125
This commit is contained in:
Daisuke Akatsuka 2021-06-21 02:30:06 +00:00
Родитель e40714855d
Коммит 0142cb5790
2 изменённых файлов: 7 добавлений и 6 удалений

Просмотреть файл

@ -325,10 +325,11 @@ class UrlbarInput {
let value = this.window.gBrowser.userTypedValue; let value = this.window.gBrowser.userTypedValue;
let valid = false; let valid = false;
// Explicitly check for nulled out value. We don't want to reset the URL // Restore the selected browser's current URI if `value` is null or if it's
// bar if the user has deleted the URL and we'd just put the same URL // an empty string and we're switching tabs. In the latter case, when the
// back. See bug 304198. // user makes the input empty, switches tabs, and switches back, we want the
if (value === null) { // URI to become visible again so the user knows what URI they're viewing.
if (value === null || (!value && dueToTabSwitch)) {
uri = uri || this.window.gBrowser.currentURI; uri = uri || this.window.gBrowser.currentURI;
// Strip off usernames and passwords for the location bar // Strip off usernames and passwords for the location bar
try { try {

Просмотреть файл

@ -77,8 +77,8 @@ add_task(async function() {
await BrowserTestUtils.switchTab(gBrowser, deletedURLTab); await BrowserTestUtils.switchTab(gBrowser, deletedURLTab);
is( is(
gURLBar.value, gURLBar.value,
"", testURL,
'gURLBar.value should be "" after switching back to deletedURLTab' "gURLBar.value should be testURL after switching back to deletedURLTab"
); );
await BrowserTestUtils.switchTab(gBrowser, fullURLTab); await BrowserTestUtils.switchTab(gBrowser, fullURLTab);