From c5f471100b820a64baab6b6a9e92e48307a8188a Mon Sep 17 00:00:00 2001 From: Iulian Moraru Date: Fri, 28 Jan 2022 21:33:34 +0200 Subject: [PATCH] Backed out changeset e15925b76a27 (bug 1745638) for causing mochitest failures on test_bug1745638.html. --- docshell/base/nsDocShell.cpp | 122 ++---------------- docshell/test/navigation/file_bug1745638.html | 15 --- docshell/test/navigation/mochitest.ini | 2 - docshell/test/navigation/test_bug1745638.html | 36 ------ 4 files changed, 11 insertions(+), 164 deletions(-) delete mode 100644 docshell/test/navigation/file_bug1745638.html delete mode 100644 docshell/test/navigation/test_bug1745638.html diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 21e82906c849..d2a87a600b94 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -891,83 +891,6 @@ bool nsDocShell::IsLoadingFromSessionHistory() { return mActiveEntryIsLoadingFromSessionHistory; } -// StopDetector is modeled similarly to OnloadBlocker; it is a rather -// dummy nsIRequest implementation which can be added to an nsILoadGroup to -// detect Cancel calls. -class StopDetector final : public nsIRequest { - public: - StopDetector() = default; - - NS_DECL_ISUPPORTS - NS_DECL_NSIREQUEST - - bool Canceled() { return mCanceled; } - - private: - ~StopDetector() = default; - - bool mCanceled = false; -}; - -NS_IMPL_ISUPPORTS(StopDetector, nsIRequest) - -NS_IMETHODIMP -StopDetector::GetName(nsACString& aResult) { - aResult.AssignLiteral("about:stop-detector"); - return NS_OK; -} - -NS_IMETHODIMP -StopDetector::IsPending(bool* aRetVal) { - *aRetVal = true; - return NS_OK; -} - -NS_IMETHODIMP -StopDetector::GetStatus(nsresult* aStatus) { - *aStatus = NS_OK; - return NS_OK; -} - -NS_IMETHODIMP -StopDetector::Cancel(nsresult aStatus) { - mCanceled = true; - return NS_OK; -} - -NS_IMETHODIMP -StopDetector::Suspend(void) { return NS_OK; } -NS_IMETHODIMP -StopDetector::Resume(void) { return NS_OK; } - -NS_IMETHODIMP -StopDetector::GetLoadGroup(nsILoadGroup** aLoadGroup) { - *aLoadGroup = nullptr; - return NS_OK; -} - -NS_IMETHODIMP -StopDetector::SetLoadGroup(nsILoadGroup* aLoadGroup) { return NS_OK; } - -NS_IMETHODIMP -StopDetector::GetLoadFlags(nsLoadFlags* aLoadFlags) { - *aLoadFlags = nsIRequest::LOAD_NORMAL; - return NS_OK; -} - -NS_IMETHODIMP -StopDetector::GetTRRMode(nsIRequest::TRRMode* aTRRMode) { - return GetTRRModeImpl(aTRRMode); -} - -NS_IMETHODIMP -StopDetector::SetTRRMode(nsIRequest::TRRMode aTRRMode) { - return SetTRRModeImpl(aTRRMode); -} - -NS_IMETHODIMP -StopDetector::SetLoadFlags(nsLoadFlags aLoadFlags) { return NS_OK; } - bool nsDocShell::MaybeHandleSubframeHistory( nsDocShellLoadState* aLoadState, bool aContinueHandlingSubframeHistory) { // First, verify if this is a subframe. @@ -1010,9 +933,7 @@ bool nsDocShell::MaybeHandleSubframeHistory( !GetCreatedDynamically()) { if (XRE_IsContentProcess()) { dom::ContentChild* contentChild = dom::ContentChild::GetSingleton(); - nsCOMPtr loadGroup; - GetLoadGroup(getter_AddRefs(loadGroup)); - if (contentChild && loadGroup && !mDocumentRequest) { + if (contentChild) { RefPtr parentDoc = parentDS->GetDocument(); parentDoc->BlockOnload(); RefPtr browsingContext = mBrowsingContext; @@ -1020,33 +941,11 @@ bool nsDocShell::MaybeHandleSubframeHistory( mBrowsingContext->GetCurrentLoadIdentifier(); RefPtr loadState = aLoadState; bool isNavigating = mIsNavigating; - RefPtr stopDetector = new StopDetector(); - loadGroup->AddRequest(stopDetector, nullptr); - // Need to set mDocumentRequest so that GetIsAttemptingToNavigate() - // returns true. - mDocumentRequest = stopDetector; auto resolve = [currentLoadIdentifier, browsingContext, parentDoc, loadState, - isNavigating, loadGroup, stopDetector]( + isNavigating]( mozilla::Maybe&& aResult) { - auto unblockParent = - MakeScopeExit([loadGroup, stopDetector, parentDoc]() { - loadGroup->RemoveRequest(stopDetector, nullptr, NS_OK); - parentDoc->UnblockOnload(false); - }); - - RefPtr docShell = - static_cast(browsingContext->GetDocShell()); - if (!docShell) { - return; - } - if (docShell->mDocumentRequest == stopDetector) { - docShell->mDocumentRequest = nullptr; - } - if (stopDetector->Canceled()) { - return; - } if (currentLoadIdentifier == browsingContext->GetCurrentLoadIdentifier() && aResult.isSome()) { @@ -1055,15 +954,16 @@ bool nsDocShell::MaybeHandleSubframeHistory( // history, index doesn't need to be updated. loadState->SetLoadIsFromSessionHistory(0, false); } - - // We got the results back from the parent process, call - // LoadURI again with the possibly updated data. - docShell->LoadURI(loadState, isNavigating, true); + RefPtr docShell = + static_cast(browsingContext->GetDocShell()); + if (docShell) { + // We got the results back from the parent process, call + // LoadURI again with the possibly updated data. + docShell->LoadURI(loadState, isNavigating, true); + } + parentDoc->UnblockOnload(false); }; - auto reject = [loadGroup, stopDetector, - parentDoc](mozilla::ipc::ResponseRejectReason) { - // In practise reject shouldn't be called ever. - loadGroup->RemoveRequest(stopDetector, nullptr, NS_OK); + auto reject = [parentDoc](mozilla::ipc::ResponseRejectReason) { parentDoc->UnblockOnload(false); }; contentChild->SendGetLoadingSessionHistoryInfoFromParent( diff --git a/docshell/test/navigation/file_bug1745638.html b/docshell/test/navigation/file_bug1745638.html deleted file mode 100644 index b98c8de91fc0..000000000000 --- a/docshell/test/navigation/file_bug1745638.html +++ /dev/null @@ -1,15 +0,0 @@ - - - -The iframe below should not be blank after a reload.
- - diff --git a/docshell/test/navigation/mochitest.ini b/docshell/test/navigation/mochitest.ini index cc500d06241b..7d671aae6024 100644 --- a/docshell/test/navigation/mochitest.ini +++ b/docshell/test/navigation/mochitest.ini @@ -98,8 +98,6 @@ support-files = file_bug1583110.html [test_bug1706090.html] support-files = file_bug1706090.html skip-if = fission # The test is currently for the old bfcache implementation -[test_bug1745638.html] -support-files = file_bug1745638.html [test_bug1747019.html] support-files = goback.html diff --git a/docshell/test/navigation/test_bug1745638.html b/docshell/test/navigation/test_bug1745638.html deleted file mode 100644 index d1f06081ade7..000000000000 --- a/docshell/test/navigation/test_bug1745638.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - bug 1745638 - - - - - -

- -

-
-