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


diff --git a/third_party/blink/public/web/web_local_frame.h b/third_party/blink/public/web/web_local_frame.h
index 437e8b22c0f589df3eb41ba8628092c3146b1f8c..0ff6b21fd5a9e49254f283dcbab0b2be9668b296 100644
--- a/third_party/blink/public/web/web_local_frame.h
+++ b/third_party/blink/public/web/web_local_frame.h
@@ -438,6 +438,9 @@ class WebLocalFrame : public WebFrame {
   // be calling this API.
   virtual v8::Local<v8::Context> MainWorldScriptContext() 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
   // 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 082b055a570c9d6ec944b3310f54934e65fbe6a0..345d97f888b522c17c755f48e43e7a699ca78472 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
@@ -874,6 +874,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 feb4b14bc8e52c8335e93d133506ecd6226c051d..95d1cc2c91ca01ec95dc3f63aa5f2546a7074095 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
@@ -145,6 +145,8 @@ class CORE_EXPORT WebLocalFrameImpl final
       int argc,
       v8::Local<v8::Value> argv[]) override;
   v8::Local<v8::Context> MainWorldScriptContext() const override;
+  v8::Local<v8::Context> WorldScriptContext(
+      v8::Isolate* isolate, int world_id) const override;
   v8::Local<v8::Object> GlobalProxy() const override;
   void StartReload(WebFrameLoadType) override;
   void ReloadImage(const WebNode&) override;
