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
|
2023-10-05 19:59:39 -04:00
|
|
|
index a4bf5bb618510ef5ef2ab2d05405cfd3688e97af..7a12c0ecb7254fe335c5563f3fd04c629abe065f 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
|
2023-10-05 19:59:39 -04:00
|
|
|
@@ -140,6 +140,8 @@ class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener,
|
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
|
2023-10-24 11:24:20 -04:00
|
|
|
index f19c8b5bff0fe6c5db2ac6b4a7409c7057191d70..2bf28010ea6e986e55f08587304c5991b9beebb3 100644
|
2020-02-07 09:45:13 -08:00
|
|
|
--- a/content/renderer/render_frame_impl.cc
|
|
|
|
+++ b/content/renderer/render_frame_impl.cc
|
2023-10-24 11:24:20 -04:00
|
|
|
@@ -4545,6 +4545,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
|
2023-10-24 11:24:20 -04:00
|
|
|
index 9ee1c23d93b096d26e3a2afc6ddfcb97aeb73aaf..8e9eec3472c4bbe1455f2026568737a8fbccfa51 100644
|
2020-02-07 09:45:13 -08:00
|
|
|
--- a/content/renderer/render_frame_impl.h
|
|
|
|
+++ b/content/renderer/render_frame_impl.h
|
2023-10-24 11:24:20 -04:00
|
|
|
@@ -614,6 +614,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
|
2023-10-24 11:24:20 -04:00
|
|
|
index e3ae568992d977adaf546cad6e226b913ecb00f7..0b8363c0edd6ca90223248603e622613a157e143 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
|
2023-10-24 11:24:20 -04:00
|
|
|
@@ -621,6 +621,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
|
2023-09-20 16:08:26 -04:00
|
|
|
index 5030619779b7bcd67923026991bb44d926d81e1a..1eea33740fcdca49e094ad7ad00cfda8938f96c1 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
|
2023-09-20 16:08:26 -04:00
|
|
|
@@ -202,6 +202,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
|
2023-10-24 11:24:20 -04:00
|
|
|
index 34a6f14a480e52fa381a9f652b2b39c8b64e5c4c..207918e8e45cd40d446fd71a4df5b2558f895c8b 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
|
2023-10-24 11:24:20 -04:00
|
|
|
@@ -321,6 +321,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
|
2023-10-24 11:24:20 -04:00
|
|
|
index d8c183fa7e38842907d37e3106f525a8fabba30b..c9d84213368f5094b0d275a9816367e962388f4c 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
|
2023-10-24 11:24:20 -04:00
|
|
|
@@ -282,6 +282,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
|
2023-10-24 11:24:20 -04:00
|
|
|
index 374811c04935519a73dbdd8eff7dcbdbd20bd230..77339de275ab737d1478c3aa386e7f40377c6dc8 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
|
2023-05-25 16:10:08 +02:00
|
|
|
@@ -84,6 +84,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
|
2023-10-24 11:24:20 -04:00
|
|
|
index fc063d5aa867e72dc3c5246f1da0bc48be4a331a..adc4d674d244bdea29e22afee90edb5c16521c06 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
|
2023-10-24 11:24:20 -04:00
|
|
|
@@ -408,6 +408,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; }
|