2020-02-07 17:45:13 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jeremy Apthorp <nornagon@nornagon.net>
|
|
|
|
Date: Wed, 15 Jan 2020 16:35:18 -0800
|
|
|
|
Subject: add DidInstallConditionalFeatures
|
|
|
|
|
|
|
|
This adds a hook on script context creation _after conditional features
|
|
|
|
have been installed_. Electron uses this to run preload scripts and
|
|
|
|
various other initialization. This is necessary because at the time
|
|
|
|
DidCreateScriptContext is called, not all JS APIs are available in the
|
|
|
|
context, which can cause some preload scripts to trip.
|
|
|
|
|
|
|
|
diff --git a/content/public/renderer/render_frame_observer.h b/content/public/renderer/render_frame_observer.h
|
2023-04-12 11:37:48 +00:00
|
|
|
index fef4c8e02067c44ed804c8b53db1007fae2d2a76..b36304ee0a832c5e1e2fd3af6151b7b03fd98ec4 100644
|
2020-02-07 17:45:13 +00:00
|
|
|
--- a/content/public/renderer/render_frame_observer.h
|
|
|
|
+++ b/content/public/renderer/render_frame_observer.h
|
2023-04-12 11:37:48 +00:00
|
|
|
@@ -137,6 +137,8 @@ class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener,
|
2020-02-07 17:45:13 +00:00
|
|
|
virtual void DidHandleOnloadEvents() {}
|
|
|
|
virtual void DidCreateScriptContext(v8::Local<v8::Context> context,
|
|
|
|
int32_t world_id) {}
|
|
|
|
+ virtual void DidInstallConditionalFeatures(v8::Local<v8::Context> context,
|
|
|
|
+ int32_t world_id) {}
|
|
|
|
virtual void WillReleaseScriptContext(v8::Local<v8::Context> context,
|
|
|
|
int32_t world_id) {}
|
|
|
|
virtual void DidClearWindowObject() {}
|
|
|
|
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
|
2023-05-23 19:58:58 +00:00
|
|
|
index 64e30259cdf7c0ee27f64d3c7d383171f6be1f4b..cc90f0e357d25f539be79f02724a27e178b501e8 100644
|
2020-02-07 17:45:13 +00:00
|
|
|
--- a/content/renderer/render_frame_impl.cc
|
|
|
|
+++ b/content/renderer/render_frame_impl.cc
|
2023-05-23 19:58:58 +00:00
|
|
|
@@ -4408,6 +4408,12 @@ void RenderFrameImpl::DidCreateScriptContext(v8::Local<v8::Context> context,
|
2020-02-07 17:45:13 +00:00
|
|
|
observer.DidCreateScriptContext(context, world_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
+void RenderFrameImpl::DidInstallConditionalFeatures(
|
|
|
|
+ v8::Local<v8::Context> context, int world_id) {
|
|
|
|
+ for (auto& observer : observers_)
|
|
|
|
+ observer.DidInstallConditionalFeatures(context, world_id);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void RenderFrameImpl::WillReleaseScriptContext(v8::Local<v8::Context> context,
|
|
|
|
int world_id) {
|
|
|
|
for (auto& observer : observers_)
|
|
|
|
diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h
|
2023-05-23 19:58:58 +00:00
|
|
|
index 0c8628f909e3a08b3f6ce7852842e50ec37e64cc..506aa2fc88003174dc7e82fc415e162e196dad61 100644
|
2020-02-07 17:45:13 +00:00
|
|
|
--- a/content/renderer/render_frame_impl.h
|
|
|
|
+++ b/content/renderer/render_frame_impl.h
|
2023-05-23 19:58:58 +00:00
|
|
|
@@ -606,6 +606,8 @@ class CONTENT_EXPORT RenderFrameImpl
|
2023-01-06 02:35:34 +00:00
|
|
|
void DidObserveLayoutShift(double score, bool after_input_or_scroll) override;
|
2020-02-07 17:45:13 +00:00
|
|
|
void DidCreateScriptContext(v8::Local<v8::Context> context,
|
|
|
|
int world_id) override;
|
|
|
|
+ void DidInstallConditionalFeatures(v8::Local<v8::Context> context,
|
|
|
|
+ int world_id) override;
|
|
|
|
void WillReleaseScriptContext(v8::Local<v8::Context> context,
|
|
|
|
int world_id) override;
|
|
|
|
void DidChangeScrollOffset() override;
|
|
|
|
diff --git a/third_party/blink/public/web/web_local_frame_client.h b/third_party/blink/public/web/web_local_frame_client.h
|
2023-05-23 19:58:58 +00:00
|
|
|
index b9ab9b46f2aab2af137583a6012d100cabc4faaf..3c6825f29f9b5d570d968c31cee25b04aed26b58 100644
|
2020-02-07 17:45:13 +00:00
|
|
|
--- a/third_party/blink/public/web/web_local_frame_client.h
|
|
|
|
+++ b/third_party/blink/public/web/web_local_frame_client.h
|
2023-05-23 19:58:58 +00:00
|
|
|
@@ -605,6 +605,9 @@ class BLINK_EXPORT WebLocalFrameClient {
|
2020-02-07 17:45:13 +00:00
|
|
|
virtual void DidCreateScriptContext(v8::Local<v8::Context>,
|
|
|
|
int32_t world_id) {}
|
|
|
|
|
|
|
|
+ virtual void DidInstallConditionalFeatures(v8::Local<v8::Context>,
|
|
|
|
+ int32_t world_id) {}
|
|
|
|
+
|
|
|
|
// WebKit is about to release its reference to a v8 context for a frame.
|
|
|
|
virtual void WillReleaseScriptContext(v8::Local<v8::Context>,
|
|
|
|
int32_t world_id) {}
|
|
|
|
diff --git a/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc b/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
|
2023-05-23 19:58:58 +00:00
|
|
|
index 62b35b9fa47f0b99f2b7b6bc712b3a4b2c1c8e4e..4a0fdbb120edc76647560fb86d95613c95ae7094 100644
|
2020-02-07 17:45:13 +00:00
|
|
|
--- a/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
|
|
|
|
+++ b/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
|
2023-03-10 16:07:42 +00:00
|
|
|
@@ -198,6 +198,7 @@ void LocalWindowProxy::Initialize() {
|
2020-02-07 17:45:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
InstallConditionalFeatures();
|
|
|
|
+ GetFrame()->Client()->DidInstallConditionalFeatures(context, world_->GetWorldId());
|
|
|
|
|
|
|
|
if (World().IsMainWorld()) {
|
2023-03-10 16:07:42 +00:00
|
|
|
probe::DidCreateMainWorldContext(GetFrame());
|
2020-10-28 00:33:04 +00:00
|
|
|
diff --git a/third_party/blink/renderer/core/frame/local_frame_client.h b/third_party/blink/renderer/core/frame/local_frame_client.h
|
2023-05-10 14:47:48 +00:00
|
|
|
index e5ad0659eb365fd99c40b0b33b6c0ff02ea6a95c..404eb3a5727886520ad7b0e90f974f889f65a150 100644
|
2020-10-28 00:33:04 +00:00
|
|
|
--- a/third_party/blink/renderer/core/frame/local_frame_client.h
|
|
|
|
+++ b/third_party/blink/renderer/core/frame/local_frame_client.h
|
2023-04-12 11:37:48 +00:00
|
|
|
@@ -315,6 +315,8 @@ class CORE_EXPORT LocalFrameClient : public FrameClient {
|
2020-10-28 00:33:04 +00:00
|
|
|
|
|
|
|
virtual void DidCreateScriptContext(v8::Local<v8::Context>,
|
|
|
|
int32_t world_id) = 0;
|
|
|
|
+ virtual void DidInstallConditionalFeatures(v8::Local<v8::Context>,
|
|
|
|
+ int32_t world_id) = 0;
|
|
|
|
virtual void WillReleaseScriptContext(v8::Local<v8::Context>,
|
|
|
|
int32_t world_id) = 0;
|
|
|
|
virtual bool AllowScriptExtensions() = 0;
|
|
|
|
diff --git a/third_party/blink/renderer/core/frame/local_frame_client_impl.cc b/third_party/blink/renderer/core/frame/local_frame_client_impl.cc
|
2023-05-10 14:47:48 +00:00
|
|
|
index 482615f3db3d26c20604780b39512c6c435cf0cc..8f31c34d1a31a991c1f344d58889becb92bc4832 100644
|
2020-10-28 00:33:04 +00:00
|
|
|
--- a/third_party/blink/renderer/core/frame/local_frame_client_impl.cc
|
|
|
|
+++ b/third_party/blink/renderer/core/frame/local_frame_client_impl.cc
|
2023-01-06 02:35:34 +00:00
|
|
|
@@ -283,6 +283,13 @@ void LocalFrameClientImpl::DidCreateScriptContext(
|
2020-02-07 17:45:13 +00:00
|
|
|
web_frame_->Client()->DidCreateScriptContext(context, world_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
+void LocalFrameClientImpl::DidInstallConditionalFeatures(
|
|
|
|
+ v8::Local<v8::Context> context,
|
|
|
|
+ int32_t world_id) {
|
|
|
|
+ if (web_frame_->Client())
|
|
|
|
+ web_frame_->Client()->DidInstallConditionalFeatures(context, world_id);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void LocalFrameClientImpl::WillReleaseScriptContext(
|
|
|
|
v8::Local<v8::Context> context,
|
|
|
|
int32_t world_id) {
|
2020-10-28 00:33:04 +00:00
|
|
|
diff --git a/third_party/blink/renderer/core/frame/local_frame_client_impl.h b/third_party/blink/renderer/core/frame/local_frame_client_impl.h
|
2023-05-10 14:47:48 +00:00
|
|
|
index 13af123a25c9b4ba446f086208d94a8833e46455..ea5befb20832edba7fee25d4c14549aca8a039e6 100644
|
2020-10-28 00:33:04 +00:00
|
|
|
--- a/third_party/blink/renderer/core/frame/local_frame_client_impl.h
|
|
|
|
+++ b/third_party/blink/renderer/core/frame/local_frame_client_impl.h
|
2023-04-12 11:37:48 +00:00
|
|
|
@@ -83,6 +83,8 @@ class CORE_EXPORT LocalFrameClientImpl final : public LocalFrameClient {
|
2020-02-07 17:45:13 +00:00
|
|
|
|
|
|
|
void DidCreateScriptContext(v8::Local<v8::Context>,
|
|
|
|
int32_t world_id) override;
|
|
|
|
+ void DidInstallConditionalFeatures(v8::Local<v8::Context>,
|
|
|
|
+ int32_t world_id) override;
|
|
|
|
void WillReleaseScriptContext(v8::Local<v8::Context>,
|
|
|
|
int32_t world_id) override;
|
|
|
|
|
|
|
|
diff --git a/third_party/blink/renderer/core/loader/empty_clients.h b/third_party/blink/renderer/core/loader/empty_clients.h
|
2023-05-10 14:47:48 +00:00
|
|
|
index bd4592a4f10d1370c72caf5c153cf831d5a55d7b..cc4d49cb14f5b259777a9b8023388175825ce8cf 100644
|
2020-02-07 17:45:13 +00:00
|
|
|
--- a/third_party/blink/renderer/core/loader/empty_clients.h
|
|
|
|
+++ b/third_party/blink/renderer/core/loader/empty_clients.h
|
2023-05-10 14:47:48 +00:00
|
|
|
@@ -403,6 +403,8 @@ class CORE_EXPORT EmptyLocalFrameClient : public LocalFrameClient {
|
2020-02-07 17:45:13 +00:00
|
|
|
|
|
|
|
void DidCreateScriptContext(v8::Local<v8::Context>,
|
|
|
|
int32_t world_id) override {}
|
|
|
|
+ void DidInstallConditionalFeatures(v8::Local<v8::Context>,
|
|
|
|
+ int32_t world_id) override {}
|
|
|
|
void WillReleaseScriptContext(v8::Local<v8::Context>,
|
|
|
|
int32_t world_id) override {}
|
|
|
|
bool AllowScriptExtensions() override { return false; }
|