зеркало из https://github.com/electron/electron.git
53 строки
2.9 KiB
Diff
53 строки
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 9bda8d2fae9929485d2278de8b7ba9d4395e24b3..73e6de07678f24b983fcc6ebfba2ef000f9eac1c 100644
|
|
--- a/third_party/blink/public/web/web_local_frame.h
|
|
+++ b/third_party/blink/public/web/web_local_frame.h
|
|
@@ -350,6 +350,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 584792c678e3f8bf965d59df16422b70a844542b..60109fdcc7499843d10c5c7e9f8e22deff6c007c 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
|
|
@@ -950,6 +950,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 a6c74bdad96fc535a52b40bf7927782d2198aefb..0f7e00f7ff58fbea3a797b6b1d90f316582d22af 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
|
|
@@ -162,6 +162,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;
|