005101424a
Co-authored-by: Charles Kerr <charles@charleskerr.com>
52 lines
2.9 KiB
Diff
52 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Anonymous <anonymous@electronjs.org>
|
|
Date: Thu, 20 Sep 2018 17:45:11 -0700
|
|
Subject: blink_world_context.patch
|
|
|
|
This exposes a method for obtaining a reference to an isolated world, which is
|
|
otherwise not available in the Blink API.
|
|
|
|
diff --git a/third_party/blink/public/web/web_local_frame.h b/third_party/blink/public/web/web_local_frame.h
|
|
index 95b0e08204792c8a872af5da754fa57830d16945..d67c80ad99fcc5f46d4a475412ec862dba69e973 100644
|
|
--- a/third_party/blink/public/web/web_local_frame.h
|
|
+++ b/third_party/blink/public/web/web_local_frame.h
|
|
@@ -370,6 +370,8 @@ class WebLocalFrame : public WebFrame {
|
|
// Returns the world ID associated with |script_context|.
|
|
virtual int32_t GetScriptContextWorldId(
|
|
v8::Local<v8::Context> script_context) const = 0;
|
|
+ virtual v8::Local<v8::Context> WorldScriptContext(
|
|
+ v8::Isolate* isolate, int world_id) const = 0;
|
|
|
|
// Executes script in the context of the current page and returns the value
|
|
// that the script evaluated to with callback. Script execution can be
|
|
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
|
|
index c9fa66566c5c81746f82a6af92bbd14da88cec0e..f78d8464f5a6c50970cc2c8b28c83559c1a1c769 100644
|
|
--- a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc
|
|
+++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc
|
|
@@ -1079,6 +1079,13 @@ v8::Local<v8::Object> WebLocalFrameImpl::GlobalProxy() const {
|
|
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
|
|
index d029bf6ca2e0aa646dd7b9b763e5854aa2962c49..e0a4c24b81128a6b0d11af8685be8a01d2ad28e6 100644
|
|
--- a/third_party/blink/renderer/core/frame/web_local_frame_impl.h
|
|
+++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.h
|
|
@@ -170,6 +170,8 @@ class CORE_EXPORT WebLocalFrameImpl final
|
|
v8::Local<v8::Context> MainWorldScriptContext() const override;
|
|
int32_t GetScriptContextWorldId(
|
|
v8::Local<v8::Context> script_context) const override;
|
|
+ v8::Local<v8::Context> WorldScriptContext(
|
|
+ v8::Isolate* isolate, int world_id) const override;
|
|
void RequestExecuteScriptAndReturnValue(const WebScriptSource&,
|
|
bool user_gesture,
|
|
WebScriptExecutionCallback*) override;
|