2020-02-07 09:45:13 -08: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
|
2025-02-21 14:46:51 -08:00
|
|
|
index 44da0544b778d6ff4c14b6f4e8463cb8260d2f0d..8ae8939af4141a684b7a6d50a43e1abb354ea028 100644
|
2020-02-07 09:45:13 -08:00
|
|
|
--- a/content/public/renderer/render_frame_observer.h
|
|
|
|
+++ b/content/public/renderer/render_frame_observer.h
|
2025-01-10 10:52:34 -06:00
|
|
|
@@ -149,6 +149,8 @@ class CONTENT_EXPORT RenderFrameObserver
|
2020-02-07 09:45:13 -08: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
|
2025-04-22 15:53:29 -04:00
|
|
|
index afb727a7f99f240e4d59970a169c2ea2265df98a..2d9453a5f38793eb112d52e4345fc9ff9dff3539 100644
|
2020-02-07 09:45:13 -08:00
|
|
|
--- a/content/renderer/render_frame_impl.cc
|
|
|
|
+++ b/content/renderer/render_frame_impl.cc
|
2025-04-22 15:53:29 -04:00
|
|
|
@@ -4810,6 +4810,12 @@ void RenderFrameImpl::DidCreateScriptContext(v8::Local<v8::Context> context,
|
2020-02-07 09:45:13 -08: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
|
2025-04-03 19:02:49 -05:00
|
|
|
index a072319de5d16d8004cb33792b2275320627fe6a..f52aa0470ca53c9997961c398d2c79d25967562e 100644
|
2020-02-07 09:45:13 -08:00
|
|
|
--- a/content/renderer/render_frame_impl.h
|
|
|
|
+++ b/content/renderer/render_frame_impl.h
|
2025-03-07 11:35:59 -06:00
|
|
|
@@ -653,6 +653,8 @@ class CONTENT_EXPORT RenderFrameImpl
|
2023-01-05 21:35:34 -05:00
|
|
|
void DidObserveLayoutShift(double score, bool after_input_or_scroll) override;
|
2020-02-07 09:45:13 -08: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
|
2025-04-03 19:02:49 -05:00
|
|
|
index fade7618e12889da5a1c3cbe465dec0869634407..53aaf91fe5e68465c9ec8b181e33b5ee95a5a5aa 100644
|
2020-02-07 09:45:13 -08:00
|
|
|
--- a/third_party/blink/public/web/web_local_frame_client.h
|
|
|
|
+++ b/third_party/blink/public/web/web_local_frame_client.h
|
2025-03-07 11:35:59 -06:00
|
|
|
@@ -664,6 +664,9 @@ class BLINK_EXPORT WebLocalFrameClient {
|
2020-02-07 09:45:13 -08: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
|
2024-07-02 09:51:33 +02:00
|
|
|
index f7e0144c74f879e9b29871d7c372b99e127966bb..c3cd7b77ed282f212a56d151dc3fbec36d183701 100644
|
2020-02-07 09:45:13 -08: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
|
2024-07-02 09:51:33 +02:00
|
|
|
@@ -217,6 +217,7 @@ void LocalWindowProxy::Initialize() {
|
2020-02-07 09:45:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
InstallConditionalFeatures();
|
|
|
|
+ GetFrame()->Client()->DidInstallConditionalFeatures(context, world_->GetWorldId());
|
|
|
|
|
|
|
|
if (World().IsMainWorld()) {
|
2023-03-10 10:07:42 -06:00
|
|
|
probe::DidCreateMainWorldContext(GetFrame());
|
2020-10-27 17:33:04 -07: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
|
2025-04-22 15:53:29 -04:00
|
|
|
index 3e041fb162ebdf8b0a04aff930b8161a37d6c4ed..8019c126e5a3132e236f169576738deffc2e31c2 100644
|
2020-10-27 17:33:04 -07:00
|
|
|
--- a/third_party/blink/renderer/core/frame/local_frame_client.h
|
|
|
|
+++ b/third_party/blink/renderer/core/frame/local_frame_client.h
|
2025-04-22 15:53:29 -04:00
|
|
|
@@ -300,6 +300,8 @@ class CORE_EXPORT LocalFrameClient : public FrameClient {
|
2020-10-27 17:33:04 -07: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
|
2025-04-22 15:53:29 -04:00
|
|
|
index bcdb1c4a762ee11bef513c4ca5b3b34f721bfd2b..598d3c504dc95ce618846fa4f06d9db65903db85 100644
|
2020-10-27 17:33:04 -07: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
|
2025-03-07 11:35:59 -06:00
|
|
|
@@ -295,6 +295,13 @@ void LocalFrameClientImpl::DidCreateScriptContext(
|
2020-02-07 09:45:13 -08: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-27 17:33:04 -07: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
|
2025-04-22 15:53:29 -04:00
|
|
|
index e38686bcbbc374d356be2705f4927903e64a7e6f..09a42b6595cb6593e94cc7496ff197e807993a5a 100644
|
2020-10-27 17:33:04 -07: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
|
2025-02-21 14:46:51 -08:00
|
|
|
@@ -82,6 +82,8 @@ class CORE_EXPORT LocalFrameClientImpl final : public LocalFrameClient {
|
2020-02-07 09:45:13 -08: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
|
2025-04-22 15:53:29 -04:00
|
|
|
index 4c36621228bb712e4a8bbac7f5f405da5e9eeeec..aef4cdbc206889f053007696504cb9cd235c688d 100644
|
2020-02-07 09:45:13 -08:00
|
|
|
--- a/third_party/blink/renderer/core/loader/empty_clients.h
|
|
|
|
+++ b/third_party/blink/renderer/core/loader/empty_clients.h
|
2025-04-22 15:53:29 -04:00
|
|
|
@@ -418,6 +418,8 @@ class CORE_EXPORT EmptyLocalFrameClient : public LocalFrameClient {
|
2020-02-07 09:45:13 -08: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; }
|