зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1625366 - Add cross-process violation event via WindowGlobal, fire violation events via WindowGlobal if they are for a window in a different process. r=ckerschb,nika
Differential Revision: https://phabricator.services.mozilla.com/D69909 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
efcf5979e5
Коммит
d65755c339
|
@ -64,6 +64,8 @@ child:
|
|||
*/
|
||||
async GetSecurityInfo() returns(nsCString? serializedSecInfo);
|
||||
|
||||
async DispatchSecurityPolicyViolation(nsString aViolationEventJSON);
|
||||
|
||||
both:
|
||||
async RawMessage(JSWindowActorMessageMeta aMetadata, ClonedMessageData aData,
|
||||
ClonedMessageData aStack);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "mozilla/dom/BrowserChild.h"
|
||||
#include "mozilla/dom/BrowserBridgeChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/SecurityPolicyViolationEvent.h"
|
||||
#include "mozilla/dom/WindowGlobalActorsBinding.h"
|
||||
#include "mozilla/dom/WindowGlobalParent.h"
|
||||
#include "mozilla/dom/WindowContext.h"
|
||||
|
@ -391,6 +392,30 @@ mozilla::ipc::IPCResult WindowGlobalChild::RecvGetSecurityInfo(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult WindowGlobalChild::RecvDispatchSecurityPolicyViolation(
|
||||
const nsString& aViolationEventJSON) {
|
||||
nsGlobalWindowInner* window = GetWindowGlobal();
|
||||
if (!window) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
Document* doc = window->GetDocument();
|
||||
if (!doc) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
SecurityPolicyViolationEventInit violationEvent;
|
||||
if (!violationEvent.Init(aViolationEventJSON)) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
RefPtr<Event> event = SecurityPolicyViolationEvent::Constructor(
|
||||
doc, NS_LITERAL_STRING("securitypolicyviolation"), violationEvent);
|
||||
event->SetTrusted(true);
|
||||
doc->DispatchEvent(*event, IgnoreErrors());
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
IPCResult WindowGlobalChild::RecvRawMessage(
|
||||
const JSWindowActorMessageMeta& aMeta, const ClonedMessageData& aData,
|
||||
const ClonedMessageData& aStack) {
|
||||
|
|
|
@ -133,6 +133,9 @@ class WindowGlobalChild final : public WindowGlobalActor,
|
|||
const uint32_t& aFlags,
|
||||
DrawSnapshotResolver&& aResolve);
|
||||
|
||||
mozilla::ipc::IPCResult RecvDispatchSecurityPolicyViolation(
|
||||
const nsString& aViolationEventJSON);
|
||||
|
||||
mozilla::ipc::IPCResult RecvGetSecurityInfo(
|
||||
GetSecurityInfoResolver&& aResolve);
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "mozilla/dom/CSPReportBinding.h"
|
||||
#include "mozilla/dom/CSPDictionariesBinding.h"
|
||||
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
||||
#include "mozilla/dom/WindowGlobalParent.h"
|
||||
#include "nsINetworkInterceptController.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "nsIScriptElement.h"
|
||||
|
@ -1328,6 +1329,17 @@ nsresult nsCSPContext::FireViolationEvent(
|
|||
eventTarget = doc;
|
||||
}
|
||||
|
||||
if (!eventTarget && mInnerWindowID && XRE_IsParentProcess()) {
|
||||
if (RefPtr<WindowGlobalParent> parent =
|
||||
WindowGlobalParent::GetByInnerWindowId(mInnerWindowID)) {
|
||||
nsAutoString json;
|
||||
if (aViolationEventInit.ToJSON(json)) {
|
||||
Unused << parent->SendDispatchSecurityPolicyViolation(json);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!eventTarget) {
|
||||
// If we are here, we are probably dealing with workers. Those are handled
|
||||
// via nsICSPEventListener. Nothing to do here.
|
||||
|
|
Загрузка…
Ссылка в новой задаче