electron/patches/chromium/refactor_expose_hostimportmoduledynamically_and.patch
trop[bot] 9c4d783d1f
chore: bump chromium to 140.0.7309.0 (38-x-y) (#47863)
* chore: bump chromium in DEPS to 140.0.7309.0

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>

* 6762172: Replace MSG_ROUTING_NONE with IPC::mojom::kRoutingIdNone.

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6762172

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* 6759543: [exit-time-destructors] Exclude target with warnings

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6759543

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* 6765167: Split PreconnectManager into interface and implementation.

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6765167

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* 6766775: [media] Clarify coded and visible size in FrameResources

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6766775

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* 6760878: Move PreconnectRequest to //content/public

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6760878

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* 6718973: Implement media playback trust check for the video PiP overlay window

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6718973

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* chore: add missing include of <iterator> in ada

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* chore: update patches

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* chore: node gen-libc++-filenames.js

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* 6759633: [media] Use format from shared image in FrameResources

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6759633

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-07-23 10:12:00 +02:00

100 lines
4.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <marshallofsound@electronjs.org>
Date: Wed, 8 Mar 2023 13:04:21 -0800
Subject: refactor: expose HostImportModuleDynamically and
HostGetImportMetaProperties to embedders
This is so that Electron can blend Blink's and Node's implementations of these isolate handlers.
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
index 9eb29fcae74cc7618f1d44fd64d63d7940f61260..e8828606e98a61a5d99c9c638e67eda887446f49 100644
--- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
+++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
@@ -628,8 +628,9 @@ bool WasmJSPromiseIntegrationEnabledCallback(v8::Local<v8::Context> context) {
return RuntimeEnabledFeatures::WebAssemblyJSPromiseIntegrationEnabled(
execution_context);
}
+} // namespace
-v8::MaybeLocal<v8::Promise> HostImportModuleWithPhaseDynamically(
+v8::MaybeLocal<v8::Promise> V8Initializer::HostImportModuleWithPhaseDynamically(
v8::Local<v8::Context> context,
v8::Local<v8::Data> v8_host_defined_options,
v8::Local<v8::Value> v8_referrer_resource_url,
@@ -707,20 +708,23 @@ v8::MaybeLocal<v8::Promise> HostImportModuleWithPhaseDynamically(
return resolver->Promise().V8Promise();
}
+// namespace
+namespace {
v8::MaybeLocal<v8::Promise> HostImportModuleDynamically(
v8::Local<v8::Context> context,
v8::Local<v8::Data> v8_host_defined_options,
v8::Local<v8::Value> v8_referrer_resource_url,
v8::Local<v8::String> v8_specifier,
v8::Local<v8::FixedArray> v8_import_attributes) {
- return HostImportModuleWithPhaseDynamically(
+ return V8Initializer::HostImportModuleWithPhaseDynamically(
context, v8_host_defined_options, v8_referrer_resource_url, v8_specifier,
v8::ModuleImportPhase::kEvaluation, v8_import_attributes);
}
+} // namespace
// https://html.spec.whatwg.org/C/#hostgetimportmetaproperties
-void HostGetImportMetaProperties(v8::Local<v8::Context> context,
+void V8Initializer::HostGetImportMetaProperties(v8::Local<v8::Context> context,
v8::Local<v8::Module> module,
v8::Local<v8::Object> meta) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
@@ -747,6 +751,7 @@ void HostGetImportMetaProperties(v8::Local<v8::Context> context,
meta->CreateDataProperty(context, resolve_key, resolve_value).ToChecked();
}
+namespace {
bool IsDOMExceptionWrapper(v8::Isolate* isolate, v8::Local<v8::Object> object) {
return V8DOMException::HasInstance(isolate, object);
}
@@ -777,7 +782,6 @@ void EmitDevToolsEvent(v8::Isolate* isolate) {
} // namespace
-// static
void V8Initializer::InitializeV8Common(v8::Isolate* isolate) {
// Set up garbage collection before setting up anything else as V8 may trigger
// GCs during Blink setup.
@@ -794,9 +798,9 @@ void V8Initializer::InitializeV8Common(v8::Isolate* isolate) {
SharedArrayBufferConstructorEnabledCallback);
isolate->SetHostImportModuleDynamicallyCallback(HostImportModuleDynamically);
isolate->SetHostImportModuleWithPhaseDynamicallyCallback(
- HostImportModuleWithPhaseDynamically);
+ V8Initializer::HostImportModuleWithPhaseDynamically);
isolate->SetHostInitializeImportMetaObjectCallback(
- HostGetImportMetaProperties);
+ V8Initializer::HostGetImportMetaProperties);
isolate->SetIsJSApiWrapperNativeErrorCallback(IsDOMExceptionWrapper);
isolate->SetMetricsRecorder(std::make_shared<V8MetricsRecorder>(isolate));
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.h b/third_party/blink/renderer/bindings/core/v8/v8_initializer.h
index be5df8f98c3f7e308d79d43c1811a16c644b6158..599121e3dabecf1a8192ba410ff447dcb540376c 100644
--- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.h
+++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.h
@@ -85,6 +85,18 @@ class CORE_EXPORT V8Initializer {
static void PromiseRejectHandlerInMainThread(v8::PromiseRejectMessage data);
static void ExceptionPropagationCallback(v8::ExceptionPropagationMessage);
+ static v8::MaybeLocal<v8::Promise> HostImportModuleWithPhaseDynamically(
+ v8::Local<v8::Context> context,
+ v8::Local<v8::Data> v8_host_defined_options,
+ v8::Local<v8::Value> v8_referrer_resource_url,
+ v8::Local<v8::String> v8_specifier,
+ v8::ModuleImportPhase import_phase,
+ v8::Local<v8::FixedArray> v8_import_assertions);
+
+ static void HostGetImportMetaProperties(v8::Local<v8::Context> context,
+ v8::Local<v8::Module> module,
+ v8::Local<v8::Object> meta);
+
static void WasmAsyncResolvePromiseCallback(
v8::Isolate* isolate,
v8::Local<v8::Context> context,