electron/patches/chromium/refactor_expose_hostimportmoduledynamically_and.patch
electron-roller[bot] 55d8b71d72
chore: bump chromium to 141.0.7346.0 (main) (#47983)
* chore: bump chromium in DEPS to 141.0.7341.0

* chore: bump chromium in DEPS to 141.0.7342.0

* chore: update patches

manually resolved conflict in `osr_shared_texture_remove_keyed_mutex_on_win_dxgi.patch` due to https://crrev.com/c/6681354

* 6819541: WebShare: Improve mac share behavior when sharing a URL
https://chromium-review.googlesource.com/c/chromium/src/+/6819541

* Add missing include for SkBitmap

Couldn't quickly find where we lost the full definition in this file's includes. 🤷

* 6771055: [SxS] Move devtools to ContentsContainerView supporting side-by-side.
https://chromium-review.googlesource.com/c/chromium/src/+/6771055

There may be some simplification possible here (set_x, Rect position, ...), but this change is satisfactory to maintain the current behavior.

* 6813689: Switch SystemMemoryInfoKB to use ByteCount
https://chromium-review.googlesource.com/c/chromium/src/+/6813689

* 6818486: Track DevTools feature usage in new badge tracker
https://chromium-review.googlesource.com/c/chromium/src/+/6818486

* chore: bump chromium in DEPS to 141.0.7344.0

* Remove ELECTRON_OZONE_PLATFORM_HINT env var

6819616: Remove OzonePlatformHint | https://chromium-review.googlesource.com/c/chromium/src/+/6819616

See: https://github.com/electron/electron/issues/48001

* chore: update patches

* Add missing include for `base::NumberToString`

* Remove `DESKTOP_STARTUP_ID` code

This was removed upstream in https://chromium-review.googlesource.com/c/chromium/src/+/6819616 and I confirmed with the author that it was an intentional change. Going to mirror upstream and remove it here too.

* chore: bump chromium in DEPS to 141.0.7346.0

* chore: update patches

* 6828465: Reland "Remove BluezDBusThreadManager"
https://chromium-review.googlesource.com/c/chromium/src/+/6828465

* Patch change to Node.js test output

V8 enhanced the stack trace of "thenable" async tasks. A couple of Node.js tests needed to have their snapshots updates to accomodate the extra stack trace frames in the output.

This patch should be upstreamed to Node.js.

See:
6826001: fix thenable async stack trace
https://chromium-review.googlesource.com/c/v8/v8/+/6826001

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
2025-08-11 12:57:31 +09: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 49ed3415ef4bbcdd71b12acbb6b149acd12eed84..91ded2f767b461d9d0152791fb02e31667186654 100644
--- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
+++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
@@ -637,8 +637,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,
@@ -716,20 +717,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();
@@ -756,6 +760,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);
}
@@ -786,7 +791,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.
@@ -803,9 +807,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,