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 fd6ce9a3df30bc11387db8ee63293f202a8d00aa..014a71c2b81cb6ab3a6a295d8ee6f403f75770fd 100644 --- a/third_party/blink/public/web/web_local_frame.h +++ b/third_party/blink/public/web/web_local_frame.h @@ -369,6 +369,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 35290011b1c32b8695e08ec80398e4df2cf611dc..1ae8fc18f467c50f2a7e0de9e24d708514c5cc86 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 @@ -1078,6 +1078,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 415bd0ead0d6be7e73dbdfc2066612b7abee99b4..7e6512649709e68b9ea9cd829f6b7ffadf8a59dd 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 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;