diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index 0b3bd4cc5fd9..42536bf5e0aa 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -7166,8 +7166,13 @@ nsGlobalWindow::RestoreWindowState(nsISupports *aState) } } - if (!didFocusContent && focusedWindow) + if (!didFocusContent && focusedWindow) { + // Clear the focus controller's memory of any focused element so that + // the element does not get inadvertently focused again. + fc->ResetElementFocus(); + focusedWindow->Focus(); + } } else if (focusedWindow) { // Just update the saved focus memory. fc->SetFocusedWindow(focusedWindow);