Bug 1594921: Don't send top-level location change events early in BrowserChild lifetime. r=nika

Doing so results in unexpected load events for the initial about:blank
document, which the frame script implementation did not see.

Differential Revision: https://phabricator.services.mozilla.com/D110173
This commit is contained in:
Kris Maglione 2021-03-30 21:52:25 +00:00
Родитель 247b41df3c
Коммит 97ee1a3fa1
2 изменённых файлов: 18 добавлений и 5 удалений

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

@ -242,6 +242,10 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
bool IsTopLevel() const { return mIsTopLevel; }
bool ShouldSendWebProgressEventsToParent() const {
return mShouldSendWebProgressEventsToParent;
}
/**
* MessageManagerCallback methods that we override.
*/

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

@ -7,6 +7,7 @@
#include "mozilla/Assertions.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/dom/BrowserChild.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/Document.h"
@ -269,11 +270,19 @@ WebNavigationContent::OnLocationChange(nsIWebProgress* aWebProgress,
isHistoryStateUpdated, isReferenceFragmentUpdated);
}
} else if (bc->IsTop()) {
// We have to catch the document changes from top level frames here,
// where we can detect the "server redirect" transition.
// (bug 1264936 and bug 125662)
ExtensionsChild::Get().SendDocumentChange(
bc, GetFrameTransitionData(aWebProgress, aRequest), aLocation);
MOZ_ASSERT(bc->IsInProcess());
if (RefPtr browserChild = dom::BrowserChild::GetFrom(bc->GetDocShell())) {
// Only send progress events which happen after we've started loading
// things into the BrowserChild. This matches the behavior of the remote
// WebProgress implementation.
if (browserChild->ShouldSendWebProgressEventsToParent()) {
// We have to catch the document changes from top level frames here,
// where we can detect the "server redirect" transition.
// (bug 1264936 and bug 125662)
ExtensionsChild::Get().SendDocumentChange(
bc, GetFrameTransitionData(aWebProgress, aRequest), aLocation);
}
}
}
return NS_OK;