Bug 1410591 - Focus the content area when restoring the selected tab. r?mikedeboer
MozReview-Commit-ID: F0IQOazc1BH
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -2500,19 +2500,16 @@ var SessionStoreInternal = {
let tab = tabbrowser.selectedTab = tabbrowser.addTab(null, state);
// restore tab content
this.restoreTab(tab, state);
// restore the tab's position
tabbrowser.moveTabTo(tab, pos);
- // focus the tab's content area (bug 342432)
- tab.linkedBrowser.focus();
-
// Notify of changes to closed objects.
this._notifyOfClosedObjectsChange();
return tab;
},
forgetClosedTab: function ssi_forgetClosedTab(aWindow, aIndex) {
if (!aWindow.__SSi) {
@@ -4014,16 +4011,21 @@ var SessionStoreInternal = {
new ViewSourceBrowser(browser);
}
browser.messageManager.sendAsyncMessage("SessionStore:restoreTabContent",
{loadArguments, isRemotenessUpdate,
reason: aOptions.restoreContentReason ||
RESTORE_TAB_CONTENT_REASON.SET_STATE,
requestTime: Services.telemetry.msSystemNow()});
+
+ // Focus the tab's content area.
+ if (aTab.selected) {
+ browser.focus();
+ }
},
/**
* Marks a given pending tab as restoring.
*
* @param aTab
* the pending tab to mark as restoring
*/
--- a/browser/components/sessionstore/test/browser.ini
+++ b/browser/components/sessionstore/test/browser.ini
@@ -232,25 +232,26 @@ skip-if = true
# Disabled on OS X:
[browser_625016.js]
skip-if = os == "mac" || (os == "linux" && debug) # linux, Bug 1348583
[browser_906076_lazy_tabs.js]
[browser_911547.js]
[browser_1284886_suspend_tab.js]
skip-if = !e10s
-[browser_send_async_message_oom.js]
+[browser_async_window_flushing.js]
+[browser_focus_after_restore.js]
+[browser_forget_async_closings.js]
[browser_multiple_navigateAndRestore.js]
run-if = e10s
-[browser_async_window_flushing.js]
-[browser_forget_async_closings.js]
[browser_newtab_userTypedValue.js]
[browser_parentProcessRestoreHash.js]
run-if = e10s
tags = openUILinkIn
+[browser_send_async_message_oom.js]
[browser_sessionStoreContainer.js]
[browser_windowStateContainer.js]
skip-if = os == "linux" && !debug
[browser_1234021.js]
[browser_remoteness_flip_on_restore.js]
run-if = e10s
[browser_background_tab_crash.js]
run-if = e10s && crashreporter
new file mode 100644
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_focus_after_restore.js
@@ -0,0 +1,19 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+add_task(async function test() {
+ gURLBar.focus();
+ is(document.activeElement, gURLBar.inputField, "urlbar is focused before restoring");
+
+ await promiseBrowserState({
+ windows: [{
+ tabs: [{
+ entries: [{
+ url: "http://example.org/", triggeringPrincipal_base64
+ }]
+ }],
+ selected: 1
+ }]
+ });
+ is(document.activeElement, gBrowser.selectedBrowser, "content area is focused after restoring");
+});