2018-10-24 18:24:11 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-09-21 00:30:26 +00:00
|
|
|
From: Anonymous <anonymous@electronjs.org>
|
|
|
|
Date: Thu, 20 Sep 2018 17:45:11 -0700
|
|
|
|
Subject: blink_world_context.patch
|
|
|
|
|
2019-12-13 17:18:45 +00:00
|
|
|
This exposes a method for obtaining a reference to an isolated world, which is
|
|
|
|
otherwise not available in the Blink API.
|
2018-09-21 00:30:26 +00:00
|
|
|
|
2018-09-14 18:03:43 +00:00
|
|
|
diff --git a/third_party/blink/public/web/web_local_frame.h b/third_party/blink/public/web/web_local_frame.h
|
2020-10-16 01:30:41 +00:00
|
|
|
index 6bbb5d6c2d98e5316eb7efa350a8fe23e26d6bfe..84f5e7b034c4dfaba72fd75f1d91cf2badf7c646 100644
|
2018-09-14 18:03:43 +00:00
|
|
|
--- a/third_party/blink/public/web/web_local_frame.h
|
|
|
|
+++ b/third_party/blink/public/web/web_local_frame.h
|
2020-10-16 01:30:41 +00:00
|
|
|
@@ -350,6 +350,8 @@ class WebLocalFrame : public WebFrame {
|
2020-06-01 20:34:34 +00:00
|
|
|
// Returns the world ID associated with |script_context|.
|
|
|
|
virtual int32_t GetScriptContextWorldId(
|
|
|
|
v8::Local<v8::Context> script_context) const = 0;
|
2018-09-14 18:03:43 +00:00
|
|
|
+ virtual v8::Local<v8::Context> WorldScriptContext(
|
|
|
|
+ v8::Isolate* isolate, int world_id) const = 0;
|
2020-06-01 20:34:34 +00:00
|
|
|
|
2018-09-14 18:03:43 +00:00
|
|
|
// Executes script in the context of the current page and returns the value
|
|
|
|
// that the script evaluated to with callback. Script execution can be
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc
|
2020-10-16 01:30:41 +00:00
|
|
|
index b1185d289c6c92bd2202823948f3ca71e80aa38d..f034415e9bdd00368cfc2e6180f0f658a62eae37 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc
|
|
|
|
+++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc
|
2020-10-16 01:30:41 +00:00
|
|
|
@@ -994,6 +994,13 @@ v8::Local<v8::Object> WebLocalFrameImpl::GlobalProxy() const {
|
2018-09-14 05:02:16 +00:00
|
|
|
return MainWorldScriptContext()->Global();
|
|
|
|
}
|
|
|
|
|
|
|
|
+v8::Local<v8::Context> WebLocalFrameImpl::WorldScriptContext(
|
|
|
|
+ v8::Isolate* isolate, int world_id) const {
|
|
|
|
+ scoped_refptr<DOMWrapperWorld> world = DOMWrapperWorld::EnsureIsolatedWorld(
|
|
|
|
+ isolate, world_id);
|
|
|
|
+ return ToScriptState(GetFrame(), *world)->GetContext();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
bool WebFrame::ScriptCanAccess(WebFrame* target) {
|
|
|
|
return BindingSecurity::ShouldAllowAccessToFrame(
|
|
|
|
CurrentDOMWindow(V8PerIsolateData::MainThreadIsolate()),
|
|
|
|
diff --git a/third_party/blink/renderer/core/frame/web_local_frame_impl.h b/third_party/blink/renderer/core/frame/web_local_frame_impl.h
|
2020-10-16 01:30:41 +00:00
|
|
|
index 4e5b1ae37464667f66c42f854152778316c9360e..417b9d6a41f97955c7b51065f6fdbeae67f75e85 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/third_party/blink/renderer/core/frame/web_local_frame_impl.h
|
|
|
|
+++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.h
|
2020-10-16 01:30:41 +00:00
|
|
|
@@ -162,6 +162,8 @@ class CORE_EXPORT WebLocalFrameImpl final
|
2018-09-14 05:02:16 +00:00
|
|
|
v8::Local<v8::Context> MainWorldScriptContext() const override;
|
2020-06-01 20:34:34 +00:00
|
|
|
int32_t GetScriptContextWorldId(
|
|
|
|
v8::Local<v8::Context> script_context) const override;
|
2018-09-14 05:02:16 +00:00
|
|
|
+ v8::Local<v8::Context> WorldScriptContext(
|
|
|
|
+ v8::Isolate* isolate, int world_id) const override;
|
2019-10-28 22:12:35 +00:00
|
|
|
void RequestExecuteScriptAndReturnValue(const WebScriptSource&,
|
|
|
|
bool user_gesture,
|
|
|
|
WebScriptExecutionCallback*) override;
|