зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1601310 - Add GetContentBlockingEvents IPC method for the child to retrive content blocking event in the parent. r=timhuang,twisniewski,Ehsan
This patch does the following: 1. Add a WindowGlobalChild IPC method - GetContentBlockingEvents. Documents can use the method retrieve content blocking events stored in the parent process. 2. Update nsIDocShell::GetHasTrackingContentBlocked to return a promise. 3. Replace API in report-site-issue to use the promise-based GetHasTrackingContentBlocked API Differential Revision: https://phabricator.services.mozilla.com/D56204 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
fca74ac308
Коммит
45330c2c4e
|
@ -80,7 +80,7 @@ function checkForFrameworks(tabId) {
|
|||
${hasFastClickPageScript};
|
||||
${hasMobifyPageScript};
|
||||
${hasMarfeelPageScript};
|
||||
|
||||
|
||||
const result = {
|
||||
hasFastClick: hasFastClickPageScript(),
|
||||
hasMobify: hasMobifyPageScript(),
|
||||
|
|
|
@ -174,11 +174,13 @@ function getInfoFrameScript(messageName) {
|
|||
});
|
||||
}
|
||||
|
||||
sendAsyncMessage(messageName, {
|
||||
hasMixedActiveContentBlocked: docShell.hasMixedActiveContentBlocked,
|
||||
hasMixedDisplayContentBlocked: docShell.hasMixedDisplayContentBlocked,
|
||||
hasTrackingContentBlocked: docShell.hasTrackingContentBlocked,
|
||||
log: getLoggedMessages(content),
|
||||
docShell.getHasTrackingContentBlocked().then(hasTrackingContentBlocked => {
|
||||
sendAsyncMessage(messageName, {
|
||||
hasMixedActiveContentBlocked: docShell.hasMixedActiveContentBlocked,
|
||||
hasMixedDisplayContentBlocked: docShell.hasMixedDisplayContentBlocked,
|
||||
hasTrackingContentBlocked,
|
||||
log: getLoggedMessages(content),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -95,8 +95,8 @@ add_task(async function test_opened_page() {
|
|||
"docShell.hasMixedDisplayContentBlocked is available"
|
||||
);
|
||||
is(
|
||||
typeof docShell.hasTrackingContentBlocked,
|
||||
"boolean",
|
||||
typeof docShell.getHasTrackingContentBlocked,
|
||||
"function",
|
||||
"docShell.hasTrackingContentBlocked is available"
|
||||
);
|
||||
|
||||
|
|
|
@ -1402,9 +1402,37 @@ nsDocShell::GetHasMixedDisplayContentBlocked(
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetHasTrackingContentBlocked(bool* aHasTrackingContentBlocked) {
|
||||
nsDocShell::GetHasTrackingContentBlocked(Promise** aPromise) {
|
||||
MOZ_ASSERT(aPromise);
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<Document> doc(GetDocument());
|
||||
*aHasTrackingContentBlocked = doc && doc->GetHasTrackingContentBlocked();
|
||||
RefPtr<Promise> retPromise = Promise::Create(doc->GetOwnerGlobal(), rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
// Retrieve the document's content blocking events from the parent process.
|
||||
RefPtr<Document::GetContentBlockingEventsPromise> promise =
|
||||
doc->GetContentBlockingEvents();
|
||||
if (promise) {
|
||||
promise->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[retPromise](const Document::GetContentBlockingEventsPromise::
|
||||
ResolveOrRejectValue& aValue) {
|
||||
if (aValue.IsResolve()) {
|
||||
bool has = aValue.ResolveValue() &
|
||||
nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT;
|
||||
retPromise->MaybeResolve(has);
|
||||
} else {
|
||||
retPromise->MaybeResolve(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
retPromise->MaybeResolve(false);
|
||||
}
|
||||
|
||||
retPromise.forget(aPromise);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -512,12 +512,6 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
*/
|
||||
[infallible] readonly attribute boolean hasMixedDisplayContentBlocked;
|
||||
|
||||
/**
|
||||
* This attribute determines whether a document has Tracking Content
|
||||
* that has been blocked from loading.
|
||||
*/
|
||||
[infallible] readonly attribute boolean hasTrackingContentBlocked;
|
||||
|
||||
/**
|
||||
* Disconnects this docshell's editor from its window, and stores the
|
||||
* editor data in the open document's session history entry. This
|
||||
|
@ -1114,6 +1108,13 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
*/
|
||||
Promise getContentBlockingLog();
|
||||
|
||||
/**
|
||||
* This returns a Promise which resolves to a boolean. True when the
|
||||
* document has Tracking Content that has been blocked from loading, false
|
||||
* otherwise.
|
||||
*/
|
||||
Promise getHasTrackingContentBlocked();
|
||||
|
||||
/**
|
||||
* Return whether this docshell is "attempting to navigate" in the
|
||||
* sense that's relevant to document.open.
|
||||
|
|
|
@ -15488,7 +15488,34 @@ already_AddRefed<mozilla::dom::Promise> Document::HasStorageAccess(
|
|||
return promise.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> Document::RequestStorageAccess(ErrorResult& aRv) {
|
||||
RefPtr<Document::GetContentBlockingEventsPromise>
|
||||
Document::GetContentBlockingEvents() {
|
||||
RefPtr<nsPIDOMWindowInner> inner = GetInnerWindow();
|
||||
if (!inner) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<WindowGlobalChild> wgc = inner->GetWindowGlobalChild();
|
||||
if (!wgc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return wgc->SendGetContentBlockingEvents()->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[](const WindowGlobalChild::GetContentBlockingEventsPromise::
|
||||
ResolveOrRejectValue& aValue) {
|
||||
if (aValue.IsResolve()) {
|
||||
return Document::GetContentBlockingEventsPromise::CreateAndResolve(
|
||||
aValue.ResolveValue(), __func__);
|
||||
}
|
||||
|
||||
return Document::GetContentBlockingEventsPromise::CreateAndReject(
|
||||
false, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
|
||||
mozilla::ErrorResult& aRv) {
|
||||
nsIGlobalObject* global = GetScopeObject();
|
||||
if (!global) {
|
||||
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
|
|
|
@ -1109,6 +1109,13 @@ class Document : public nsINode,
|
|||
mHasUnsafeEvalCSP = aHasUnsafeEvalCSP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a promise which resolves to the content blocking events.
|
||||
*/
|
||||
typedef MozPromise<uint32_t, bool, true> GetContentBlockingEventsPromise;
|
||||
MOZ_MUST_USE RefPtr<GetContentBlockingEventsPromise>
|
||||
GetContentBlockingEvents();
|
||||
|
||||
/**
|
||||
* Get the content blocking log.
|
||||
*/
|
||||
|
|
|
@ -88,6 +88,9 @@ parent:
|
|||
// Attempts to perform a "Web Share".
|
||||
async Share(IPCWebShareData aData) returns (nsresult rv);
|
||||
|
||||
// Get content blocking events from the parent process.
|
||||
async GetContentBlockingEvents() returns (uint32_t events);
|
||||
|
||||
async Destroy();
|
||||
};
|
||||
|
||||
|
|
|
@ -442,6 +442,14 @@ NS_IMPL_ISUPPORTS0(ShareHandler)
|
|||
|
||||
} // namespace
|
||||
|
||||
mozilla::ipc::IPCResult WindowGlobalParent::RecvGetContentBlockingEvents(
|
||||
WindowGlobalParent::GetContentBlockingEventsResolver&& aResolver) {
|
||||
uint32_t events = GetContentBlockingLog()->GetContentBlockingEventsInLog();
|
||||
aResolver(events);
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult WindowGlobalParent::RecvShare(
|
||||
IPCWebShareData&& aData, WindowGlobalParent::ShareResolver&& aResolver) {
|
||||
// Widget Layer handoff...
|
||||
|
|
|
@ -166,6 +166,9 @@ class WindowGlobalParent final : public WindowGlobalActor,
|
|||
const ClonedMessageData& aData,
|
||||
const ClonedMessageData& aStack);
|
||||
|
||||
mozilla::ipc::IPCResult RecvGetContentBlockingEvents(
|
||||
GetContentBlockingEventsResolver&& aResolver);
|
||||
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
void DrawSnapshotInternal(gfx::CrossProcessPaint* aPaint,
|
||||
|
|
Загрузка…
Ссылка в новой задаче