зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1627971 - Move docshell embedder unblock load to a helper. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D70584 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c7a24ee34a
Коммит
ce7219acd5
|
@ -3330,6 +3330,25 @@ nsDocShell::LoadURIFromScript(const nsAString& aURI,
|
|||
return LoadURI(aURI, loadURIOptions);
|
||||
}
|
||||
|
||||
void nsDocShell::UnblockEmbedderLoadEventForFailure() {
|
||||
// If we're not in a content frame, or are at a BrowsingContext tree boundary,
|
||||
// such as the content-chrome boundary, don't fire the error event.
|
||||
if (mBrowsingContext->IsTopContent() || mBrowsingContext->IsChrome()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we have a cross-process parent document, we must notify it that we no
|
||||
// longer block its load event. This is necessary for OOP sub-documents
|
||||
// because error documents do not result in a call to
|
||||
// SendMaybeFireEmbedderLoadEvents via any of the normal call paths.
|
||||
// (Obviously, we must do this before any of the returns below.)
|
||||
RefPtr<BrowserChild> browserChild = BrowserChild::GetFrom(this);
|
||||
if (browserChild) {
|
||||
mozilla::Unused << browserChild->SendMaybeFireEmbedderLoadEvents(
|
||||
/*aFireLoadAtEmbeddingElement*/ false);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
|
||||
const char16_t* aURL, nsIChannel* aFailedChannel,
|
||||
|
@ -3337,18 +3356,6 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
|
|||
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug,
|
||||
("DOCSHELL %p DisplayLoadError %s\n", this,
|
||||
aURI ? aURI->GetSpecOrDefault().get() : ""));
|
||||
// If we have a cross-process parent document, we must notify it that we no
|
||||
// longer block its load event. This is necessary for OOP sub-documents
|
||||
// because error documents do not result in a call to
|
||||
// SendMaybeFireEmbedderLoadEvents via any of the normal call paths.
|
||||
// (Obviously, we must do this before any of the returns below.)
|
||||
if (GetBrowsingContext()->IsContentSubframe() &&
|
||||
!GetBrowsingContext()->GetParent()->IsInProcess()) {
|
||||
if (BrowserChild* browserChild = BrowserChild::GetFrom(this)) {
|
||||
mozilla::Unused << browserChild->SendMaybeFireEmbedderLoadEvents(
|
||||
/*aFireLoadAtEmbeddingElement*/ false);
|
||||
}
|
||||
}
|
||||
|
||||
*aDisplayedErrorPage = false;
|
||||
// Get prompt and string bundle services
|
||||
|
@ -5977,6 +5984,7 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
|
|||
aStatus == NS_ERROR_FILE_ACCESS_DENIED ||
|
||||
aStatus == NS_ERROR_CORRUPTED_CONTENT ||
|
||||
aStatus == NS_ERROR_INVALID_CONTENT_ENCODING) {
|
||||
UnblockEmbedderLoadEventForFailure();
|
||||
DisplayLoadError(aStatus, url, nullptr, aChannel);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -5987,6 +5995,8 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
|
|||
// document. (document of parent window of blocked document)
|
||||
if (!isTopFrame &&
|
||||
UrlClassifierFeatureFactory::IsClassifierBlockingErrorCode(aStatus)) {
|
||||
UnblockEmbedderLoadEventForFailure();
|
||||
|
||||
// frameElement is our nsIContent to be annotated
|
||||
RefPtr<Element> frameElement;
|
||||
nsPIDOMWindowOuter* thisWindow = GetWindow();
|
||||
|
@ -6013,7 +6023,6 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
|
|||
}
|
||||
|
||||
parentDoc->AddBlockedNodeByClassifier(frameElement);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -6188,6 +6197,8 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
|
|||
// Well, fixup didn't work :-(
|
||||
// It is time to throw an error dialog box, and be done with it...
|
||||
|
||||
UnblockEmbedderLoadEventForFailure();
|
||||
|
||||
// Errors to be shown only on top-level frames
|
||||
if ((aStatus == NS_ERROR_UNKNOWN_HOST ||
|
||||
aStatus == NS_ERROR_CONNECTION_REFUSED ||
|
||||
|
@ -8992,6 +9003,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
|
|||
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCOMPtr<nsIChannel> chan(do_QueryInterface(req));
|
||||
UnblockEmbedderLoadEventForFailure();
|
||||
if (DisplayLoadError(rv, aLoadState->URI(), nullptr, chan) &&
|
||||
aLoadState->HasLoadFlags(LOAD_FLAGS_ERROR_LOAD_CHANGES_RV)) {
|
||||
return NS_ERROR_LOAD_SHOWED_ERRORPAGE;
|
||||
|
|
|
@ -1060,6 +1060,12 @@ class nsDocShell final : public nsDocLoader,
|
|||
// this docshell.
|
||||
uint32_t DetermineContentType();
|
||||
|
||||
// If this is an iframe, and the embedder is OOP, then notifes the
|
||||
// embedder that loading has finished and we shouldn't be blocking
|
||||
// load of the embedder. Only called when we fail to load, as we wait
|
||||
// for the load event of our Document before notifying success.
|
||||
void UnblockEmbedderLoadEventForFailure();
|
||||
|
||||
struct SameDocumentNavigationState {
|
||||
nsAutoCString mCurrentHash;
|
||||
nsAutoCString mNewHash;
|
||||
|
|
Загрузка…
Ссылка в новой задаче