From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Anonymous 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 dbc00b0e8e34ab0ba922cb4ad42a78bb188faccc..ce078ef2a5dbe360e1aff4926df4b5ac434c17a3 100644 --- a/third_party/blink/public/web/web_local_frame.h +++ b/third_party/blink/public/web/web_local_frame.h @@ -352,6 +352,8 @@ class WebLocalFrame : public WebFrame { // Returns the world ID associated with |script_context|. virtual int32_t GetScriptContextWorldId( v8::Local script_context) const = 0; + virtual v8::Local 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 ad206e51535ebf3e44de6dcfa98c2ba28e67e825..08bc2ce2f6cc938c22172ee03eeb807d3a4a2fd9 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 @@ -967,6 +967,13 @@ v8::Local WebLocalFrameImpl::GlobalProxy() const { return MainWorldScriptContext()->Global(); } +v8::Local WebLocalFrameImpl::WorldScriptContext( + v8::Isolate* isolate, int world_id) const { + scoped_refptr 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 d3dbe21b34cafa395706320bde5b7b11c1b84b4e..bc00e411e3ea6e08909d004de1a01cc548ec700d 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 @@ -166,6 +166,8 @@ class CORE_EXPORT WebLocalFrameImpl final v8::Local MainWorldScriptContext() const override; int32_t GetScriptContextWorldId( v8::Local script_context) const override; + v8::Local WorldScriptContext( + v8::Isolate* isolate, int world_id) const override; void RequestExecuteScriptAndReturnValue(const WebScriptSource&, bool user_gesture, WebScriptExecutionCallback*) override;