зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1611855 - Worklet must be part of the same parent's agentCluster - part 8 - usage of IsSharedMemoryAllowed, r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D61278 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1edd5d228f
Коммит
d59cd20bc8
|
@ -179,7 +179,9 @@ PostMessageEvent::Run() {
|
|||
cloneDataPolicy.allowIntraClusterClonableSharedObjects();
|
||||
}
|
||||
|
||||
// TODO: what about cloneDataPolicy.allowSharedMemoryObjects()
|
||||
if (targetWindow->IsSharedMemoryAllowed()) {
|
||||
cloneDataPolicy.allowSharedMemoryObjects();
|
||||
}
|
||||
|
||||
StructuredCloneHolder* holder;
|
||||
if (mHolder.constructed<StructuredCloneHolder>()) {
|
||||
|
|
|
@ -5777,12 +5777,15 @@ void nsGlobalWindowOuter::PostMessageMozOuter(JSContext* aCx,
|
|||
scriptLocation, callerAgentClusterId);
|
||||
|
||||
JS::CloneDataPolicy clonePolicy;
|
||||
if (GetDocGroup() && callerInnerWindow &&
|
||||
callerInnerWindow->IsSharedMemoryAllowed()) {
|
||||
|
||||
if (GetDocGroup() && callerAgentClusterId.isSome() &&
|
||||
GetDocGroup()->AgentClusterId().Equals(callerAgentClusterId.value())) {
|
||||
clonePolicy.allowIntraClusterClonableSharedObjects();
|
||||
}
|
||||
|
||||
// TODO: what about cloneDataPolicy.allowSharedMemoryObjects()
|
||||
if (callerInnerWindow && callerInnerWindow->IsSharedMemoryAllowed()) {
|
||||
clonePolicy.allowSharedMemoryObjects();
|
||||
}
|
||||
|
||||
event->Write(aCx, aMessage, aTransfer, clonePolicy, aError);
|
||||
if (NS_WARN_IF(aError.Failed())) {
|
||||
|
|
|
@ -33,10 +33,16 @@ void SharedMessageBody::Write(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
|||
MOZ_ASSERT(aRefMessageBodyService);
|
||||
|
||||
JS::CloneDataPolicy cloneDataPolicy;
|
||||
// TODO: this is going to change in the next patches.
|
||||
// During a writing, we don't know the destination, so we assume it is part of
|
||||
// the same agent cluster.
|
||||
cloneDataPolicy.allowIntraClusterClonableSharedObjects();
|
||||
|
||||
// TODO: what about cloneDataPolicy.allowSharedMemoryObjects()
|
||||
nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx);
|
||||
MOZ_ASSERT(global);
|
||||
|
||||
if (global->IsSharedMemoryAllowed()) {
|
||||
cloneDataPolicy.allowSharedMemoryObjects();
|
||||
}
|
||||
|
||||
mCloneData = MakeUnique<ipc::StructuredCloneData>(
|
||||
JS::StructuredCloneScope::UnknownDestination, mSupportsTransferring);
|
||||
|
@ -71,12 +77,12 @@ void SharedMessageBody::Read(JSContext* aCx,
|
|||
|
||||
JS::CloneDataPolicy cloneDataPolicy;
|
||||
|
||||
nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx);
|
||||
MOZ_ASSERT(global);
|
||||
|
||||
// Clones within the same agent cluster are allowed to use shared array
|
||||
// buffers and WASM modules.
|
||||
if (mAgentClusterId.isSome()) {
|
||||
nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx);
|
||||
MOZ_ASSERT(global);
|
||||
|
||||
Maybe<nsID> agentClusterId = global->GetAgentClusterId();
|
||||
if (agentClusterId.isSome() &&
|
||||
mAgentClusterId.value().Equals(agentClusterId.value())) {
|
||||
|
@ -84,7 +90,9 @@ void SharedMessageBody::Read(JSContext* aCx,
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: what about cloneDataPolicy.allowSharedMemoryObjects()
|
||||
if (global->IsSharedMemoryAllowed()) {
|
||||
cloneDataPolicy.allowSharedMemoryObjects();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mRefData);
|
||||
MOZ_ASSERT(mRefDataId.isSome());
|
||||
|
|
|
@ -67,7 +67,10 @@ bool MessageEventRunnable::DispatchDOMEvent(JSContext* aCx,
|
|||
parent->GetClientInfo()->AgentClusterId()->Equals(
|
||||
aWorkerPrivate->AgentClusterId())) {
|
||||
cloneDataPolicy.allowIntraClusterClonableSharedObjects();
|
||||
// TODO: what about cloneDataPolicy.allowSharedMemoryObjects()
|
||||
}
|
||||
|
||||
if (aWorkerPrivate->IsSharedMemoryAllowed()) {
|
||||
cloneDataPolicy.allowSharedMemoryObjects();
|
||||
}
|
||||
|
||||
Read(parent, aCx, &messageData, cloneDataPolicy, rv);
|
||||
|
|
|
@ -103,19 +103,21 @@ void Worker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|||
}
|
||||
|
||||
JS::CloneDataPolicy clonePolicy;
|
||||
// DedicatedWorkers are always part of the same agent cluster.
|
||||
clonePolicy.allowIntraClusterClonableSharedObjects();
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
nsGlobalWindowInner* win = nsContentUtils::CallerInnerWindow();
|
||||
if (win && win->IsSharedMemoryAllowed()) {
|
||||
clonePolicy.allowIntraClusterClonableSharedObjects();
|
||||
clonePolicy.allowSharedMemoryObjects();
|
||||
}
|
||||
} else {
|
||||
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
|
||||
if (worker && worker->IsSharedMemoryAllowed()) {
|
||||
clonePolicy.allowIntraClusterClonableSharedObjects();
|
||||
clonePolicy.allowSharedMemoryObjects();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: what about cloneDataPolicy.allowSharedMemoryObjects()
|
||||
runnable->Write(aCx, aMessage, transferable, clonePolicy, aRv);
|
||||
|
||||
if (isTimelineRecording) {
|
||||
|
|
|
@ -4039,11 +4039,13 @@ void WorkerPrivate::PostMessageToParent(
|
|||
}
|
||||
|
||||
JS::CloneDataPolicy clonePolicy;
|
||||
if (IsSharedMemoryAllowed()) {
|
||||
clonePolicy.allowIntraClusterClonableSharedObjects();
|
||||
}
|
||||
|
||||
// TODO: what about cloneDataPolicy.allowSharedMemoryObjects()
|
||||
// Parent and dedicated workers are always part of the same cluster.
|
||||
clonePolicy.allowIntraClusterClonableSharedObjects();
|
||||
|
||||
if (IsSharedMemoryAllowed()) {
|
||||
clonePolicy.allowSharedMemoryObjects();
|
||||
}
|
||||
|
||||
runnable->Write(aCx, aMessage, transferable, clonePolicy, aRv);
|
||||
|
||||
|
@ -5072,8 +5074,6 @@ const nsAString& WorkerPrivate::Id() {
|
|||
}
|
||||
|
||||
bool WorkerPrivate::IsSharedMemoryAllowed() const {
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
if (StaticPrefs::
|
||||
dom_postMessage_sharedArrayBuffer_bypassCOOP_COEP_insecure_enabled()) {
|
||||
return true;
|
||||
|
@ -5083,8 +5083,6 @@ bool WorkerPrivate::IsSharedMemoryAllowed() const {
|
|||
}
|
||||
|
||||
bool WorkerPrivate::CrossOriginIsolated() const {
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
if (!StaticPrefs::dom_postMessage_sharedArrayBuffer_withCOOP_COEP()) {
|
||||
return false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче