Bug 1659696 - Check PendingInitialization before targeting in window.open, r=kmag

This requires adding the flag as a synced field on the BrowsingContext, and
checking it in a few more places. Attempts to open a new window in this racy
manner will now raise an exception.

This should avoid the issue from bug 1658854 by blocking the buggy attempts to
load before the nested event loop has been exited.

Differential Revision: https://phabricator.services.mozilla.com/D87927
This commit is contained in:
Nika Layzell
2020-09-16 20:47:55 +00:00
parent b676d04b21
commit cbb7e8111c
5 changed files with 38 additions and 11 deletions

View File

@@ -8584,6 +8584,12 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) {
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(targetContext, rv);
// If our target BrowsingContext is still pending initialization, ignore the
// navigation request targeting it.
if (NS_WARN_IF(targetContext->GetPendingInitialization())) {
return NS_OK;
}
aLoadState->SetTargetBrowsingContext(targetContext);
//
// Transfer the load to the target BrowsingContext... Clear the window target
@@ -9001,7 +9007,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
MOZ_ASSERT(false, "InternalLoad needs a valid triggeringPrincipal");
return NS_ERROR_FAILURE;
}
if (mBrowsingContext->PendingInitialization()) {
if (NS_WARN_IF(mBrowsingContext->GetPendingInitialization())) {
return NS_ERROR_NOT_AVAILABLE;
}