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-11-01 14:02:12 +00:00
|
|
|
index c302f3e672cea9b73591048cf581f3e81078d5cb..eb1d1b0b59e687b996e76c205a8712346089c04b 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-10-05 23:59:39 +00:00
|
|
|
@@ -140,6 +140,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-11-07 12:24:50 +00:00
|
|
|
index cdcb4a0a0ec3a44a79dac18086721d8fbb598e2e..9eab0679b498157d6376600dc08a206ba04c3e01 100644
|
2020-02-07 17:45:13 +00:00
|
|
|
--- a/content/renderer/render_frame_impl.cc
|
|
|
|
+++ b/content/renderer/render_frame_impl.cc
|
2023-11-07 12:24:50 +00:00
|
|
|
@@ -4551,6 +4551,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-11-01 14:02:12 +00:00
|
|
|
index 7a49bed638125a9980475ac6d4c825fcc9481548..7317ca6d2aca2362e6a260c931ec72fc2374fab5 100644
|
2020-02-07 17:45:13 +00:00
|
|
|
--- a/content/renderer/render_frame_impl.h
|
|
|
|
+++ b/content/renderer/render_frame_impl.h
|
2023-10-24 15:24:20 +00:00
|
|
|
@@ -614,6 +614,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-11-03 19:37:55 +00:00
|
|
|
index 64d8aca52be5e63c56fea2cb2a835761df11e098..6d3c66f3b08a625c4bcfffc3f2caf2d67f9ca258 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-11-03 19:37:55 +00:00
|
|
|
@@ -620,6 +620,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-09-20 20:08:26 +00:00
|
|
|
index 5030619779b7bcd67923026991bb44d926d81e1a..1eea33740fcdca49e094ad7ad00cfda8938f96c1 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-11-01 23:01:01 +00:00
|
|
|
index c0fa11ea9ec9f35fe7ee1c36a8ea618cc0ccaea0..cd8a420bb51be71996d697b49ccf51f2bcce2c4c 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-01 14:02:12 +00:00
|
|
|
@@ -320,6 +320,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-11-01 14:02:12 +00:00
|
|
|
index 5dd3383cfddf4edc050ef5b37e98452f3476d7a9..25942059009f735a1d6b52fc9c1033d26c893306 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-11-01 14:02:12 +00:00
|
|
|
index 2dd6df6727828335ca4462b470df4afd8dd29539..91ee3bf31ba43e650cacd2f781a3a8103d216570 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-03 19:37:55 +00:00
|
|
|
index e0c700c76f360b24d7ffa4edfe16dc855e4fd8b1..265f3c590062009ec98be231f9e1f496c39370e0 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-10-24 15:24:20 +00:00
|
|
|
@@ -408,6 +408,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; }
|