diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index 98ddb73c6b60..0b42a651582b 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -237,7 +237,7 @@ bool BrowsingContext::IsOwnedByProcess() const { } bool BrowsingContext::SameOriginWithTop() { - MOZ_DIAGNOSTIC_ASSERT(IsInProcess()); + MOZ_ASSERT(IsInProcess()); // If the top BrowsingContext is not same-process to us, it is cross-origin if (!Top()->IsInProcess()) { return false; diff --git a/docshell/base/WindowContext.cpp b/docshell/base/WindowContext.cpp index a4fccf63248e..042eb2fb1d53 100644 --- a/docshell/base/WindowContext.cpp +++ b/docshell/base/WindowContext.cpp @@ -394,7 +394,7 @@ bool WindowContext::HasBeenUserGestureActivated() { } bool WindowContext::HasValidTransientUserGestureActivation() { - MOZ_DIAGNOSTIC_ASSERT(mInProcess); + MOZ_ASSERT(mInProcess); if (GetUserActivationState() != UserActivation::State::FullActivated) { MOZ_ASSERT(mUserGestureStart.IsNull(), @@ -414,7 +414,7 @@ bool WindowContext::HasValidTransientUserGestureActivation() { } bool WindowContext::ConsumeTransientUserGestureActivation() { - MOZ_DIAGNOSTIC_ASSERT(mInProcess); + MOZ_ASSERT(mInProcess); MOZ_ASSERT(!IsCached()); if (!HasValidTransientUserGestureActivation()) { diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index d56ae321a5bc..da86bbd9d5eb 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -9916,32 +9916,9 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState, nsIProtocolHandler::URI_DOES_NOT_RETURN_DATA, &doesNotReturnData); if (doesNotReturnData) { - // The context to check user-interaction with for the purposes of - // popup-blocking. - // - // We generally want to check the context that initiated the navigation. - WindowContext* sourceWindowContext = [&] { - const MaybeDiscardedBrowsingContext& sourceBC = - aLoadState->SourceBrowsingContext(); - if (!sourceBC.IsNullOrDiscarded()) { - if (WindowContext* wc = sourceBC.get()->GetCurrentWindowContext()) { - return wc; - } - } - return mBrowsingContext->GetParentWindowContext(); - }(); - - MOZ_ASSERT(sourceWindowContext); - // FIXME: We can't check user-interaction against an OOP window. This is - // the next best thing we can really do. The load state keeps whether - // the navigation had a user interaction in process - // (aLoadState->HasValidUserGestureActivation()), but we can't really - // consume it, which we want to prevent popup-spamming from the same - // click event. - WindowContext* context = - sourceWindowContext->IsInProcess() - ? sourceWindowContext - : mBrowsingContext->GetCurrentWindowContext(); + WindowContext* parentContext = + mBrowsingContext->GetParentWindowContext(); + MOZ_ASSERT(parentContext); const bool popupBlocked = [&] { const bool active = mBrowsingContext->IsActive(); @@ -9950,15 +9927,15 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState, // // We consume the flag now even if there's no user activation. const bool hasFreePass = [&] { - if (!active || !context->SameOriginWithTop()) { + if (!active || !parentContext->SameOriginWithTop()) { return false; } nsGlobalWindowInner* win = - context->TopWindowContext()->GetInnerWindow(); + parentContext->TopWindowContext()->GetInnerWindow(); return win && win->TryOpenExternalProtocolIframe(); }(); - if (context->ConsumeTransientUserGestureActivation()) { + if (parentContext->ConsumeTransientUserGestureActivation()) { // If the user has interacted with the page, consume it. return false; } @@ -9971,7 +9948,7 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState, return false; } - if (sourceWindowContext->CanShowPopup()) { + if (parentContext->CanShowPopup()) { return false; } @@ -9991,7 +9968,7 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState, if (NS_SUCCEEDED(rv)) { nsContentUtils::ReportToConsoleByWindowID( message, nsIScriptError::warningFlag, "DOM"_ns, - context->InnerWindowId()); + parentContext->InnerWindowId()); } return NS_OK; } diff --git a/uriloader/exthandler/tests/mochitest/browser_protocol_ask_dialog.js b/uriloader/exthandler/tests/mochitest/browser_protocol_ask_dialog.js index a829cb9d5f53..375dbcd721f6 100644 --- a/uriloader/exthandler/tests/mochitest/browser_protocol_ask_dialog.js +++ b/uriloader/exthandler/tests/mochitest/browser_protocol_ask_dialog.js @@ -310,38 +310,3 @@ add_task(async function nested_iframes() { await dialogClosedPromise; gBrowser.removeTab(tab); }); - -add_task(async function test_oop_iframe() { - const URI = `data:text/html,
`; - - let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URI); - - // Wait for the window and then click the link. - let dialogWindowPromise = waitForProtocolAppChooserDialog( - tab.linkedBrowser, - true - ); - - BrowserTestUtils.synthesizeMouseAtCenter( - "a:link", - {}, - tab.linkedBrowser.browsingContext.children[0] - ); - - let dialog = await dialogWindowPromise; - - is( - dialog._frame.contentDocument.location.href, - CONTENT_HANDLING_URL, - "Dialog URL is as expected" - ); - let dialogClosedPromise = waitForProtocolAppChooserDialog( - tab.linkedBrowser, - false - ); - - info("Removing tab to close the dialog."); - gBrowser.removeTab(tab); - await dialogClosedPromise; - ok(!dialog._frame.contentWindow, "The dialog should have been closed."); -});