Bug 1608516 - Part 2: Make AddBlockedNodeByClassifier() in nsDocShell::EndPageLoad() Fission-compatible. r=baku

In this patch, we report the blocked node across the process
boundaries if the parent is in a different process. If the parent
document is in the same process as the reporting document, we
will directly add the blocked node in the parent document without
sending an IPC.

Depends on D71938

Differential Revision: https://phabricator.services.mozilla.com/D71939
This commit is contained in:
Tim Huang 2020-04-22 14:32:02 +00:00
Родитель 63168eae1d
Коммит 6ef45fb9b0
1 изменённых файлов: 34 добавлений и 21 удалений

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

@ -5994,32 +5994,45 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
UrlClassifierFeatureFactory::IsClassifierBlockingErrorCode(aStatus)) { UrlClassifierFeatureFactory::IsClassifierBlockingErrorCode(aStatus)) {
UnblockEmbedderLoadEventForFailure(); UnblockEmbedderLoadEventForFailure();
// frameElement is our nsIContent to be annotated RefPtr<BrowsingContext> bc = GetBrowsingContext();
RefPtr<Element> frameElement; RefPtr<BrowsingContext> parentBC = bc->GetParent();
nsPIDOMWindowOuter* thisWindow = GetWindow();
if (!thisWindow) { if (!parentBC) {
return NS_OK; return NS_OK;
} }
frameElement = thisWindow->GetFrameElement(); if (parentBC->IsInProcess()) {
if (!frameElement) { // We can directly add the blocked node in the parent document if the
return NS_OK; // parent is in the same process.
nsCOMPtr<nsPIDOMWindowOuter> parentOuter = parentBC->GetDOMWindow();
if (!parentOuter) {
return NS_OK;
}
nsCOMPtr<nsPIDOMWindowInner> parentInner =
parentOuter->GetCurrentInnerWindow();
if (!parentInner) {
return NS_OK;
}
RefPtr<Document> parentDoc;
parentDoc = parentInner->GetExtantDoc();
if (!parentDoc) {
return NS_OK;
}
parentDoc->AddBlockedNodeByClassifier(bc->GetEmbedderElement());
} else {
// If the parent is out-of-process, we send to the process of the
// document which embeds the frame to add the blocked node there.
RefPtr<BrowserChild> browserChild = BrowserChild::GetFrom(this);
if (browserChild) {
Unused << browserChild->SendReportBlockedEmbedderNodeByClassifier();
}
} }
// Parent window
nsCOMPtr<nsIDocShellTreeItem> parentItem;
GetInProcessSameTypeParent(getter_AddRefs(parentItem));
if (!parentItem) {
return NS_OK;
}
RefPtr<Document> parentDoc;
parentDoc = parentItem->GetDocument();
if (!parentDoc) {
return NS_OK;
}
parentDoc->AddBlockedNodeByClassifier(frameElement);
return NS_OK; return NS_OK;
} }