Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/BindingSecurity.cpp

Issue 2058133002: Fix DevTools support of worklets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/BindingSecurity.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/BindingSecurity.cpp b/third_party/WebKit/Source/bindings/core/v8/BindingSecurity.cpp
index 8d4873af01c1476e750837de65dcbba650261e6a..d766a75057ce9ccea677efcd91801854f19d7242 100644
--- a/third_party/WebKit/Source/bindings/core/v8/BindingSecurity.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/BindingSecurity.cpp
@@ -131,13 +131,39 @@ bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi
return canAccessFrame(isolate, accessingWindow, frame->securityContext()->getSecurityOrigin(), frame->domWindow(), reportingOption);
}
-bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWindow* accessingWindow, const MainThreadWorkletGlobalScope* target, SecurityReportingOption reportingOption)
+bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, v8::Local<v8::Context> context, const ExecutionContext* executionContext, const MainThreadWorkletGlobalScope* workletGlobalScope, SecurityReportingOption reportingOption)
{
- ASSERT(target);
- const Frame* frame = target->frame();
- if (!frame || !frame->securityContext())
+ DCHECK(executionContext);
+ DOMWindow* domWindow = toDOMWindow(context);
+ if (executionContext->isMainThreadWorkletGlobalScope()) {
+ Frame* callingFrame = toMainThreadWorkletGlobalScope(executionContext)->frame();
+ domWindow = callingFrame ? callingFrame->domWindow() : nullptr;
+ }
+
+ DCHECK(workletGlobalScope);
+ const Frame* workletGlobalScopeFrame = workletGlobalScope->frame();
+ if (!workletGlobalScopeFrame || !workletGlobalScopeFrame->securityContext())
return false;
- return canAccessFrame(isolate, accessingWindow, frame->securityContext()->getSecurityOrigin(), frame->domWindow(), reportingOption);
+
+ return domWindow && canAccessFrame(isolate, toLocalDOMWindow(domWindow), workletGlobalScopeFrame->securityContext()->getSecurityOrigin(), workletGlobalScopeFrame->domWindow(), reportingOption);
+}
+
+bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, v8::Local<v8::Context> calling, v8::Local<v8::Context> target, SecurityReportingOption reportingOption)
+{
+ ExecutionContext* targetExecutionContext = toExecutionContext(target);
+ DCHECK(targetExecutionContext);
+
+ ExecutionContext* callingExecutionContext = toExecutionContext(calling);
+ DCHECK(callingExecutionContext);
+
+ if (targetExecutionContext->isMainThreadWorkletGlobalScope())
+ return shouldAllowAccessTo(isolate, calling, callingExecutionContext, toMainThreadWorkletGlobalScope(targetExecutionContext), DoNotReportSecurityError);
+
+ if (callingExecutionContext->isMainThreadWorkletGlobalScope())
+ return shouldAllowAccessTo(isolate, target, targetExecutionContext, toMainThreadWorkletGlobalScope(callingExecutionContext), DoNotReportSecurityError);
+
+ DOMWindow* window = toDOMWindow(target);
+ return window && shouldAllowAccessTo(isolate, toLocalDOMWindow(toDOMWindow(calling)), window, DoNotReportSecurityError);
}
bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWindow* accessingWindow, const Node* target, ExceptionState& exceptionState)

Powered by Google App Engine
This is Rietveld 408576698