Bug 1613054 part 2 - On iframe.focus() create the initial about:blank for in-process case and treat the iframe as focusable for OOP case. r=nika

Test cases in https://bugzilla.mozilla.org/show_bug.cgi?id=1649099

Differential Revision: https://phabricator.services.mozilla.com/D88978
This commit is contained in:
Henri Sivonen 2020-09-09 12:09:44 +00:00
Родитель 8bb9ef510a
Коммит 323bd1842b
2 изменённых файлов: 20 добавлений и 0 удалений

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

@ -6454,6 +6454,7 @@ nsresult nsDocShell::CreateAboutBlankContentViewer(
bool hadTiming = mTiming;
bool toBeReset = MaybeInitTiming();
if (mContentViewer) {
MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
if (aCheckPermitUnload) {
// We've got a content viewer already. Make sure the user
// permits us to discard the current document and replace it

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

@ -1985,6 +1985,25 @@ Element* nsFocusManager::FlushAndCheckIfFocusable(Element* aElement,
: nullptr;
}
// If this is an iframe that doesn't have an in-process subdocument, it is
// either an OOP iframe or an in-process iframe without lazy about:blank
// creation having taken place. In the OOP case, treat the frame as
// focusable for consistency with Chrome. In the in-process case, create
// the initial about:blank for in-process BrowsingContexts in order to
// have the `GetSubDocumentFor` call after this block return something.
if (RefPtr<nsFrameLoaderOwner> flo = do_QueryObject(aElement)) {
// Only look at pre-existing browsing contexts. If this function is
// called during reflow, calling GetBrowsingContext() could cause frame
// loader initialization at a time when it isn't safe.
if (BrowsingContext* bc = flo->GetExtantBrowsingContext()) {
// This call may create a contentViewer-created about:blank.
// That's intentional, so we can move focus there.
if (!bc->GetDocument()) {
return aElement;
}
}
}
// if this is a child frame content node, check if it is visible and
// call the content node's IsFocusable method instead of the frame's
// IsFocusable method. This skips checking the style system and ensures that