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-12-11 20:58:26 +00:00
|
|
|
index 27d84a5d61f39dc039608b8a1e84bca47cb8d5d3..5a9bdc6593a9262bdcf6d9ad007f6e9388892086 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-12-11 20:58:26 +00:00
|
|
|
@@ -141,6 +141,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-12-11 20:58:26 +00:00
|
|
|
index 7f9d758df761b1d7946d80900e35dec833dea48e..1443c3cbc7ad79fba2a3f42a172a97422a470170 100644
|
2020-02-07 17:45:13 +00:00
|
|
|
--- a/content/renderer/render_frame_impl.cc
|
|
|
|
+++ b/content/renderer/render_frame_impl.cc
|
2023-12-11 20:58:26 +00:00
|
|
|
@@ -4573,6 +4573,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-12-11 20:58:26 +00:00
|
|
|
index 05c969e5ae96170ed9cf99bba6bb52ef11f9d158..16c4e4ef47d928bb3abf8650dd8af17cee9aa3c0 100644
|
2020-02-07 17:45:13 +00:00
|
|
|
--- a/content/renderer/render_frame_impl.h
|
|
|
|
+++ b/content/renderer/render_frame_impl.h
|
2023-12-11 20:58:26 +00:00
|
|
|
@@ -620,6 +620,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-12-11 20:58:26 +00:00
|
|
|
index bc8e5ac55bd663ecd95b7d61e899a13ae7e0c5bd..f7ca98a8b04fec36b3ccd1a75068e41787b21431 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-12-11 20:58:26 +00:00
|
|
|
@@ -634,6 +634,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-11-28 21:40:12 +00:00
|
|
|
index e22ccf32a9e3c596e44506244f284f1c2be86762..65ff494dc7c5676fbb534c1dd1854010c507a1eb 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-09-20 20:08:26 +00:00
|
|
|
@@ -202,6 +202,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-12-11 20:58:26 +00:00
|
|
|
index 98a8a2c427cc60408e1042ce6b2fcd58afa0150d..3e179d19ffd078ca85b5a6c050cc23b8c43cad30 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-11-28 21:40:12 +00:00
|
|
|
@@ -302,6 +302,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-12-11 20:58:26 +00:00
|
|
|
index 13a48fefbdf9eb1845522ace6c551fb7af7807db..41915ebed1e41970d8d61785a3aa89cedeb279d2 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-11-01 14:02:12 +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-12-11 20:58:26 +00:00
|
|
|
index 1c8f50ee733b4caba9a6ee4a7fe025dfb412a47a..29e8fdcb7d34f30674ed86a0024ee5c23dbb503e 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-05-25 14:10:08 +00:00
|
|
|
@@ -84,6 +84,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-11-28 21:40:12 +00:00
|
|
|
index 97bd9953e14088517a80b44c244f2bacf3b699bb..e67b3126f1082ecd2b6867ae01ab30d4c6ea41c5 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-11-28 21:40:12 +00:00
|
|
|
@@ -406,6 +406,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; }
|