зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1591892 - Expose {window, self}.crossOriginIsolated r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D52532 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
513f38c497
Коммит
e65a2c3ebb
|
@ -2359,7 +2359,7 @@ void nsGlobalWindowInner::UpdateTopInnerWindow() {
|
|||
mTopInnerWindow->UpdateWebSocketCount(-(int32_t)mNumOfOpenWebSockets);
|
||||
}
|
||||
|
||||
bool nsGlobalWindowInner::IsCrossOriginIsolated() const {
|
||||
bool nsGlobalWindowInner::IsSharedMemoryAllowed() const {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (StaticPrefs::
|
||||
|
@ -2367,6 +2367,12 @@ bool nsGlobalWindowInner::IsCrossOriginIsolated() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
return CrossOriginIsolated();
|
||||
}
|
||||
|
||||
bool nsGlobalWindowInner::CrossOriginIsolated() const {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!StaticPrefs::dom_postMessage_sharedArrayBuffer_withCOOP_COEP()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -940,8 +940,10 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
|||
return GetExtantDoc() && GetExtantDoc()->IsInSyncOperation();
|
||||
}
|
||||
|
||||
bool IsSharedMemoryAllowed() const;
|
||||
|
||||
// https://whatpr.org/html/4734/structured-data.html#cross-origin-isolated
|
||||
bool IsCrossOriginIsolated() const;
|
||||
bool CrossOriginIsolated() const;
|
||||
|
||||
protected:
|
||||
// Web IDL helpers
|
||||
|
|
|
@ -6058,7 +6058,7 @@ void nsGlobalWindowOuter::PostMessageMozOuter(JSContext* aCx,
|
|||
|
||||
JS::CloneDataPolicy clonePolicy;
|
||||
if (GetDocGroup() && callerInnerWindow &&
|
||||
callerInnerWindow->IsCrossOriginIsolated()) {
|
||||
callerInnerWindow->IsSharedMemoryAllowed()) {
|
||||
clonePolicy.allowSharedMemory();
|
||||
}
|
||||
event->Write(aCx, aMessage, aTransfer, clonePolicy, aError);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
[Exposed=(Window,Worker)]
|
||||
interface mixin WindowOrWorkerGlobalScope {
|
||||
[Replaceable] readonly attribute USVString origin;
|
||||
readonly attribute boolean crossOriginIsolated;
|
||||
|
||||
// base64 utility methods
|
||||
[Throws]
|
||||
|
|
|
@ -104,12 +104,12 @@ void Worker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|||
JS::CloneDataPolicy clonePolicy;
|
||||
if (NS_IsMainThread()) {
|
||||
nsGlobalWindowInner* win = nsContentUtils::CallerInnerWindow();
|
||||
if (win && win->IsCrossOriginIsolated()) {
|
||||
if (win && win->IsSharedMemoryAllowed()) {
|
||||
clonePolicy.allowSharedMemory();
|
||||
}
|
||||
} else {
|
||||
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
|
||||
if (worker && worker->IsCrossOriginIsolated()) {
|
||||
if (worker && worker->IsSharedMemoryAllowed()) {
|
||||
clonePolicy.allowSharedMemory();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3950,7 +3950,7 @@ void WorkerPrivate::PostMessageToParent(
|
|||
}
|
||||
|
||||
JS::CloneDataPolicy clonePolicy;
|
||||
if (IsCrossOriginIsolated()) {
|
||||
if (IsSharedMemoryAllowed()) {
|
||||
clonePolicy.allowSharedMemory();
|
||||
}
|
||||
runnable->Write(aCx, aMessage, transferable, clonePolicy, aRv);
|
||||
|
@ -4974,7 +4974,7 @@ const nsAString& WorkerPrivate::Id() {
|
|||
return mId;
|
||||
}
|
||||
|
||||
bool WorkerPrivate::IsCrossOriginIsolated() const {
|
||||
bool WorkerPrivate::IsSharedMemoryAllowed() const {
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
if (StaticPrefs::
|
||||
|
@ -4982,6 +4982,12 @@ bool WorkerPrivate::IsCrossOriginIsolated() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
return CrossOriginIsolated();
|
||||
}
|
||||
|
||||
bool WorkerPrivate::CrossOriginIsolated() const {
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
if (!StaticPrefs::dom_postMessage_sharedArrayBuffer_withCOOP_COEP()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -896,8 +896,10 @@ class WorkerPrivate : public RelativeTimeline {
|
|||
|
||||
const nsID& AgentClusterId() const { return mAgentClusterId; }
|
||||
|
||||
bool IsSharedMemoryAllowed() const;
|
||||
|
||||
// https://whatpr.org/html/4734/structured-data.html#cross-origin-isolated
|
||||
bool IsCrossOriginIsolated() const;
|
||||
bool CrossOriginIsolated() const;
|
||||
|
||||
private:
|
||||
WorkerPrivate(
|
||||
|
|
|
@ -386,6 +386,10 @@ void WorkerGlobalScope::GetOrigin(nsAString& aOrigin) const {
|
|||
aOrigin = mWorkerPrivate->Origin();
|
||||
}
|
||||
|
||||
bool WorkerGlobalScope::CrossOriginIsolated() const {
|
||||
return mWorkerPrivate->CrossOriginIsolated();
|
||||
}
|
||||
|
||||
void WorkerGlobalScope::Atob(const nsAString& aAtob, nsAString& aOutput,
|
||||
ErrorResult& aRv) const {
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
|
|
@ -142,6 +142,7 @@ class WorkerGlobalScope : public DOMEventTargetHelper,
|
|||
void ClearInterval(int32_t aHandle);
|
||||
|
||||
void GetOrigin(nsAString& aOrigin) const;
|
||||
bool CrossOriginIsolated() const;
|
||||
|
||||
void Atob(const nsAString& aAtob, nsAString& aOutput, ErrorResult& aRv) const;
|
||||
void Btoa(const nsAString& aBtoa, nsAString& aOutput, ErrorResult& aRv) const;
|
||||
|
|
Загрузка…
Ссылка в новой задаче