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 2aefec4bd9877ee9109e3ab8ca9a8ab94d21b420..14a9a3c30164ced30d4bae47ea53f29ad831ab0d 100644 --- a/third_party/blink/public/web/web_local_frame.h +++ b/third_party/blink/public/web/web_local_frame.h @@ -333,6 +333,9 @@ class WebLocalFrame : public WebFrame { // be calling this API. virtual v8::Local MainWorldScriptContext() 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 // suspend. 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 da1e0054a3bf57364055b37aad06a65a3bab783e..99cd24e4665943369f38278ba0737d2eb79e713a 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 @@ -922,6 +922,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 1a349aee35a766015692922211b225e6cdeed97a..2e248e65407833ef893784b15e3e11d8cfeec371 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 @@ -160,6 +160,8 @@ class CORE_EXPORT WebLocalFrameImpl final int argc, v8::Local argv[]) override; v8::Local MainWorldScriptContext() const override; + v8::Local WorldScriptContext( + v8::Isolate* isolate, int world_id) const override; void RequestExecuteScriptAndReturnValue(const WebScriptSource&, bool user_gesture, WebScriptExecutionCallback*) override;