Compare commits

..

76 Commits

Author SHA1 Message Date
Niklas Wenzel
c51f1aa46e build: reenable graphics effects for macOS tests (#46454) 2025-04-02 21:38:31 -05:00
trop[bot]
f41b4e3a81 perf: cache the return value of IsX11() (#46426)
* perf: cache the return value of IsX11()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* fix: mark as nodiscard for those who call, but mark as maybe_unused for Windows

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-04-01 17:55:09 -05:00
trop[bot]
4a55ffe1d8 build: make it clearer when cookie auth runs (#46421)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-04-01 18:32:42 -04:00
trop[bot]
2b94469560 perf: avoid redundant map lookup in UsbChooserContext::OnDeviceRemoved() (#46420)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-04-01 16:04:40 -05:00
trop[bot]
ab71a179ec perf: have ErrorThrower lazily lookup the current isolate (#46416)
perf: have ErrorThrower lazy-lookup the current isolate

ErrorThrower's default constructor is marked as "should rarely if ever
be used" because it's expensive to call.

Unfortunately, nearly every instance of ErrorThrower comes as an argument
in gin_helper's JS-->C++ function marshalling where a thrower is
default-constructed and then populated in gin_helper::GetNextArgument()
with an assignment operator to a temporary ErrorThrower constructed
with the gin::Arguments' isolate.

tldr: most of the time we use the slow constructor first, then throw
that work away unused by overwriting with a fast-constructed one.

This refactor avoids that cost by deferring the expensive work to
`ErrorThrower::isolate()`, where it happens only as a fallback iff
isolate_ hasn't been set.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-04-01 15:29:42 -05:00
trop[bot]
dc5091680c fix: leaked gfx::Canvas in AutofillPopupView::OnPaint() (#46411)
* perf: avoid redundant call to popup_bounds_in_view()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: use a std::optional<> for paint_canvas local

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* fix: fix leaked gfx::Canvas in AutofillPopupView::OnPaint()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: remove redundant get() call when testing smart pointer for nonempty

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: remove unnecessary draw_canvas variable

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: rename bitmap to offscreen_bitmap for symmetry

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: avoid another redundant call to popup_bounds_in_view()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-04-01 15:29:30 -05:00
electron-roller[bot]
8bfd7f05ac chore: bump node to v20.19.0 (34-x-y) (#46037)
* chore: bump node in DEPS to v20.19.0

* deps, src: simplifying base64 encoding

https://github.com/nodejs/node/pull/52714

* module: simplify --inspect-brk handling

https://github.com/nodejs/node/pull/55679

* test: make test-crypto-hash compatible with OpenSSL > 3.4.0

https://github.com/nodejs/node/pull/56160

* module: refactor ESM loader for adding future synchronous hooks

https://github.com/nodejs/node/pull/54769

* module: detect ESM syntax by trying to recompile as SourceTextModule

https://github.com/nodejs/node/pull/52413

* worker: add postMessageToThread

https://github.com/nodejs/node/pull/53682

* backport unflagging of require(esm) to v20

https://github.com/nodejs/node/pull/56927

* module: detect ESM syntax by trying to recompile as SourceTextModule

https://github.com/nodejs/node/pull/52413

* chore: fixup patch indices

* chore: handle filename.json changes

- https://github.com/nodejs/node/pull/51711
- https://github.com/nodejs/node/pull/53573

* src: refactor embedded entrypoint loading

https://github.com/nodejs/node/pull/53573

* lib: allow CJS source map cache to be reclaimed

https://github.com/nodejs/node/pull/51711

* test: make eval snapshot tests more flexible

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-04-01 20:51:57 +02:00
trop[bot]
b241c0d98a fix: UtilityProcess.fork crash before app ready (#46405)
fix: UtilityProcess.fork crash before app ready

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-04-01 09:32:22 -05:00
trop[bot]
75f5c91ad4 perf: avoid unnecessary vector copy in GetMimeTypeToExtensionIdMap() (#46397)
* perf: avoid making an unnecessary copy of the vector

MimeTypesHandler::GetMIMETypeAllowlist() returns a const&, so we can
iterate that directly instead of making a temporary copy of it.

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: move the call to ExtensionRegistry::Get() outside of the loop

Also, keep the previous behavior of not calling it at all if there
aren't any whitelisted extensions.

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: avoid redundant map lookup

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: const correctness

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: cleanup

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-04-01 08:55:26 -05:00
trop[bot]
b1a378ba26 refactor: use v8::String::Empty() when creating empty strings (#46370)
refactor: use v8::String::Empty() when creating empty strings

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-31 09:26:46 -05:00
trop[bot]
ab1d266535 perf: prefer absl::flat_hash_set over std::unordered_set (#46376)
* perf: use absl::flat_hash_set in SpellCheckClient::SpellCheckText()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: use absl::flat_hash_set in MessagePort::DisentanglePorts()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-31 10:39:42 +02:00
trop[bot]
b4540e013d perf: avoid double map lookup in HidChooserContext::DeviceRemoved() (#46360)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-29 08:12:22 -05:00
trop[bot]
b4568e63aa perf: avoid 3x call to GetID() in RegisterPendingSiteInstance() (#46357)
perf: avoid 3x call to GetID() in RegisterPendingSiteInstance()

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-29 08:12:11 -05:00
trop[bot]
db034229c4 perf: avoid a double-map lookup in NotificationPresenter::RemoveNotification() (#46355)
perf: avoid a double-map lokup in NotificationPresenter::RemoveNotification()

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-29 08:10:06 -05:00
trop[bot]
6f58c2ab8e perf: avoid redundant map lookups in GetStorageMask() (#46344)
* perf: avoid a redundant map lookuop in GetStorageMask()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: avoid a redundant map lookup in GetDataTypeMask()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-28 10:58:11 -05:00
trop[bot]
d046aacb00 fix: allow NSMenuItems to be disabled (#46340)
* fix: disable NSMenu autoenable feature to allow disabling of NSMenuItems

Co-authored-by: Hailey Schauman <hschauman@slack-corp.com>

* style: fix linter issues and update comments

Co-authored-by: Hailey Schauman <hschauman@slack-corp.com>

* chore: remove unneeded comment

Co-authored-by: Hailey <hschauman@slack-corp.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Hailey Schauman <hschauman@slack-corp.com>
2025-03-28 00:04:07 -05:00
trop[bot]
0410455878 build: validate Chromium cookie authentication (#46325)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-03-27 17:45:41 -07:00
trop[bot]
ef8c4f283d perf: avoid double map lookup in WebFrameMain::UpdateRenderFrameHost() (#46330)
perf: avoid double map lookup in WebFrameMain::UpdateRenderFrameHost()

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-27 19:21:04 -05:00
Robo
9e2af54b40 fix: emit context-menu event in Windows draggable regions (#46328)
fix: emit `context-menu` event in Windows draggable regions (#46032)

fix: emit context-menu event in Windows draggable regions

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-03-27 18:14:55 -05:00
trop[bot]
d7fabf348f perf: avoid a triple-redundant map lookup in ViewsDelegate::GetAppbarAutohideEdges() (#46332)
perf: avoid a triple-redundant map lookup in ViewsDelegate::GetAppbarAutohideEdges()

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-27 18:10:57 -05:00
trop[bot]
e87dc57071 build: roll build-images SHAs (#46318)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-03-27 17:32:44 +01:00
Pedro Pontes
cd7644ff00 chore: cherry-pick 1 changes from 3-M134 (#46304)
* chore: [34-x-y] cherry-pick 1 changes from 3-M134

* b8f80176b163 from chromium

* chore: update patches

---------

Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
2025-03-27 10:56:37 +01:00
trop[bot]
8d77d66e5a fix: set userAgent on navigationHistory.restore() (#46298)
fix: set userAgent on navigationHistory restore

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-03-26 19:53:18 -05:00
trop[bot]
3d51ce2ca5 perf: avoid std::map temporaries in WebContents::DevToolsRequestFileSystems() (#46310)
* perf: move the GetDevToolsWebContents() call outside of the loop

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: remove std::map temporary in WebContents::DevToolsRequestFileSystems()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: remove unused GetAddedFileSystemPaths()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: remove std::vector temporary in WebContents::DevToolsRequestFileSystems()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-26 19:25:34 -05:00
trop[bot]
5daff5468b perf: avoid redundant map lookup in AddComponentResourceEntries() (#46289)
* perf: avoid double map lookup in ElectronComponentExtensionResourceManager::AddComponentResourceEntries()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: move the path key when calling try_emplace()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-26 19:11:09 -05:00
trop[bot]
09a9b419b8 perf: avoid redundant map lookup in WebContents::DevToolsIndexPath() (#46297)
perf: avoid double map lookup in WebContents::DevToolsIndexPath()

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-26 18:34:26 -05:00
Shelley Vohr
9049d01bd6 fix: build failure when printing is disabled (#46286)
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-26 09:46:58 -05:00
trop[bot]
42c8938c9a perf: avoid redundant map lookup in WebFrameMain constructor (#46277)
perf: avoid double map lookup in WebFrameMain constructor

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-25 22:00:40 -04:00
trop[bot]
b5f8c7554a perf: avoid std::map temporaries in IsDevToolsFileSystemAdded() (#46266)
* refactor: extract-method GetAddedFileSystems()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: use GetAddedFileSystems() in GetAddedFileSystemPaths()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: use GetAddedFileSystems() in IsDevToolsFileSystemAdded()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-25 23:40:42 +01:00
trop[bot]
0b34f5b45e build: fixup windows source cache for release (#46269)
* build: fixup ffmpeg gn gen

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

* build: add build-tools depot_tools to PATH

There are some cases where it is still expected that depot_tools be in the path

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

* put back regular gn gen for ffmpeg

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

* build: add retry to moving source cache

This resolves the error: `Move-Item : The process cannot access the file because it is being used by another process.`

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-03-25 16:34:00 -05:00
trop[bot]
2b7f32428f fix: webContents.printToPDF() with cross-process subframes (#46258)
fix: webContents.printToPDF() with cross-process subframes

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-03-25 13:09:38 -05:00
trop[bot]
2d7cfd3de2 perf: don't wait for thumbnails if they were not requested on macOS (#46250)
When using the SCK thumbnail capturer, the first refresh has the list of
sources, and the second refresh has the thumbnails. If thumbnails are
not needed, only wait for the first refresh.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Beutner <beutner.john@gmail.com>
2025-03-25 16:44:25 +01:00
trop[bot]
06c84f35bd fix: oob string read when parsing node_options (#46246)
* fix: oob string read when parsing node_options

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* chore: re-enable test

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* fix: missing linux server env for tests

Co-authored-by: deepak1556 <hop2deep@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2025-03-25 08:14:59 -05:00
Robo
cfb7237c6c fix: system-context-menu should only fire in draggable regions (34-x-y) (#46175) 2025-03-25 12:20:57 +01:00
trop[bot]
fa4462341a fix: NODE_OPTIONS parsing for child processes on macOS (#46242)
* fix: NODE_OPTIONS parsing for child processes on macOS

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* chore: temporarily disable test

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* chore: apply review feedback

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* chore: fix build

Co-authored-by: deepak1556 <hop2deep@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2025-03-25 19:32:04 +09:00
trop[bot]
19069ead12 feat: add ffmpeg.dll to delay load configuration (#46174)
feat: set ffmpeg.dll as a delay-loaded DLL

Updated the /DELAYLOAD linker config in BUILD.gn to set ffmpeg.dll
as a delay-loaded DLL. This reduces startup overhead and prevents unnecessary
loading when ffmpeg-related functionality is not used (e.g., the browser process
was unnecessarily loading it).

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Zonglong Liu <83216456+mai-121@users.noreply.github.com>
2025-03-24 23:15:05 -05:00
trop[bot]
6da5666aa5 build: fixup release builds (#46232)
* build: fixup release builds

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

* build: fixup windows source cache for release

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-03-24 17:19:28 -04:00
trop[bot]
fcdf08ce75 fix: Wayland resizing border (#46223)
* fix: Wayland resizing border

Closes https://github.com/electron/electron/issues/44543
Refs CL:5180720

Fixes an issue where the resizing border didn't work as expected on Wayland windows.

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: border insets when fullscreen

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-03-24 10:54:32 -05:00
trop[bot]
fe9e90af7b refactor: remove unused weak_factory_ in electron_management_api_delegate.cc (#46219)
refactor: remove unused weak_factory_

Appears to have been added in 3745b76da but never used

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-24 15:03:08 +01:00
trop[bot]
ef9cd3464d build: Use windows src cache (#46187)
build: use source cache on windows

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-03-24 09:33:37 -04:00
trop[bot]
51f771224a refactor: remove unused method ProxyingWebSocket::web_request_api() (#46216)
Appears to have been added in c608d6d7 but never used

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-24 08:21:59 -05:00
trop[bot]
23d574152e refactor: remove unused method ElectronBrowserContext::GetWeakPtr() (#46197)
* refactor: use forward declaration of MediaDeviceIDSalt in electron_browser_context.h

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: remove unused #include from browser_context.h

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: remove unused ElectronBrowserContext::GetWeakPtr()

last use removed in Aug 2020 by bac2f46

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-22 14:22:19 -05:00
trop[bot]
4bee1eaded refactor: use = default to define trivial destructors (#46192)
refactor: use '= default' to define trivial destructors

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-22 10:14:28 -05:00
Pedro Pontes
88f4deb3a3 chore: restore forced LF for patch files with exception (#45902)
chore: restore forced LF for patch files and add exception
2025-03-21 14:11:36 -04:00
trop[bot]
165ea64314 build: fail for out of date patches on forks (#46125)
* build: fail for out of date patches on forks

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: update patches

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-03-21 19:04:34 +01:00
trop[bot]
8961eb074b build: move set chromium cookie before build tools step (#46096)
build: move set cookie before build tools

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: alice <alice@makenotion.com>
2025-03-21 12:43:59 -04:00
trop[bot]
b194cb1486 refactor: reduce coupling in electron::api::Protocol (#46181)
* refactor: decouple api::Protocol from ElectronBrowserContext

now they do not know about each other

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: make electron::api::ProtocolError private

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: remove unused isolate arg in Protocol constructor

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: use =default for trivial destructor

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-21 11:09:19 -05:00
trop[bot]
470a82869c refactor: use GetDefaultStoragePartition() instead of GetStoragePartition(nullptr) (#46082)
refactor: use GetDefaultStoragePartition()

Use GetDefaultStorageParition() instead of GetStoragePartition(nullptr)

- It improves code uniformity, since we use get-default everywhere else
- It's more readable
- It's marginally faster, since GetStoragePartition() has more steps

Added in 49b0a1bf4a

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-20 23:06:39 -05:00
Charles Kerr
a19f617ab0 refactor: make URLPipeLoader private (34-x-y) (#46168)
refactor: make URLPipeLoader private

Move the URLPipeLoader class into an anonymous namespace in
electron_url_loader_factory.cc. Manual backport of 1b5db99.
2025-03-20 21:02:00 -05:00
trop[bot]
f008b0d0b2 fix: APNS token ids are lowercase ASCII (#46150)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-03-20 16:52:03 -05:00
trop[bot]
ce2f471e9d refactor: Add ElectronBrowserContext::BrowserContexts() (#46159)
* refactor: add ElectronBrowserContext::BrowserContexts()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: use ElectronBrowserContext::BrowserContexts() in ElectronBrowserMainParts::PostMainMessageLoopRun()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: use ElectronBrowserContext::BrowserContexts() in ElectronExtensionsBrowserClient::IsValidContext()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: use ElectronBrowserContext::BrowserContexts() in ElectronExtensionsBrowserClient::BroadcastEventToRenderers()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: move PartitionKey, BrowserContextMap private

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add ElectronBrowserContext::IsValidContext()

decouple ElectronExtensionsBrowserClient from the internals of ElectronBrowserContext

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-20 16:51:28 -05:00
trop[bot]
5cda3d226c refactor: use base::NumberToString() (#46152)
base::NumberToString() is slightly more efficient than
absl::StrFormat("%u").

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-20 13:47:41 -05:00
Charles Kerr
30358180c7 refactor: remove unused system header includes (34-x-y) (#46135)
refactor: remove unused system header includes (#46015)

* chore: remove unused #include <string>

* chore: remove unused #include <optional>

* chore: remove unused #include <vector>

* chore: remove unused #include <string_view>

* chore: remove unused #include <memory>

* chore: remove unused #include <utility>

* chore: remove unused #include <tuple>

* chore: remove unused #include <unordered_set>

* chore: remove unused #include <functional>

* chore: iwyu <set>

* chore: iwyu <map>
2025-03-20 07:57:29 +01:00
Charles Kerr
e151aae7a3 refactor: add ElectronBrowserContext::GetDefaultBrowserContext() (34-x-y) (#46136)
refactor: add `ElectronBrowserContext::GetDefaultBrowserContext()` (#46065)

* refactor: add ElectronBrowserContext::DestroyAllContexts()

Simpler semantics than previous implementation; also hides the
"default context must be destroyed last" implementation detail.

* refactor: add ElectronBrowserContext::GetDefaultBrowserContext()

clearer semantics than everyone calling From("", false)
2025-03-19 17:25:35 -05:00
trop[bot]
bc9b5af26e build: fix compound bash conditional in patchup (#46057)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-03-17 12:48:42 +01:00
trop[bot]
952b9c0b46 fix: warning in file picker UI (#46076)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-16 23:28:30 -05:00
trop[bot]
5705ce1d6e fix: take Snapped status into account when showing a window (#46039)
* fix: take Snapped status into account when showing a window

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fixup! fix: take Snapped status into account when showing a window

fix: bad trop

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-16 11:15:55 +01:00
trop[bot]
c8ac7b0efd perf: avoid redundant map lookup in ElectronBrowserContext::From() (#46060)
perf: avoid redundant map lookup in ElectronBrowserContext::FromPath()

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-15 13:46:49 -05:00
trop[bot]
dbeed26c0d fix: ElectronBrowserContext raw_ptr bug + remove dead code (#46054)
refactor: remove unused ElectronBrowserContext::extension_system()

Last use removed on Jul 21, 2020 by 2fb14f5 in PR #24575

This fixes a raw_ptr warning by letting us remove the raw_ptr field
`ElectronBrowserContext::extension_system_`.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-15 11:39:19 -05:00
trop[bot]
99e589c2cf fix: prevent title change for within page navigation (#46034)
* fix: prevent title change for on page navigation

Co-authored-by: Michaela Laurencin <mlaurencin@electronjs.org>

* add back and forward testing

Co-authored-by: Michaela Laurencin <mlaurencin@electronjs.org>

* update Chromium comment

Co-authored-by: Michaela Laurencin <mlaurencin@electronjs.org>

* remove errant script tag

Co-authored-by: Michaela Laurencin <mlaurencin@electronjs.org>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Michaela Laurencin <mlaurencin@electronjs.org>
2025-03-14 09:53:52 -05:00
trop[bot]
3782fe51ff fix: don't crash Web Workers on unhandled rejections (#46019)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-03-14 09:58:37 +01:00
trop[bot]
be7b06108e refactor: make a variadic gin_helper::internal::InvokeFactory() (#46029)
refactor: make a variadic gin_helper::internal::InvokeFactory()

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-13 23:41:02 -05:00
Pedro Pontes
6b956d036d chore: cherry-pick 1 changes from 3-M133 (#46008)
chore: [34-x-y] cherry-pick 1 changes from 3-M133

* 91343bb45c78 from v8

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-13 16:27:22 -05:00
Pedro Pontes
370ffe0df5 chore: cherry-pick 3 changes from 0-M134 (#46009) 2025-03-13 11:31:56 -05:00
Pedro Pontes
14456ecfbc chore: cherry-pick 1 changes from 1-M134 (#46011)
chore: [34-x-y] cherry-pick 1 changes from 1-M134

* 2b4812d502b2 from v8
2025-03-13 10:19:23 -05:00
trop[bot]
974c8f5150 refactor: use private inheritance from mojo::MessageReceiver (#45994)
* refactor: make UtilityProcessWrapper inherit privately from mojo::MessageReceiver

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: make ParentPort inherit privately from mojo::MessageReceiver

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: make MessagePort inherit privately from mojo::MessageReceiver

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-12 22:49:24 -05:00
trop[bot]
ac5b5995e8 build: roll sysroots to pick up glibc fix (#45982)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-03-12 09:26:33 +01:00
trop[bot]
5ccd41cf5c test: fix timing issue in utilityProcess test fixtures (#45976)
* fix: potential timing issue in utilityProcess test

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* fix: potential timing issue in utilityProcess esm test

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-11 17:31:16 -04:00
Michaela Laurencin
060cfb94e9 fix: cherry-pick 3a72ebf7ec6f0 from chromium (#45966)
* fix: backport chromium revert 6262017

* add reasoning for patch
2025-03-11 10:09:32 -05:00
trop[bot]
587e115527 fix: remove redundant MediaCaptureDevicesDispatcher::GetInstance() call (#45959)
fix: remove redundant MediaCaptureDevicesDispatcher::GetInstance() call

This appears to be a copy-paste error introduced in 465dee2c

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-10 14:50:37 -05:00
trop[bot]
a56b2acadd fix: race condition in utilityProcess tests (#45954)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-10 14:49:21 -05:00
trop[bot]
58479848b2 refactor: eliminate duplicate code in spec/api-process-spec.ts (#45949)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Milan Burda <milan.burda@gmail.com>
2025-03-10 11:39:12 -05:00
trop[bot]
ba2cad1670 perf: prefer base::SplitStringPiece() over base::SplitString() (#45948)
* perf: use base::SplitStringPiece() in SetNodeOptions()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: use base::SplitStringPiece() in StringToAccelerator()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: StringToAccelerator() now takes a std::string_view

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-10 09:50:03 -05:00
Samuel Attard
f98501308a chore: cherry-pick 521faebc8a7c from chromium (#45944) 2025-03-09 17:01:50 -07:00
Samuel Attard
1d9f1a4cd4 chore: cherry-pick 9dacf5694dfd from chromium (#45939)
* chore: cherry-pick 9dacf5694dfd from chromium

* chore: update patch for <=34
2025-03-09 17:01:20 -07:00
trop[bot]
7d01169091 fix: resolve font list in default prefernce values (#45917)
* fix: resolve font list in default prefernce values

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* chore: fix unsafe buffer usage

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* docs: add code comment

Co-authored-by: deepak1556 <hop2deep@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2025-03-07 16:01:49 +01:00
182 changed files with 3472 additions and 1549 deletions

View File

@@ -2,7 +2,7 @@ version: '3'
services:
buildtools:
image: ghcr.io/electron/devcontainer:77262e58c37631ab082482f42c33cdf68c6c394b
image: ghcr.io/electron/devcontainer:9f11982e806f439d0a0a8ebbbf566cd5e0d9e952
volumes:
- ..:/workspaces/gclient/src/electron:cached

4
.gitattributes vendored
View File

@@ -1,10 +1,14 @@
# `git apply` and friends don't understand CRLF, even on windows. Force those
# files to be checked out with LF endings even if core.autocrlf is true.
*.patch text eol=lf
DEPS text eol=lf
yarn.lock text eol=lf
script/zip_manifests/*.manifest text eol=lf
patches/**/.patches merge=union
# Patch file line ending exceptions (patches that affect CRLF files)
reland_lzma_sdk_update_to_24_09.patch -text
# Source code and markdown files should always use LF as line ending.
*.c text eol=lf
*.cc text eol=lf

View File

@@ -9,6 +9,8 @@ inputs:
description: 'Whether to persist the cache to the shared drive'
required: false
default: 'true'
target-platform:
description: 'Target platform, should be linux, win, macos'
runs:
using: "composite"
steps:
@@ -18,40 +20,34 @@ runs:
echo "GIT_CACHE_PATH=$(pwd)/git-cache" >> $GITHUB_ENV
- name: Install Dependencies
uses: ./src/electron/.github/actions/install-dependencies
- name: Install Build Tools
uses: ./src/electron/.github/actions/install-build-tools
- name: Set Chromium Git Cookie
uses: ./src/electron/.github/actions/set-chromium-cookie
- name: Get Depot Tools
shell: bash
run: |
if [[ ! -d depot_tools ]]; then
git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
# Ensure depot_tools does not update.
test -d depot_tools && cd depot_tools
touch .disable_auto_update
fi
- name: Add Depot Tools to PATH
shell: bash
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
- name: Install Build Tools
uses: ./src/electron/.github/actions/install-build-tools
- name: Generate DEPS Hash
shell: bash
run: |
node src/electron/script/generate-deps-hash.js
echo "DEPSHASH=v1-src-cache-$(cat src/electron/.depshash)" >> $GITHUB_ENV
DEPSHASH="v1-src-cache-$(cat src/electron/.depshash)"
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
echo "CACHE_FILE=$DEPSHASH.tar" >> $GITHUB_ENV
if [ "${{ inputs.target-platform }}" = "win" ]; then
echo "CACHE_DRIVE=/mnt/win-cache" >> $GITHUB_ENV
else
echo "CACHE_DRIVE=/mnt/cross-instance-cache" >> $GITHUB_ENV
fi
- name: Generate SAS Key
if: ${{ inputs.generate-sas-token == 'true' }}
shell: bash
run: |
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$DEPSHASH.tar" > sas-token
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$CACHE_FILE?platform=${{ inputs.target-platform }}" > sas-token
- name: Save SAS Key
if: ${{ inputs.generate-sas-token == 'true' }}
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf
with:
path: |
sas-token
key: sas-key-${{ github.run_number }}-${{ github.run_attempt }}
path: sas-token
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
enableCrossOsArchive: true
- name: Check If Cache Exists
id: check-cache
shell: bash
@@ -60,7 +56,7 @@ runs:
echo "Not using cache this time..."
echo "cache_exists=false" >> $GITHUB_OUTPUT
else
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
cache_path=$CACHE_DRIVE/$CACHE_FILE
echo "Using cache key: $DEPSHASH"
echo "Checking for cache in: $cache_path"
if [ ! -f "$cache_path" ] || [ `du $cache_path | cut -f1` = "0" ]; then
@@ -76,8 +72,8 @@ runs:
shell: bash
run: |
# if there is less than 35 GB free space then creating the cache might fail so exit early
freespace=`df -m /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
freespace_human=`df -h /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
freespace=`df -m $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
freespace_human=`df -h $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
if [ $freespace -le 35000 ]; then
echo "The cross mount cache has $freespace_human free space which is not enough - exiting"
exit 1
@@ -99,7 +95,7 @@ runs:
fi
ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 e d gclient sync --with_branch_heads --with_tags -vv
if [ "${{ inputs.is-release }}" != "true" && -n "${{ env.PATCH_UP_APP_CREDS }}" ]; then
if [[ "${{ inputs.is-release }}" != "true" ]]; then
# Re-export all the patches to check if there were changes.
python3 src/electron/script/export_all_patches.py src/electron/patches/config.json
cd src/electron
@@ -128,6 +124,8 @@ runs:
cat ../../patches/update-patches.patch
exit 1
fi
else
echo "No changes to patches detected"
fi
fi
@@ -165,14 +163,14 @@ runs:
shell: bash
run: |
echo "Uncompressed src size: $(du -sh src | cut -f1 -d' ')"
tar -cf $DEPSHASH.tar src
echo "Compressed src to $(du -sh $DEPSHASH.tar | cut -f1 -d' ')"
cp ./$DEPSHASH.tar /mnt/cross-instance-cache/
tar -cf $CACHE_FILE src
echo "Compressed src to $(du -sh $CACHE_FILE | cut -f1 -d' ')"
cp ./$CACHE_FILE $CACHE_DRIVE/
- name: Persist Src Cache
if: ${{ steps.check-cache.outputs.cache_exists == 'false' && inputs.use-cache == 'true' }}
shell: bash
run: |
final_cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
final_cache_path=$CACHE_DRIVE/$CACHE_FILE
echo "Using cache key: $DEPSHASH"
echo "Checking path: $final_cache_path"
if [ ! -f "$final_cache_path" ]; then

40
.github/actions/cipd-install/action.yml vendored Normal file
View File

@@ -0,0 +1,40 @@
name: 'CIPD install'
description: 'Installs the specified CIPD package'
inputs:
cipd-root-prefix-path:
description: 'Path to prepend to installation directory'
default: ''
dependency:
description: 'Name of dependency to install'
deps-file:
description: 'Location of DEPS file that defines the dependency'
installation-dir:
description: 'Location to install dependency'
target-platform:
description: 'Target platform, should be linux, win, macos'
package:
description: 'Package to install'
runs:
using: "composite"
steps:
- name: Delete wrong ${{ inputs.dependency }}
shell: bash
run : |
rm -rf ${{ inputs.cipd-root-prefix-path }}${{ inputs.installation-dir }}
- name: Create ensure file for ${{ inputs.dependency }}
shell: bash
run: |
echo '${{ inputs.package }}' `e d gclient getdep --deps-file=${{ inputs.deps-file }} -r '${{ inputs.installation-dir }}:${{ inputs.package }}'` > ${{ inputs.dependency }}_ensure_file
cat ${{ inputs.dependency }}_ensure_file
- name: CIPD installation of ${{ inputs.dependency }} (macOS)
if: ${{ inputs.target-platform == 'macos' }}
shell: bash
run: |
echo "ensuring ${{ inputs.dependency }} on macOS"
e d cipd ensure --root ${{ inputs.cipd-root-prefix-path }}${{ inputs.installation-dir }} -ensure-file ${{ inputs.dependency }}_ensure_file
- name: CIPD installation of ${{ inputs.dependency }} (Windows)
if: ${{ inputs.target-platform == 'win' }}
shell: powershell
run: |
echo "ensuring ${{ inputs.dependency }} on Windows"
e d cipd ensure --root ${{ inputs.cipd-root-prefix-path }}${{ inputs.installation-dir }} -ensure-file ${{ inputs.dependency }}_ensure_file

View File

@@ -1,61 +0,0 @@
name: 'Fix Sync macOS'
description: 'Checks out Electron and stores it in the AKS Cache'
runs:
using: "composite"
steps:
- name: Fix Sync
shell: bash
# This step is required to correct for differences between "gclient sync"
# on Linux and the expected state on macOS. This requires:
# 1. Fixing Clang Install (wrong binary)
# 2. Fixing esbuild (wrong binary)
# 3. Fixing rustc (wrong binary)
# 4. Fixing gn (wrong binary)
# 5. Fix reclient (wrong binary)
# 6. Fixing dsymutil (wrong binary)
# 7. Ensuring we are using the correct ninja and adding it to PATH
# 8. Fixing angle (wrong remote)
run : |
SEDOPTION="-i ''"
rm -rf src/third_party/llvm-build
python3 src/tools/clang/scripts/update.py
echo 'infra/3pp/tools/esbuild/${platform}' `gclient getdep --deps-file=src/third_party/devtools-frontend/src/DEPS -r 'third_party/esbuild:infra/3pp/tools/esbuild/${platform}'` > esbuild_ensure_file
# Remove extra output from calling gclient getdep which always calls update_depot_tools
sed -i '' "s/Updating depot_tools... //g" esbuild_ensure_file
cipd ensure --root src/third_party/devtools-frontend/src/third_party/esbuild -ensure-file esbuild_ensure_file
rm -rf src/third_party/rust-toolchain
python3 src/tools/rust/update_rust.py
# Prevent calling gclient getdep which always calls update_depot_tools
echo 'gn/gn/mac-${arch}' `gclient getdep --deps-file=src/DEPS -r 'src/buildtools/mac:gn/gn/mac-${arch}'` > gn_ensure_file
sed -i '' "s/Updating depot_tools... //g" gn_ensure_file
cipd ensure --root src/buildtools/mac -ensure-file gn_ensure_file
# Prevent calling gclient getdep which always calls update_depot_tools
echo 'infra/rbe/client/${platform}' `gclient getdep --deps-file=src/DEPS -r 'src/buildtools/reclient:infra/rbe/client/${platform}'` > gn_ensure_file
sed -i '' "s/Updating depot_tools... //g" gn_ensure_file
cipd ensure --root src/buildtools/reclient -ensure-file gn_ensure_file
python3 src/buildtools/reclient_cfgs/configure_reclient_cfgs.py --rbe_instance "projects/rbe-chrome-untrusted/instances/default_instance" --reproxy_cfg_template reproxy.cfg.template --rewrapper_cfg_project "" --skip_remoteexec_cfg_fetch
if [ "${{ env.TARGET_ARCH }}" == "arm64" ]; then
DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.arm64.sha1
else
DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.x64.sha1
fi
python3 src/third_party/depot_tools/download_from_google_storage.py --no_resume --no_auth --bucket chromium-browser-clang -s $DSYM_SHA_FILE -o src/tools/clang/dsymutil/bin/dsymutil
echo 'infra/3pp/tools/ninja/${platform}' `gclient getdep --deps-file=src/DEPS -r 'src/third_party/ninja:infra/3pp/tools/ninja/${platform}'` > ninja_ensure_file
sed $SEDOPTION "s/Updating depot_tools... //g" ninja_ensure_file
cipd ensure --root src/third_party/ninja -ensure-file ninja_ensure_file
echo "$(pwd)/src/third_party/ninja" >> $GITHUB_PATH
cd src/third_party/angle
rm -f .git/objects/info/alternates
git remote set-url origin https://chromium.googlesource.com/angle/angle.git
cp .git/config .git/config.backup
git remote remove origin
mv .git/config.backup .git/config
git fetch

120
.github/actions/fix-sync/action.yml vendored Normal file
View File

@@ -0,0 +1,120 @@
name: 'Fix Sync'
description: 'Ensures proper binaries are in place'
# This action is required to correct for differences between "gclient sync"
# on Linux and the expected state on macOS/windows. This requires:
# 1. Fixing Clang Install (wrong binary)
# 2. Fixing esbuild (wrong binary)
# 3. Fixing rustc (wrong binary)
# 4. Fixing gn (wrong binary)
# 5. Fix reclient (wrong binary)
# 6. Fixing dsymutil (wrong binary)
# 7. Ensuring we are using the correct ninja and adding it to PATH
# 8. Fixing angle (wrong remote)
# 9. Install windows toolchain on Windows
# 10. Fix node binary on Windows
# 11. Fix rc binary on Windows
inputs:
target-platform:
description: 'Target platform, should be linux, win, macos'
runs:
using: "composite"
steps:
- name: Fix clang
shell: bash
run : |
rm -rf src/third_party/llvm-build
python3 src/tools/clang/scripts/update.py
- name: Fix esbuild
uses: ./src/electron/.github/actions/cipd-install
with:
cipd-root-prefix-path: src/third_party/devtools-frontend/src/
dependency: esbuild
deps-file: src/third_party/devtools-frontend/src/DEPS
installation-dir: third_party/esbuild
target-platform: ${{ inputs.target-platform }}
package: infra/3pp/tools/esbuild/${platform}
- name: Fix rustc
shell: bash
run : |
rm -rf src/third_party/rust-toolchain
python3 src/tools/rust/update_rust.py
- name: Fix gn (macOS)
if: ${{ inputs.target-platform == 'macos' }}
uses: ./src/electron/.github/actions/cipd-install
with:
dependency: gn
deps-file: src/DEPS
installation-dir: src/buildtools/mac
target-platform: ${{ inputs.target-platform }}
package: gn/gn/mac-${arch}
- name: Fix gn (Windows)
if: ${{ inputs.target-platform == 'win' }}
uses: ./src/electron/.github/actions/cipd-install
with:
dependency: gn
deps-file: src/DEPS
installation-dir: src/buildtools/win
target-platform: ${{ inputs.target-platform }}
package: gn/gn/windows-amd64
- name: Fix reclient
uses: ./src/electron/.github/actions/cipd-install
with:
dependency: reclient
deps-file: src/DEPS
installation-dir: src/buildtools/reclient
target-platform: ${{ inputs.target-platform }}
package: infra/rbe/client/${platform}
- name: Configure reclient configs
shell: bash
run : |
python3 src/buildtools/reclient_cfgs/configure_reclient_cfgs.py --rbe_instance "projects/rbe-chrome-untrusted/instances/default_instance" --reproxy_cfg_template reproxy.cfg.template --rewrapper_cfg_project "" --skip_remoteexec_cfg_fetch
- name: Fix dsymutil (macOS)
if: ${{ inputs.target-platform == 'macos' }}
shell: bash
run : |
# Fix dsymutil
if [ "${{ inputs.target-platform }}" = "macos" ]; then
if [ "${{ env.TARGET_ARCH }}" == "arm64" ]; then
DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.arm64.sha1
else
DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.x64.sha1
fi
python3 src/third_party/depot_tools/download_from_google_storage.py --no_resume --no_auth --bucket chromium-browser-clang -s $DSYM_SHA_FILE -o src/tools/clang/dsymutil/bin/dsymutil
fi
- name: Fix ninja
uses: ./src/electron/.github/actions/cipd-install
with:
dependency: ninja
deps-file: src/DEPS
installation-dir: src/third_party/ninja
target-platform: ${{ inputs.target-platform }}
package: infra/3pp/tools/ninja/${platform}
- name: Set ninja in path
shell: bash
run : |
echo "$(pwd)/src/third_party/ninja" >> $GITHUB_PATH
- name: Fixup angle git
shell: bash
run : |
cd src/third_party/angle
rm -f .git/objects/info/alternates
git remote set-url origin https://chromium.googlesource.com/angle/angle.git
cp .git/config .git/config.backup
git remote remove origin
mv .git/config.backup .git/config
git fetch
- name: Get Windows toolchain
if: ${{ inputs.target-platform == 'win' }}
shell: powershell
run: e d vpython3 src\build\vs_toolchain.py update --force
- name: Download nodejs
if: ${{ inputs.target-platform == 'win' }}
shell: powershell
run: |
$nodedeps = e d gclient getdep --deps-file=src/DEPS -r src/third_party/node/win | ConvertFrom-JSON
python3 src\third_party\depot_tools\download_from_google_storage.py --no_resume --no_auth --bucket chromium-nodejs -o src\third_party\node\win\node.exe $nodedeps.object_name
- name: Install rc
if: ${{ inputs.target-platform == 'win' }}
shell: bash
run: |
python3 src/third_party/depot_tools/download_from_google_storage.py --no_resume --no_auth --bucket chromium-browser-clang/rc -s src/build/toolchain/win/rc/win/rc.exe.sha1

View File

@@ -14,7 +14,9 @@ runs:
export BUILD_TOOLS_SHA=8246e57791b0af4ae5975eb96f09855f9269b1cd
npm i -g @electron/build-tools
e auto-update disable
e d auto-update disable
if [ "$(expr substr $(uname -s) 1 10)" == "MSYS_NT-10" ]; then
e d cipd.bat --version
cp "C:\Python311\python.exe" "C:\Python311\python3.exe"
fi
echo "$HOME/.electron_build_tools/third_party/depot_tools" >> $GITHUB_PATH

View File

@@ -1,12 +1,20 @@
name: 'Restore Cache AKS'
description: 'Restores Electron src cache via AKS'
inputs:
target-platform:
description: 'Target platform, should be linux, win, macos'
runs:
using: "composite"
steps:
- name: Restore and Ensure Src Cache
shell: bash
run: |
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
if [ "${{ inputs.target-platform }}" = "win" ]; then
cache_path=/mnt/win-cache/$DEPSHASH.tar
else
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
fi
echo "Using cache key: $DEPSHASH"
echo "Checking for cache in: $cache_path"
if [ ! -f "$cache_path" ]; then

View File

@@ -1,22 +1,25 @@
name: 'Restore Cache AZCopy'
description: 'Restores Electron src cache via AZCopy'
inputs:
target-platform:
description: 'Target platform, should be linux, win, macos'
runs:
using: "composite"
steps:
- name: Obtain SAS Key
continue-on-error: true
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf
with:
path: |
sas-token
key: sas-key-${{ github.run_number }}-1
path: sas-token
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-1
enableCrossOsArchive: true
- name: Obtain SAS Key
continue-on-error: true
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf
with:
path: |
sas-token
key: sas-key-${{ github.run_number }}-${{ github.run_attempt }}
path: sas-token
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
enableCrossOsArchive: true
- name: Download Src Cache from AKS
# The cache will always exist here as a result of the checkout job
# Either it was uploaded to Azure in the checkout job for this commit
@@ -26,21 +29,30 @@ runs:
timeout_minutes: 30
max_attempts: 3
retry_on: error
shell: bash
command: |
sas_token=$(cat sas-token)
if [ -z $sas-token ]; then
echo "SAS Token not found; exiting src cache download early..."
exit 1
else
if [ "${{ inputs.target-platform }}" = "win" ]; then
azcopy copy --log-level=ERROR \
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_WIN_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
else
azcopy copy --log-level=ERROR \
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
fi
fi
azcopy copy --log-level=ERROR \
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
env:
AZURE_AKS_CACHE_STORAGE_ACCOUNT: f723719aa87a34622b5f7f3
AZURE_AKS_CACHE_SHARE_NAME: pvc-f6a4089f-b082-4bee-a3f9-c3e1c0c02d8f
AZURE_AKS_WIN_CACHE_SHARE_NAME: pvc-71dec4f2-0d44-4fd1-a2c3-add049d70bdf
- name: Clean SAS Key
shell: bash
run: rm -f sas-token
- name: Unzip and Ensure Src Cache
if: ${{ inputs.target-platform == 'macos' }}
shell: bash
run: |
echo "Downloaded cache is $(du -sh $DEPSHASH.tar | cut -f1)"
@@ -68,4 +80,45 @@ runs:
fi
echo "Wiping Electron Directory"
rm -rf src/electron
rm -rf src/electron
- name: Unzip and Ensure Src Cache (Windows)
if: ${{ inputs.target-platform == 'win' }}
shell: powershell
run: |
$src_cache = "$env:DEPSHASH.tar"
$cache_size = $(Get-Item $src_cache).length
Write-Host "Downloaded cache is $cache_size"
if ($cache_size -eq 0) {
Write-Host "Cache is empty - exiting"
exit 1
}
$TEMP_DIR=New-Item -ItemType Directory -Path temp-cache
$TEMP_DIR_PATH = $TEMP_DIR.FullName
C:\ProgramData\Chocolatey\bin\7z.exe -y x $src_cache -o"$TEMP_DIR_PATH"
- name: Move Src Cache (Windows)
if: ${{ inputs.target-platform == 'win' }}
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
timeout_minutes: 30
max_attempts: 3
retry_on: error
shell: powershell
command: |
if (Test-Path "temp-cache\src") {
Write-Host "Relocating Cache"
Remove-Item -Recurse -Force src
Move-Item temp-cache\src src
Write-Host "Deleting zip file"
Remove-Item -Force $src_cache
}
if (-Not (Test-Path "src\third_party\blink")) {
Write-Host "Cache was not correctly restored - exiting"
exit 1
}
Write-Host "Wiping Electron Directory"
Remove-Item -Recurse -Force src\electron

View File

@@ -4,9 +4,14 @@ runs:
using: "composite"
steps:
- name: Set the git cookie from chromium.googlesource.com (Unix)
if: ${{ runner.os != 'Windows' && env.CHROMIUM_GIT_COOKIE }}
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
if [[ -z "${{ env.CHROMIUM_GIT_COOKIE }}" ]]; then
echo "CHROMIUM_GIT_COOKIE is not set - cannot authenticate."
exit 0
fi
eval 'set +o history' 2>/dev/null || setopt HIST_IGNORE_SPACE 2>/dev/null
touch ~/.gitcookies
chmod 0600 ~/.gitcookies
@@ -17,10 +22,37 @@ runs:
${{ env.CHROMIUM_GIT_COOKIE }}
__END__
eval 'set -o history' 2>/dev/null || unsetopt HIST_IGNORE_SPACE 2>/dev/null
RESPONSE=$(curl -s -b ~/.gitcookies https://chromium-review.googlesource.com/a/accounts/self)
if [[ $RESPONSE == ")]}'"* ]]; then
# Extract account email for verification
EMAIL=$(echo "$RESPONSE" | tail -c +5 | jq -r '.email // "No email found"')
echo "Cookie authentication successful - authenticated as: $EMAIL"
else
echo "Cookie authentication failed - ensure CHROMIUM_GIT_COOKIE is set correctly"
echo $RESPONSE
fi
- name: Set the git cookie from chromium.googlesource.com (Windows)
if: ${{ runner.os == 'Windows' && env.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
if: ${{ runner.os == 'Windows' }}
shell: cmd
run: |
if "%CHROMIUM_GIT_COOKIE_WINDOWS_STRING%"=="" (
echo CHROMIUM_GIT_COOKIE_WINDOWS_STRING is not set - cannot authenticate.
exit /b 0
)
git config --global http.cookiefile "%USERPROFILE%\.gitcookies"
powershell -noprofile -nologo -command Write-Output "${{ env.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}" >>"%USERPROFILE%\.gitcookies"
curl -s -b "%USERPROFILE%\.gitcookies" https://chromium-review.googlesource.com/a/accounts/self > response.txt
findstr /B /C:")]}'" response.txt > nul
if %ERRORLEVEL% EQU 0 (
echo Cookie authentication successful
powershell -NoProfile -Command "& {$content = Get-Content -Raw response.txt; $content = $content.Substring(4); try { $json = ConvertFrom-Json $content; if($json.email) { Write-Host 'Authenticated as:' $json.email } else { Write-Host 'No email found in response' } } catch { Write-Host 'Error parsing JSON:' $_ }}"
) else (
echo Cookie authentication failed - ensure CHROMIUM_GIT_COOKIE_WINDOWS_STRING is set correctly
type response.txt
)
del response.txt

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
default: '9f11982e806f439d0a0a8ebbbf566cd5e0d9e952'
required: true
skip-macos:
type: boolean
@@ -64,7 +64,7 @@ jobs:
id: set-output
run: |
if [ -z "${{ inputs.build-image-sha }}" ]; then
echo "build-image-sha=bc2f48b2415a670de18d13605b1cf0eb5fdbaae1" >> "$GITHUB_OUTPUT"
echo "build-image-sha=9f11982e806f439d0a0a8ebbbf566cd5e0d9e952" >> "$GITHUB_OUTPUT"
else
echo "build-image-sha=${{ inputs.build-image-sha }}" >> "$GITHUB_OUTPUT"
fi
@@ -115,6 +115,7 @@ jobs:
uses: ./src/electron/.github/actions/checkout
with:
generate-sas-token: 'true'
target-platform: macos
checkout-linux:
needs: setup
@@ -150,7 +151,8 @@ jobs:
image: ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
volumes:
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
- /mnt/win-cache:/mnt/win-cache
- /var/run/sas:/var/run/sas
env:
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
@@ -168,6 +170,9 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout & Sync & Save
uses: ./src/electron/.github/actions/checkout
with:
generate-sas-token: 'true'
target-platform: win
# GN Check Jobs
macos-gn-check:
@@ -198,7 +203,7 @@ jobs:
target-platform: win
target-archs: x64 x86 arm64
check-runs-on: electron-arc-linux-amd64-8core
check-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-windows.outputs.build-image-sha }}","options":"--user root --device /dev/fuse --cap-add SYS_ADMIN","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
check-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-windows.outputs.build-image-sha }}","options":"--user root --device /dev/fuse --cap-add SYS_ADMIN","volumes":["/mnt/win-cache:/mnt/win-cache"]}'
gn-build-type: testing
secrets: inherit
@@ -326,7 +331,7 @@ jobs:
issues: read
pull-requests: read
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
needs: setup
needs: checkout-windows
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
with:
build-runs-on: electron-arc-windows-amd64-16core
@@ -345,7 +350,7 @@ jobs:
issues: read
pull-requests: read
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
needs: setup
needs: checkout-windows
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
with:
build-runs-on: electron-arc-windows-amd64-16core
@@ -364,7 +369,7 @@ jobs:
issues: read
pull-requests: read
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
needs: setup
needs: checkout-windows
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
with:
build-runs-on: electron-arc-windows-amd64-16core

View File

@@ -16,6 +16,7 @@ jobs:
options: --user root
volumes:
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
- /mnt/win-cache:/mnt/win-cache
steps:
- name: Cleanup Source Cache
shell: bash
@@ -23,3 +24,6 @@ jobs:
df -h /mnt/cross-instance-cache
find /mnt/cross-instance-cache -type f -mtime +15 -delete
df -h /mnt/cross-instance-cache
df -h /mnt/win-cache
find /mnt/win-cache -type f -mtime +15 -delete
df -h /mnt/win-cache

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
default: '9f11982e806f439d0a0a8ebbbf566cd5e0d9e952'
upload-to-storage:
description: 'Uploads to Azure storage'
required: false
@@ -27,6 +27,7 @@ jobs:
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
- /var/run/sas:/var/run/sas
env:
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
steps:
- name: Checkout Electron

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
default: '9f11982e806f439d0a0a8ebbbf566cd5e0d9e952'
required: true
upload-to-storage:
description: 'Uploads to Azure storage'
@@ -28,6 +28,7 @@ jobs:
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
- /var/run/sas:/var/run/sas
env:
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
steps:
- name: Checkout Electron
@@ -39,6 +40,7 @@ jobs:
uses: ./src/electron/.github/actions/checkout
with:
generate-sas-token: 'true'
target-platform: macos
publish-x64-darwin:
uses: ./.github/workflows/pipeline-segment-electron-build.yml

View File

@@ -129,24 +129,8 @@ jobs:
echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
- name: Set Chromium Git Cookie
uses: ./src/electron/.github/actions/set-chromium-cookie
- name: Get Depot Tools
timeout-minutes: 5
run: |
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
SEDOPTION="-i"
if [ "`uname`" = "Darwin" ]; then
SEDOPTION="-i ''"
fi
# remove ninjalog_uploader_wrapper.py from autoninja since we don't use it and it causes problems
sed $SEDOPTION '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja
# Ensure depot_tools does not update.
test -d depot_tools && cd depot_tools
touch .disable_auto_update
- name: Add Depot Tools to PATH
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
- name: Install Build Tools
uses: ./src/electron/.github/actions/install-build-tools
- name: Generate DEPS Hash
run: |
node src/electron/script/generate-deps-hash.js
@@ -154,24 +138,26 @@ jobs:
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
echo "CACHE_PATH=$DEPSHASH.tar" >> $GITHUB_ENV
- name: Restore src cache via AZCopy
if: ${{ inputs.target-platform == 'macos' }}
if: ${{ inputs.target-platform != 'linux' }}
uses: ./src/electron/.github/actions/restore-cache-azcopy
with:
target-platform: ${{ inputs.target-platform }}
- name: Restore src cache via AKS
if: ${{ inputs.target-platform == 'linux' }}
uses: ./src/electron/.github/actions/restore-cache-aks
- name: Checkout src via gclient sync
if: ${{ inputs.target-platform == 'win' }}
uses: ./src/electron/.github/actions/checkout
with:
use-cache: 'false'
- name: Checkout Electron
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
with:
path: src/electron
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Install Build Tools
uses: ./src/electron/.github/actions/install-build-tools
- name: Fix Sync
if: ${{ inputs.target-platform != 'linux' }}
uses: ./src/electron/.github/actions/fix-sync
with:
target-platform: ${{ inputs.target-platform }}
env:
ELECTRON_DEPOT_TOOLS_DISABLE_LOG: true
- name: Init Build Tools
run: |
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }}
@@ -184,9 +170,6 @@ jobs:
echo "DEPSHASH=$(cat src/electron/.depshash)" >> $GITHUB_ENV
- name: Add CHROMIUM_BUILDTOOLS_PATH to env
run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV
- name: Fix Sync (macOS)
if: ${{ inputs.target-platform == 'macos' }}
uses: ./src/electron/.github/actions/fix-sync-macos
- name: Setup Number of Ninja Processes
run: |
echo "NUMBER_OF_NINJA_PROCESSES=${{ inputs.target-platform != 'macos' && '300' || '200' }}" >> $GITHUB_ENV

View File

@@ -65,7 +65,9 @@ jobs:
sudo rm -rf $TMPDIR/del-target
- name: Check disk space after freeing up space
if: ${{ inputs.target-platform == 'macos' }}
run: df -h
run: df -h
- name: Set Chromium Git Cookie
uses: ./src/electron/.github/actions/set-chromium-cookie
- name: Install Build Tools
uses: ./src/electron/.github/actions/install-build-tools
- name: Enable windows toolchain
@@ -81,9 +83,13 @@ jobs:
- name: Restore src cache via AZCopy
if: ${{ inputs.target-platform == 'macos' }}
uses: ./src/electron/.github/actions/restore-cache-azcopy
with:
target-platform: ${{ inputs.target-platform }}
- name: Restore src cache via AKS
if: ${{ inputs.target-platform == 'linux' || inputs.target-platform == 'win' }}
uses: ./src/electron/.github/actions/restore-cache-aks
with:
target-platform: ${{ inputs.target-platform }}
- name: Run Electron Only Hooks
run: |
echo "solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]" > tmpgclient

View File

@@ -115,6 +115,15 @@ jobs:
configure_sys_tccdb "$values"
fi
done
- name: Turn off the unexpectedly quit dialog on macOS
if: ${{ inputs.target-platform == 'macos' }}
run: defaults write com.apple.CrashReporter DialogType server
- name: Reenable graphics effects on macOS
if: ${{ inputs.target-platform == 'macos' }}
run: |
# These options to reduce graphics effects were enabled upstream in https://github.com/actions/runner-images/pull/11877
defaults write com.apple.universalaccess reduceMotion -bool false
defaults write com.apple.universalaccess reduceTransparency -bool false
- name: Checkout Electron
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
with:

View File

@@ -51,6 +51,8 @@ jobs:
path: src/electron
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set Chromium Git Cookie
uses: ./src/electron/.github/actions/set-chromium-cookie
- name: Install Build Tools
uses: ./src/electron/.github/actions/install-build-tools
- name: Init Build Tools
@@ -58,17 +60,6 @@ jobs:
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }}
- name: Install Dependencies
uses: ./src/electron/.github/actions/install-dependencies
- name: Set Chromium Git Cookie
uses: ./src/electron/.github/actions/set-chromium-cookie
- name: Get Depot Tools
timeout-minutes: 5
run: |
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
# Ensure depot_tools does not update.
test -d depot_tools && cd depot_tools
touch .disable_auto_update
- name: Add Depot Tools to PATH
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
- name: Download Generated Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
@@ -114,6 +105,8 @@ jobs:
path: src/electron
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set Chromium Git Cookie
uses: ./src/electron/.github/actions/set-chromium-cookie
- name: Install Build Tools
uses: ./src/electron/.github/actions/install-build-tools
- name: Init Build Tools
@@ -121,17 +114,6 @@ jobs:
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }}
- name: Install Dependencies
uses: ./src/electron/.github/actions/install-dependencies
- name: Set Chromium Git Cookie
uses: ./src/electron/.github/actions/set-chromium-cookie
- name: Get Depot Tools
timeout-minutes: 5
run: |
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
# Ensure depot_tools does not update.
test -d depot_tools && cd depot_tools
touch .disable_auto_update
- name: Add Depot Tools to PATH
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
- name: Download Generated Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
default: '9f11982e806f439d0a0a8ebbbf566cd5e0d9e952'
required: true
upload-to-storage:
description: 'Uploads to Azure storage'
@@ -25,8 +25,10 @@ jobs:
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
volumes:
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
- /mnt/win-cache:/mnt/win-cache
- /var/run/sas:/var/run/sas
env:
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_win=True'
TARGET_OS: 'win'
ELECTRON_DEPOT_TOOLS_WIN_TOOLCHAIN: '1'
@@ -40,6 +42,9 @@ jobs:
fetch-depth: 0
- name: Checkout & Sync & Save
uses: ./src/electron/.github/actions/checkout
with:
generate-sas-token: 'true'
target-platform: win
publish-x64-win:
uses: ./.github/workflows/pipeline-segment-electron-build.yml

View File

@@ -1231,7 +1231,7 @@ if (is_mac) {
"//components/crash/core/app:run_as_crashpad_handler",
]
ldflags = []
ldflags = [ "/DELAYLOAD:ffmpeg.dll" ]
libs = [
"comctl32.lib",

2
DEPS
View File

@@ -4,7 +4,7 @@ vars = {
'chromium_version':
'132.0.6834.210',
'node_version':
'v20.18.3',
'v20.19.0',
'nan_version':
'e14bdcd1f72d62bca1d541b66da43130384ec213',
'squirrel.mac_version':

View File

@@ -46,4 +46,7 @@ See: https://developer.apple.com/documentation/appkit/nsapplication/1428476-regi
### `pushNotifications.unregisterForAPNSNotifications()` _macOS_
Unregisters the app from notifications received from APNS.
Apps unregistered through this method can always reregister.
See: https://developer.apple.com/documentation/appkit/nsapplication/1428747-unregisterforremotenotifications?language=objc

View File

@@ -44,6 +44,8 @@ Process: [Main](../glossary.md#main-process)<br />
Returns [`UtilityProcess`](utility-process.md#class-utilityprocess)
**Note:** `utilityProcess.fork` can only be called after the `ready` event has been emitted on `App`.
## Class: UtilityProcess
> Instances of the `UtilityProcess` represent the Chromium spawned child process

View File

@@ -456,8 +456,6 @@ filenames = {
"shell/browser/net/system_network_context_manager.h",
"shell/browser/net/url_loader_network_observer.cc",
"shell/browser/net/url_loader_network_observer.h",
"shell/browser/net/url_pipe_loader.cc",
"shell/browser/net/url_pipe_loader.h",
"shell/browser/net/web_request_api_interface.h",
"shell/browser/network_hints_handler_impl.cc",
"shell/browser/network_hints_handler_impl.h",

View File

@@ -84,7 +84,6 @@ feat_filter_out_non-shareable_windows_in_the_current_application_in.patch
disable_freezing_flags_after_init_in_node.patch
short-circuit_permissions_checks_in_mediastreamdevicescontroller.patch
chore_add_electron_deps_to_gitignores.patch
chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch
add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
add_electron_deps_to_license_credits_file.patch
fix_crash_loading_non-standard_schemes_in_iframes.patch
@@ -144,3 +143,12 @@ cherry-pick-dd8e2822e507.patch
fix_osr_stutter_in_both_cpu_and_gpu_capture_when_page_has_animation.patch
reland_lzma_sdk_update_to_24_09.patch
fix_drag_and_drop_icons_on_windows.patch
cherry-pick-521faebc8a7c.patch
cherry-pick-9dacf5694dfd.patch
revert_blink_fix_over_invalidation_with_view_transitions.patch
add_a_flag_to_enable_strict_js_compliance_in_audioworklet.patch
remove_denormalenabler_from_scriptprocessornode.patch
allow_denormal_flushing_to_outlive_scoped_object.patch
fix_take_snapped_status_into_account_when_showing_a_window.patch
chore_modify_chromium_handling_of_mouse_events.patch
cherry-pick-b8f80176b163.patch

View File

@@ -0,0 +1,333 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Michael Wilson <mjwilson@chromium.org>
Date: Thu, 12 Dec 2024 08:45:53 -0800
Subject: Add a flag to enable strict JS compliance in AudioWorklet
AudioWorklet and ScriptProcessorNode are not strictly JavaScript spec
compliant because we disable denormal numbers for performance reasons.
This CL adds a flag to allow experimenting with enabling denormal
numbers in AudioWorklet and ScriptProcessorNode, so that we can
quantify the actual performance impact.
The flag can also be used as a server-side switch.
Bug: 382005099
Change-Id: Ib41253cc42dd2f16c262036817cf3db4697f986f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6077677
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Wilson <mjwilson@chromium.org>
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1395444}
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
index e7224e03e80f8351556b3d2d43650dad7e29edef..1b2b6128e69953be7f9f96853d76c5c0e16552fe 100644
--- a/third_party/blink/common/features.cc
+++ b/third_party/blink/common/features.cc
@@ -2754,6 +2754,12 @@ BASE_FEATURE(kWebAppManifestLockScreen,
"WebAppManifestLockScreen",
base::FEATURE_DISABLED_BY_DEFAULT);
+// Allow denormals in AudioWorklet and ScriptProcessorNode, to enable strict
+// JavaScript denormal compliance. See https://crbug.com/382005099.
+BASE_FEATURE(kWebAudioAllowDenormalInProcessing,
+ "WebAudioAllowDenormalInProcessing",
+ base::FEATURE_DISABLED_BY_DEFAULT);
+
// Parameters can be used to control to which latency hints the feature is
// applied.
BASE_FEATURE_PARAM(bool,
diff --git a/third_party/blink/public/common/features.h b/third_party/blink/public/common/features.h
index e8f79c39e03f5777c1accd4446c97f18fb3e34de..0bc9302cd8f3f291949be328aba5df88e2ab0d03 100644
--- a/third_party/blink/public/common/features.h
+++ b/third_party/blink/public/common/features.h
@@ -1791,6 +1791,7 @@ BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAppEnableScopeExtensions);
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAppEnableUrlHandlers);
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAppManifestLockScreen);
+BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAudioAllowDenormalInProcessing);
// Parameters are used to control to which latency hints the feature is applied
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE_PARAM(
bool,
diff --git a/third_party/blink/renderer/modules/webaudio/audio_worklet_handler.cc b/third_party/blink/renderer/modules/webaudio/audio_worklet_handler.cc
index 0382f578a4f98cbac422d5f927c73a6b922c01b8..9a662e7730d3e01dcf8e69f66c4eafa9dd7dd031 100644
--- a/third_party/blink/renderer/modules/webaudio/audio_worklet_handler.cc
+++ b/third_party/blink/renderer/modules/webaudio/audio_worklet_handler.cc
@@ -29,6 +29,7 @@
#include "third_party/blink/renderer/modules/webaudio/cross_thread_audio_worklet_processor_info.h"
#include "third_party/blink/renderer/platform/audio/audio_bus.h"
#include "third_party/blink/renderer/platform/audio/audio_utilities.h"
+#include "third_party/blink/renderer/platform/audio/denormal_disabler.h"
#include "third_party/blink/renderer/platform/bindings/exception_messages.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
@@ -52,7 +53,9 @@ AudioWorkletHandler::AudioWorkletHandler(
const AudioWorkletNodeOptions* options)
: AudioHandler(kNodeTypeAudioWorklet, node, sample_rate),
name_(name),
- param_handler_map_(param_handler_map) {
+ param_handler_map_(param_handler_map),
+ allow_denormal_in_processing_(base::FeatureList::IsEnabled(
+ features::kWebAudioAllowDenormalInProcessing)) {
DCHECK(IsMainThread());
for (const auto& param_name : param_handler_map_.Keys()) {
@@ -112,7 +115,7 @@ scoped_refptr<AudioWorkletHandler> AudioWorkletHandler::Create(
param_handler_map, options));
}
-void AudioWorkletHandler::Process(uint32_t frames_to_process) {
+void AudioWorkletHandler::ProcessInternal(uint32_t frames_to_process) {
DCHECK(Context()->IsAudioThread());
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("webaudio.audionode"),
@@ -175,6 +178,15 @@ void AudioWorkletHandler::Process(uint32_t frames_to_process) {
}
}
+void AudioWorkletHandler::Process(uint32_t frames_to_process) {
+ if (allow_denormal_in_processing_) {
+ DenormalEnabler denormal_enabler;
+ ProcessInternal(frames_to_process);
+ } else {
+ ProcessInternal(frames_to_process);
+ }
+}
+
void AudioWorkletHandler::CheckNumberOfChannelsForInput(AudioNodeInput* input) {
DCHECK(Context()->IsAudioThread());
Context()->AssertGraphOwner();
diff --git a/third_party/blink/renderer/modules/webaudio/audio_worklet_handler.h b/third_party/blink/renderer/modules/webaudio/audio_worklet_handler.h
index e6291f5e9e25433281646965f048a7f2abfc8c01..3ec80cd49a87a76ac03df105b37f1ae17437a328 100644
--- a/third_party/blink/renderer/modules/webaudio/audio_worklet_handler.h
+++ b/third_party/blink/renderer/modules/webaudio/audio_worklet_handler.h
@@ -68,6 +68,10 @@ class AudioWorkletHandler final : public AudioHandler {
HashMap<String, scoped_refptr<AudioParamHandler>> param_handler_map,
const AudioWorkletNodeOptions*);
+ // Used to avoid code duplication when using scoped objects that affect
+ // `Process`.
+ void ProcessInternal(uint32_t frames_to_process);
+
String name_;
double tail_time_ = std::numeric_limits<double>::infinity();
@@ -102,6 +106,9 @@ class AudioWorkletHandler final : public AudioHandler {
// when a processor stops invoking the user-defined `process()` callback.
bool is_processor_active_ = true;
+ // Cached feature flag value
+ const bool allow_denormal_in_processing_;
+
base::WeakPtrFactory<AudioWorkletHandler> weak_ptr_factory_{this};
};
diff --git a/third_party/blink/renderer/modules/webaudio/script_processor_handler.cc b/third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
index d3d44d2a4c87bf5d4191807ec31d87c7e597fef9..ea04e2cd2bfb553a58ba6fb9c63c70c5a2690442 100644
--- a/third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
+++ b/third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
@@ -26,6 +26,7 @@
#include "third_party/blink/renderer/modules/webaudio/base_audio_context.h"
#include "third_party/blink/renderer/modules/webaudio/realtime_audio_destination_node.h"
#include "third_party/blink/renderer/modules/webaudio/script_processor_node.h"
+#include "third_party/blink/renderer/platform/audio/denormal_disabler.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
@@ -48,7 +49,9 @@ ScriptProcessorHandler::ScriptProcessorHandler(
internal_input_bus_(AudioBus::Create(
number_of_input_channels,
node.context()->GetDeferredTaskHandler().RenderQuantumFrames(),
- false)) {
+ false)),
+ allow_denormal_in_processing_(base::FeatureList::IsEnabled(
+ features::kWebAudioAllowDenormalInProcessing)) {
DCHECK_GE(buffer_size_,
node.context()->GetDeferredTaskHandler().RenderQuantumFrames());
DCHECK_LE(number_of_input_channels, BaseAudioContext::MaxNumberOfChannels());
@@ -109,7 +112,7 @@ void ScriptProcessorHandler::Initialize() {
AudioHandler::Initialize();
}
-void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
+void ScriptProcessorHandler::ProcessInternal(uint32_t frames_to_process) {
TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("webaudio.audionode"),
"ScriptProcessorHandler::Process");
@@ -238,6 +241,15 @@ void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
"ScriptProcessorHandler::Process");
}
+void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
+ if (allow_denormal_in_processing_) {
+ DenormalEnabler denormal_enabler;
+ ProcessInternal(frames_to_process);
+ } else {
+ ProcessInternal(frames_to_process);
+ }
+}
+
void ScriptProcessorHandler::FireProcessEvent(uint32_t double_buffer_index) {
DCHECK(IsMainThread());
diff --git a/third_party/blink/renderer/modules/webaudio/script_processor_handler.h b/third_party/blink/renderer/modules/webaudio/script_processor_handler.h
index 82ac7cebaefb515a04442e7a24896177d66fcb01..99103e947ade50f07a16a61bc8702d6097266296 100644
--- a/third_party/blink/renderer/modules/webaudio/script_processor_handler.h
+++ b/third_party/blink/renderer/modules/webaudio/script_processor_handler.h
@@ -65,6 +65,11 @@ class ScriptProcessorHandler final : public AudioHandler {
uint32_t number_of_output_channels,
const HeapVector<Member<AudioBuffer>>& input_buffers,
const HeapVector<Member<AudioBuffer>>& output_buffers);
+
+ // Used to avoid code duplication when using scoped objects that affect
+ // `Process`.
+ void ProcessInternal(uint32_t frames_to_process);
+
double TailTime() const override;
double LatencyTime() const override;
bool RequiresTailProcessing() const final;
@@ -92,6 +97,9 @@ class ScriptProcessorHandler final : public AudioHandler {
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ // Cached feature flag value
+ const bool allow_denormal_in_processing_;
+
base::WeakPtrFactory<ScriptProcessorHandler> weak_ptr_factory_{this};
FRIEND_TEST_ALL_PREFIXES(ScriptProcessorNodeTest, BufferLifetime);
diff --git a/third_party/blink/renderer/platform/audio/denormal_disabler.h b/third_party/blink/renderer/platform/audio/denormal_disabler.h
index e8fadf60eea81b017dc29b39c2d1cfe8c102999b..ac1cdfa026aa1f845a892e96200fd9de46a45c92 100644
--- a/third_party/blink/renderer/platform/audio/denormal_disabler.h
+++ b/third_party/blink/renderer/platform/audio/denormal_disabler.h
@@ -52,28 +52,28 @@ namespace blink {
#endif
#if defined(HAVE_DENORMAL)
-class DenormalDisabler {
- DISALLOW_NEW();
-
+class DenormalModifier {
public:
- DenormalDisabler() { DisableDenormals(); }
-
- ~DenormalDisabler() { RestoreState(); }
-
- // This is a nop if we can flush denormals to zero in hardware.
- static inline float FlushDenormalFloatToZero(float f) { return f; }
+ virtual ~DenormalModifier() = default;
private:
unsigned saved_csr_ = 0;
#if defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY)
+ protected:
inline void DisableDenormals() {
saved_csr_ = GetCSR();
SetCSR(saved_csr_ | 0x8040);
}
+ inline void EnableDenormals() {
+ saved_csr_ = GetCSR();
+ SetCSR(saved_csr_ & (~0x8040));
+ }
+
inline void RestoreState() { SetCSR(saved_csr_); }
+ private:
inline int GetCSR() {
int result;
asm volatile("stmxcsr %0" : "=m"(result));
@@ -86,6 +86,7 @@ class DenormalDisabler {
}
#elif BUILDFLAG(IS_WIN) && defined(COMPILER_MSVC)
+ protected:
inline void DisableDenormals() {
// Save the current state, and set mode to flush denormals.
//
@@ -95,11 +96,18 @@ class DenormalDisabler {
_controlfp_s(&unused, _DN_FLUSH, _MCW_DN);
}
+ inline void EnableDenormals() {
+ _controlfp_s(&saved_csr_, 0, 0);
+ unsigned unused;
+ _controlfp_s(&unused, _DN_SAVE, _MCW_DN);
+ }
+
inline void RestoreState() {
unsigned unused;
_controlfp_s(&unused, saved_csr_, _MCW_DN);
}
#elif defined(ARCH_CPU_ARM_FAMILY)
+ protected:
inline void DisableDenormals() {
saved_csr_ = GetStatusWord();
// Bit 24 is the flush-to-zero mode control bit. Setting it to 1 flushes
@@ -107,8 +115,14 @@ class DenormalDisabler {
SetStatusWord(saved_csr_ | (1 << 24));
}
+ inline void EnableDenormals() {
+ saved_csr_ = GetStatusWord();
+ SetStatusWord(saved_csr_ & (~(1 << 24)));
+ }
+
inline void RestoreState() { SetStatusWord(saved_csr_); }
+ private:
inline int GetStatusWord() {
int result;
#if defined(ARCH_CPU_ARM64)
@@ -130,13 +144,33 @@ class DenormalDisabler {
#endif
};
+class DenormalDisabler final : public DenormalModifier {
+ DISALLOW_NEW();
+
+ public:
+ DenormalDisabler() { DisableDenormals(); }
+ ~DenormalDisabler() final { RestoreState(); }
+
+ // This is a nop if we can flush denormals to zero in hardware.
+ static inline float FlushDenormalFloatToZero(float f) { return f; }
+};
+
+class DenormalEnabler final : public DenormalModifier {
+ DISALLOW_NEW();
+
+ public:
+ DenormalEnabler() { EnableDenormals(); }
+ ~DenormalEnabler() final { RestoreState(); }
+};
+
#else
// FIXME: add implementations for other architectures and compilers
class DenormalDisabler {
STACK_ALLOCATED();
public:
- DenormalDisabler() {}
+ DenormalDisabler() = default;
+ ~DenormalDisabler() = default;
// Assume the worst case that other architectures and compilers
// need to flush denormals to zero manually.
@@ -145,6 +179,14 @@ class DenormalDisabler {
}
};
+class DenormalEnabler {
+ STACK_ALLOCATED();
+
+ public:
+ DenormalEnabler() = default;
+ ~DenormalEnabler() = default;
+};
+
#endif
} // namespace blink

View File

@@ -0,0 +1,293 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Michael Wilson <mjwilson@chromium.org>
Date: Fri, 7 Feb 2025 13:33:40 -0800
Subject: Allow denormal flushing to outlive scoped object
After this refactor we can disable or enable denormals for longer than
a scoped object.
Use this new functionality in audio_worklet_global_scope.cc.
(cherry picked from commit 93c4f6fb0a0f10562ef9a637449605caae9200e6)
Bug: 382005099
Change-Id: I54f4810a4ec035f639d50275e14dae03b726b876
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6226252
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Wilson <mjwilson@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1415886}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6242822
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/branch-heads/6998@{#221}
Cr-Branched-From: de9c6fafd8ae5c6ea0438764076ca7d04a0b165d-refs/heads/main@{#1415337}
diff --git a/third_party/blink/renderer/modules/webaudio/audio_worklet_global_scope.cc b/third_party/blink/renderer/modules/webaudio/audio_worklet_global_scope.cc
index c9bd1e8934d7058cb4c8044aa5618033ec975cec..09de112b96b6062f702d57e6181dd39e681e99a1 100644
--- a/third_party/blink/renderer/modules/webaudio/audio_worklet_global_scope.cc
+++ b/third_party/blink/renderer/modules/webaudio/audio_worklet_global_scope.cc
@@ -23,6 +23,7 @@
#include "third_party/blink/renderer/modules/webaudio/audio_worklet_processor.h"
#include "third_party/blink/renderer/modules/webaudio/audio_worklet_processor_definition.h"
#include "third_party/blink/renderer/modules/webaudio/cross_thread_audio_worklet_processor_info.h"
+#include "third_party/blink/renderer/platform/audio/denormal_disabler.h"
#include "third_party/blink/renderer/platform/bindings/callback_method_retriever.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
@@ -34,6 +35,9 @@ AudioWorkletGlobalScope::AudioWorkletGlobalScope(
: WorkletGlobalScope(std::move(creation_params),
thread->GetWorkerReportingProxy(),
thread) {
+ // Disable denormals for performance.
+ DenormalModifier::DisableDenormals();
+
// Audio is prone to jank introduced by e.g. the garbage collector. Workers
// are generally put in a background mode (as they are non-visible). Audio is
// an exception here, requiring low-latency behavior similar to any visible
diff --git a/third_party/blink/renderer/platform/BUILD.gn b/third_party/blink/renderer/platform/BUILD.gn
index ffb2cc23eb74da99ca5875293879659b4f171303..01366aa7b5b4438f9d62de4065623a1ede71cc41 100644
--- a/third_party/blink/renderer/platform/BUILD.gn
+++ b/third_party/blink/renderer/platform/BUILD.gn
@@ -2142,6 +2142,7 @@ source_set("blink_platform_unittests_sources") {
"animation/timing_function_test.cc",
"audio/audio_destination_test.cc",
"audio/audio_frame_stats_accumulator_test.cc",
+ "audio/denormal_disabler_test.cc",
"audio/push_pull_fifo_multithread_test.cc",
"audio/push_pull_fifo_test.cc",
"audio/vector_math_test.cc",
diff --git a/third_party/blink/renderer/platform/audio/denormal_disabler.h b/third_party/blink/renderer/platform/audio/denormal_disabler.h
index ac1cdfa026aa1f845a892e96200fd9de46a45c92..a50d7b884e8fdc65f4c1fbe6b5cab7a7801a3b62 100644
--- a/third_party/blink/renderer/platform/audio/denormal_disabler.h
+++ b/third_party/blink/renderer/platform/audio/denormal_disabler.h
@@ -56,74 +56,65 @@ class DenormalModifier {
public:
virtual ~DenormalModifier() = default;
- private:
- unsigned saved_csr_ = 0;
-
#if defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY)
- protected:
- inline void DisableDenormals() {
- saved_csr_ = GetCSR();
- SetCSR(saved_csr_ | 0x8040);
+ public:
+ static void DisableDenormals() {
+ unsigned old_csr = GetCsr();
+ SetCsr(old_csr | 0x8040);
}
- inline void EnableDenormals() {
- saved_csr_ = GetCSR();
- SetCSR(saved_csr_ & (~0x8040));
+ static void EnableDenormals() {
+ unsigned old_csr = GetCsr();
+ SetCsr(old_csr & (~0x8040));
}
- inline void RestoreState() { SetCSR(saved_csr_); }
-
- private:
- inline int GetCSR() {
+ protected:
+ static inline unsigned GetCsr() {
int result;
asm volatile("stmxcsr %0" : "=m"(result));
return result;
}
- inline void SetCSR(int a) {
+ static inline void SetCsr(int a) {
int temp = a;
asm volatile("ldmxcsr %0" : : "m"(temp));
}
#elif BUILDFLAG(IS_WIN) && defined(COMPILER_MSVC)
+ public:
+ static void DisableDenormals() { SetCsr(_DN_FLUSH); }
+
+ static void EnableDenormals() { SetCsr(_DN_SAVE); }
+
protected:
- inline void DisableDenormals() {
- // Save the current state, and set mode to flush denormals.
- //
- // http://stackoverflow.com/questions/637175/possible-bug-in-controlfp-s-may-not-restore-control-word-correctly
- _controlfp_s(&saved_csr_, 0, 0);
- unsigned unused;
- _controlfp_s(&unused, _DN_FLUSH, _MCW_DN);
+ static inline unsigned GetCsr() {
+ unsigned result;
+ _controlfp_s(&result, 0, 0);
+ return result;
}
- inline void EnableDenormals() {
- _controlfp_s(&saved_csr_, 0, 0);
+ static inline void SetCsr(unsigned a) {
+ // http://stackoverflow.com/questions/637175/possible-bug-in-controlfp-s-may-not-restore-control-word-correctly
unsigned unused;
- _controlfp_s(&unused, _DN_SAVE, _MCW_DN);
+ _controlfp_s(&unused, a, _MCW_DN);
}
- inline void RestoreState() {
- unsigned unused;
- _controlfp_s(&unused, saved_csr_, _MCW_DN);
- }
#elif defined(ARCH_CPU_ARM_FAMILY)
- protected:
- inline void DisableDenormals() {
- saved_csr_ = GetStatusWord();
+ public:
+ static void DisableDenormals() {
+ unsigned old_csr = GetCsr();
// Bit 24 is the flush-to-zero mode control bit. Setting it to 1 flushes
// denormals to 0.
- SetStatusWord(saved_csr_ | (1 << 24));
+ SetCsr(old_csr | (1 << 24));
}
- inline void EnableDenormals() {
- saved_csr_ = GetStatusWord();
- SetStatusWord(saved_csr_ & (~(1 << 24)));
+ static void EnableDenormals() {
+ unsigned old_csr = GetCsr();
+ SetCsr(old_csr & (~(1 << 24)));
}
- inline void RestoreState() { SetStatusWord(saved_csr_); }
-
- private:
- inline int GetStatusWord() {
+ protected:
+ static inline unsigned GetCsr() {
int result;
#if defined(ARCH_CPU_ARM64)
asm volatile("mrs %x[result], FPCR" : [result] "=r"(result));
@@ -133,7 +124,7 @@ class DenormalModifier {
return result;
}
- inline void SetStatusWord(int a) {
+ static inline void SetCsr(int a) {
#if defined(ARCH_CPU_ARM64)
asm volatile("msr FPCR, %x[src]" : : [src] "r"(a));
#else
@@ -148,24 +139,44 @@ class DenormalDisabler final : public DenormalModifier {
DISALLOW_NEW();
public:
- DenormalDisabler() { DisableDenormals(); }
- ~DenormalDisabler() final { RestoreState(); }
+ DenormalDisabler() {
+ // Save the current state, and set mode to flush denormals.
+ saved_csr_ = GetCsr();
+ DisableDenormals();
+ }
+ ~DenormalDisabler() final { SetCsr(saved_csr_); }
// This is a nop if we can flush denormals to zero in hardware.
static inline float FlushDenormalFloatToZero(float f) { return f; }
+
+ private:
+ unsigned saved_csr_ = 0;
};
class DenormalEnabler final : public DenormalModifier {
DISALLOW_NEW();
public:
- DenormalEnabler() { EnableDenormals(); }
- ~DenormalEnabler() final { RestoreState(); }
+ DenormalEnabler() {
+ saved_csr_ = GetCsr();
+ EnableDenormals();
+ }
+ ~DenormalEnabler() final { SetCsr(saved_csr_); }
+
+ private:
+ unsigned saved_csr_ = 0;
};
#else
// FIXME: add implementations for other architectures and compilers
-class DenormalDisabler {
+class DenormalModifier final {
+ public:
+ virtual ~DenormalModifier() = default;
+ static void DisableDenormals() {}
+ static void EnableDenormals() {}
+};
+
+class DenormalDisabler final {
STACK_ALLOCATED();
public:
@@ -179,7 +190,7 @@ class DenormalDisabler {
}
};
-class DenormalEnabler {
+class DenormalEnabler final {
STACK_ALLOCATED();
public:
diff --git a/third_party/blink/renderer/platform/audio/denormal_disabler_test.cc b/third_party/blink/renderer/platform/audio/denormal_disabler_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5083bbf2da9d4e0e12f1a4608d5e14e4ca910297
--- /dev/null
+++ b/third_party/blink/renderer/platform/audio/denormal_disabler_test.cc
@@ -0,0 +1,51 @@
+// Copyright 2025 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/platform/audio/denormal_disabler.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+namespace {
+
+bool DenormalsAreFlushedToZero() {
+ volatile double denorm = 2.225e-308;
+ return !((denorm / 2.0) > 0.0);
+}
+
+TEST(DenormalDisablerTest, DisableScoped) {
+ const bool already_flushed = DenormalsAreFlushedToZero();
+ if (!already_flushed) {
+ DenormalDisabler scoped_disabler;
+ EXPECT_TRUE(DenormalsAreFlushedToZero());
+ }
+}
+
+TEST(DenormalDisablerTest, EnableScoped) {
+ const bool already_flushed = DenormalsAreFlushedToZero();
+ if (!already_flushed) {
+ DenormalDisabler scoped_disabler;
+ EXPECT_TRUE(DenormalsAreFlushedToZero());
+ {
+ DenormalEnabler scoped_enabler;
+ EXPECT_FALSE(DenormalsAreFlushedToZero());
+ }
+ EXPECT_TRUE(DenormalsAreFlushedToZero());
+ }
+}
+
+TEST(DenormalDisablerTest, ModifyUnscoped) {
+ const bool already_flushed = DenormalsAreFlushedToZero();
+ if (!already_flushed) {
+ DenormalModifier::DisableDenormals();
+ EXPECT_TRUE(DenormalsAreFlushedToZero());
+ DenormalModifier::EnableDenormals();
+ EXPECT_FALSE(DenormalsAreFlushedToZero());
+ }
+}
+
+} // namespace
+
+} // namespace blink

View File

@@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Geoff Lang <geofflang@chromium.org>
Date: Thu, 6 Mar 2025 19:39:37 -0800
Subject: Disable setting primtive restart for WebGL in the cmd decoder.
Until it's blocked in ANGLE for WebGL contexts, disable it in the
command decoder on the service side.
Bug: 401059730
Change-Id: Ia9c7d951cbd122454afec2f884968e0a709cee77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6334632
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1429307}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
index 54310b8878fa7aeca45e6001cb884a794272138c..2cb2a3b4913a54373b84cebf9326ee09a98f6bcc 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
@@ -2160,6 +2160,11 @@ bool GLES2DecoderPassthroughImpl::IsIgnoredCap(GLenum cap) const {
case GL_DEBUG_OUTPUT:
return true;
+ case GL_PRIMITIVE_RESTART_FIXED_INDEX:
+ // Disable setting primitive restart at the command decoder level until
+ // it's blocked in ANGLE for WebGL contexts.
+ return feature_info_->IsWebGLContext();
+
default:
return false;
}

View File

@@ -0,0 +1,94 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Geoff Lang <geofflang@chromium.org>
Date: Thu, 6 Mar 2025 16:02:41 -0800
Subject: Move WebGL primitive restart state setting to the GPU process.
ANGLE will validate and initialize this state and errors are generated
when the WebGL client also initializes it on startup.
Initialize it even in the passthrough command decoder temporarily so
that ANGLE can roll without breaking WebGL tests.
Bug: 401059730
Change-Id: I0bfee710673bbcea6f915ffc4fc9be20438a2654
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6330188
Auto-Submit: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1429228}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 03a26a5f81dee1cd1bba28621c1ecd30ea709df8..60447a8e71e056db01515db8bc6c56048537870f 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -3285,6 +3285,13 @@ gpu::ContextResult GLES2DecoderImpl::Initialize(
}
}
+ if (feature_info_->context_type() == CONTEXT_TYPE_WEBGL2) {
+ // If WebGL 2, the PRIMITIVE_RESTART_FIXED_INDEX should be always enabled.
+ // See the section <Primitive Restart is Always Enabled> in WebGL 2 spec:
+ // https://www.khronos.org/registry/webgl/specs/latest/2.0/#4.1.4
+ DoEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
+ }
+
if (group_->gpu_preferences().enable_gpu_driver_debug_logging &&
feature_info_->feature_flags().khr_debug) {
InitializeGLDebugLogging(true, GLDebugMessageCallback, &logger_);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
index 2cb2a3b4913a54373b84cebf9326ee09a98f6bcc..ee9ad4fa2838a22bc8b24185267a29687129f721 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
@@ -1065,6 +1065,17 @@ gpu::ContextResult GLES2DecoderPassthroughImpl::Initialize(
api()->glDisableFn(GL_TEXTURE_RECTANGLE_ANGLE);
#endif
+ // TEMPORARY: Set primitive restart to enabled by default for WebGL2. Clear
+ // errors afterwards so that when this state is initialized and validated in
+ // ANGLE, it will not generate errors during command buffer initialization.
+ if (feature_info_->context_type() == CONTEXT_TYPE_WEBGL2) {
+ // If WebGL 2, the PRIMITIVE_RESTART_FIXED_INDEX should be always enabled.
+ // See the section <Primitive Restart is Always Enabled> in WebGL 2 spec:
+ // https://www.khronos.org/registry/webgl/specs/latest/2.0/#4.1.4
+ api()->glEnableFn(GL_PRIMITIVE_RESTART_FIXED_INDEX);
+ CheckErrorCallbackState();
+ }
+
// Register this object as a GPU switching observer.
if (feature_info_->IsWebGLContext()) {
ui::GpuSwitchingManager::GetInstance()->AddObserver(this);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
index 1683b266f349d4b70ae2861cf4f05542380d8c44..0a0c1b3f6f9fe2caddf86602d2ae9978eff928f1 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -440,6 +440,13 @@ ContextResult GLES2DecoderTestBase::MaybeInitDecoderWithWorkarounds(
}
#endif
+ if (init.context_type == CONTEXT_TYPE_WEBGL2 &&
+ group_->feature_info()->gl_version_info().is_es3) {
+ EXPECT_CALL(*gl_, Enable(GL_PRIMITIVE_RESTART_FIXED_INDEX))
+ .Times(1)
+ .RetiresOnSaturation();
+ }
+
if (context_->HasRobustness()) {
EXPECT_CALL(*gl_, GetGraphicsResetStatusARB())
.WillOnce(Return(init.lose_context_on_init ? GL_GUILTY_CONTEXT_RESET_ARB
diff --git a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
index 6057cf83454f0deabc1904cb5e87b306bda4e788..304f4c7beb87212c70e91770d494254da7ed24bf 100644
--- a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
+++ b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
@@ -1432,12 +1432,6 @@ void WebGLRenderingContextBase::InitializeNewContext() {
->GetCapabilities()
.mesa_framebuffer_flip_y;
- // If WebGL 2, the PRIMITIVE_RESTART_FIXED_INDEX should be always enabled.
- // See the section <Primitive Restart is Always Enabled> in WebGL 2 spec:
- // https://www.khronos.org/registry/webgl/specs/latest/2.0/#4.1.4
- if (IsWebGL2())
- ContextGL()->Enable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
-
// This ensures that the context has a valid "lastFlushID" and won't be
// mistakenly identified as the "least recently used" context.
ContextGL()->Flush();

View File

@@ -0,0 +1,173 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alex Gough <ajgo@chromium.org>
Date: Mon, 24 Mar 2025 09:04:37 -0700
Subject: Avoid receiving or sending sentinel handle values
These values can be misinterpreted by OS functions, so
avoid sending or receiving them over IPCZ.
(cherry picked from commit 36dbbf38697dd1e23ef8944bb9e57f6e0b3d41ec)
Bug: 405143032
Change-Id: Ib578fb4727e78e2697c60c42005daa97e08695e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6380193
Reviewed-by: Will Harris <wfh@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1436135}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6383569
Owners-Override: Srinivas Sista <srinivassista@chromium.org>
Commit-Queue: Srinivas Sista <srinivassista@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/6998@{#2315}
Cr-Branched-From: de9c6fafd8ae5c6ea0438764076ca7d04a0b165d-refs/heads/main@{#1415337}
diff --git a/base/win/win_util.h b/base/win/win_util.h
index 2c23658cdc25339cdf36b8d5cf951b85cb1c74da..73442a61a323394282876a453ec437aff5c6393c 100644
--- a/base/win/win_util.h
+++ b/base/win/win_util.h
@@ -46,6 +46,25 @@ struct NativeLibraryLoadError;
namespace win {
+inline bool IsPseudoHandle(HANDLE h) {
+ // Note that there appears to be no official documentation covering the
+ // existence of specific pseudo handle values. In practice it's clear that
+ // e.g. -1 is the current process, -2 is the current thread, etc. The largest
+ // negative value known to be an issue with DuplicateHandle in fuzzers is
+ // -12.
+ //
+ // Note that there is virtually no risk of a real handle value falling within
+ // this range and being misclassified as a pseudo handle.
+ //
+ // Cast through uintptr_t and then unsigned int to make the truncation to
+ // 32 bits explicit. Handles are size of-pointer but are always 32-bit values.
+ // https://msdn.microsoft.com/en-us/library/aa384203(VS.85).aspx says:
+ // 64-bit versions of Windows use 32-bit handles for interoperability.
+ constexpr int kMinimumKnownPseudoHandleValue = -12;
+ const auto value = static_cast<int32_t>(reinterpret_cast<uintptr_t>(h));
+ return value < 0 && value >= kMinimumKnownPseudoHandleValue;
+}
+
inline uint32_t HandleToUint32(HANDLE h) {
// Cast through uintptr_t and then unsigned int to make the truncation to
// 32 bits explicit. Handles are size of-pointer but are always 32-bit values.
diff --git a/base/win/win_util_unittest.cc b/base/win/win_util_unittest.cc
index a2e0c6da978e5013e5027c8d11a9fb2c63fd0593..39b03eec238b21d91ae60d741e9dce2fe0f8edc0 100644
--- a/base/win/win_util_unittest.cc
+++ b/base/win/win_util_unittest.cc
@@ -84,6 +84,12 @@ TEST(BaseWinUtilTest, TestUint32ToInvalidHandle) {
EXPECT_EQ(INVALID_HANDLE_VALUE, Uint32ToHandle(invalid_handle));
}
+TEST(BaseWinUtilTest, PseudoHandles) {
+ EXPECT_TRUE(IsPseudoHandle(::GetCurrentProcess()));
+ EXPECT_TRUE(IsPseudoHandle(::GetCurrentThread()));
+ EXPECT_FALSE(IsPseudoHandle(nullptr));
+}
+
TEST(BaseWinUtilTest, WStringFromGUID) {
const GUID kGuid = {0x7698f759,
0xf5b0,
diff --git a/mojo/core/ipcz_driver/transport.cc b/mojo/core/ipcz_driver/transport.cc
index 4e15366a756c3491de814cbdf0ae744a2c7061ee..d13778473bb88d71f1d9452f61de0aee81f53d41 100644
--- a/mojo/core/ipcz_driver/transport.cc
+++ b/mojo/core/ipcz_driver/transport.cc
@@ -34,6 +34,7 @@
#include "third_party/ipcz/include/ipcz/ipcz.h"
#if BUILDFLAG(IS_WIN)
+#include "base/win/win_util.h"
#include "mojo/public/cpp/platform/platform_handle_security_util_win.h"
#endif
@@ -135,10 +136,12 @@ bool EncodeHandle(PlatformHandle& handle,
HandleOwner handle_owner,
HandleData& out_handle_data,
bool is_remote_process_untrusted) {
+ CHECK(handle.is_valid());
// Duplicating INVALID_HANDLE_VALUE passes a process handle. If you intend to
// do this, you must open a valid process handle, not pass the result of
- // GetCurrentProcess(). e.g. https://crbug.com/243339.
- CHECK(handle.is_valid());
+ // GetCurrentProcess() or GetCurrentThread(). e.g. https://crbug.com/243339.
+ CHECK(!handle.is_pseudo_handle());
+
if (handle_owner == HandleOwner::kSender) {
// Nothing to do when sending handles that belong to us. The recipient must
// be sufficiently privileged and equipped to duplicate such handles to
@@ -178,6 +181,10 @@ PlatformHandle DecodeHandle(HandleData data,
HandleOwner handle_owner,
Transport& from_transport) {
const HANDLE handle = DataToHandle(data);
+ // Do not decode sentinel values used by Windows (INVALID_HANDLE_VALUE &
+ // GetCurrentThread()).
+ CHECK(!base::win::IsPseudoHandle(handle));
+
if (handle_owner == HandleOwner::kRecipient) {
if (from_transport.destination_type() != Transport::kBroker &&
!from_transport.is_peer_trusted() && !remote_process.is_current()) {
diff --git a/mojo/core/platform_handle_in_transit.cc b/mojo/core/platform_handle_in_transit.cc
index 44330d2563da0c22dccb193f1c4dc57f7112cdd3..670dca4889dc566896aec029218e911d6c2d83af 100644
--- a/mojo/core/platform_handle_in_transit.cc
+++ b/mojo/core/platform_handle_in_transit.cc
@@ -18,6 +18,7 @@
#include "base/win/nt_status.h"
#include "base/win/scoped_handle.h"
+#include "base/win/win_util.h"
#include "mojo/public/cpp/platform/platform_handle_security_util_win.h"
#endif
@@ -37,8 +38,8 @@ HANDLE TransferHandle(HANDLE handle,
// Duplicating INVALID_HANDLE_VALUE passes a process handle. If you intend to
// do this, you must open a valid process handle, not pass the result of
- // GetCurrentProcess(). e.g. https://crbug.com/243339.
- CHECK(handle != INVALID_HANDLE_VALUE);
+ // GetCurrentProcess() or GetCurrentThread(). e.g. https://crbug.com/243339.
+ CHECK(!base::win::IsPseudoHandle(handle));
HANDLE out_handle;
BOOL result =
@@ -164,17 +165,7 @@ bool PlatformHandleInTransit::TransferToProcess(
#if BUILDFLAG(IS_WIN)
// static
bool PlatformHandleInTransit::IsPseudoHandle(HANDLE handle) {
- // Note that there appears to be no official documentation covering the
- // existence of specific pseudo handle values. In practice it's clear that
- // e.g. -1 is the current process, -2 is the current thread, etc. The largest
- // negative value known to be an issue with DuplicateHandle in the fuzzer is
- // -12.
- //
- // Note that there is virtually no risk of a real handle value falling within
- // this range and being misclassified as a pseudo handle.
- constexpr int kMinimumKnownPseudoHandleValue = -12;
- const auto value = static_cast<int32_t>(reinterpret_cast<uintptr_t>(handle));
- return value < 0 && value >= kMinimumKnownPseudoHandleValue;
+ return base::win::IsPseudoHandle(handle);
}
// static
diff --git a/mojo/public/cpp/platform/platform_handle.h b/mojo/public/cpp/platform/platform_handle.h
index 7154aebfbf95c2e970b5c6c60612c9f1f12a202d..3390540d8a172d3110cc80ef3f2d2e60466ee7d1 100644
--- a/mojo/public/cpp/platform/platform_handle.h
+++ b/mojo/public/cpp/platform/platform_handle.h
@@ -13,6 +13,7 @@
#if BUILDFLAG(IS_WIN)
#include "base/win/scoped_handle.h"
+#include "base/win/win_util.h"
#elif BUILDFLAG(IS_FUCHSIA)
#include <lib/zx/handle.h>
#elif BUILDFLAG(IS_APPLE)
@@ -117,6 +118,9 @@ class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) PlatformHandle {
bool is_valid() const { return is_valid_handle(); }
bool is_valid_handle() const { return handle_.IsValid(); }
bool is_handle() const { return type_ == Type::kHandle; }
+ bool is_pseudo_handle() const {
+ return base::win::IsPseudoHandle(handle_.get());
+ }
const base::win::ScopedHandle& GetHandle() const { return handle_; }
base::win::ScopedHandle TakeHandle() {
DCHECK_EQ(type_, Type::kHandle);

View File

@@ -1,11 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Fri, 29 Jul 2022 00:29:35 +0900
Subject: chore: allow chromium to handle synthetic mouse events for touch
Subject: chore: modify chromium handling of mouse events
With WCO, allow chromium to handle synthetic mouse events generated for touch
This patch does the following:
1. When Windows Control Overlay is enabled, it allows chromium to handle synthetic mouse events generated for touch
actions in the non-client caption area.
2. It calls HandleMouseEvent on the delegate earlier in HandleMouseEventInternal, so that Electron can selectively disable
draggable regions to allow events to propagate to the underlying renderer.
diff --git a/ui/events/event.h b/ui/events/event.h
index 39b5a8fdd165efd74b00256552b51b5413107958..bfc4ef4f50efff4a77f2aef64335bb7e34c69f34 100644
--- a/ui/events/event.h
+++ b/ui/events/event.h
@@ -587,6 +587,9 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
const PointerDetails& pointer_details() const { return pointer_details_; }
+ bool is_system_menu() const { return is_system_menu_; }
+ void set_is_system_menu(bool is_menu) { is_system_menu_ = is_menu; }
+
// Event:
std::string ToString() const override;
std::unique_ptr<Event> Clone() const override;
@@ -619,6 +622,8 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
// Structure for holding pointer details for implementing PointerEvents API.
PointerDetails pointer_details_;
+
+ bool is_system_menu_ = false;
};
class ScrollEvent;
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
index e2146f0a06fb70d16c48fe6e06d0615caf7d4619..f7d38f5d308eadc1dc27fd1dde706259b9197ad9 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
@@ -34,10 +61,10 @@ index 1e2c5bb35cc314d44dba85a9bafc5e55bf2b5f14..d110d0a2f005888c4450262fc1887cbf
Widget* GetWidget();
const Widget* GetWidget() const;
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index 9ac53e223aa095acdf90b68bc1e6bc81e3021ab9..026b0f9b404267b17e1ea6b61b5ebb188b9b0bed 100644
index b5d8f82255764a42df816e58bfcbd588534de2e4..8ad548a445ff7f66a7fe61e0f18d04d08668a69b 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -3042,15 +3042,19 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message,
@@ -3063,15 +3063,19 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message,
SetMsgHandled(FALSE);
// We must let Windows handle the caption buttons if it's drawing them, or
// they won't work.
@@ -59,6 +86,25 @@ index 9ac53e223aa095acdf90b68bc1e6bc81e3021ab9..026b0f9b404267b17e1ea6b61b5ebb18
return 0;
}
@@ -3099,7 +3103,17 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message,
w_param = static_cast<WPARAM>(SendMessage(
hwnd(), WM_NCHITTEST, 0, MAKELPARAM(screen_point.x, screen_point.y)));
if (w_param == HTCAPTION || w_param == HTSYSMENU) {
- ShowSystemMenuAtScreenPixelLocation(hwnd(), gfx::Point(screen_point));
+ LONG message_time = GetMessageTime();
+ CHROME_MSG msg = {hwnd(),
+ message,
+ w_param,
+ l_param,
+ static_cast<DWORD>(message_time),
+ {CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param)}};
+ ui::MouseEvent event(msg);
+ event.set_is_system_menu(true);
+ if (!delegate_->HandleMouseEvent(&event))
+ ShowSystemMenuAtScreenPixelLocation(hwnd(), gfx::Point(screen_point));
return 0;
}
} else if (message == WM_NCLBUTTONDOWN &&
diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h
index 04dea68d74ea4f559db60f716c919e555db9ec80..2f8bd1a3c156bb6c04663c74b7279bb59926fc3d 100644
--- a/ui/views/win/hwnd_message_handler_delegate.h

View File

@@ -14,7 +14,7 @@ This patch likely can't be upstreamed as-is, as Chromium doesn't have
this use case in mind currently.
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index fda18ecab7e982b3087c7667d36578177d370066..a949e73dabad71d2550e38b09dbcf45160b3a853 100644
index 562532f5795ee833493614f3f16d35bda2654d8d..98a3365ce2b5ef4e34eb9edf66ef3f620af9ab1d 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -908,13 +908,13 @@ void HWNDMessageHandler::FrameTypeChanged() {

View File

@@ -40,7 +40,7 @@ accessing uninitialized lower indexes can return garbage values that cannot be n
Refer to v8::EmbedderDataSlot::store_aligned_pointer for context.
diff --git a/gin/public/gin_embedders.h b/gin/public/gin_embedders.h
index 8d7c5631fd8f1499c67384286f0e3c4037673b32..99b2e2f63be8a46c5546dd53bc9b05e8c54e857c 100644
index 8d7c5631fd8f1499c67384286f0e3c4037673b32..2b7bdfbac06a42e6bc51eb65e023c3673e6eb885 100644
--- a/gin/public/gin_embedders.h
+++ b/gin/public/gin_embedders.h
@@ -20,6 +20,8 @@ enum GinEmbedder : uint16_t {
@@ -86,7 +86,7 @@ index e4a27a24c83dd1a478b2ada8b6c8220076790791..c76dc818f38a62fff63852dbecbc85e3
// Cut the reference from ScriptState to V8 context.
diff --git a/third_party/blink/renderer/platform/bindings/script_state.h b/third_party/blink/renderer/platform/bindings/script_state.h
index b3cc8d819b06108386aed9465cab4f27a28b675f..a1757901e52360a9c2ec3c573adb20d03cd6ecae 100644
index b3cc8d819b06108386aed9465cab4f27a28b675f..9c8818f10de59fdd2a3fd44d9cd23d40a93b53a7 100644
--- a/third_party/blink/renderer/platform/bindings/script_state.h
+++ b/third_party/blink/renderer/platform/bindings/script_state.h
@@ -185,7 +185,12 @@ class PLATFORM_EXPORT ScriptState : public GarbageCollected<ScriptState> {

View File

@@ -18,7 +18,7 @@ or resizing, but Electron does not seem to run into that issue
for opaque frameless windows even with that block commented out.
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index 026b0f9b404267b17e1ea6b61b5ebb188b9b0bed..fda18ecab7e982b3087c7667d36578177d370066 100644
index 9ac53e223aa095acdf90b68bc1e6bc81e3021ab9..562532f5795ee833493614f3f16d35bda2654d8d 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -1736,7 +1736,23 @@ LRESULT HWNDMessageHandler::OnCreate(CREATESTRUCT* create_struct) {

View File

@@ -0,0 +1,58 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 13 Mar 2025 10:47:00 +0100
Subject: fix: take Snapped status into account when showing a window
Adjusts HWNDMessageHandler::Show to correctly restore windows that were
in a snapped state prior to being hidden or maximized. From Windows
documentation at
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-iswindowarranged:
> A snapped window (see Snap your windows) is considered to be arranged.
> You should treat arranged as a window state similar to maximized. Arranged,
> maximized, and minimized are mutually exclusive states.
The logic already took into account a window being maximized and
correctly restored it, but if the window was snapped prior to this CL it
would be removed from its snapped state when re-shown. This fixes that.
Upstreamed at https://chromium-review.googlesource.com/c/chromium/src/+/6330848.
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index 98a3365ce2b5ef4e34eb9edf66ef3f620af9ab1d..b5d8f82255764a42df816e58bfcbd588534de2e4 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -656,7 +656,8 @@ void HWNDMessageHandler::Show(ui::mojom::WindowShowState show_state,
SetWindowPlacement(hwnd(), &placement);
native_show_state = SW_SHOWMAXIMIZED;
} else {
- const bool is_maximized = IsMaximized();
+ const bool is_maximized_or_arranged =
+ IsMaximized() || IsWindowArranged(hwnd());
// Use SW_SHOW/SW_SHOWNA instead of SW_SHOWNORMAL/SW_SHOWNOACTIVATE so that
// the window is not restored to its original position if it is maximized.
@@ -666,7 +667,8 @@ void HWNDMessageHandler::Show(ui::mojom::WindowShowState show_state,
// position, some do not. See crbug.com/1296710
switch (show_state) {
case ui::mojom::WindowShowState::kInactive:
- native_show_state = is_maximized ? SW_SHOWNA : SW_SHOWNOACTIVATE;
+ native_show_state =
+ is_maximized_or_arranged ? SW_SHOWNA : SW_SHOWNOACTIVATE;
break;
case ui::mojom::WindowShowState::kMaximized:
native_show_state = SW_SHOWMAXIMIZED;
@@ -677,9 +679,11 @@ void HWNDMessageHandler::Show(ui::mojom::WindowShowState show_state,
case ui::mojom::WindowShowState::kNormal:
if ((GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_TRANSPARENT) ||
(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_NOACTIVATE)) {
- native_show_state = is_maximized ? SW_SHOWNA : SW_SHOWNOACTIVATE;
+ native_show_state =
+ is_maximized_or_arranged ? SW_SHOWNA : SW_SHOWNOACTIVATE;
} else {
- native_show_state = is_maximized ? SW_SHOW : SW_SHOWNORMAL;
+ native_show_state =
+ is_maximized_or_arranged ? SW_SHOW : SW_SHOWNORMAL;
}
break;
case ui::mojom::WindowShowState::kFullscreen:

View File

@@ -657,7 +657,7 @@ index 116153b69e56f519fad9a117ecc1402e8d3ef64f..a07930287a6d3612badf2a6db2fd12cc
align 16
Reverse_Endian_Mask db 3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12
diff --git a/third_party/lzma_sdk/Asm/x86/XzCrc64Opt.asm b/third_party/lzma_sdk/Asm/x86/XzCrc64Opt.asm
index 1c67037ba8a20bdb30f6521a841e7b72c6394282..de023f9f490bafbf8637e4fc116b8326a07c40d8 100644
index 1c67037ba8a20bdb30f6521a841e7b72c6394282..f9e95746d3ab6b7e556a6a427ba1fabf917106e5 100644
--- a/third_party/lzma_sdk/Asm/x86/XzCrc64Opt.asm
+++ b/third_party/lzma_sdk/Asm/x86/XzCrc64Opt.asm
@@ -1,113 +1,231 @@
@@ -694,10 +694,9 @@ index 1c67037ba8a20bdb30f6521a841e7b72c6394282..de023f9f490bafbf8637e4fc116b8326
rN equ r10
-rT equ r5
-num_VAR equ r8
-
-SRCDAT4 equ dword ptr [rD + rN * 1]
+rT equ r9
+
-SRCDAT4 equ dword ptr [rD + rN * 1]
+CRC_OP macro op:req, dest:req, src:req, t:req
+ op dest, QWORD PTR [rT + @CatStr(src, _R) * 8 + 0800h * (t)]
+endm
@@ -776,6 +775,22 @@ index 1c67037ba8a20bdb30f6521a841e7b72c6394282..de023f9f490bafbf8637e4fc116b8326
+ shr r0, 8
+ CRC_XOR r0, x6, 0
+ dec rN
+endm
+
+
+; ALIGN_MASK is 3 or 7 bytes alignment:
+ALIGN_MASK equ (7 - (NUM_WORDS and 1) * 4)
+
+if NUM_WORDS eq 1
+
+src_rN_offset equ 4
+; + 4 for prefetching next 4-bytes after current iteration
+NUM_BYTES_LIMIT equ (NUM_WORDS * 4 + 4)
+SRCDAT4 equ DWORD PTR [rN + rD * 1]
+
+XOR_NEXT macro
+ mov x1, [rD]
+ xor r0, r1
endm
-MY_PROC XzCrc64UpdateT4, 4
@@ -799,22 +814,6 @@ index 1c67037ba8a20bdb30f6521a841e7b72c6394282..de023f9f490bafbf8637e4fc116b8326
- jnz main_loop_4
-
- MY_EPILOG crc_end_4
+
+; ALIGN_MASK is 3 or 7 bytes alignment:
+ALIGN_MASK equ (7 - (NUM_WORDS and 1) * 4)
+
+if NUM_WORDS eq 1
+
+src_rN_offset equ 4
+; + 4 for prefetching next 4-bytes after current iteration
+NUM_BYTES_LIMIT equ (NUM_WORDS * 4 + 4)
+SRCDAT4 equ DWORD PTR [rN + rD * 1]
+
+XOR_NEXT macro
+ mov x1, [rD]
+ xor r0, r1
+endm
+
+else ; NUM_WORDS > 1
+
+src_rN_offset equ 8
@@ -3847,7 +3846,7 @@ index 69fad9ca2b476ed8589f6bee8a08de37be47297e..9408017ed4fc1cda88c7e5e4ce6b7a61
+#undef Z7_CRC_NUM_TABLES_USE
#endif
diff --git a/third_party/lzma_sdk/C/7zDec.c b/third_party/lzma_sdk/C/7zDec.c
index fbfd016e1e6a11bd976f39fe90de619166910e0e..520cbfd833be22e29a248eb05aca7e81d55d2ac4 100644
index fbfd016e1e6a11bd976f39fe90de619166910e0e..341fbce3c3cf923305a47120ef41f752fbf0e5c7 100644
--- a/third_party/lzma_sdk/C/7zDec.c
+++ b/third_party/lzma_sdk/C/7zDec.c
@@ -1,11 +1,11 @@
@@ -5932,7 +5931,7 @@ index 3be2041eb75502c36faf8064e0edd6679d7abdbb..01bf6b7dd6b1c7fabbd8c2797738b6f5
#endif
diff --git a/third_party/lzma_sdk/C/Bcj2.c b/third_party/lzma_sdk/C/Bcj2.c
index c7b956708f6e82641623bcaa9e9abcecf1635750..7cb57ad62dcf0aef9f5cb77078897d17400266be 100644
index c7b956708f6e82641623bcaa9e9abcecf1635750..4ec5ea924598db2167887abd3483cd9c1f002882 100644
--- a/third_party/lzma_sdk/C/Bcj2.c
+++ b/third_party/lzma_sdk/C/Bcj2.c
@@ -1,29 +1,24 @@
@@ -6367,7 +6366,7 @@ index c7b956708f6e82641623bcaa9e9abcecf1635750..7cb57ad62dcf0aef9f5cb77078897d17
+#undef kBitModelTotal
+#undef kNumMoveBits
diff --git a/third_party/lzma_sdk/C/Bcj2.h b/third_party/lzma_sdk/C/Bcj2.h
index 8824080acfbcf767ee4aa127fd56354723f20bb6..4575545b62c06dd4a26646104e26a5a39685aa10 100644
index 8824080acfbcf767ee4aa127fd56354723f20bb6..4e9ec45e30b7665905a70dd28102c4fc6015c2db 100644
--- a/third_party/lzma_sdk/C/Bcj2.h
+++ b/third_party/lzma_sdk/C/Bcj2.h
@@ -1,8 +1,8 @@
@@ -6504,13 +6503,13 @@ index 8824080acfbcf767ee4aa127fd56354723f20bb6..4575545b62c06dd4a26646104e26a5a3
+ following condition is met for stream sizes:
+ ( size(ORIG) == size(MAIN) + size(CALL) + size(JUMP) )
+*/
+
+/* (state == BCJ2_STREAM_MAIN) means that decoder is ready for
+ additional input data in BCJ2_STREAM_MAIN stream.
+ Note that (state == BCJ2_STREAM_MAIN) is allowed for non-finished decoding.
+*/
+#define Bcj2Dec_IsMaybeFinished_state_MAIN(_p_) ((_p_)->state == BCJ2_STREAM_MAIN)
+
+/* if the stream decoding was finished correctly, then range decoder
+ part of CBcj2Dec also was finished, and then (CBcj2Dec::code == 0).
+ Note that (CBcj2Dec::code == 0) is allowed for non-finished decoding.
@@ -6526,8 +6525,8 @@ index 8824080acfbcf767ee4aa127fd56354723f20bb6..4575545b62c06dd4a26646104e26a5a3
+ Bcj2Dec_IsMaybeFinished_state_MAIN(_p_) && \
+ Bcj2Dec_IsMaybeFinished_code(_p_))
+
+
+
+/* ---------- BCJ2 Encoder ---------- */
typedef enum
@@ -6637,11 +6636,10 @@ index 8824080acfbcf767ee4aa127fd56354723f20bb6..4575545b62c06dd4a26646104e26a5a3
UInt32 range;
UInt64 low;
UInt64 cacheSize;
+
+ // UInt32 context; // for marker version, it can include marker flag.
- UInt32 ip;
-
+ // UInt32 context; // for marker version, it can include marker flag.
- /* 32-bit ralative offset in JUMP/CALL commands is
- - (mod 4 GB) in 32-bit mode
- - signed Int32 in 64-bit mode
@@ -6687,9 +6685,7 @@ index 8824080acfbcf767ee4aa127fd56354723f20bb6..4575545b62c06dd4a26646104e26a5a3
+ p->State == BCJ2_ENC_STATE_FINISHED : after fully encoded stream
+*/
+void Bcj2Enc_Encode(CBcj2Enc *p);
-#define BCJ2_RELAT_LIMIT_NUM_BITS 26
-#define BCJ2_RELAT_LIMIT ((UInt32)1 << BCJ2_RELAT_LIMIT_NUM_BITS)
+
+/* Bcj2Enc encoder can look ahead for up 4 bytes of source stream.
+ CBcj2Enc::tempPos : is the number of bytes that were copied from input stream to temp[] buffer.
+ (CBcj2Enc::src) after Bcj2Enc_Encode() is starting position after
@@ -6704,10 +6700,12 @@ index 8824080acfbcf767ee4aa127fd56354723f20bb6..4575545b62c06dd4a26646104e26a5a3
+/* get the size of input data that was stored in temp[] buffer: */
+#define Bcj2Enc_Get_AvailInputSize_in_Temp(p) ((p)->tempPos)
-#define BCJ2_RELAT_LIMIT_NUM_BITS 26
-#define BCJ2_RELAT_LIMIT ((UInt32)1 << BCJ2_RELAT_LIMIT_NUM_BITS)
+#define Bcj2Enc_IsFinished(p) ((p)->flushRem == 0)
-/* limit for CBcj2Enc::fileSize variable */
-#define BCJ2_FileSize_MAX ((UInt32)1 << 31)
+#define Bcj2Enc_IsFinished(p) ((p)->flushRem == 0)
+
+/* Note : the decoder supports overlapping of marker (0f 80).
+ But we can eliminate such overlapping cases by setting
+ the limit for relative offset conversion as
@@ -6721,7 +6719,7 @@ index 8824080acfbcf767ee4aa127fd56354723f20bb6..4575545b62c06dd4a26646104e26a5a3
EXTERN_C_END
diff --git a/third_party/lzma_sdk/C/Bra.c b/third_party/lzma_sdk/C/Bra.c
index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5ded259280f 100644
index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..49156bafce30b351d386c53af0723282b33dba5a 100644
--- a/third_party/lzma_sdk/C/Bra.c
+++ b/third_party/lzma_sdk/C/Bra.c
@@ -1,230 +1,709 @@
@@ -6819,7 +6817,8 @@ index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5de
+ lim = p + size;
+ BR_PC_INIT
+ pc -= 4; // because (p) will point to next instruction
+
- if (encoding)
+ BR_EXTERNAL_FOR
+ {
+ // Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE
@@ -6858,9 +6857,8 @@ index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5de
+ }
+}
+Z7_BRANCH_FUNCS_IMP(BranchConv_ARM64)
- if (encoding)
+
+
+Z7_BRANCH_FUNC_MAIN(BranchConv_ARM)
+{
+ // Byte *p = data;
@@ -6871,7 +6869,7 @@ index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5de
+ /* in ARM: branch offset is relative to the +2 instructions from current instruction.
+ (p) will point to next instruction */
+ pc += 8 - 4;
+
for (;;)
{
for (;;)
@@ -6902,7 +6900,7 @@ index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5de
}
+}
+Z7_BRANCH_FUNCS_IMP(BranchConv_ARM)
+
+
+Z7_BRANCH_FUNC_MAIN(BranchConv_PPC)
+{
@@ -6912,7 +6910,7 @@ index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5de
+ lim = p + size;
+ BR_PC_INIT
+ pc -= 4; // because (p) will point to next instruction
+
for (;;)
{
+ UInt32 v;
@@ -6953,13 +6951,13 @@ index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5de
}
}
+Z7_BRANCH_FUNCS_IMP(BranchConv_PPC)
+
-SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
+#ifdef Z7_CPU_FAST_ROTATE_SUPPORTED
+#define BR_SPARC_USE_ROTATE
+#endif
-SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
+
+Z7_BRANCH_FUNC_MAIN(BranchConv_SPARC)
{
- Byte *p;
@@ -7104,12 +7102,12 @@ index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5de
{
+ /* we can adjust pc for (0xf800) to rid of (& 0x7FF) operation.
+ But gcc/clang for arm64 can use bfi instruction for full code here */
UInt32 v =
- ((UInt32)b1 << 19)
+ UInt32 v =
+ ((UInt32)GetUi16a(p - 2) << 11) |
+ ((UInt32)GetUi16a(p) & 0x7FF);
+ /*
+ UInt32 v =
UInt32 v =
- ((UInt32)b1 << 19)
+ ((UInt32)p[1 - 2] << 19)
+ (((UInt32)p[1] & 0x7) << 8)
+ (((UInt32)p[-2] << 11))
@@ -7149,11 +7147,11 @@ index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5de
+ // return (Byte *)(lim + 2 - (((((unsigned)lim[1] ^ 8) + 8) >> 7) & 2));
}
+Z7_BRANCH_FUNCS_IMP(BranchConv_ARMT)
+
+// #define BR_IA64_NO_INLINE
-SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
+// #define BR_IA64_NO_INLINE
+
+Z7_BRANCH_FUNC_MAIN(BranchConv_IA64)
{
- Byte *p;
@@ -7163,13 +7161,12 @@ index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5de
- ip -= 4;
- p = data;
- lim = data + size;
-
+ size &= ~(SizeT)15;
+ lim = p + size;
+ pc -= 1 << 4;
+ pc >>= 4 - 1;
+ // pc -= 1 << 1;
+
for (;;)
{
+ unsigned m;
@@ -7255,12 +7252,11 @@ index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5de
+
+#define BR_CONVERT_VAL_ENC(v) v += BR_PC_GET;
+#define BR_CONVERT_VAL_DEC(v) v -= BR_PC_GET;
+
+#if 1 && defined(MY_CPU_LE_UNALIGN)
+ #define RISCV_USE_UNALIGNED_LOAD
+#endif
-SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
+#ifdef RISCV_USE_UNALIGNED_LOAD
+ #define RISCV_GET_UI32(p) GetUi32(p)
+ #define RISCV_SET_UI32(p, v) { SetUi32(p, v) }
@@ -7272,7 +7268,8 @@ index 3b854d9cad7fba3cd7986cde50d17b23f5d7d24f..e61edf8f12e1a7710d1e108923bdc5de
+ SetUi16a(p, (UInt16)(v)) \
+ SetUi16a((p) + 2, (UInt16)(v >> 16)) }
+#endif
+
-SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
+#if 1 && defined(MY_CPU_LE)
+ #define RISCV_USE_16BIT_LOAD
+#endif
@@ -7728,7 +7725,7 @@ index 855e37a6b5018e07b5e049b014401069d2158747..b47112cedc3dbe14079af262dd17aa59
#endif
diff --git a/third_party/lzma_sdk/C/Bra86.c b/third_party/lzma_sdk/C/Bra86.c
index 10a0fbd161cb78f8778c4fee5df1461310df337e..d81f392ae040469faf1a3514d1f88c5677b03aae 100644
index 10a0fbd161cb78f8778c4fee5df1461310df337e..6bb1e49329d38d05d2dc8ee4efa5b2bbc07a1e2a 100644
--- a/third_party/lzma_sdk/C/Bra86.c
+++ b/third_party/lzma_sdk/C/Bra86.c
@@ -1,82 +1,187 @@
@@ -7847,8 +7844,7 @@ index 10a0fbd161cb78f8778c4fee5df1461310df337e..d81f392ae040469faf1a3514d1f88c56
+ if (BR86_IS_BCJ_BYTE(3)) { goto a3; }
}
+ goto main_loop;
- if (Test86MSByte(p[4]))
+
+ m0: p--;
+ m1: p--;
+ m2: p--;
@@ -7856,7 +7852,8 @@ index 10a0fbd161cb78f8778c4fee5df1461310df337e..d81f392ae040469faf1a3514d1f88c56
+ goto a3;
+ if (p > lim)
+ goto fin_p;
+
- if (Test86MSByte(p[4]))
+ // if (((0x17u >> mask) & 1) == 0)
+ if (mask > 4 || mask == 3)
+ {
@@ -7910,16 +7907,13 @@ index 10a0fbd161cb78f8778c4fee5df1461310df337e..d81f392ae040469faf1a3514d1f88c56
+ SetUi32(p, v)
+ p += 4;
+ goto main_loop;
}
- else
+ }
+
+ main_loop:
+ if (p >= lim)
+ goto fin;
+ for (;;)
{
- mask = (mask >> 1) | 4;
- pos++;
+ {
+ BR86_PREPARE_BCJ_SCAN
+ p += 4;
+ if (BR86_IS_BCJ_BYTE(0)) { goto a0; }
@@ -7928,7 +7922,8 @@ index 10a0fbd161cb78f8778c4fee5df1461310df337e..d81f392ae040469faf1a3514d1f88c56
+ if (BR86_IS_BCJ_BYTE(3)) { goto a3; }
+ if (p >= lim)
+ goto fin;
+ }
}
- else
+
+ a0: p--;
+ a1: p--;
@@ -7937,7 +7932,9 @@ index 10a0fbd161cb78f8778c4fee5df1461310df337e..d81f392ae040469faf1a3514d1f88c56
+ if (p > lim)
+ goto fin_p;
+ // if (!BR86_NEED_CONV_FOR_MS_BYTE(p[3])) continue; // goto cont;
+ {
{
- mask = (mask >> 1) | 4;
- pos++;
+ UInt32 v = GetUi32(p);
+ UInt32 c;
+ v += (1 << 24); if (v & 0xfe000000) continue; // goto cont;
@@ -8045,7 +8042,7 @@ index d1dbc62c55bebd5ff5d4d53b51f28aabecab6179..9dfe3e289589d6288227ee819835941b
+#pragma GCC diagnostic ignored "-Wempty-translation-unit"
+#endif
diff --git a/third_party/lzma_sdk/C/Compiler.h b/third_party/lzma_sdk/C/Compiler.h
index a9816fa5ad014863211aa19723f8a87b312e4bfa..2a9c2b7a0896c847d65b9aae4b5c1f2cbf29297b 100644
index a9816fa5ad014863211aa19723f8a87b312e4bfa..e83e37d11981bd9f54e63a32c546497a914a1906 100644
--- a/third_party/lzma_sdk/C/Compiler.h
+++ b/third_party/lzma_sdk/C/Compiler.h
@@ -1,12 +1,105 @@
@@ -8302,7 +8299,7 @@ index a9816fa5ad014863211aa19723f8a87b312e4bfa..2a9c2b7a0896c847d65b9aae4b5c1f2c
#define UNUSED_VAR(x) (void)x;
diff --git a/third_party/lzma_sdk/C/CpuArch.c b/third_party/lzma_sdk/C/CpuArch.c
index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f9ce6fc95 100644
index 30451fba9b97b34669186865dcf72d8792334423..8ba93446e854ddfca2b252c241aca1e91673acd6 100644
--- a/third_party/lzma_sdk/C/CpuArch.c
+++ b/third_party/lzma_sdk/C/CpuArch.c
@@ -1,187 +1,357 @@
@@ -8518,8 +8515,7 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+// for gcc/clang and other: we can try to use __cpuid macro:
+#include <cpuid.h>
+void Z7_FASTCALL z7_x86_cpuid(UInt32 p[4], UInt32 func)
{
- #ifdef USE_ASM
+{
+ __cpuid(func, p[0], p[1], p[2], p[3]);
+}
+UInt32 Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void)
@@ -8534,7 +8530,8 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+ p[0] = p[1] = p[2] = p[3] = 0;
+}
+UInt32 Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void)
+{
{
- #ifdef USE_ASM
+ return 0;
+}
@@ -8686,7 +8683,8 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+ where ECX value is first parameter for FASTCALL / NO_INLINE func.
+ So the caller of MY_cpuidex_HACK() sets ECX as subFunction, and
+ old MSVC for __cpuid() doesn't change ECX and cpuid instruction gets (subFunction) value.
+
- #endif
+DON'T remove Z7_NO_INLINE and Z7_FASTCALL for MY_cpuidex_HACK(): !!!
+*/
+static
@@ -8694,7 +8692,7 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+{
+ UNUSED_VAR(subFunction)
+ __cpuid(CPUInfo, func);
+}
}
+ #define MY_cpuidex(info, func, func2) MY_cpuidex_HACK(func2, func, info)
+ #pragma message("======== MY_cpuidex_HACK WAS USED ========")
+static
@@ -8703,8 +8701,7 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+ MY_cpuidex_HACK(subFunc, func, (Int32 *)p);
+}
+ #endif // _MSC_VER >= 1600
- #endif
+
+#if !defined(MY_CPU_AMD64)
+/* inlining for __cpuid() in MSVC x86 (32-bit) produces big ineffective code,
+ so we disable inlining here */
@@ -8713,9 +8710,8 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+void Z7_FASTCALL z7_x86_cpuid(UInt32 p[4], UInt32 func)
+{
+ MY_cpuidex((Int32 *)p, (Int32)func, 0);
}
-BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p)
+}
+
+Z7_NO_INLINE
+UInt32 Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void)
+{
@@ -8734,7 +8730,8 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+#endif
+#undef NEED_CHECK_FOR_CPUID
+
+
-BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p)
+static
+BoolInt x86cpuid_Func_1(UInt32 *p)
{
@@ -8894,28 +8891,30 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+ UInt32 a[4];
CHECK_SYS_SSE_SUPPORT
- if (!x86cpuid_CheckAndRead(&p))
+ if (!x86cpuid_Func_1(&a[0]))
+ return 0;
+ return (BoolInt)(a[3] >> 25) & 1;
+}
+
+BoolInt CPU_IsSupported_SSE2(void)
+{
+ UInt32 a[4];
+ CHECK_SYS_SSE_SUPPORT
+ if (!x86cpuid_Func_1(&a[0]))
return 0;
- return p.c;
+ return (BoolInt)(a[3] >> 26) & 1;
+ return (BoolInt)(a[3] >> 25) & 1;
}
-BoolInt CPU_IsSupported_AES()
+BoolInt CPU_IsSupported_SSE2(void)
{
- return (X86_CPUID_ECX_Get_Flags() >> 25) & 1;
+ UInt32 a[4];
+ CHECK_SYS_SSE_SUPPORT
+ if (!x86cpuid_Func_1(&a[0]))
+ return 0;
+ return (BoolInt)(a[3] >> 26) & 1;
}
-BoolInt CPU_IsSupported_SSSE3()
+#endif
+
+
+static UInt32 x86cpuid_Func_1_ECX(void)
{
- return (X86_CPUID_ECX_Get_Flags() >> 25) & 1;
- return (X86_CPUID_ECX_Get_Flags() >> 9) & 1;
+ UInt32 a[4];
+ CHECK_SYS_SSE_SUPPORT
+ if (!x86cpuid_Func_1(&a[0]))
@@ -8923,21 +8922,19 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+ return a[2];
}
-BoolInt CPU_IsSupported_SSSE3()
-BoolInt CPU_IsSupported_SSE41()
+BoolInt CPU_IsSupported_AES(void)
{
- return (X86_CPUID_ECX_Get_Flags() >> 9) & 1;
- return (X86_CPUID_ECX_Get_Flags() >> 19) & 1;
+ return (BoolInt)(x86cpuid_Func_1_ECX() >> 25) & 1;
}
-BoolInt CPU_IsSupported_SSE41()
+BoolInt CPU_IsSupported_SSSE3(void)
{
- return (X86_CPUID_ECX_Get_Flags() >> 19) & 1;
+ return (BoolInt)(x86cpuid_Func_1_ECX() >> 9) & 1;
}
-BoolInt CPU_IsSupported_SHA()
+BoolInt CPU_IsSupported_SSSE3(void)
+{
+ return (BoolInt)(x86cpuid_Func_1_ECX() >> 9) & 1;
+}
+
+BoolInt CPU_IsSupported_SSE41(void)
+{
+ return (BoolInt)(x86cpuid_Func_1_ECX() >> 19) & 1;
@@ -8957,9 +8954,9 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+ return (BoolInt)(d[1] >> 29) & 1;
+ }
+}
+
- if (p.maxFunc < 7)
+
+BoolInt CPU_IsSupported_SHA512(void)
+{
+ if (!CPU_IsSupported_AVX2()) return False; // maybe CPU_IsSupported_AVX() is enough here
@@ -9018,15 +9015,15 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+// #define ATTRIB_XGETBV __attribute__((__target__("xsave")))
+#else
+#define ATTRIB_XGETBV
#endif
+#endif
+
#endif
-BoolInt CPU_IsSupported_AVX2()
+#if defined(ATTRIB_XGETBV)
+#include <immintrin.h>
+#endif
+
-BoolInt CPU_IsSupported_AVX2()
+
+// XFEATURE_ENABLED_MASK/XCR0
+#define MY_XCR_XFEATURE_ENABLED_MASK 0
+
@@ -9105,7 +9102,7 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+
+#endif
+}
+
+#ifdef _WIN32
+/*
+ Windows versions do not know about new ISA extensions that
@@ -9126,7 +9123,7 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+// #define MY_PF_AVX2_INSTRUCTIONS_AVAILABLE 40
+// #define MY_PF_AVX512F_INSTRUCTIONS_AVAILABLE 41
+#endif
+
+BoolInt CPU_IsSupported_AVX(void)
+{
#ifdef _WIN32
@@ -9309,7 +9306,7 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
#else
@@ -378,29 +809,40 @@ static void Print_sysctlbyname(const char *name)
@@ -378,30 +809,41 @@ static void Print_sysctlbyname(const char *name)
}
}
*/
@@ -9343,8 +9340,8 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
{
- return My_sysctlbyname_Get_BoolInt("hw.optional.neon");
+ return z7_sysctlbyname_Get_BoolInt("hw.optional.neon");
+}
+
}
+BoolInt CPU_IsSupported_SHA512(void)
+{
+ return z7_sysctlbyname_Get_BoolInt("hw.optional.armv8_2_sha512");
@@ -9354,11 +9351,12 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
+BoolInt CPU_IsSupported_SHA3(void)
+{
+ return z7_sysctlbyname_Get_BoolInt("hw.optional.armv8_2_sha3");
}
+}
+*/
+
#ifdef MY_CPU_ARM64
#define APPLE_CRYPTO_SUPPORT_VAL 1
#else
@@ -415,35 +857,70 @@ BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYPTO_SUPPORT_VAL; }
#else // __APPLE__
@@ -9476,7 +9474,7 @@ index 30451fba9b97b34669186865dcf72d8792334423..6e02551e2dca2d98db76fa4a31f23a1f
return EFAULT;
return res;
diff --git a/third_party/lzma_sdk/C/CpuArch.h b/third_party/lzma_sdk/C/CpuArch.h
index 8cd55bea48dc6ffa4d7b8be52e7baf3fd47e7ad9..2843b4562c2bd9b06aabfc5c13300d14639bedc9 100644
index 8cd55bea48dc6ffa4d7b8be52e7baf3fd47e7ad9..483a4d797f9014309cd2baca1549e8d7d450443e 100644
--- a/third_party/lzma_sdk/C/CpuArch.h
+++ b/third_party/lzma_sdk/C/CpuArch.h
@@ -1,8 +1,8 @@
@@ -10242,7 +10240,7 @@ index 64ff26cd93aa741a39a2c11300e85e2a02eac19a..9fa41538265ac26c09123747b7806dab
#include "7zTypes.h"
diff --git a/third_party/lzma_sdk/C/LzFind.c b/third_party/lzma_sdk/C/LzFind.c
index 36f7330911435779e4d213f340c33c93c9df20cb..5941582e7977685a981afa0a0b2589479d2a9f7b 100644
index 36f7330911435779e4d213f340c33c93c9df20cb..8c30c2039c149f77211626443ef7eb7787959058 100644
--- a/third_party/lzma_sdk/C/LzFind.c
+++ b/third_party/lzma_sdk/C/LzFind.c
@@ -1,5 +1,5 @@
@@ -11498,7 +11496,7 @@ index 36f7330911435779e4d213f340c33c93c9df20cb..5941582e7977685a981afa0a0b258947
+#undef MOVE_POS_RET
+#undef PRF
diff --git a/third_party/lzma_sdk/C/LzFind.h b/third_party/lzma_sdk/C/LzFind.h
index eea873ff61ede1bee4c75f85e451c51333d76d56..67e8a6e0286ee0877043601039c5fbdae8588148 100644
index eea873ff61ede1bee4c75f85e451c51333d76d56..7e1be1d68479f597f410974da499b477858b5ca5 100644
--- a/third_party/lzma_sdk/C/LzFind.h
+++ b/third_party/lzma_sdk/C/LzFind.h
@@ -1,8 +1,8 @@
@@ -11636,7 +11634,7 @@ index 77b898cfab57c7df241b767b21390e26cc23ec57..2b6290b64c08f7eb44568a67e90abcf4
/*
(kHash2Size >= (1 << 8)) : Required
diff --git a/third_party/lzma_sdk/C/Lzma2Dec.c b/third_party/lzma_sdk/C/Lzma2Dec.c
index ac970a843d9fabcd6337577648524b0b8e990791..8bf54e499edf73a88df3a89ac04377201e5127f3 100644
index ac970a843d9fabcd6337577648524b0b8e990791..31581afd5941461967696d27d5b737f4cb80a56d 100644
--- a/third_party/lzma_sdk/C/Lzma2Dec.c
+++ b/third_party/lzma_sdk/C/Lzma2Dec.c
@@ -1,5 +1,5 @@
@@ -14393,7 +14391,7 @@ index aa38501e57948196761aec76c9475fcbe67fc677..75329cdf02267d32eb0a20358608fc08
/*
call Sha256Prepare() once at program start.
diff --git a/third_party/lzma_sdk/C/Sha256Opt.c b/third_party/lzma_sdk/C/Sha256Opt.c
index decc1382cd6ee9c7cb6e6ac27e3ee6e2cdb46b88..1c6b50f8d336e63be89462f15d48c7ed3ca625e9 100644
index decc1382cd6ee9c7cb6e6ac27e3ee6e2cdb46b88..42dfac837dc6de8e09bf1725f9824ac89c8e845c 100644
--- a/third_party/lzma_sdk/C/Sha256Opt.c
+++ b/third_party/lzma_sdk/C/Sha256Opt.c
@@ -1,71 +1,53 @@
@@ -14622,11 +14620,10 @@ index decc1382cd6ee9c7cb6e6ac27e3ee6e2cdb46b88..1c6b50f8d336e63be89462f15d48c7ed
#endif // USE_HW_SHA
-#elif defined(MY_CPU_ARM_OR_ARM64)
-
+#elif defined(MY_CPU_ARM_OR_ARM64) && defined(MY_CPU_LE)
- #if defined(__clang__)
- #if (__clang_major__ >= 8) // fix that check
+#elif defined(MY_CPU_ARM_OR_ARM64) && defined(MY_CPU_LE)
+
+ #if defined(__ARM_FEATURE_SHA2) \
+ || defined(__ARM_FEATURE_CRYPTO)
+ #define USE_HW_SHA
@@ -15940,7 +15937,7 @@ index 93a9ffff5f8113b885ef2963725e620d6eede939..0c1fc2ffecb89ebe834823eeda226a9a
+#undef Z7_CRC64_NUM_TABLES_USE
#endif
diff --git a/third_party/lzma_sdk/C/XzDec.c b/third_party/lzma_sdk/C/XzDec.c
index 3f96a37f94fc751ed98c31e5d2e731b6526d1957..3d1c98e63194f088ce7907d61f376b5416be341b 100644
index 3f96a37f94fc751ed98c31e5d2e731b6526d1957..4b6b8c2887249bd18879ff65a94947b28107c710 100644
--- a/third_party/lzma_sdk/C/XzDec.c
+++ b/third_party/lzma_sdk/C/XzDec.c
@@ -1,5 +1,5 @@
@@ -17203,7 +17200,7 @@ index 7458450739601b3a8236e421241bb9ed73f3a014..a07824208330eec265a88310e42c3803
+4. Remove files irrelevant to Chromium use.
+5. Remove AVX and SSE41 code in LzFind.
diff --git a/third_party/lzma_sdk/chromium.patch b/third_party/lzma_sdk/chromium.patch
index 85b8089a6a0d31113f1570483fe07fb905f5b825..168ca263574d83a27d4afebc8857545254ebe79a 100644
index 85b8089a6a0d31113f1570483fe07fb905f5b825..c712da067c0a88941e31e3f6de6c06208d1a83ea 100644
--- a/third_party/lzma_sdk/chromium.patch
+++ b/third_party/lzma_sdk/chromium.patch
@@ -1,138 +1,46 @@

View File

@@ -0,0 +1,90 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Michael Wilson <mjwilson@chromium.org>
Date: Thu, 30 Jan 2025 14:09:57 -0800
Subject: Remove DenormalEnabler from ScriptProcessorNode
This is a follow-up to https://crrev.com/c/6077677
After experimenting, ScriptProcessorNode JavaScript is already running
in a complaint mode so the DenormalEnabler is not necessary.
Bug: 382005099
Change-Id: If9774e60640446c567270a8f065500beecc8a40b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6219685
Commit-Queue: Michael Wilson <mjwilson@chromium.org>
Reviewed-by: Alvin Ji <alvinji@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413754}
diff --git a/third_party/blink/renderer/modules/webaudio/script_processor_handler.cc b/third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
index ea04e2cd2bfb553a58ba6fb9c63c70c5a2690442..d3d44d2a4c87bf5d4191807ec31d87c7e597fef9 100644
--- a/third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
+++ b/third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
@@ -26,7 +26,6 @@
#include "third_party/blink/renderer/modules/webaudio/base_audio_context.h"
#include "third_party/blink/renderer/modules/webaudio/realtime_audio_destination_node.h"
#include "third_party/blink/renderer/modules/webaudio/script_processor_node.h"
-#include "third_party/blink/renderer/platform/audio/denormal_disabler.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
@@ -49,9 +48,7 @@ ScriptProcessorHandler::ScriptProcessorHandler(
internal_input_bus_(AudioBus::Create(
number_of_input_channels,
node.context()->GetDeferredTaskHandler().RenderQuantumFrames(),
- false)),
- allow_denormal_in_processing_(base::FeatureList::IsEnabled(
- features::kWebAudioAllowDenormalInProcessing)) {
+ false)) {
DCHECK_GE(buffer_size_,
node.context()->GetDeferredTaskHandler().RenderQuantumFrames());
DCHECK_LE(number_of_input_channels, BaseAudioContext::MaxNumberOfChannels());
@@ -112,7 +109,7 @@ void ScriptProcessorHandler::Initialize() {
AudioHandler::Initialize();
}
-void ScriptProcessorHandler::ProcessInternal(uint32_t frames_to_process) {
+void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("webaudio.audionode"),
"ScriptProcessorHandler::Process");
@@ -241,15 +238,6 @@ void ScriptProcessorHandler::ProcessInternal(uint32_t frames_to_process) {
"ScriptProcessorHandler::Process");
}
-void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
- if (allow_denormal_in_processing_) {
- DenormalEnabler denormal_enabler;
- ProcessInternal(frames_to_process);
- } else {
- ProcessInternal(frames_to_process);
- }
-}
-
void ScriptProcessorHandler::FireProcessEvent(uint32_t double_buffer_index) {
DCHECK(IsMainThread());
diff --git a/third_party/blink/renderer/modules/webaudio/script_processor_handler.h b/third_party/blink/renderer/modules/webaudio/script_processor_handler.h
index 99103e947ade50f07a16a61bc8702d6097266296..78deeb9219e3d5a98ac4d3b5cd4c98dd403407e3 100644
--- a/third_party/blink/renderer/modules/webaudio/script_processor_handler.h
+++ b/third_party/blink/renderer/modules/webaudio/script_processor_handler.h
@@ -66,10 +66,6 @@ class ScriptProcessorHandler final : public AudioHandler {
const HeapVector<Member<AudioBuffer>>& input_buffers,
const HeapVector<Member<AudioBuffer>>& output_buffers);
- // Used to avoid code duplication when using scoped objects that affect
- // `Process`.
- void ProcessInternal(uint32_t frames_to_process);
-
double TailTime() const override;
double LatencyTime() const override;
bool RequiresTailProcessing() const final;
@@ -97,9 +93,6 @@ class ScriptProcessorHandler final : public AudioHandler {
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
- // Cached feature flag value
- const bool allow_denormal_in_processing_;
-
base::WeakPtrFactory<ScriptProcessorHandler> weak_ptr_factory_{this};
FRIEND_TEST_ALL_PREFIXES(ScriptProcessorNodeTest, BufferLifetime);

View File

@@ -0,0 +1,390 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Xianzhu Wang <wangxianzhu@chromium.org>
Date: Fri, 14 Feb 2025 08:58:16 -0800
Subject: Revert "blink: Fix over invalidation with view transitions"
This patch can be removed when we bump Chromium to 135.0.7019.0
This reverts commit bde2842dd31e89215d395470964797c92773819f.
Reason for revert: The CL caused crbug.com/391907157.
Original change's description:
> blink: Fix over invalidation with view transitions
>
> View Transition conditionally generates the view transition effect node
> for the LayoutView during the transition. This results in invalidation
> of it's scrolling background layer at the start/end of the transition.
>
> Avoid this by always generating this node for the LayoutView. This is
> not necessary for the child LayoutObjects. If they are composited, they
> already have an EffectNode which avoids invalidation from paint property
> node changes.
>
> Fixed: 361370195
> Change-Id: I1c8c309dea5bb1d2572995bbaafb2fb8003be96e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5996658
> Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
> Auto-Submit: Khushal Sagar <khushalsagar@chromium.org>
> Commit-Queue: Khushal Sagar <khushalsagar@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1380843}
Bug: 391907157, 361370195
Change-Id: Ifc7bb6fedb326867e5ed608b2c8152844ae2dd95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6262017
Auto-Submit: Xianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1420533}
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc b/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc
index 4dd99f130cb99355e4d58766a322e8db1e69bca9..9b9851dbb92977d76a842b0a943e969493231275 100644
--- a/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc
+++ b/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc
@@ -1834,32 +1834,25 @@ void FragmentPaintPropertyTreeBuilder::UpdateViewTransitionEffect() {
properties_->ViewTransitionEffect()
->SelfOrAncestorParticipatesInViewTransition();
- const bool is_view_transition_element =
+ const bool needs_view_transition_effect =
full_context_.direct_compositing_reasons &
CompositingReason::kViewTransitionElement;
- const bool needs_view_transition_effect =
- is_view_transition_element ||
- (object_.IsLayoutView() && !IsInLocalSubframe(object_) &&
- !object_.GetDocument().IsSVGDocument());
-
if (needs_view_transition_effect) {
auto* transition =
ViewTransitionUtils::GetTransition(object_.GetDocument());
- DCHECK(!is_view_transition_element || transition);
+ DCHECK(transition);
EffectPaintPropertyNode::State state;
+ state.direct_compositing_reasons =
+ CompositingReason::kViewTransitionElement;
state.local_transform_space = context_.current.transform;
state.output_clip = context_.current.clip;
state.compositor_element_id = CompositorElementIdFromUniqueObjectId(
object_.UniqueId(),
CompositorElementIdNamespace::kViewTransitionElement);
- if (is_view_transition_element) {
- state.direct_compositing_reasons =
- CompositingReason::kViewTransitionElement;
- state.view_transition_element_resource_id =
- transition->GetSnapshotId(object_);
- }
+ state.view_transition_element_resource_id =
+ transition->GetSnapshotId(object_);
// The value isn't set on the root, since clipping rules are different for
// the root view transition element.
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc b/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc
index b3da3b381113fb6ea17d3d6de7bf2cf43e175362..aa57763835d2e8dbf4d021d58c14e1dd605d5cd6 100644
--- a/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc
+++ b/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc
@@ -77,17 +77,6 @@ const ScrollPaintPropertyNode* PaintPropertyTreeBuilderTest::DocScroll(
return document->GetLayoutView()->FirstFragment().PaintProperties()->Scroll();
}
-const EffectPaintPropertyNode* PaintPropertyTreeBuilderTest::DocEffect(
- const Document* document) {
- if (!document) {
- document = &GetDocument();
- }
- return document->GetLayoutView()
- ->FirstFragment()
- .PaintProperties()
- ->ViewTransitionEffect();
-}
-
const ObjectPaintProperties*
PaintPropertyTreeBuilderTest::PaintPropertiesForElement(const char* name) {
return GetDocument()
@@ -1058,7 +1047,8 @@ TEST_P(PaintPropertyTreeBuilderTest, EffectNodesInSVG) {
PaintPropertiesForElement("groupWithOpacity");
EXPECT_EQ(0.6f, group_with_opacity_properties->Effect()->Opacity());
EXPECT_EQ(svg_clip, group_with_opacity_properties->Effect()->OutputClip());
- EXPECT_EQ(DocEffect(), group_with_opacity_properties->Effect()->Parent());
+ EXPECT_EQ(&EffectPaintPropertyNode::Root(),
+ group_with_opacity_properties->Effect()->Parent());
EXPECT_EQ(nullptr, PaintPropertiesForElement("rectWithoutOpacity"));
@@ -4762,7 +4752,7 @@ TEST_P(PaintPropertyTreeBuilderTest, Reflection) {
filter_properties->PaintOffsetTranslation()->Parent());
EXPECT_EQ(gfx::Vector2dF(8, 8),
filter_properties->PaintOffsetTranslation()->Get2dTranslation());
- EXPECT_EQ(filter_properties->Filter()->Parent(), DocEffect());
+ EXPECT_TRUE(filter_properties->Filter()->Parent()->IsRoot());
EXPECT_EQ(filter_properties->PaintOffsetTranslation(),
&filter_properties->Filter()->LocalTransformSpace());
EXPECT_EQ(DocContentClip(), filter_properties->Filter()->OutputClip());
@@ -4775,7 +4765,7 @@ TEST_P(PaintPropertyTreeBuilderTest, SimpleFilter) {
const ObjectPaintProperties* filter_properties =
GetLayoutObjectByElementId("filter")->FirstFragment().PaintProperties();
EXPECT_FALSE(filter_properties->PaintOffsetTranslation());
- EXPECT_EQ(filter_properties->Filter()->Parent(), DocEffect());
+ EXPECT_TRUE(filter_properties->Filter()->Parent()->IsRoot());
EXPECT_FALSE(filter_properties->PixelMovingFilterClipExpander());
EXPECT_EQ(DocScrollTranslation(),
&filter_properties->Filter()->LocalTransformSpace());
@@ -4792,7 +4782,7 @@ TEST_P(PaintPropertyTreeBuilderTest, PixelMovingFilter) {
auto* filter = filter_properties->Filter();
ASSERT_TRUE(filter);
- EXPECT_EQ(filter->Parent(), DocEffect());
+ EXPECT_TRUE(filter->Parent()->IsRoot());
EXPECT_TRUE(filter->HasFilterThatMovesPixels());
EXPECT_EQ(DocScrollTranslation(), &filter->LocalTransformSpace());
EXPECT_EQ(DocContentClip(), filter->OutputClip());
@@ -4847,7 +4837,7 @@ TEST_P(PaintPropertyTreeBuilderTest, FilterReparentClips) {
GetLayoutObjectByElementId("clip")->FirstFragment().PaintProperties();
const ObjectPaintProperties* filter_properties =
GetLayoutObjectByElementId("filter")->FirstFragment().PaintProperties();
- EXPECT_TRUE(DocEffect());
+ EXPECT_TRUE(filter_properties->Filter()->Parent()->IsRoot());
EXPECT_EQ(clip_properties->OverflowClip(),
filter_properties->Filter()->OutputClip());
EXPECT_EQ(DocScrollTranslation(),
@@ -5089,7 +5079,7 @@ TEST_P(PaintPropertyTreeBuilderTest, MaskSimple) {
EXPECT_EQ(properties->Effect(),
&target->FirstFragment().LocalBorderBoxProperties().Effect());
- EXPECT_TRUE(DocEffect());
+ EXPECT_TRUE(properties->Effect()->Parent()->IsRoot());
EXPECT_EQ(SkBlendMode::kSrcOver, properties->Effect()->BlendMode());
EXPECT_EQ(mask_clip->Parent(), properties->Effect()->OutputClip());
@@ -5118,7 +5108,7 @@ TEST_P(PaintPropertyTreeBuilderTest, MaskWithOutset) {
EXPECT_EQ(properties->Effect(),
&target->FirstFragment().LocalBorderBoxProperties().Effect());
- EXPECT_TRUE(DocEffect());
+ EXPECT_TRUE(properties->Effect()->Parent()->IsRoot());
EXPECT_EQ(SkBlendMode::kSrcOver, properties->Effect()->BlendMode());
EXPECT_EQ(mask_clip->Parent(), properties->Effect()->OutputClip());
@@ -5172,7 +5162,7 @@ TEST_P(PaintPropertyTreeBuilderTest, MaskEscapeClip) {
EXPECT_EQ(target_properties->Effect(),
&target->FirstFragment().LocalBorderBoxProperties().Effect());
- EXPECT_TRUE(DocEffect());
+ EXPECT_TRUE(target_properties->Effect()->Parent()->IsRoot());
EXPECT_EQ(SkBlendMode::kSrcOver, target_properties->Effect()->BlendMode());
EXPECT_EQ(nullptr, target_properties->Effect()->OutputClip());
@@ -5215,7 +5205,7 @@ TEST_P(PaintPropertyTreeBuilderTest, MaskInline) {
EXPECT_EQ(properties->Effect(),
&target->FirstFragment().LocalBorderBoxProperties().Effect());
- EXPECT_TRUE(DocEffect());
+ EXPECT_TRUE(properties->Effect()->Parent()->IsRoot());
EXPECT_EQ(SkBlendMode::kSrcOver, properties->Effect()->BlendMode());
EXPECT_EQ(mask_clip->Parent(), properties->Effect()->OutputClip());
@@ -5316,7 +5306,8 @@ TEST_P(PaintPropertyTreeBuilderTest, SVGBlending) {
ASSERT_TRUE(svg_root_properties->Effect());
EXPECT_EQ(SkBlendMode::kSrcOver, svg_root_properties->Effect()->BlendMode());
- EXPECT_EQ(DocEffect(), svg_root_properties->Effect()->Parent());
+ EXPECT_EQ(&EffectPaintPropertyNode::Root(),
+ svg_root_properties->Effect()->Parent());
EXPECT_EQ(svg_root_properties->Effect(), rect_properties->Effect()->Parent());
}
@@ -5338,7 +5329,8 @@ TEST_P(PaintPropertyTreeBuilderTest, SVGRootBlending) {
ASSERT_TRUE(svg_root_properties->Effect());
EXPECT_EQ(SkBlendMode::kMultiply, svg_root_properties->Effect()->BlendMode());
- EXPECT_EQ(DocEffect(), html_properties->Effect()->Parent());
+ EXPECT_EQ(&EffectPaintPropertyNode::Root(),
+ html_properties->Effect()->Parent());
EXPECT_EQ(html_properties->Effect(), svg_root_properties->Effect()->Parent());
}
@@ -6454,7 +6446,7 @@ TEST_P(PaintPropertyTreeBuilderTest, SVGRootCompositedClipPathSimple) {
const auto* effect = properties->Effect();
ASSERT_NE(nullptr, effect);
- EXPECT_EQ(DocEffect(), effect->Parent());
+ EXPECT_EQ(&EffectPaintPropertyNode::Root(), effect->Parent());
EXPECT_EQ(transform, &effect->LocalTransformSpace());
EXPECT_EQ(clip_path_clip, effect->OutputClip());
EXPECT_EQ(SkBlendMode::kSrcOver, effect->BlendMode());
@@ -6492,7 +6484,7 @@ TEST_P(PaintPropertyTreeBuilderTest, SVGRootCompositedClipPathComplex) {
const auto* effect = properties->Effect();
ASSERT_NE(nullptr, effect);
EXPECT_TRUE(effect->HasDirectCompositingReasons());
- EXPECT_EQ(DocEffect(), effect->Parent());
+ EXPECT_EQ(&EffectPaintPropertyNode::Root(), effect->Parent());
EXPECT_EQ(transform, &effect->LocalTransformSpace());
EXPECT_EQ(clip_path_clip, effect->OutputClip());
EXPECT_EQ(SkBlendMode::kSrcOver, effect->BlendMode());
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.h b/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.h
index 7ab50dfc1dbfacba271f1a189f990e8dd78c4b21..252f6e568fbecb29c210e52bc8a43b34d002417d 100644
--- a/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.h
+++ b/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.h
@@ -34,7 +34,6 @@ class PaintPropertyTreeBuilderTest : public PaintControllerPaintTest {
const Document* = nullptr);
const ClipPaintPropertyNode* DocContentClip(const Document* = nullptr);
const ScrollPaintPropertyNode* DocScroll(const Document* = nullptr);
- const EffectPaintPropertyNode* DocEffect(const Document* = nullptr);
// Return the local border box's paint offset. For more details, see
// ObjectPaintProperties::localBorderBoxProperties().
diff --git a/third_party/blink/renderer/core/view_transition/view_transition_test.cc b/third_party/blink/renderer/core/view_transition/view_transition_test.cc
index a6fa914af41568cde2fbbe59c7bbbb1de5f59d0f..bb0473719d38c049c0a92bd5f533a351e8cd8484 100644
--- a/third_party/blink/renderer/core/view_transition/view_transition_test.cc
+++ b/third_party/blink/renderer/core/view_transition/view_transition_test.cc
@@ -22,6 +22,7 @@
#include "third_party/blink/renderer/core/dom/dom_token_list.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
+#include "third_party/blink/renderer/core/dom/layout_tree_builder_traversal.h"
#include "third_party/blink/renderer/core/dom/pseudo_element.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
#include "third_party/blink/renderer/core/html/html_element.h"
@@ -32,7 +33,6 @@
#include "third_party/blink/renderer/core/layout/physical_box_fragment.h"
#include "third_party/blink/renderer/core/navigation_api/navigation_api.h"
#include "third_party/blink/renderer/core/navigation_api/navigation_history_entry.h"
-#include "third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
@@ -706,100 +706,6 @@ TEST_P(ViewTransitionTest, ViewTransitionElementInvalidation) {
UpdateAllLifecyclePhasesAndFinishDirectives();
}
-namespace {
-void AssertOnlyViewTransitionElementsInvalidated(
- PaintArtifactCompositor* compositor) {
- const char kViewTransition[] = "view-transition";
- const char kLayoutViewTransition[] = "ViewTransition";
- compositor->ForAllContentLayersForTesting(
- [&](ContentLayerClientImpl* client) {
- if (::testing::Matcher<std::string>(
- ::testing::ContainsRegex(kViewTransition))
- .Matches(client->Layer().DebugName())) {
- return;
- }
- if (::testing::Matcher<std::string>(
- ::testing::ContainsRegex(kLayoutViewTransition))
- .Matches(client->Layer().DebugName())) {
- return;
- }
- auto* tracking = client->GetRasterInvalidator().GetTracking();
- EXPECT_FALSE(tracking->HasInvalidations())
- << client->Layer().DebugName();
- for (const auto& invalidation : tracking->Invalidations()) {
- LOG(ERROR) << "Invalidation " << invalidation;
- }
- });
-}
-} // namespace
-
-TEST_P(ViewTransitionTest, NoInvalidationOnRoot) {
- SetHtmlInnerHTML(R"HTML(
- <style>
- /* TODO(crbug.com/1336462): html.css is parsed before runtime flags are enabled */
- html { view-transition-name: root; backgrond: grey; }
- #element {
- width: 100px;
- height: 100px;
- view-transition-name: shared;
- will-change: transform;
- }
- </style>
-
- <div id=element></div>
- <div>test</div>
- )HTML");
-
- // Run all lifecycle phases to ensure paint is clean.
- UpdateAllLifecyclePhasesForTest();
-
- GetDocument().View()->SetTracksRasterInvalidations(true);
-
- ScriptState* script_state = GetScriptState();
- ScriptState::Scope scope(script_state);
-
- auto start_setup_lambda =
- [](const v8::FunctionCallbackInfo<v8::Value>& info) {};
-
- // This callback sets the elements for the start phase of the transition.
- auto start_setup_callback =
- v8::Function::New(script_state->GetContext(), start_setup_lambda, {})
- .ToLocalChecked();
-
- auto* compositor = GetLocalFrameView()->GetPaintArtifactCompositor();
- auto* transition = ViewTransitionSupplement::startViewTransition(
- script_state, GetDocument(),
- V8ViewTransitionCallback::Create(start_setup_callback),
- ASSERT_NO_EXCEPTION);
-
- UpdateAllLifecyclePhasesForTest();
- {
- SCOPED_TRACE("old dom capture");
- AssertOnlyViewTransitionElementsInvalidated(compositor);
- }
-
- // Finish the prepare phase, mutate the DOM and start the animation.
- UpdateAllLifecyclePhasesAndFinishDirectives();
- test::RunPendingTasks();
- EXPECT_EQ(GetState(transition), State::kAnimating);
-
- // The start phase should generate pseudo elements for rendering new live
- // content.
- UpdateAllLifecyclePhasesAndFinishDirectives();
- {
- SCOPED_TRACE("animation started");
- AssertOnlyViewTransitionElementsInvalidated(compositor);
- }
-
- // Finish the animations which should remove the pseudo element tree.
- FinishTransition();
- UpdateAllLifecyclePhasesAndFinishDirectives();
- {
- SCOPED_TRACE("transition finished");
- AssertOnlyViewTransitionElementsInvalidated(compositor);
- }
-}
-
TEST_P(ViewTransitionTest, InspectorStyleResolver) {
SetHtmlInnerHTML(R"HTML(
<style>
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc
index 4952082b87f80611b16a0730615bc0eaabe79791..d8568a1052ec82a8d56736aee7929ca9c4a4656c 100644
--- a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc
+++ b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc
@@ -1524,15 +1524,6 @@ void PaintArtifactCompositor::ShowDebugData() {
}
#endif
-void PaintArtifactCompositor::ForAllContentLayersForTesting(
- base::FunctionRef<void(ContentLayerClientImpl*)> func) const {
- for (auto& pending_layer : pending_layers_) {
- if (auto* client = pending_layer.GetContentLayerClient()) {
- func(client);
- }
- }
-}
-
ContentLayerClientImpl* PaintArtifactCompositor::ContentLayerClientForTesting(
wtf_size_t i) const {
for (auto& pending_layer : pending_layers_) {
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h
index fc4339bff1763d6dd6e99e3332e0e3bd1729e859..7d8a4526c9adcedf3ee0955aa2e7736a1d5e9e20 100644
--- a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h
+++ b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h
@@ -231,8 +231,6 @@ class PLATFORM_EXPORT PaintArtifactCompositor final
void ShowDebugData();
#endif
- void ForAllContentLayersForTesting(
- base::FunctionRef<void(ContentLayerClientImpl*)> func) const;
// Returns the ith ContentLayerClientImpl for testing.
ContentLayerClientImpl* ContentLayerClientForTesting(wtf_size_t i) const;

View File

@@ -54,3 +54,4 @@ build_restore_clang_as_default_compiler_on_macos.patch
esm_drop_support_for_import_assertions.patch
build_remove_explicit_linker_call_to_libm_on_macos.patch
build_define_nominmax_in_common_gypi.patch
test_make_eval_snapshot_tests_more_flexible.patch

View File

@@ -11,7 +11,7 @@ really in 20/21. We have to wait until 22 is released to be able to
build with upstream GN files.
diff --git a/BUILD.gn b/BUILD.gn
index 1ed186b597eece7c34cb69c8e1e20870555a040d..2ce1e8a7dcca2ba153d387d11970c72b5f43c167 100644
index 1ed186b597eece7c34cb69c8e1e20870555a040d..4171613ba865bb3ba82a2e3a219def63bb7abdc1 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1,14 +1,406 @@
@@ -284,7 +284,6 @@ index 1ed186b597eece7c34cb69c8e1e20870555a040d..2ce1e8a7dcca2ba153d387d11970c72b
+ ":node_js2c_exec",
+ "deps/googletest:gtest",
+ "deps/ada",
+ "deps/base64",
+ "deps/simdutf",
+ "deps/uvwasi",
+ "//third_party/zlib",
@@ -333,6 +332,7 @@ index 1ed186b597eece7c34cb69c8e1e20870555a040d..2ce1e8a7dcca2ba153d387d11970c72b
+ "-Wno-sometimes-uninitialized",
+ "-Wno-string-plus-int",
+ "-Wno-unused-function",
+ "-Wno-unreachable-code-return",
+ "-Wno-unused-label",
+ "-Wno-unused-private-field",
+ "-Wno-unused-variable",
@@ -458,84 +458,6 @@ index e92ac3a3beac143dced2efb05304ed8ba832b067..1ce69e9deba1a9b191e8d95f4c82e0ec
-ada_gn_build("ada") {
+ public_configs = [ ":ada_config" ]
}
diff --git a/deps/base64/unofficial.gni b/deps/base64/unofficial.gni
index 0e69d7383762f6b81c5b57698aa9d121d5a9c401..35bbeb37acc7ccb14b4b8a644ec3d4c76ca5c61c 100644
--- a/deps/base64/unofficial.gni
+++ b/deps/base64/unofficial.gni
@@ -12,6 +12,10 @@ template("base64_gn_build") {
}
}
+ # FIXME(zcbenz): ASM on win/x86 compiles perfectly in upstream Node, figure
+ # out why it does not work in Electron's build configs.
+ support_x86_asm = current_cpu == "x64" || (current_cpu == "x86" && !is_win)
+
config("base64_internal_config") {
include_dirs = [ "base64/lib" ]
if (is_component_build) {
@@ -19,7 +23,7 @@ template("base64_gn_build") {
} else {
defines = []
}
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (support_x86_asm) {
defines += [
"HAVE_SSSE3=1",
"HAVE_SSE41=1",
@@ -69,7 +73,7 @@ template("base64_gn_build") {
source_set("base64_ssse3") {
configs += [ ":base64_internal_config" ]
sources = [ "base64/lib/arch/ssse3/codec.c" ]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (support_x86_asm) {
if (is_clang || !is_win) {
cflags_c = [ "-mssse3" ]
}
@@ -79,7 +83,7 @@ template("base64_gn_build") {
source_set("base64_sse41") {
configs += [ ":base64_internal_config" ]
sources = [ "base64/lib/arch/sse41/codec.c" ]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (support_x86_asm) {
if (is_clang || !is_win) {
cflags_c = [ "-msse4.1" ]
}
@@ -89,7 +93,7 @@ template("base64_gn_build") {
source_set("base64_sse42") {
configs += [ ":base64_internal_config" ]
sources = [ "base64/lib/arch/sse42/codec.c" ]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (support_x86_asm) {
if (is_clang || !is_win) {
cflags_c = [ "-msse4.2" ]
}
@@ -99,7 +103,7 @@ template("base64_gn_build") {
source_set("base64_avx") {
configs += [ ":base64_internal_config" ]
sources = [ "base64/lib/arch/avx/codec.c" ]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (support_x86_asm) {
if (is_clang || !is_win) {
cflags_c = [ "-mavx" ]
} else if (is_win) {
@@ -111,7 +115,7 @@ template("base64_gn_build") {
source_set("base64_avx2") {
configs += [ ":base64_internal_config" ]
sources = [ "base64/lib/arch/avx2/codec.c" ]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (support_x86_asm) {
if (is_clang || !is_win) {
cflags_c = [ "-mavx2" ]
} else if (is_win) {
@@ -123,7 +127,7 @@ template("base64_gn_build") {
source_set("base64_avx512") {
configs += [ ":base64_internal_config" ]
sources = [ "base64/lib/arch/avx512/codec.c" ]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (support_x86_asm) {
if (is_clang || !is_win) {
cflags_c = [
"-mavx512vl",
diff --git a/deps/cares/BUILD.gn b/deps/cares/BUILD.gn
index ac19ac73ed1e24c61cb679f3851685b79cfc8b39..ef745c19f2b1cd433cc43c834a18db7eaa8e5162 100644
--- a/deps/cares/BUILD.gn
@@ -1281,7 +1203,7 @@ index 0000000000000000000000000000000000000000..af9cbada10203b387fb9732b346583b1
+}
diff --git a/filenames.json b/filenames.json
new file mode 100644
index 0000000000000000000000000000000000000000..c429d4cbfff605ff78c7c8ee3c5ad046594163f3
index 0000000000000000000000000000000000000000..72ddbe405908109ab7563e0c8f2e61c75cac88fc
--- /dev/null
+++ b/filenames.json
@@ -0,0 +1,740 @@
@@ -1649,6 +1571,7 @@ index 0000000000000000000000000000000000000000..c429d4cbfff605ff78c7c8ee3c5ad046
+ "lib/internal/source_map/prepare_stack_trace.js",
+ "lib/internal/source_map/source_map.js",
+ "lib/internal/source_map/source_map_cache.js",
+ "lib/internal/source_map/source_map_cache_map.js",
+ "lib/internal/stream_base_commons.js",
+ "lib/internal/streams/add-abort-signal.js",
+ "lib/internal/streams/compose.js",
@@ -1696,10 +1619,8 @@ index 0000000000000000000000000000000000000000..c429d4cbfff605ff78c7c8ee3c5ad046
+ "lib/internal/util/colors.js",
+ "lib/internal/util/comparisons.js",
+ "lib/internal/util/debuglog.js",
+ "lib/internal/util/embedding.js",
+ "lib/internal/util/inspect.js",
+ "lib/internal/util/inspector.js",
+ "lib/internal/util/iterable_weak_map.js",
+ "lib/internal/util/parse_args/parse_args.js",
+ "lib/internal/util/parse_args/utils.js",
+ "lib/internal/util/types.js",
@@ -1725,6 +1646,7 @@ index 0000000000000000000000000000000000000000..c429d4cbfff605ff78c7c8ee3c5ad046
+ "lib/internal/worker.js",
+ "lib/internal/worker/io.js",
+ "lib/internal/worker/js_transferable.js",
+ "lib/internal/worker/messaging.js",
+ "lib/module.js",
+ "lib/net.js",
+ "lib/os.js",

View File

@@ -10,7 +10,7 @@ V8 requires C++20 support as of https://chromium-review.googlesource.com/c/v8/v8
This can be removed when Electron upgrades to a version of Node.js containing the required V8 version.
diff --git a/common.gypi b/common.gypi
index 690068f093f12b6831f8ccce41289d02d7047a7a..5a3df388773ad288553bf036be42dc1a0ba75c09 100644
index 3b26f0e9c8a16135d6c614374cfb943ebc07f992..4a79378a6633b33f86f6576c27659df18193ed46 100644
--- a/common.gypi
+++ b/common.gypi
@@ -305,7 +305,7 @@

View File

@@ -18,7 +18,7 @@ significant.
PR-URL: https://github.com/nodejs/node/pull/52794
diff --git a/common.gypi b/common.gypi
index 9bbf1b277eb17d78ca385643c3177638fd75866a..959ee74af88b44d31f2e6fa65c6f260820bd8c46 100644
index 2f0dab65717ac59a32bd91dbac6a0b9ded5c93e6..cd3700f5290e69ec60fc22bd5fa32b54565aa049 100644
--- a/common.gypi
+++ b/common.gypi
@@ -480,6 +480,10 @@

View File

@@ -7,7 +7,7 @@ Subject: build: ensure native module compilation fails if not using a new
This should not be upstreamed, it is a quality-of-life patch for downstream module builders.
diff --git a/common.gypi b/common.gypi
index 776a6dcf3a729a65b367fb5b4c5685f841089eea..690068f093f12b6831f8ccce41289d02d7047a7a 100644
index 46761b75327826b1f608670a1511be01df9be08e..3b26f0e9c8a16135d6c614374cfb943ebc07f992 100644
--- a/common.gypi
+++ b/common.gypi
@@ -86,6 +86,8 @@

View File

@@ -40,10 +40,10 @@ index 5e07e106672a04508a77584c109c97a67926c858..91001fa43ea4807d061f296eaeccb751
}
if (is_clang || !is_win) {
diff --git a/deps/uv/unofficial.gni b/deps/uv/unofficial.gni
index 7a73f891e3fc3261b77af97af63fca2eade49849..bda1b5dc899558c2b4a22377dde9fb3bcce5488c 100644
index 348d2f0703e47ca7c5326a4b4c1d6ae31157eeb5..0944d6ddd241b113970ab6aa5804f9534fde882a 100644
--- a/deps/uv/unofficial.gni
+++ b/deps/uv/unofficial.gni
@@ -82,11 +82,11 @@ template("uv_gn_build") {
@@ -87,11 +87,11 @@ template("uv_gn_build") {
]
}
if (is_posix) {

View File

@@ -11,7 +11,7 @@ node-gyp will use the result of `process.config` that reflects the environment
in which the binary got built.
diff --git a/common.gypi b/common.gypi
index 5a3df388773ad288553bf036be42dc1a0ba75c09..9bbf1b277eb17d78ca385643c3177638fd75866a 100644
index 4a79378a6633b33f86f6576c27659df18193ed46..2f0dab65717ac59a32bd91dbac6a0b9ded5c93e6 100644
--- a/common.gypi
+++ b/common.gypi
@@ -125,6 +125,7 @@

View File

@@ -15,20 +15,20 @@ This patch is expected to be deleted once we catch up with a Node.js
upgrade that includes the original Node.js commit above.
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index ff658ec88e5161cd66536ee6e95dba675b16eccc..9bbb8ab908d8d992abb43254860d51f57f56387b 100644
index 0f0b16fcdd8a97bba60faeff09300dd8102cf02c..094d12ffe99500af700a591f5cb33e7d7b247ed1 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -202,8 +202,7 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
}
Local<String> source_text = args[2].As<String>();
- ScriptOrigin origin(isolate,
- url,
+ ScriptOrigin origin(url,
line_offset,
column_offset,
true, // is cross origin
@@ -464,7 +463,6 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
@@ -304,8 +304,7 @@ MaybeLocal<Module> ModuleWrap::CompileSourceTextModule(
bool* cache_rejected) {
Isolate* isolate = realm->isolate();
EscapableHandleScope scope(isolate);
- ScriptOrigin origin(isolate,
- url,
+ ScriptOrigin origin(url,
line_offset,
column_offset,
true, // is cross origin
@@ -500,7 +499,6 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
ShouldNotAbortOnUncaughtScope no_abort_scope(realm->env());
TryCatchScope try_catch(realm->env());
@@ -36,6 +36,16 @@ index ff658ec88e5161cd66536ee6e95dba675b16eccc..9bbb8ab908d8d992abb43254860d51f5
bool timed_out = false;
bool received_signal = false;
@@ -1009,8 +1007,7 @@ void ModuleWrap::CreateRequiredModuleFacade(
ASSIGN_OR_RETURN_UNWRAP(&original, wrap);
// Use the same facade source and URL to hit the compilation cache.
- ScriptOrigin origin(isolate,
- env->required_module_facade_url_string(),
+ ScriptOrigin origin(env->required_module_facade_url_string(),
0, // line offset
0, // column offset
true, // is cross origin
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
index 4bf80aa6cc6385dc376fd0a3538efc27fe5bd0a2..3e37aa8b0c9696cceb3f3cfab9721f38c74a2fba 100644
--- a/src/node_builtins.cc
@@ -50,36 +60,20 @@ index 4bf80aa6cc6385dc376fd0a3538efc27fe5bd0a2..3e37aa8b0c9696cceb3f3cfab9721f38
BuiltinCodeCacheData cached_data{};
{
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 6456d87d4202c013aafe071adbac06852b3ae2c1..28ba7dbe66a44a43c39e3d75edf0be9513bcf732 100644
index c8ccf38eaaeaccf3715b742e7e64cf7803dbb392..a3f70f6cba773d0a7a00aca96a1687c1e2ae38e6 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -877,16 +877,15 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
@@ -878,8 +878,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
host_defined_options->Set(
isolate, loader::HostDefinedOptions::kID, id_symbol);
- ScriptOrigin origin(isolate,
- filename,
- line_offset, // line offset
- column_offset, // column offset
- true, // is cross origin
- -1, // script id
- Local<Value>(), // source map URL
- false, // is opaque (?)
- false, // is WASM
- false, // is ES Module
+ ScriptOrigin origin(filename,
+ line_offset, // line offset
+ column_offset, // column offset
+ true, // is cross origin
+ -1, // script id
+ Local<Value>(), // source map URL
+ false, // is opaque (?)
+ false, // is WASM
+ false, // is ES Module
host_defined_options);
ScriptCompiler::Source source(code, origin, cached_data);
ScriptCompiler::CompileOptions compile_options =
@@ -998,7 +997,7 @@ MaybeLocal<Function> CompileFunction(Local<Context> context,
line_offset, // line offset
column_offset, // column offset
true, // is cross origin
@@ -999,7 +998,7 @@ MaybeLocal<Function> CompileFunction(Local<Context> context,
Local<String> filename,
Local<String> content,
std::vector<Local<String>>* parameters) {
@@ -88,7 +82,7 @@ index 6456d87d4202c013aafe071adbac06852b3ae2c1..28ba7dbe66a44a43c39e3d75edf0be95
ScriptCompiler::Source script_source(content, script_origin);
return ScriptCompiler::CompileFunction(context,
@@ -1108,7 +1107,6 @@ bool ContextifyScript::EvalMachine(Local<Context> context,
@@ -1109,7 +1108,6 @@ bool ContextifyScript::EvalMachine(Local<Context> context,
}
TryCatchScope try_catch(env);
@@ -96,73 +90,26 @@ index 6456d87d4202c013aafe071adbac06852b3ae2c1..28ba7dbe66a44a43c39e3d75edf0be95
ContextifyScript* wrapped_script;
ASSIGN_OR_RETURN_UNWRAP(&wrapped_script, args.This(), false);
Local<UnboundScript> unbound_script =
@@ -1286,8 +1284,7 @@ void ContextifyContext::CompileFunction(
@@ -1278,8 +1276,7 @@ void ContextifyContext::CompileFunction(
Local<PrimitiveArray> host_defined_options =
GetHostDefinedOptions(isolate, id_symbol);
ScriptCompiler::Source source =
- GetCommonJSSourceInstance(isolate,
- code,
+ GetCommonJSSourceInstance(code,
filename,
line_offset,
column_offset,
@@ -1342,15 +1339,13 @@ void ContextifyContext::CompileFunction(
}
loader::ModuleWrap::GetHostDefinedOptions(isolate, id_symbol);
ScriptCompiler::Source ContextifyContext::GetCommonJSSourceInstance(
- Isolate* isolate,
Local<String> code,
Local<String> filename,
int line_offset,
int column_offset,
Local<PrimitiveArray> host_defined_options,
ScriptCompiler::CachedData* cached_data) {
- ScriptOrigin origin(isolate,
- filename,
+ ScriptOrigin origin(filename,
line_offset, // line offset
column_offset, // column offset
true, // is cross origin
@@ -1528,7 +1523,7 @@ void ContextifyContext::ContainsModuleSyntax(
Local<PrimitiveArray> host_defined_options =
GetHostDefinedOptions(isolate, id_symbol);
ScriptCompiler::Source source = GetCommonJSSourceInstance(
- isolate, code, filename, 0, 0, host_defined_options, nullptr);
+ code, filename, 0, 0, host_defined_options, nullptr);
ScriptCompiler::CompileOptions options = GetCompileOptions(source);
std::vector<Local<String>> params = GetCJSParameters(env->isolate_data());
@@ -1576,7 +1571,7 @@ void ContextifyContext::ContainsModuleSyntax(
code,
String::NewFromUtf8(isolate, "})();").ToLocalChecked());
ScriptCompiler::Source wrapped_source = GetCommonJSSourceInstance(
- isolate, code, filename, 0, 0, host_defined_options, nullptr);
+ code, filename, 0, 0, host_defined_options, nullptr);
std::ignore = ScriptCompiler::CompileFunction(
context,
&wrapped_source,
@@ -1629,8 +1624,7 @@ static void CompileFunctionForCJSLoader(
@@ -1466,8 +1463,7 @@ static MaybeLocal<Function> CompileFunctionForCJSLoader(
Local<Symbol> symbol = env->vm_dynamic_import_default_internal();
Local<PrimitiveArray> hdo = GetHostDefinedOptions(isolate, symbol);
Local<PrimitiveArray> hdo =
loader::ModuleWrap::GetHostDefinedOptions(isolate, symbol);
- ScriptOrigin origin(isolate,
- filename,
+ ScriptOrigin origin(filename,
0, // line offset
0, // column offset
true, // is cross origin
diff --git a/src/node_contextify.h b/src/node_contextify.h
index 517e3f44d324900222e1da961a4cd60bbb4a85f9..10715c7eb07715cc11e49734bd54747dad95f6a4 100644
--- a/src/node_contextify.h
+++ b/src/node_contextify.h
@@ -99,7 +99,6 @@ class ContextifyContext : public BaseObject {
v8::Local<v8::Symbol> id_symbol,
const errors::TryCatchScope& try_catch);
static v8::ScriptCompiler::Source GetCommonJSSourceInstance(
- v8::Isolate* isolate,
v8::Local<v8::String> code,
v8::Local<v8::String> filename,
int line_offset,
diff --git a/test/cctest/test_environment.cc b/test/cctest/test_environment.cc
index 64e38c83006a004ebc3519a5e9f8b04263244514..14e82cc80ff73084fb43b2ef07febfd2667a0abc 100644
--- a/test/cctest/test_environment.cc

View File

@@ -8,23 +8,23 @@ they use themselves as the entry point. We should try to upstream some form
of this.
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 364469160af5e348f8890417de16a63c0d1dca67..75d5f58fe02fa8cfa7716ffaf761d567ab403a2c 100644
index 82a3b80f6ffe8bf484d00f7898572dbf27918461..6e2802ab497c1659dfbda081e1d190ea0a94b586 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -1441,6 +1441,13 @@ Module.prototype._compile = function(content, filename, loadAsESM = false) {
if (getOptionValue('--inspect-brk') && process._eval == null) {
if (!resolvedArgv) {
// We enter the repl if we're not given a filename argument.
+ // process._firstFileName is used by Embedders to tell node what
+ // the first "real" file is when they use themselves as the entry
+ // point
+ if (process._firstFileName) {
+ resolvedArgv = process._firstFileName
+ delete process._firstFileName
+ } else
if (process.argv[1]) {
try {
resolvedArgv = Module._resolveFilename(process.argv[1], null, false);
@@ -1530,6 +1530,13 @@ Module.prototype._compile = function(content, filename, format) {
this[kIsExecuting] = true;
if (this[kIsMainSymbol] && getOptionValue('--inspect-brk')) {
const { callAndPauseOnStart } = internalBinding('inspector');
+ // process._firstFileName is used by Embedders to tell node what
+ // the first "real" file is when they use themselves as the entry
+ // point
+ if (process._firstFileName) {
+ resolvedArgv = process._firstFileName;
+ delete process._firstFileName;
+ }
result = callAndPauseOnStart(compiledWrapper, thisValue, exports,
require, module, filename, dirname,
process, localGlobal, localBuffer);
diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js
index 0bbabb80c26a1208860f6d32447c0ae53316f501..ba18bfa3cd17c2b8e977f53651ce2744b17a829f 100644
--- a/lib/internal/process/pre_execution.js

View File

@@ -11,7 +11,7 @@ its own blended handler between Node and Blink.
Not upstreamable.
diff --git a/lib/internal/modules/esm/utils.js b/lib/internal/modules/esm/utils.js
index 150816057129c147c13ce044474f341581679f34..dd8627653265e22f55e67ec4a47641b20fba6c9d 100644
index 38b5eaf1d7e0f2c006ceae9e6ac3edaa87d22838..d71b19f986653b37aed520584ab84e8003de972f 100644
--- a/lib/internal/modules/esm/utils.js
+++ b/lib/internal/modules/esm/utils.js
@@ -30,7 +30,7 @@ const {
@@ -23,7 +23,7 @@ index 150816057129c147c13ce044474f341581679f34..dd8627653265e22f55e67ec4a47641b2
const {
loadPreloadModules,
initializeFrozenIntrinsics,
@@ -273,12 +273,13 @@ let _forceDefaultLoader = false;
@@ -274,12 +274,13 @@ let _forceDefaultLoader = false;
* @param {boolean} [forceDefaultLoader=false] - A boolean indicating disabling custom loaders.
*/
function initializeESM(forceDefaultLoader = false) {
@@ -40,10 +40,10 @@ index 150816057129c147c13ce044474f341581679f34..dd8627653265e22f55e67ec4a47641b2
/**
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index eea74bed4bb8a980f99a9a1404c9a2df203ca09c..e862b51293135995c527c32aa3c3579780d7831c 100644
index c0776ffbbf0497d4675ae052b06682061e3aa27d..9a9b219352aa134cffa2b179b77dd948563c842b 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -752,7 +752,7 @@ MaybeLocal<Module> ModuleWrap::ResolveModuleCallback(
@@ -770,7 +770,7 @@ MaybeLocal<Module> ModuleWrap::ResolveModuleCallback(
return module->module_.Get(isolate);
}
@@ -52,7 +52,7 @@ index eea74bed4bb8a980f99a9a1404c9a2df203ca09c..e862b51293135995c527c32aa3c35797
Local<Context> context,
Local<v8::Data> host_defined_options,
Local<Value> resource_name,
@@ -817,12 +817,13 @@ void ModuleWrap::SetImportModuleDynamicallyCallback(
@@ -835,12 +835,13 @@ void ModuleWrap::SetImportModuleDynamicallyCallback(
Realm* realm = Realm::GetCurrent(args);
HandleScope handle_scope(isolate);
@@ -68,7 +68,7 @@ index eea74bed4bb8a980f99a9a1404c9a2df203ca09c..e862b51293135995c527c32aa3c35797
}
void ModuleWrap::HostInitializeImportMetaObjectCallback(
@@ -864,13 +865,14 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback(
@@ -882,13 +883,14 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback(
Realm* realm = Realm::GetCurrent(args);
Isolate* isolate = realm->isolate();
@@ -87,18 +87,18 @@ index eea74bed4bb8a980f99a9a1404c9a2df203ca09c..e862b51293135995c527c32aa3c35797
MaybeLocal<Value> ModuleWrap::SyntheticModuleEvaluationStepsCallback(
diff --git a/src/module_wrap.h b/src/module_wrap.h
index 45a338b38e01c824f69ea59ee286130c67e9eddf..99bb079df11696fc3ba5e6bcca7e7a42818fe3d1 100644
index 51b127209af695e9e4682f959b263e2c613d6243..78b2dd399a5c5eace5fba4713a5eacd2d636ab66 100644
--- a/src/module_wrap.h
+++ b/src/module_wrap.h
@@ -7,6 +7,7 @@
#include <string>
@@ -8,6 +8,7 @@
#include <unordered_map>
#include <vector>
#include "base_object.h"
+#include "node.h"
#include "v8-script.h"
namespace node {
@@ -31,7 +32,14 @@ enum HostDefinedOptions : int {
@@ -33,7 +34,14 @@ enum HostDefinedOptions : int {
kLength = 9,
};
@@ -114,20 +114,20 @@ index 45a338b38e01c824f69ea59ee286130c67e9eddf..99bb079df11696fc3ba5e6bcca7e7a42
public:
enum InternalFields {
kModuleSlot = BaseObject::kInternalFieldCount,
@@ -68,6 +76,8 @@ class ModuleWrap : public BaseObject {
return true;
}
@@ -90,6 +98,8 @@ class ModuleWrap : public BaseObject {
static void CreateRequiredModuleFacade(
const v8::FunctionCallbackInfo<v8::Value>& args);
+ static ModuleWrap* GetFromModule(node::Environment*, v8::Local<v8::Module>);
+
private:
ModuleWrap(Realm* realm,
v8::Local<v8::Object> object,
@@ -110,7 +120,6 @@ class ModuleWrap : public BaseObject {
@@ -128,7 +138,6 @@ class ModuleWrap : public BaseObject {
v8::Local<v8::String> specifier,
v8::Local<v8::FixedArray> import_attributes,
v8::Local<v8::Module> referrer);
- static ModuleWrap* GetFromModule(node::Environment*, v8::Local<v8::Module>);
v8::Global<v8::Module> module_;
std::unordered_map<std::string, v8::Global<v8::Promise>> resolve_cache_;
std::unordered_map<std::string, v8::Global<v8::Object>> resolve_cache_;

View File

@@ -24,12 +24,12 @@ index c028204481d44cb5f35ad98413022e7b07ce04b2..230c2378996c5d1ec18a9183ef138bbf
message: Use `const { Blob } = require('buffer');` instead of the global.
- name: BroadcastChannel
diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js
index cfd1d1b6f18e2943e155cf021b566a4673f71ab0..8d1a184ad1936c0d8493d6c54c32bebcf0021d8b 100644
index 54f92797323ef914f23b9cc9174de8bc46ffa7e5..1944fdbf5c7e81bff5a0818c9cac95ed5287a2e7 100644
--- a/lib/internal/main/worker_thread.js
+++ b/lib/internal/main/worker_thread.js
@@ -113,7 +113,7 @@ port.on('message', (message) => {
@@ -117,7 +117,7 @@ port.on('message', (message) => {
require('internal/worker').assignEnvironmentData(environmentData);
setupMainThreadPort(mainThreadPort);
- if (SharedArrayBuffer !== undefined && Atomics !== undefined) {
+ if (SharedArrayBuffer !== undefined) {
@@ -37,10 +37,10 @@ index cfd1d1b6f18e2943e155cf021b566a4673f71ab0..8d1a184ad1936c0d8493d6c54c32bebc
// not to workers created by other workers.
let cachedCwd = '';
diff --git a/lib/internal/worker.js b/lib/internal/worker.js
index 401bc43550ea7f19847dfd588e3fba0507243905..560f69c6c2de2bd976bcd62cd7ac9c770b838446 100644
index 519faa4ff765f63beda02f6081a4fbf181440053..a0d819bcbabdceba9b521d79c555c8314c10e303 100644
--- a/lib/internal/worker.js
+++ b/lib/internal/worker.js
@@ -101,8 +101,7 @@ let cwdCounter;
@@ -102,8 +102,7 @@ let cwdCounter;
const environmentData = new SafeMap();
// SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer.

View File

@@ -21,7 +21,7 @@ index 606a6f5caa3b11b6d2a9068ed2fd65800530a5eb..080dcce21da05ccea398d8a856deb397
typedef void (*FreeCallback)(char* data, void* hint);
diff --git a/src/node_errors.h b/src/node_errors.h
index ac07b96b5cad0f3502468c86745e2b341d338e1f..f51c4309ceec3f0dc5e07982fb789ff6663076ba 100644
index d5e2f86f516bbb49fc2ed64076dcd436ea6433ac..c027da4fcf0aa31864fe75c567b2e1cec2a97136 100644
--- a/src/node_errors.h
+++ b/src/node_errors.h
@@ -235,7 +235,7 @@ inline v8::Local<v8::Object> ERR_BUFFER_TOO_LARGE(v8::Isolate* isolate) {

View File

@@ -68,7 +68,7 @@ index af23e674cb361ed81dafa22670d5633559cd1144..1dd59990cb7cdba8aecf4f499ee6b92e
+ await once(spawn(process.execPath, ['-r', reset, '--test', '--test-reporter', 'tap', test], { stdio: 'inherit', env: { ELECTRON_RUN_AS_NODE: 1 } }), 'exit');
})().then(common.mustCall());
diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs
index 84f20a77dda367fe1ada8d616c7b6813d39efd43..9bebb256776c5be155a8de07abbe4284bc8dad8a 100644
index 6f36dbeb15b869bf96bd8e9b80674bd1c2d12603..d62bfb574a37ce434afdbc2ae67ac3b5daa33dae 100644
--- a/test/parallel/test-node-output-errors.mjs
+++ b/test/parallel/test-node-output-errors.mjs
@@ -3,6 +3,7 @@ import * as fixtures from '../common/fixtures.mjs';

View File

@@ -18,10 +18,10 @@ Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
diff --git a/doc/api/cli.md b/doc/api/cli.md
index df7031f65d44f9abfcf43281c0d153c654269b60..d0d78beed2b02a3703bd45fdaa4291600f98d35e 100644
index 85920e71be2cc5b9747181830e41d3249097f5bf..a4e9a7fb6a1d413190c79ea01de2c87da459538f 100644
--- a/doc/api/cli.md
+++ b/doc/api/cli.md
@@ -2886,7 +2886,6 @@ V8 options that are allowed are:
@@ -2920,7 +2920,6 @@ V8 options that are allowed are:
* `--disallow-code-generation-from-strings`
* `--enable-etw-stack-walking`
* `--expose-gc`
@@ -30,10 +30,10 @@ index df7031f65d44f9abfcf43281c0d153c654269b60..d0d78beed2b02a3703bd45fdaa429160
* `--jitless`
* `--max-old-space-size`
diff --git a/src/node_options.cc b/src/node_options.cc
index e19b9d88a908154dbcfd0b0e3efbc7510609f810..e056e43c36de885df57fb3d9f8d76f0bdc412537 100644
index a2fe006a201c946c8de336b8e2e86dabc5f5443b..f493285b4ce39e16565109f583f4383432c28b2c 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -870,11 +870,6 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
@@ -893,11 +893,6 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
"disallow eval and friends",
V8Option{},
kAllowedInEnvvar);

View File

@@ -9,17 +9,16 @@ This patch can be removed when Electron upgrades to a version of Node.js that
contains the above CL.
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index e862b51293135995c527c32aa3c3579780d7831c..ff658ec88e5161cd66536ee6e95dba675b16eccc 100644
index 9a9b219352aa134cffa2b179b77dd948563c842b..0f0b16fcdd8a97bba60faeff09300dd8102cf02c 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -186,7 +186,9 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
@@ -197,7 +197,8 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
export_names[i] = export_name_val.As<String>();
}
- module = Module::CreateSyntheticModule(isolate, url, export_names,
+
+ module = Module::CreateSyntheticModule(isolate, url,
+ v8::MemorySpan<const Local<String>>(export_names.begin(), export_names.end()),
SyntheticModuleEvaluationStepsCallback);
} else {
ScriptCompiler::CachedData* cached_data = nullptr;
// When we are compiling for the default loader, this will be

View File

@@ -35,10 +35,10 @@ Reviewed-By: James M Snell <jasnell@gmail.com>
(cherry picked from commit 8fd90938f923ef2a04bb3ebb08b89568fe6fd4ee)
diff --git a/src/node.cc b/src/node.cc
index 1fc236d88e53ebe2fd388b9799c0e857d8b4e88e..751d818308ee499a1201e5972ec80f12ed998114 100644
index 4ad2c8b80493aa3e74dc247701dfb36542fac72a..a60c3504029d4e1566fd1905991719700260997a 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -782,12 +782,6 @@ static ExitCode ProcessGlobalArgsInternal(std::vector<std::string>* args,
@@ -790,12 +790,6 @@ static ExitCode ProcessGlobalArgsInternal(std::vector<std::string>* args,
return ExitCode::kInvalidCommandLineArgument2;
}

View File

@@ -7,7 +7,7 @@ common.gypi is a file that's included in the node header bundle, despite
the fact that we do not build node with gyp.
diff --git a/common.gypi b/common.gypi
index 04852d81103ef83c5213464f543839dea6f0b181..776a6dcf3a729a65b367fb5b4c5685f841089eea 100644
index d3c17d47bc141b201b741fd0b2e26d096c48ec35..46761b75327826b1f608670a1511be01df9be08e 100644
--- a/common.gypi
+++ b/common.gypi
@@ -88,6 +88,23 @@

View File

@@ -13,10 +13,10 @@ CL: https://chromium-review.googlesource.com/c/v8/v8/+/5630388
This patch can be removed when the node change is incorporated into main.
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465e11439b8 100644
index a3f70f6cba773d0a7a00aca96a1687c1e2ae38e6..9f38cdf60f36dbd32007ee2536b13e71b265989d 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -49,6 +49,7 @@ using v8::FunctionTemplate;
@@ -51,6 +51,7 @@ using v8::FunctionTemplate;
using v8::HandleScope;
using v8::IndexedPropertyHandlerConfiguration;
using v8::Int32;
@@ -24,7 +24,7 @@ index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465
using v8::Isolate;
using v8::Just;
using v8::Local;
@@ -484,14 +485,15 @@ bool ContextifyContext::IsStillInitializing(const ContextifyContext* ctx) {
@@ -485,14 +486,15 @@ bool ContextifyContext::IsStillInitializing(const ContextifyContext* ctx) {
}
// static
@@ -44,7 +44,7 @@ index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465
Local<Context> context = ctx->context();
Local<Object> sandbox = ctx->sandbox();
@@ -515,18 +517,22 @@ void ContextifyContext::PropertyGetterCallback(
@@ -516,18 +518,22 @@ void ContextifyContext::PropertyGetterCallback(
rv = ctx->global_proxy();
args.GetReturnValue().Set(rv);
@@ -70,7 +70,7 @@ index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465
Local<Context> context = ctx->context();
PropertyAttribute attributes = PropertyAttribute::None;
@@ -544,8 +550,9 @@ void ContextifyContext::PropertySetterCallback(
@@ -545,8 +551,9 @@ void ContextifyContext::PropertySetterCallback(
(static_cast<int>(attributes) &
static_cast<int>(PropertyAttribute::ReadOnly));
@@ -82,7 +82,7 @@ index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465
// true for x = 5
// false for this.x = 5
@@ -564,11 +571,16 @@ void ContextifyContext::PropertySetterCallback(
@@ -565,11 +572,16 @@ void ContextifyContext::PropertySetterCallback(
bool is_declared = is_declared_on_global_proxy || is_declared_on_sandbox;
if (!is_declared && args.ShouldThrowOnError() && is_contextual_store &&
@@ -103,7 +103,7 @@ index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465
Local<Value> desc;
if (is_declared_on_sandbox &&
@@ -582,19 +594,23 @@ void ContextifyContext::PropertySetterCallback(
@@ -583,19 +595,23 @@ void ContextifyContext::PropertySetterCallback(
// We have to specify the return value for any contextual or get/set
// property
if (desc_obj->HasOwnProperty(context, env->get_string()).FromMaybe(false) ||
@@ -132,7 +132,7 @@ index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465
Local<Context> context = ctx->context();
@@ -604,19 +620,23 @@ void ContextifyContext::PropertyDescriptorCallback(
@@ -605,19 +621,23 @@ void ContextifyContext::PropertyDescriptorCallback(
Local<Value> desc;
if (sandbox->GetOwnPropertyDescriptor(context, property).ToLocal(&desc)) {
args.GetReturnValue().Set(desc);
@@ -159,7 +159,7 @@ index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465
Local<Context> context = ctx->context();
Isolate* isolate = context->GetIsolate();
@@ -635,7 +655,7 @@ void ContextifyContext::PropertyDefinerCallback(
@@ -636,7 +656,7 @@ void ContextifyContext::PropertyDefinerCallback(
// If the property is set on the global as neither writable nor
// configurable, don't change it on the global or sandbox.
if (is_declared && read_only && dont_delete) {
@@ -168,7 +168,7 @@ index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465
}
Local<Object> sandbox = ctx->sandbox();
@@ -658,6 +678,9 @@ void ContextifyContext::PropertyDefinerCallback(
@@ -659,6 +679,9 @@ void ContextifyContext::PropertyDefinerCallback(
desc.has_set() ? desc.set() : Undefined(isolate).As<Value>());
define_prop_on_sandbox(&desc_for_sandbox);
@@ -178,7 +178,7 @@ index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465
} else {
Local<Value> value =
desc.has_value() ? desc.value() : Undefined(isolate).As<Value>();
@@ -669,26 +692,32 @@ void ContextifyContext::PropertyDefinerCallback(
@@ -670,26 +693,32 @@ void ContextifyContext::PropertyDefinerCallback(
PropertyDescriptor desc_for_sandbox(value);
define_prop_on_sandbox(&desc_for_sandbox);
}
@@ -217,7 +217,7 @@ index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465
}
// static
@@ -708,76 +737,84 @@ void ContextifyContext::PropertyEnumeratorCallback(
@@ -709,76 +738,84 @@ void ContextifyContext::PropertyEnumeratorCallback(
}
// static
@@ -328,11 +328,11 @@ index 28ba7dbe66a44a43c39e3d75edf0be9513bcf732..0401b968916e5f45d148281c74b7e465
void ContextifyScript::CreatePerIsolateProperties(
diff --git a/src/node_contextify.h b/src/node_contextify.h
index 10715c7eb07715cc11e49734bd54747dad95f6a4..49b9fabb399aed962e0d29e784a25ca4e9780a8f 100644
index 88b5684844b915325b28a37b7357a02231cd119e..eac9ac311f04bfe037ac07c560f08e136707c713 100644
--- a/src/node_contextify.h
+++ b/src/node_contextify.h
@@ -111,42 +111,39 @@ class ContextifyContext : public BaseObject {
const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -100,42 +100,39 @@ class ContextifyContext : public BaseObject {
const errors::TryCatchScope& try_catch);
static void WeakCallback(
const v8::WeakCallbackInfo<ContextifyContext>& data);
- static void PropertyGetterCallback(

View File

@@ -58,10 +58,10 @@ index 66d0a75e90dd11d5d96a738c01939dc1f5703dde..c101c0f314575b489e9ee93281a56b87
}
diff --git a/src/node_options.cc b/src/node_options.cc
index b7ef44b018c7aec59d8311642a811d1280247689..e19b9d88a908154dbcfd0b0e3efbc7510609f810 100644
index 7a937d4b6559fe9d616f9540591f69610fa5d9d7..a2fe006a201c946c8de336b8e2e86dabc5f5443b 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -1409,14 +1409,16 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
@@ -1432,14 +1432,16 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
}
Isolate* isolate = args.GetIsolate();

View File

@@ -24,10 +24,10 @@ index be02d4aaa04685cbd6a9ecfe082e38f179129ab5..277748a30bd97ae816d9ba1f2d73851a
wrap->object()->Has(env->context(), env->handle_onclose_symbol())
.FromMaybe(false)) {
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 8951cd378a9025f58fada47cf96f686d14639f95..6456d87d4202c013aafe071adbac06852b3ae2c1 100644
index 7f82bca746408ba718f3b5416392ff336d458aa1..c8ccf38eaaeaccf3715b742e7e64cf7803dbb392 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -487,6 +487,7 @@ bool ContextifyContext::IsStillInitializing(const ContextifyContext* ctx) {
@@ -488,6 +488,7 @@ bool ContextifyContext::IsStillInitializing(const ContextifyContext* ctx) {
void ContextifyContext::PropertyGetterCallback(
Local<Name> property,
const PropertyCallbackInfo<Value>& args) {
@@ -35,7 +35,7 @@ index 8951cd378a9025f58fada47cf96f686d14639f95..6456d87d4202c013aafe071adbac0685
ContextifyContext* ctx = ContextifyContext::Get(args);
// Still initializing
@@ -494,6 +495,8 @@ void ContextifyContext::PropertyGetterCallback(
@@ -495,6 +496,8 @@ void ContextifyContext::PropertyGetterCallback(
Local<Context> context = ctx->context();
Local<Object> sandbox = ctx->sandbox();
@@ -44,7 +44,7 @@ index 8951cd378a9025f58fada47cf96f686d14639f95..6456d87d4202c013aafe071adbac0685
MaybeLocal<Value> maybe_rv =
sandbox->GetRealNamedProperty(context, property);
if (maybe_rv.IsEmpty()) {
@@ -503,6 +506,11 @@ void ContextifyContext::PropertyGetterCallback(
@@ -504,6 +507,11 @@ void ContextifyContext::PropertyGetterCallback(
Local<Value> rv;
if (maybe_rv.ToLocal(&rv)) {

View File

@@ -453,18 +453,18 @@ index d22281abbd5c3cab3aaa3ac494301fa6b4a8a968..5f0c6a4aed2e868a1a1049212edf2187
s.pipe(h).on('data', common.mustCall(function(c) {
assert.strictEqual(c, expect);
diff --git a/test/parallel/test-crypto-hash.js b/test/parallel/test-crypto-hash.js
index af2146982c7a3bf7bd7527f44e4b17a3b605026e..f6b91f675cfea367c608892dee078b565814f2dd 100644
index 8a946ac55adb00ccd6c7cdeb020e6aa137e1be8a..66d5b10f5fdd8e831793e208b7117dff5064e8d1 100644
--- a/test/parallel/test-crypto-hash.js
+++ b/test/parallel/test-crypto-hash.js
@@ -182,6 +182,7 @@ assert.throws(
@@ -183,6 +183,7 @@ assert.throws(
// Test XOF hash functions and the outputLength option.
{
+ /*
// Default outputLengths.
assert.strictEqual(crypto.createHash('shake128').digest('hex'),
'7f9c2ba4e88f827d616045507605853e');
@@ -236,6 +237,7 @@ assert.throws(
// Default outputLengths. Since OpenSSL 3.4 an outputLength is mandatory
if (!hasOpenSSL(3, 4)) {
assert.strictEqual(crypto.createHash('shake128').digest('hex'),
@@ -239,6 +240,7 @@ assert.throws(
assert.strictEqual(superLongHash.length, 2 * 1024 * 1024);
assert.ok(superLongHash.endsWith('193414035ddba77bf7bba97981e656ec'));
assert.ok(superLongHash.startsWith('a2a28dbc49cfd6e5d6ceea3d03e77748'));

View File

@@ -6,10 +6,10 @@ Subject: fix: do not resolve electron entrypoints
This wastes fs cycles and can result in strange behavior if this path actually exists on disk
diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
index 22248b753c14960122f1d6b9bfe6b89fdb8d2010..9d245a04fbcb98dcd1c61e60f7cfe528bd1c8af0 100644
index 41daab801d67689b50cc5e10a0e167701da301f8..227d31d19317ec94348c67029b407b3e534ab1b6 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -132,7 +132,7 @@ async function defaultLoad(url, context = kEmptyObject) {
@@ -134,7 +134,7 @@ async function defaultLoad(url, context = kEmptyObject) {
source = null;
format ??= 'builtin';
} else if (format !== 'commonjs' || defaultType === 'module') {
@@ -19,10 +19,10 @@ index 22248b753c14960122f1d6b9bfe6b89fdb8d2010..9d245a04fbcb98dcd1c61e60f7cfe528
context = { __proto__: context, source };
}
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index 9c9b403774e51e2f7e1201ad53e60e98fc3b26e8..477a3b2cf61fcaa154f01ac77c8047ef548ac1f8 100644
index 27cf7d0ae4a9e07897f8b1faef2884aec29d3975..6943c7973b4ae5246f4b019331c45aa9619eb017 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -375,6 +375,9 @@ function cjsPreparseModuleExports(filename, source) {
@@ -322,6 +322,9 @@ function cjsPreparseModuleExports(filename, source) {
if (module && module[kModuleExportNames] !== undefined) {
return { module, exportNames: module[kModuleExportNames] };
}
@@ -33,7 +33,7 @@ index 9c9b403774e51e2f7e1201ad53e60e98fc3b26e8..477a3b2cf61fcaa154f01ac77c8047ef
if (!loaded) {
module = new CJSModule(filename);
diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js
index 4ad694debfc72f56dd98a4e56dd0bbc63711242e..73f0e00ad34132e7d2fd37ec321110881e89617f 100644
index a22bddf635f5e6270554ac87f11f4e12f540a84c..b0543b4ca1ddcf289d9c4162e6641f0b4af8b7bd 100644
--- a/lib/internal/modules/run_main.js
+++ b/lib/internal/modules/run_main.js
@@ -2,6 +2,7 @@
@@ -43,8 +43,8 @@ index 4ad694debfc72f56dd98a4e56dd0bbc63711242e..73f0e00ad34132e7d2fd37ec32111088
+ StringPrototypeStartsWith,
} = primordials;
const { containsModuleSyntax } = internalBinding('contextify');
@@ -22,6 +23,13 @@ const {
const { getOptionValue } = require('internal/options');
@@ -21,6 +22,13 @@ const {
* @param {string} main - Entry point path
*/
function resolveMainPath(main) {
@@ -58,7 +58,7 @@ index 4ad694debfc72f56dd98a4e56dd0bbc63711242e..73f0e00ad34132e7d2fd37ec32111088
const defaultType = getOptionValue('--experimental-default-type');
/** @type {string} */
let mainPath;
@@ -58,6 +66,13 @@ function resolveMainPath(main) {
@@ -57,6 +65,13 @@ function resolveMainPath(main) {
* @param {string} mainPath - Absolute path to the main entry point
*/
function shouldUseESMLoader(mainPath) {

View File

@@ -6,10 +6,10 @@ Subject: fix: expose the built-in electron module via the ESM loader
This allows usage of `import { app } from 'electron'` and `import('electron')` natively in the browser + non-sandboxed renderer
diff --git a/lib/internal/modules/esm/get_format.js b/lib/internal/modules/esm/get_format.js
index 1fe5564545dbc86d7f2968274a25ee1579bcbf28..b876af21a0e97ae06dc344d9f78c8f5c7e403d43 100644
index fe7528e32a497c4ab8a08ac80f774576ec41b8ee..d01878eab8a2e1b353f861081e6ed8d4f11e6ffb 100644
--- a/lib/internal/modules/esm/get_format.js
+++ b/lib/internal/modules/esm/get_format.js
@@ -31,6 +31,7 @@ const protocolHandlers = {
@@ -32,6 +32,7 @@ const protocolHandlers = {
'http:': getHttpProtocolModuleFormat,
'https:': getHttpProtocolModuleFormat,
'node:'() { return 'builtin'; },
@@ -18,10 +18,10 @@ index 1fe5564545dbc86d7f2968274a25ee1579bcbf28..b876af21a0e97ae06dc344d9f78c8f5c
/**
diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
index 7b77af35a1dfebf6ad45ace521f1a55b5fa18293..ac24cf305bd5995ad13b37ee36f9e1fe3589c5d7 100644
index d5004f4495bacc5d231a84f340ecd389940a7ef7..7beac5f7b3ec96577e4fd3056e3a72456167a11d 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -142,7 +142,7 @@ async function defaultLoad(url, context = kEmptyObject) {
@@ -144,7 +144,7 @@ async function defaultLoad(url, context = kEmptyObject) {
// Now that we have the source for the module, run `defaultGetFormat` to detect its format.
format = await defaultGetFormat(urlInstance, context);
@@ -30,7 +30,7 @@ index 7b77af35a1dfebf6ad45ace521f1a55b5fa18293..ac24cf305bd5995ad13b37ee36f9e1fe
// For backward compatibility reasons, we need to discard the source in
// order for the CJS loader to re-fetch it.
source = null;
@@ -234,6 +234,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
@@ -226,6 +226,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
protocol !== 'file:' &&
protocol !== 'data:' &&
protocol !== 'node:' &&
@@ -38,7 +38,7 @@ index 7b77af35a1dfebf6ad45ace521f1a55b5fa18293..ac24cf305bd5995ad13b37ee36f9e1fe
(
!experimentalNetworkImports ||
(
@@ -242,7 +243,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
@@ -234,7 +235,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
)
)
) {
@@ -73,10 +73,10 @@ index 93c7a040fd47f050b10b949e4f619d85660110c8..77b85490b1a65b594bb140deb07b33f3
parsePackageName(specifier, base);
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index 044d820161a5f9809dd042be7e53b717de8678ab..5281d7c220c8adee0f3d7269a0116d082726ec91 100644
index 23c14e2ec6c85e36d7973a9918987127e3a08aee..0be9253a005790d9b106d456638a11a8499f9664 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -272,7 +272,7 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
@@ -226,7 +226,7 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
const { exportNames, module } = cjsPreparseModuleExports(filename, source);
cjsCache.set(url, module);
@@ -85,7 +85,7 @@ index 044d820161a5f9809dd042be7e53b717de8678ab..5281d7c220c8adee0f3d7269a0116d08
[...exportNames] : ['default', ...exportNames];
if (isMain) {
@@ -294,8 +294,8 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
@@ -248,8 +248,8 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
({ exports } = module);
}
for (const exportName of exportNames) {
@@ -96,7 +96,7 @@ index 044d820161a5f9809dd042be7e53b717de8678ab..5281d7c220c8adee0f3d7269a0116d08
continue;
}
// We might trigger a getter -> dont fail.
@@ -329,6 +329,10 @@ translators.set('require-commonjs', (url, source, isMain) => {
@@ -283,6 +283,10 @@ translators.set('require-commonjs', (url, source, isMain) => {
return createCJSModuleWrap(url, source);
});
@@ -106,9 +106,9 @@ index 044d820161a5f9809dd042be7e53b717de8678ab..5281d7c220c8adee0f3d7269a0116d08
+
// Handle CommonJS modules referenced by `import` statements or expressions,
// or as the initial entry point when the ESM loader handles a CommonJS entry.
translators.set('commonjs', async function commonjsStrategy(url, source,
translators.set('commonjs', function commonjsStrategy(url, source, isMain) {
diff --git a/lib/internal/url.js b/lib/internal/url.js
index 42debfc20005b0d293e5507546dcd8caec2b6a4e..4b6d07b14bd92ac527b7f4bd55ff7005967cee7d 100644
index 91976bceb0db19adceaad566a05eb5ea29e7d3bc..4fdecccdde5174f516e6077ccad71584d4b91717 100644
--- a/lib/internal/url.js
+++ b/lib/internal/url.js
@@ -1485,6 +1485,8 @@ function fileURLToPath(path, options = kEmptyObject) {

View File

@@ -109,7 +109,7 @@ index 85d48dfd2c15c453707bf6eb94e22f89b4f856b2..fe31a9a7f465a03d2de365cef392dfbb
crypto::EVPKeyPointer key(raw_key);
diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc
index cef0c877c67643d47da787eddb95ed5a410a941b..1b8af49a48f1a34a92d4f0b502d435f3a4ab5d8e 100644
index dab6cf87a0809fe10db3a7c9664815d8dc091c2d..ad0652fa775373142301e1564c33fa52c3be7ad6 100644
--- a/src/crypto/crypto_context.cc
+++ b/src/crypto/crypto_context.cc
@@ -63,7 +63,7 @@ inline X509_STORE* GetOrCreateRootCertStore() {
@@ -121,7 +121,7 @@ index cef0c877c67643d47da787eddb95ed5a410a941b..1b8af49a48f1a34a92d4f0b502d435f3
if (!bio) return nullptr;
ByteSource bsrc = ByteSource::FromStringOrBuffer(env, v);
if (bsrc.size() > INT_MAX) return nullptr;
@@ -882,10 +882,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
@@ -883,10 +883,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
// If the user specified "auto" for dhparams, the JavaScript layer will pass
// true to this function instead of the original string. Any other string
// value will be interpreted as custom DH parameters below.
@@ -353,7 +353,7 @@ index 990638ec3993bde40ad3dd40d373d816ebc66a6a..63d971e1fe6b861e29c12f04563701b0
} // namespace
diff --git a/src/env.h b/src/env.h
index 2ec0a56e05ff879df8c55bf140677e571a56fafa..a30c25a3a61dfe73944731760404c555f2782d72 100644
index 598082f68aefe29fc31beeb70167225e8b3cf25e..d5eb12ebaeaf95c57e91261151aeb382c7620afd 100644
--- a/src/env.h
+++ b/src/env.h
@@ -49,7 +49,7 @@
@@ -375,7 +375,7 @@ index 2ec0a56e05ff879df8c55bf140677e571a56fafa..a30c25a3a61dfe73944731760404c555
// We declare another alias here to avoid having to include crypto_util.h
using EVPMDPointer = DeleteFnPtr<EVP_MD, EVP_MD_free>;
diff --git a/src/node_metadata.h b/src/node_metadata.h
index cf051585e779e2b03bd7b95fe5008b89cc7f8162..9de49c6828468fdf846dcd4ad445390f14446099 100644
index 3628a9d04aa65f637cda27763d39dc4b16a939a3..b53f24c74d9c5de9bd716c441941aaac0bd703b6 100644
--- a/src/node_metadata.h
+++ b/src/node_metadata.h
@@ -6,7 +6,7 @@
@@ -388,7 +388,7 @@ index cf051585e779e2b03bd7b95fe5008b89cc7f8162..9de49c6828468fdf846dcd4ad445390f
#if NODE_OPENSSL_HAS_QUIC
#include <openssl/quic.h>
diff --git a/src/node_options.cc b/src/node_options.cc
index f6ff810953b224b7e343d91e1065d95bc3e78d39..b7ef44b018c7aec59d8311642a811d1280247689 100644
index 9d5accc3ebc4165f23f8cd0373c061df24ce49a6..7a937d4b6559fe9d616f9540591f69610fa5d9d7 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -6,7 +6,7 @@
@@ -401,7 +401,7 @@ index f6ff810953b224b7e343d91e1065d95bc3e78d39..b7ef44b018c7aec59d8311642a811d12
#endif
diff --git a/src/node_options.h b/src/node_options.h
index 10c220f66122336215f25b9674acfdfe6df82a8e..e8b2243d24fe95ff31254071133fb646e186c07e 100644
index f7a5654a5cfcaa053a2f0e46a1dfc346e998f0b3..9bb0375cede24811b2190a775f49a56ecbe29933 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -11,7 +11,7 @@

View File

@@ -6,10 +6,10 @@ Subject: fix: lazyload fs in esm loaders to apply asar patches
Changes { foo } from fs to just "fs.foo" so that our patching of fs is applied to esm loaders
diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
index ac24cf305bd5995ad13b37ee36f9e1fe3589c5d7..22248b753c14960122f1d6b9bfe6b89fdb8d2010 100644
index 7beac5f7b3ec96577e4fd3056e3a72456167a11d..41daab801d67689b50cc5e10a0e167701da301f8 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -10,7 +10,7 @@ const { kEmptyObject } = require('internal/util');
@@ -12,7 +12,7 @@ const {
const { defaultGetFormat } = require('internal/modules/esm/get_format');
const { validateAttributes, emitImportAssertionWarning } = require('internal/modules/esm/assert');
const { getOptionValue } = require('internal/options');
@@ -18,7 +18,7 @@ index ac24cf305bd5995ad13b37ee36f9e1fe3589c5d7..22248b753c14960122f1d6b9bfe6b89f
// Do not eagerly grab .manifest, it may be in TDZ
const policy = getOptionValue('--experimental-policy') ?
@@ -42,8 +42,7 @@ async function getSource(url, context) {
@@ -44,8 +44,7 @@ async function getSource(url, context) {
let responseURL = href;
let source;
if (protocol === 'file:') {
@@ -28,7 +28,7 @@ index ac24cf305bd5995ad13b37ee36f9e1fe3589c5d7..22248b753c14960122f1d6b9bfe6b89f
} else if (protocol === 'data:') {
const match = RegExpPrototypeExec(DATA_URL_PATTERN, url.pathname);
if (!match) {
@@ -82,7 +81,7 @@ function getSourceSync(url, context) {
@@ -84,7 +83,7 @@ function getSourceSync(url, context) {
const responseURL = href;
let source;
if (protocol === 'file:') {
@@ -78,10 +78,10 @@ index 77b85490b1a65b594bb140deb07b33f3accc9736..da99cc2d4ca930222ca018ddf42ee2e5
// Check for !stat.isDirectory()
if (stat !== 1) {
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index 5281d7c220c8adee0f3d7269a0116d082726ec91..9c9b403774e51e2f7e1201ad53e60e98fc3b26e8 100644
index 0be9253a005790d9b106d456638a11a8499f9664..27cf7d0ae4a9e07897f8b1faef2884aec29d3975 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -36,7 +36,7 @@ const {
@@ -33,7 +33,7 @@ const {
const { BuiltinModule } = require('internal/bootstrap/realm');
const assert = require('internal/assert');
@@ -90,7 +90,7 @@ index 5281d7c220c8adee0f3d7269a0116d082726ec91..9c9b403774e51e2f7e1201ad53e60e98
const { dirname, extname, isAbsolute } = require('path');
const {
loadBuiltinModule,
@@ -356,7 +356,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
@@ -304,7 +304,7 @@ translators.set('commonjs', function commonjsStrategy(url, source, isMain) {
try {
// We still need to read the FS to detect the exports.
@@ -99,7 +99,7 @@ index 5281d7c220c8adee0f3d7269a0116d082726ec91..9c9b403774e51e2f7e1201ad53e60e98
} catch {
// Continue regardless of error.
}
@@ -424,7 +424,7 @@ function cjsPreparseModuleExports(filename, source) {
@@ -371,7 +371,7 @@ function cjsPreparseModuleExports(filename, source) {
isAbsolute(resolved)) {
// TODO: this should be calling the `load` hook chain to get the source
// (and fallback to reading the FS only if the source is nullish).

View File

@@ -86,10 +86,10 @@ index 149c7c107322919dfeea1dfe89dc223f78b0e979..e4e8dac6b8b5924a7eae83935031e091
NODE_DEFINE_CONSTANT(target, ETIMEDOUT);
#endif
diff --git a/src/node_errors.cc b/src/node_errors.cc
index 69e474257b0427f894375fbc8a2c031f1b8e0c55..f0e968c0dfa8963404c3b87827b8d11a139051cc 100644
index 52c0179845fdad1b605e372d9ad132f2355b162d..12c20ba1bebc22b34950f6d016a9e1f20c822044 100644
--- a/src/node_errors.cc
+++ b/src/node_errors.cc
@@ -855,10 +855,6 @@ const char* errno_string(int errorno) {
@@ -860,10 +860,6 @@ const char* errno_string(int errorno) {
ERRNO_CASE(ENOBUFS);
#endif
@@ -100,7 +100,7 @@ index 69e474257b0427f894375fbc8a2c031f1b8e0c55..f0e968c0dfa8963404c3b87827b8d11a
#ifdef ENODEV
ERRNO_CASE(ENODEV);
#endif
@@ -897,14 +893,6 @@ const char* errno_string(int errorno) {
@@ -902,14 +898,6 @@ const char* errno_string(int errorno) {
ERRNO_CASE(ENOSPC);
#endif
@@ -115,7 +115,7 @@ index 69e474257b0427f894375fbc8a2c031f1b8e0c55..f0e968c0dfa8963404c3b87827b8d11a
#ifdef ENOSYS
ERRNO_CASE(ENOSYS);
#endif
@@ -987,10 +975,6 @@ const char* errno_string(int errorno) {
@@ -992,10 +980,6 @@ const char* errno_string(int errorno) {
ERRNO_CASE(ESTALE);
#endif

View File

@@ -142,7 +142,7 @@ index da99cc2d4ca930222ca018ddf42ee2e5f898576a..34631a1f4ffea33ba520874e6571054d
const encodedSepRegEx = /%2F|%5C/i;
diff --git a/src/node_file.cc b/src/node_file.cc
index 73ad5a1a2c092d7f8dac84585fb9b13e76e84e13..039f693de14bec248f93262ad70f2736c24827e3 100644
index 39a70311f4ad212ee855d73f45232d3f21250ef4..9fd1fb88cd528a68c0cc85db972df4b948108e63 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -19,14 +19,11 @@

View File

@@ -6,10 +6,10 @@ Subject: Pass all globals through "require"
(cherry picked from commit 7d015419cb7a0ecfe6728431a4ed2056cd411d62)
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index c284b39b1ac13eaea8776b7b4f457c084dce5fb8..c794751ecd4448119ce33d661e694f83b3323f03 100644
index ebccdb28256314e7cd8ac8d7e3dec670286022d2..7b5958ef2c32101629d800991ff0ad32fe5c5695 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -185,6 +185,13 @@ const {
@@ -188,6 +188,13 @@ const {
CHAR_FORWARD_SLASH,
} = require('internal/constants');
@@ -23,18 +23,18 @@ index c284b39b1ac13eaea8776b7b4f457c084dce5fb8..c794751ecd4448119ce33d661e694f83
const {
isProxy,
} = require('internal/util/types');
@@ -1464,10 +1471,12 @@ Module.prototype._compile = function(content, filename, loadAsESM = false) {
this[kIsExecuting] = true;
if (inspectorWrapper) {
result = inspectorWrapper(compiledWrapper, thisValue, exports,
- require, module, filename, dirname);
+ require, module, filename, dirname,
+ process, localGlobal, localBuffer);
@@ -1524,10 +1531,12 @@ Module.prototype._compile = function(content, filename, format) {
if (this[kIsMainSymbol] && getOptionValue('--inspect-brk')) {
const { callAndPauseOnStart } = internalBinding('inspector');
result = callAndPauseOnStart(compiledWrapper, thisValue, exports,
- require, module, filename, dirname);
+ require, module, filename, dirname,
+ process, localGlobal, localBuffer);
} else {
result = ReflectApply(compiledWrapper, thisValue,
- [exports, require, module, filename, dirname]);
+ [exports, require, module, filename,
+ dirname, process, localGlobal, localBuffer]);
+ [exports, require, module, filename, dirname,
+ process, localGlobal, localBuffer]);
}
this[kIsExecuting] = false;
if (requireDepth === 0) { statCache = null; }

View File

@@ -7,7 +7,7 @@ We use this to allow node's 'fs' module to read from ASAR files as if they were
a real filesystem.
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 12262f40ce123440a9a0f974386cfbe8511f4459..f3c15b61d33bdae44de528e106fcc6f930f1c388 100644
index 2b12f9fb2966de350432ae63e411c88774a026a4..deb3decfe03925762228d689be20dbd6ebdb975b 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -134,6 +134,10 @@ process.domain = null;
@@ -22,10 +22,10 @@ index 12262f40ce123440a9a0f974386cfbe8511f4459..f3c15b61d33bdae44de528e106fcc6f9
const binding = internalBinding('builtins');
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index c794751ecd4448119ce33d661e694f83b3323f03..364469160af5e348f8890417de16a63c0d1dca67 100644
index 7b5958ef2c32101629d800991ff0ad32fe5c5695..82a3b80f6ffe8bf484d00f7898572dbf27918461 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -138,7 +138,7 @@ const {
@@ -141,7 +141,7 @@ const {
const assert = require('internal/assert');
const fs = require('fs');
const path = require('path');
@@ -34,7 +34,7 @@ index c794751ecd4448119ce33d661e694f83b3323f03..364469160af5e348f8890417de16a63c
const { safeGetenv } = internalBinding('credentials');
const {
privateSymbols: {
@@ -233,7 +233,7 @@ function stat(filename) {
@@ -236,7 +236,7 @@ function stat(filename) {
const result = statCache.get(filename);
if (result !== undefined) { return result; }
}

View File

@@ -146,7 +146,7 @@ index ca75e0360bbf6a20ea18e67dda167d5ec523b075..158b96a9b1ea5553fa74d2429152a5c9
void IsolateData::MemoryInfo(MemoryTracker* tracker) const {
diff --git a/src/env.h b/src/env.h
index a30c25a3a61dfe73944731760404c555f2782d72..6137551bb8168d8fa9a3e6bc79c3d1e79b306931 100644
index d5eb12ebaeaf95c57e91261151aeb382c7620afd..aea955e490ede3cba37eb1b484b1f3323aa4a1f6 100644
--- a/src/env.h
+++ b/src/env.h
@@ -174,10 +174,6 @@ class NODE_EXTERN_PRIVATE IsolateData : public MemoryRetainer {

View File

@@ -6,10 +6,10 @@ Subject: src: use supported API to get stalled TLA messages
Refs: https://github.com/v8/v8/commit/23e3b6f650162ed2b332e55aa802adb8f41b50f2
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index 9bbb8ab908d8d992abb43254860d51f57f56387b..92edfc6fc6401edd3685a0137eac25d9e37566f6 100644
index 094d12ffe99500af700a591f5cb33e7d7b247ed1..0b88c84601a32181deb3245edb9c4a93e47e8222 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -587,11 +587,10 @@ void ModuleWrap::EvaluateSync(const FunctionCallbackInfo<Value>& args) {
@@ -635,11 +635,10 @@ void ModuleWrap::EvaluateSync(const FunctionCallbackInfo<Value>& args) {
if (module->IsGraphAsync()) {
CHECK(env->options()->print_required_tla);

View File

@@ -28,7 +28,7 @@ index a7860449225092529e1a262aed3f30fb21212e9d..1a55ea53c602b3fede260fffc173dfab
test-net-write-fully-async-hex-string: PASS, FLAKY
# https://github.com/nodejs/node/issues/52273
diff --git a/test/sequential/sequential.status b/test/sequential/sequential.status
index dd2275ddc9540464d838476f998cea683d5ceccc..796e3c56174d9cd2b9d3969150d9605b32c46f0b 100644
index a3199b385dd99de57ac0fc25b1b3ecfebfcb5e61..725457846899583698ae37a8ba6088c694b09053 100644
--- a/test/sequential/sequential.status
+++ b/test/sequential/sequential.status
@@ -7,6 +7,18 @@ prefix sequential

View File

@@ -0,0 +1,84 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Tue, 1 Apr 2025 09:16:56 +0000
Subject: test: make eval snapshot tests more flexible
Upstreamed in https://github.com/nodejs/node/pull/57020
diff --git a/test/fixtures/eval/eval_messages.snapshot b/test/fixtures/eval/eval_messages.snapshot
index 6a37ad2263461796c2c6a55f21b35b49302021b4..d844c4a4dacf73259a864f4fd8dc9df072046452 100644
--- a/test/fixtures/eval/eval_messages.snapshot
+++ b/test/fixtures/eval/eval_messages.snapshot
@@ -62,7 +62,7 @@ Node.js *
var ______________________________________________; throw 10
^
10
-(Use `node --trace-uncaught ...` to show where the exception was thrown)
+(Use `* --trace-uncaught ...` to show where the exception was thrown)
Node.js *
@@ -70,7 +70,7 @@ Node.js *
var ______________________________________________; throw 10
^
10
-(Use `node --trace-uncaught ...` to show where the exception was thrown)
+(Use `* --trace-uncaught ...` to show where the exception was thrown)
Node.js *
done
diff --git a/test/fixtures/eval/stdin_messages.snapshot b/test/fixtures/eval/stdin_messages.snapshot
index 3c03bd64072061bd78b0424becc0f2ce960ca34b..89f2cd87b31b16d698e06cc5da18b17f7fd153e9 100644
--- a/test/fixtures/eval/stdin_messages.snapshot
+++ b/test/fixtures/eval/stdin_messages.snapshot
@@ -75,7 +75,7 @@ Node.js *
let ______________________________________________; throw 10
^
10
-(Use `node --trace-uncaught ...` to show where the exception was thrown)
+(Use `* --trace-uncaught ...` to show where the exception was thrown)
Node.js *
@@ -83,7 +83,7 @@ Node.js *
let ______________________________________________; throw 10
^
10
-(Use `node --trace-uncaught ...` to show where the exception was thrown)
+(Use `* --trace-uncaught ...` to show where the exception was thrown)
Node.js *
done
diff --git a/test/parallel/test-node-output-eval.mjs b/test/parallel/test-node-output-eval.mjs
index 2fa60206e1ea1c1ba14ea2b6822e06e36bb856f9..2be134747842da25795cab50adb5d1956abda1eb 100644
--- a/test/parallel/test-node-output-eval.mjs
+++ b/test/parallel/test-node-output-eval.mjs
@@ -1,6 +1,7 @@
import '../common/index.mjs';
import * as fixtures from '../common/fixtures.mjs';
import * as snapshot from '../common/assertSnapshot.js';
+import { basename } from 'node:path';
import { describe, it } from 'node:test';
describe('eval output', { concurrency: true }, () => {
@@ -14,13 +15,19 @@ describe('eval output', { concurrency: true }, () => {
normalize,
snapshot.replaceWindowsLineEndings,
snapshot.replaceWindowsPaths,
- snapshot.replaceNodeVersion
+ snapshot.replaceNodeVersion,
+ generalizeProcessName,
);
function removeStackTraces(output) {
return output.replaceAll(/^ *at .+$/gm, '');
}
+ function generalizeProcessName(output) {
+ const baseName = basename(process.argv0 || 'node', '.exe');
+ return output.replaceAll(`${baseName} --`, '* --');
+ }
+
const tests = [
{ name: 'eval/eval_messages.js' },
{ name: 'eval/stdin_messages.js' },

View File

@@ -1,3 +1,5 @@
chore_allow_customizing_microtask_policy_per_context.patch
deps_add_v8_object_setinternalfieldfornodecore.patch
revert_fastapi_promote_deprecation_of_fastapitypedarray.patch
cherry-pick-2b4812d502b2.patch
cherry-pick-91343bb45c78.patch

View File

@@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Olivier=20Fl=C3=BCckiger?= <olivf@chromium.org>
Date: Thu, 27 Feb 2025 09:19:22 +0100
Subject: merged: [maglev] Add missing ClearAllocationBlock
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixed: 398065918
(cherry picked from commit eb9b25970b0ad4a3f8ce23d8de3583c62e5d6b87)
Change-Id: I20f3979984c1df11509f1630cf4c4c4460d6a83a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6304712
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Auto-Submit: Olivier Flückiger <olivf@chromium.org>
Commit-Queue: Olivier Flückiger <olivf@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/branch-heads/13.4@{#29}
Cr-Branched-From: 0f87a54dade4353b6ece1d7591ca8c66f90c1c93-refs/heads/13.4.114@{#1}
Cr-Branched-From: 27af2e9363b2701abc5f3feb701b1dad7d1a9fe8-refs/heads/main@{#98459}
diff --git a/src/maglev/maglev-graph-builder.cc b/src/maglev/maglev-graph-builder.cc
index 28032bb9d9202e0649adaf8d8120e76a5ac10f68..f0ea889c4ce81846ac4f44cb0f50cb65749f0fe8 100644
--- a/src/maglev/maglev-graph-builder.cc
+++ b/src/maglev/maglev-graph-builder.cc
@@ -12171,7 +12171,13 @@ ValueNode* MaglevGraphBuilder::BuildInlinedAllocation(
CreateHeapNumber(node->Cast<Float64Constant>()->value()),
allocation_type);
} else {
- node = GetTaggedValue(node);
+ ValueNode* new_node = GetTaggedValue(node);
+ if (new_node != node && new_node->properties().can_allocate()) {
+ // TODO(olivf): Remove this and instead always clear when we
+ // emit an allocating instruction.
+ ClearCurrentAllocationBlock();
+ }
+ node = new_node;
}
values[i] = node;
}

View File

@@ -0,0 +1,47 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Darius Mercadier <dmercadier@chromium.org>
Date: Tue, 18 Feb 2025 09:32:04 +0100
Subject: Disable escape analysis for TrustedHeapConstant
More precisely: prevent eliding objects that contain
TrustedHeapConstant, because it can lead to this constant flowing into
a Phis where other inputs are regular HeapConstant, which confuses
decompression optimization and leads to memory corruption.
(cherry picked from commit b75e527fb521dca5e7621928846c0c7c6becc8dd)
Fixed: chromium:390743124
Change-Id: Ic60e4d7dd156367f7d4bb385d422591384c3033c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6278358
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
Auto-Submit: Darius Mercadier <dmercadier@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#98748}
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6317725
Reviewed-by: Darius Mercadier <dmercadier@chromium.org>
Commit-Queue: Gyuyoung Kim (xWF) <qkim@google.com>
Cr-Commit-Position: refs/branch-heads/13.2@{#82}
Cr-Branched-From: 24068c59cedad9ee976ddc05431f5f497b1ebd71-refs/heads/13.2.152@{#1}
Cr-Branched-From: 6054ba94db0969220be4f94dc1677fc4696bdc4f-refs/heads/main@{#97085}
diff --git a/src/compiler/escape-analysis.cc b/src/compiler/escape-analysis.cc
index eb223bc9113b0af22a61c81c879c1ef5a9ec9ba8..c9a7bc999a7163d4b034c9a3b9ab610766f39ea6 100644
--- a/src/compiler/escape-analysis.cc
+++ b/src/compiler/escape-analysis.cc
@@ -622,6 +622,16 @@ void ReduceNode(const Operator* op, EscapeAnalysisTracker::Scope* current,
Node* value = current->ValueInput(1);
const VirtualObject* vobject = current->GetVirtualObject(object);
Variable var;
+ if (value->opcode() == IrOpcode::kTrustedHeapConstant) {
+ // TODO(dmercadier): enable escaping objects containing
+ // TrustedHeapConstants. This is currently disabled because it leads to
+ // bugs when Trusted HeapConstant and regular HeapConstant flow into the
+ // same Phi, which can then be marked as Compressed, messing up the
+ // tagging of the Trusted HeapConstant.
+ current->SetEscaped(object);
+ current->SetEscaped(value);
+ break;
+ }
// BoundedSize fields cannot currently be materialized by the deoptimizer,
// so we must not dematerialze them.
if (vobject && !vobject->HasEscaped() &&

View File

@@ -2,23 +2,31 @@ const { appCredentialsFromString, getTokenForRepo } = require('@electron/github-
const cp = require('node:child_process');
const { PATCH_UP_APP_CREDS } = process.env;
async function main () {
if (!PATCH_UP_APP_CREDS) {
throw new Error('PATCH_UP_APP_CREDS environment variable not set');
}
const token = await getTokenForRepo(
{
name: 'electron',
owner: 'electron'
},
appCredentialsFromString(process.env.PATCH_UP_APP_CREDS)
appCredentialsFromString(PATCH_UP_APP_CREDS)
);
const remoteURL = `https://x-access-token:${token}@github.com/electron/electron.git`;
// NEVER LOG THE OUTPUT OF THIS COMMAND
// GIT LEAKS THE ACCESS CREDENTIALS IN CONSOLE LOGS
const { status } = cp.spawnSync('git', ['push', '--set-upstream', remoteURL], {
stdio: 'ignore'
});
if (status !== 0) {
console.error('Failed to push to target branch');
process.exit(1);
throw new Error('Failed to push to target branch');
}
}

View File

@@ -1,14 +1,14 @@
{
"bullseye_amd64": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "7c93e71bf9c4cd0825aa59fb2479054d981e36ba9be34ecf4c1d73051cae40fe",
"Sha256Sum": "0be326b106f0df7b8547ec8d3b58ccb95435c8414a45cda675c4805821d4d860",
"SysrootDir": "debian_bullseye_amd64-sysroot",
"Tarball": "debian_bullseye_amd64_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"
},
"bullseye_arm64": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "d649177e37aef2c043e54e670e42934f18558c0e730c1b854719ca7463e2b1eb",
"Sha256Sum": "1225cd518c1609e54033bb6a1c687875d4f4c21b2dbd5d5d81c4b5927d0fc0f1",
"SysrootDir": "debian_bullseye_arm64-sysroot",
"Tarball": "debian_bullseye_arm64_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"
@@ -22,28 +22,28 @@
},
"bullseye_armhf": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "fe3b9203e30e70f533776d565501bc1e3d4ebf6eeb909b2c2bfca0df807e1be0",
"Sha256Sum": "ed5a71ce5fc6d1691817c3b203139328ee88395c9e54ff726f67c84ee1561e65",
"SysrootDir": "debian_bullseye_armhf-sysroot",
"Tarball": "debian_bullseye_armhf_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"
},
"bullseye_i386": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "4efcb1870129da1ad5c3b634903a4efcc0ca9abd67dd5a993cca144ea9b5d31f",
"Sha256Sum": "57f800042b0c4bd00a8755da165823cc70decc0481b78d751924db7470af6b5e",
"SysrootDir": "debian_bullseye_i386-sysroot",
"Tarball": "debian_bullseye_i386_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"
},
"bullseye_mips64el": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "c3a3bf3b0aa40ec90747c951942d40077ff6796b336818eaba6fa21564249a00",
"Sha256Sum": "187b8644a949d0124cb00fa099a8a5842e9a88bb48d8d1c682604ebf546796b7",
"SysrootDir": "debian_bullseye_mips64el-sysroot",
"Tarball": "debian_bullseye_mips64el_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"
},
"bullseye_mipsel": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "564de884ed1810e1cf3a20d94edfa21972ac2be9568bf1526d093c31f15ef225",
"Sha256Sum": "f08771dc7a813e7f0fd540b49a1b611416979630b0009e9ecc51f999a7543081",
"SysrootDir": "debian_bullseye_mipsel-sysroot",
"Tarball": "debian_bullseye_mipsel_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"

View File

@@ -6,7 +6,6 @@
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/command_line.h"

View File

@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include <cstdlib>
#include <utility>
#include "base/at_exit.h"
#include "base/command_line.h"

View File

@@ -14,7 +14,6 @@
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/at_exit.h"
#include "base/debug/alias.h"

View File

@@ -90,7 +90,10 @@
#if BUILDFLAG(IS_MAC)
#include <CoreFoundation/CoreFoundation.h>
#include "base/no_destructor.h"
#include "content/browser/mac_helpers.h"
#include "shell/browser/ui/cocoa/electron_bundle_mover.h"
#include "shell/common/process_util.h"
#endif
#if BUILDFLAG(IS_LINUX)
@@ -161,7 +164,7 @@ struct Converter<JumpListItem::Type> {
if (item_val == val)
return gin::ConvertToV8(isolate, name);
return gin::ConvertToV8(isolate, "");
return v8::String::Empty(isolate);
}
private:
@@ -252,7 +255,7 @@ struct Converter<JumpListCategory::Type> {
if (type_val == val)
return gin::ConvertToV8(isolate, name);
return gin::ConvertToV8(isolate, "");
return v8::String::Empty(isolate);
}
private:
@@ -898,6 +901,21 @@ bool App::IsPackaged() {
#if BUILDFLAG(IS_WIN)
return base_name != FILE_PATH_LITERAL("electron.exe");
#elif BUILDFLAG(IS_MAC)
static const base::NoDestructor<std::string> default_helper(
"electron helper" +
base::ToLowerASCII(content::kMacHelperSuffix_default));
static const base::NoDestructor<std::string> renderer_helper(
"electron helper" +
base::ToLowerASCII(content::kMacHelperSuffix_renderer));
static const base::NoDestructor<std::string> plugin_helper(
"electron helper" + base::ToLowerASCII(content::kMacHelperSuffix_plugin));
if (IsRendererProcess()) {
return base_name != *renderer_helper;
} else if (IsUtilityProcess()) {
return base_name != *default_helper && base_name != *plugin_helper;
}
return base_name != FILE_PATH_LITERAL("electron");
#else
return base_name != FILE_PATH_LITERAL("electron");
#endif

View File

@@ -326,8 +326,9 @@ void DesktopCapturer::StartHandling(bool capture_window,
window_capturer_->SetThumbnailSize(thumbnail_size);
#if BUILDFLAG(IS_MAC)
window_capturer_->skip_next_refresh_ =
ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kWindow) ? 2
: 0;
ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kWindow)
? thumbnail_size.IsEmpty() ? 1 : 2
: 0;
#endif
OnceCallback update_callback = base::BindOnce(
@@ -356,8 +357,9 @@ void DesktopCapturer::StartHandling(bool capture_window,
screen_capturer_->SetThumbnailSize(thumbnail_size);
#if BUILDFLAG(IS_MAC)
screen_capturer_->skip_next_refresh_ =
ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kScreen) ? 2
: 0;
ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kScreen)
? thumbnail_size.IsEmpty() ? 1 : 2
: 0;
#endif
OnceCallback update_callback = base::BindOnce(

View File

@@ -14,7 +14,6 @@
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "shell/browser/browser.h"
#include "shell/browser/electron_browser_context.h"
#include "shell/browser/protocol_registry.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/net_converter.h"
@@ -194,41 +193,39 @@ const char* const kBuiltinSchemes[] = {
"about", "file", "http", "https", "data", "filesystem",
};
} // namespace
Protocol::Protocol(ProtocolRegistry* protocol_registry)
: protocol_registry_{protocol_registry} {}
// Convert error code to string.
constexpr std::string_view ErrorCodeToString(ProtocolError error) {
// static
std::string_view Protocol::ErrorCodeToString(Error error) {
switch (error) {
case ProtocolError::kRegistered:
case Error::kRegistered:
return "The scheme has been registered";
case ProtocolError::kNotRegistered:
case Error::kNotRegistered:
return "The scheme has not been registered";
case ProtocolError::kIntercepted:
case Error::kIntercepted:
return "The scheme has been intercepted";
case ProtocolError::kNotIntercepted:
case Error::kNotIntercepted:
return "The scheme has not been intercepted";
default:
return "Unexpected error";
}
}
} // namespace
Protocol::Protocol(v8::Isolate* isolate, ProtocolRegistry* protocol_registry)
: protocol_registry_(protocol_registry) {}
Protocol::~Protocol() = default;
ProtocolError Protocol::RegisterProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
Protocol::Error Protocol::RegisterProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
bool added = protocol_registry_->RegisterProtocol(type, scheme, handler);
return added ? ProtocolError::kOK : ProtocolError::kRegistered;
return added ? Error::kOK : Error::kRegistered;
}
bool Protocol::UnregisterProtocol(const std::string& scheme,
gin::Arguments* args) {
bool removed = protocol_registry_->UnregisterProtocol(scheme);
HandleOptionalCallback(
args, removed ? ProtocolError::kOK : ProtocolError::kNotRegistered);
HandleOptionalCallback(args, removed ? Error::kOK : Error::kNotRegistered);
return removed;
}
@@ -236,18 +233,17 @@ bool Protocol::IsProtocolRegistered(const std::string& scheme) {
return protocol_registry_->FindRegistered(scheme) != nullptr;
}
ProtocolError Protocol::InterceptProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
Protocol::Error Protocol::InterceptProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
bool added = protocol_registry_->InterceptProtocol(type, scheme, handler);
return added ? ProtocolError::kOK : ProtocolError::kIntercepted;
return added ? Error::kOK : Error::kIntercepted;
}
bool Protocol::UninterceptProtocol(const std::string& scheme,
gin::Arguments* args) {
bool removed = protocol_registry_->UninterceptProtocol(scheme);
HandleOptionalCallback(
args, removed ? ProtocolError::kOK : ProtocolError::kNotIntercepted);
HandleOptionalCallback(args, removed ? Error::kOK : Error::kNotIntercepted);
return removed;
}
@@ -275,15 +271,14 @@ v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme,
base::Contains(kBuiltinSchemes, scheme));
}
void Protocol::HandleOptionalCallback(gin::Arguments* args,
ProtocolError error) {
void Protocol::HandleOptionalCallback(gin::Arguments* args, Error error) {
base::RepeatingCallback<void(v8::Local<v8::Value>)> callback;
if (args->GetNext(&callback)) {
util::EmitWarning(
args->isolate(),
"The callback argument of protocol module APIs is no longer needed.",
"ProtocolDeprecateCallback");
if (error == ProtocolError::kOK)
if (error == Error::kOK)
callback.Run(v8::Null(args->isolate()));
else
callback.Run(v8::Exception::Error(
@@ -292,11 +287,9 @@ void Protocol::HandleOptionalCallback(gin::Arguments* args,
}
// static
gin::Handle<Protocol> Protocol::Create(
v8::Isolate* isolate,
ElectronBrowserContext* browser_context) {
return gin::CreateHandle(
isolate, new Protocol(isolate, browser_context->protocol_registry()));
gin::Handle<Protocol> Protocol::Create(v8::Isolate* isolate,
ProtocolRegistry* protocol_registry) {
return gin::CreateHandle(isolate, new Protocol{protocol_registry});
}
// static

View File

@@ -22,7 +22,6 @@ class Handle;
namespace electron {
class ElectronBrowserContext;
class ProtocolRegistry;
namespace api {
@@ -35,21 +34,12 @@ void AddServiceWorkerScheme(const std::string& scheme);
void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> val);
// Possible errors.
enum class ProtocolError {
kOK, // no error
kRegistered,
kNotRegistered,
kIntercepted,
kNotIntercepted,
};
// Protocol implementation based on network services.
class Protocol final : public gin::Wrappable<Protocol>,
public gin_helper::Constructible<Protocol> {
public:
static gin::Handle<Protocol> Create(v8::Isolate* isolate,
ElectronBrowserContext* browser_context);
ProtocolRegistry* protocol_registry);
// gin_helper::Constructible
static gin::Handle<Protocol> New(gin_helper::ErrorThrower thrower);
@@ -63,23 +53,34 @@ class Protocol final : public gin::Wrappable<Protocol>,
const char* GetTypeName() override;
private:
Protocol(v8::Isolate* isolate, ProtocolRegistry* protocol_registry);
~Protocol() override;
// Possible errors.
enum class Error {
kOK, // no error
kRegistered,
kNotRegistered,
kIntercepted,
kNotIntercepted,
};
// Callback types.
using CompletionCallback =
base::RepeatingCallback<void(v8::Local<v8::Value>)>;
explicit Protocol(ProtocolRegistry* protocol_registry);
~Protocol() override = default;
[[nodiscard]] static std::string_view ErrorCodeToString(Error error);
// JS APIs.
ProtocolError RegisterProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler);
Error RegisterProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler);
bool UnregisterProtocol(const std::string& scheme, gin::Arguments* args);
bool IsProtocolRegistered(const std::string& scheme);
ProtocolError InterceptProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler);
Error InterceptProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler);
bool UninterceptProtocol(const std::string& scheme, gin::Arguments* args);
bool IsProtocolIntercepted(const std::string& scheme);
@@ -92,21 +93,21 @@ class Protocol final : public gin::Wrappable<Protocol>,
bool RegisterProtocolFor(const std::string& scheme,
const ProtocolHandler& handler,
gin::Arguments* args) {
auto result = RegisterProtocol(type, scheme, handler);
const auto result = RegisterProtocol(type, scheme, handler);
HandleOptionalCallback(args, result);
return result == ProtocolError::kOK;
return result == Error::kOK;
}
template <ProtocolType type>
bool InterceptProtocolFor(const std::string& scheme,
const ProtocolHandler& handler,
gin::Arguments* args) {
auto result = InterceptProtocol(type, scheme, handler);
const auto result = InterceptProtocol(type, scheme, handler);
HandleOptionalCallback(args, result);
return result == ProtocolError::kOK;
return result == Error::kOK;
}
// Be compatible with old interface, which accepts optional callback.
void HandleOptionalCallback(gin::Arguments* args, ProtocolError error);
void HandleOptionalCallback(gin::Arguments* args, Error error);
// Weak pointer; the lifetime of the ProtocolRegistry is guaranteed to be
// longer than the lifetime of this JS interface.

View File

@@ -19,10 +19,7 @@ v8::Local<v8::Promise> PushNotifications::RegisterForAPNSNotifications(
gin_helper::Promise<std::string> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
[[AtomApplication sharedApplication]
registerForRemoteNotificationTypes:NSRemoteNotificationTypeBadge |
NSRemoteNotificationTypeAlert |
NSRemoteNotificationTypeSound];
[[AtomApplication sharedApplication] registerForRemoteNotifications];
PushNotifications::apns_promise_set_.emplace_back(std::move(promise));
return handle;
@@ -30,8 +27,7 @@ v8::Local<v8::Promise> PushNotifications::RegisterForAPNSNotifications(
void PushNotifications::ResolveAPNSPromiseSetWithToken(
const std::string& token_string) {
std::vector<gin_helper::Promise<std::string>> promises =
std::move(PushNotifications::apns_promise_set_);
auto promises = std::move(PushNotifications::apns_promise_set_);
for (auto& promise : promises) {
promise.Resolve(token_string);
}
@@ -39,8 +35,7 @@ void PushNotifications::ResolveAPNSPromiseSetWithToken(
void PushNotifications::RejectAPNSPromiseSetWithError(
const std::string& error_message) {
std::vector<gin_helper::Promise<std::string>> promises =
std::move(PushNotifications::apns_promise_set_);
auto promises = std::move(PushNotifications::apns_promise_set_);
for (auto& promise : promises) {
promise.RejectWithErrorMessage(error_message);
}

View File

@@ -13,6 +13,7 @@
#include "base/command_line.h"
#include "base/containers/fixed_flat_map.h"
#include "base/containers/map_util.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -141,9 +142,8 @@ uint32_t GetStorageMask(const std::vector<std::string>& storage_types) {
uint32_t storage_mask = 0;
for (const auto& it : storage_types) {
auto type = base::ToLowerASCII(it);
if (Lookup.contains(type))
storage_mask |= Lookup.at(type);
if (const uint32_t* val = base::FindOrNull(Lookup, base::ToLowerASCII(it)))
storage_mask |= *val;
}
return storage_mask;
}
@@ -183,9 +183,8 @@ BrowsingDataRemover::DataType GetDataTypeMask(
const std::vector<std::string>& data_types) {
BrowsingDataRemover::DataType mask = 0u;
for (const auto& type : data_types) {
if (kDataTypeLookup.contains(type)) {
mask |= kDataTypeLookup.at(type);
}
if (const auto* val = base::FindOrNull(kDataTypeLookup, type))
mask |= *val;
}
return mask;
}
@@ -557,7 +556,9 @@ Session::Session(v8::Isolate* isolate, ElectronBrowserContext* browser_context)
SessionPreferences::CreateForBrowserContext(browser_context);
protocol_.Reset(isolate, Protocol::Create(isolate, browser_context).ToV8());
protocol_.Reset(
isolate,
Protocol::Create(isolate, browser_context->protocol_registry()).ToV8());
browser_context->SetUserData(
kElectronApiSessionKey,
@@ -713,14 +714,13 @@ v8::Local<v8::Promise> Session::ClearStorageData(gin::Arguments* args) {
ClearStorageDataOptions options;
args->GetNext(&options);
auto* storage_partition = browser_context()->GetStoragePartition(nullptr);
if (options.storage_types & StoragePartition::REMOVE_DATA_MASK_COOKIES) {
// Reset media device id salt when cookies are cleared.
// https://w3c.github.io/mediacapture-main/#dom-mediadeviceinfo-deviceid
MediaDeviceIDSalt::Reset(browser_context()->prefs());
}
storage_partition->ClearData(
browser_context()->GetDefaultStoragePartition()->ClearData(
options.storage_types, options.quota_types, options.storage_key,
base::Time(), base::Time::Max(),
base::BindOnce(gin_helper::Promise<void>::ResolvePromise,
@@ -729,8 +729,7 @@ v8::Local<v8::Promise> Session::ClearStorageData(gin::Arguments* args) {
}
void Session::FlushStorageData() {
auto* storage_partition = browser_context()->GetStoragePartition(nullptr);
storage_partition->Flush();
browser_context()->GetDefaultStoragePartition()->Flush();
}
v8::Local<v8::Promise> Session::SetProxy(gin::Arguments* args) {
@@ -1718,7 +1717,7 @@ gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
ElectronBrowserContext* browser_context;
if (partition.empty()) {
browser_context =
ElectronBrowserContext::From("", false, std::move(options));
ElectronBrowserContext::GetDefaultBrowserContext(std::move(options));
} else if (partition.starts_with(kPersistPrefix)) {
std::string name = partition.substr(8);
browser_context =

View File

@@ -21,11 +21,13 @@
#include "gin/object_template_builder.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "shell/browser/api/message_port.h"
#include "shell/browser/browser.h"
#include "shell/browser/javascript_environment.h"
#include "shell/browser/net/system_network_context_manager.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h"
#include "shell/common/v8_util.h"
@@ -412,6 +414,13 @@ raw_ptr<UtilityProcessWrapper> UtilityProcessWrapper::FromProcessId(
// static
gin::Handle<UtilityProcessWrapper> UtilityProcessWrapper::Create(
gin::Arguments* args) {
if (!Browser::Get()->is_ready()) {
gin_helper::ErrorThrower(args->isolate())
.ThrowTypeError(
"utilityProcess cannot be created before app is ready.");
return {};
}
gin_helper::Dictionary dict;
if (!args->GetNext(&dict)) {
args->ThrowTypeError("Options must be an object.");

View File

@@ -43,7 +43,7 @@ class UtilityProcessWrapper final
: public gin::Wrappable<UtilityProcessWrapper>,
public gin_helper::Pinnable<UtilityProcessWrapper>,
public gin_helper::EventEmitterMixin<UtilityProcessWrapper>,
public mojo::MessageReceiver,
private mojo::MessageReceiver,
public node::mojom::NodeServiceClient,
public content::ServiceProcessHost::Observer {
public:

View File

@@ -155,7 +155,7 @@ class JSLayoutManager : public views::LayoutManagerBase {
public:
explicit JSLayoutManager(LayoutCallback layout_callback)
: layout_callback_(std::move(layout_callback)) {}
~JSLayoutManager() override {}
~JSLayoutManager() override = default;
// views::LayoutManagerBase
views::ProposedLayout CalculateProposedLayout(

View File

@@ -174,6 +174,7 @@
#if BUILDFLAG(ENABLE_PRINTING)
#include "chrome/browser/printing/print_view_manager_base.h"
#include "components/printing/browser/print_composite_client.h"
#include "components/printing/browser/print_manager_utils.h"
#include "components/printing/browser/print_to_pdf/pdf_print_result.h"
#include "components/printing/browser/print_to_pdf/pdf_print_utils.h"
@@ -673,23 +674,15 @@ PrefService* GetPrefService(content::WebContents* web_contents) {
return static_cast<electron::ElectronBrowserContext*>(context)->prefs();
}
std::map<std::string, std::string> GetAddedFileSystemPaths(
// returns a Dict of filesystem_path -> type
[[nodiscard]] const base::Value::Dict& GetAddedFileSystems(
content::WebContents* web_contents) {
auto* pref_service = GetPrefService(web_contents);
const base::Value::Dict& file_system_paths =
pref_service->GetDict(prefs::kDevToolsFileSystemPaths);
std::map<std::string, std::string> result;
for (auto it : file_system_paths) {
std::string type =
it.second.is_string() ? it.second.GetString() : std::string();
result[it.first] = type;
}
return result;
return GetPrefService(web_contents)->GetDict(prefs::kDevToolsFileSystemPaths);
}
bool IsDevToolsFileSystemAdded(content::WebContents* web_contents,
const std::string& file_system_path) {
return GetAddedFileSystemPaths(web_contents).contains(file_system_path);
const std::string_view file_system_path) {
return GetAddedFileSystems(web_contents).contains(file_system_path);
}
content::RenderFrameHost* GetRenderFrameHost(
@@ -1021,6 +1014,7 @@ void WebContents::InitWithWebContents(
#if BUILDFLAG(ENABLE_PRINTING)
PrintViewManagerElectron::CreateForWebContents(web_contents.get());
printing::CreateCompositeClientIfNeeded(web_contents.get(), GetUserAgent());
#endif
// Determine whether the WebContents is offscreen.
@@ -2107,6 +2101,19 @@ void WebContents::DraggableRegionsChanged(
draggable_region_ = DraggableRegionsToSkRegion(regions);
}
#if BUILDFLAG(ENABLE_PRINTING)
void WebContents::PrintCrossProcessSubframe(
content::WebContents* web_contents,
const gfx::Rect& rect,
int document_cookie,
content::RenderFrameHost* subframe_host) const {
if (auto* client =
printing::PrintCompositeClient::FromWebContents(web_contents)) {
client->PrintCrossProcessSubframe(rect, document_cookie, subframe_host);
}
}
#endif
SkRegion* WebContents::draggable_region() {
return g_disable_draggable_regions ? nullptr : draggable_region_.get();
}
@@ -2181,6 +2188,17 @@ void WebContents::DidFinishNavigation(
if (is_main_frame) {
Emit("did-navigate", url, http_response_code, http_status_text);
}
content::NavigationEntry* entry = navigation_handle->GetNavigationEntry();
// This check is needed due to an issue in Chromium
// Upstream is open to patching:
// https://bugs.chromium.org/p/chromium/issues/detail?id=1178663
// If a history entry has been made and the forward/back call has been
// made, proceed with setting the new title
if (entry &&
(entry->GetTransitionType() & ui::PAGE_TRANSITION_FORWARD_BACK))
WebContents::TitleWasSet(entry);
}
if (is_guest())
Emit("load-commit", url, is_main_frame);
@@ -2201,15 +2219,6 @@ void WebContents::DidFinishNavigation(
frame_process_id, frame_routing_id);
}
}
content::NavigationEntry* entry = navigation_handle->GetNavigationEntry();
// This check is needed due to an issue in Chromium
// Check the Chromium issue to keep updated:
// https://bugs.chromium.org/p/chromium/issues/detail?id=1178663
// If a history entry has been made and the forward/back call has been made,
// proceed with setting the new title
if (entry && (entry->GetTransitionType() & ui::PAGE_TRANSITION_FORWARD_BACK))
WebContents::TitleWasSet(entry);
}
void WebContents::TitleWasSet(content::NavigationEntry* entry) {
@@ -2633,6 +2642,9 @@ void WebContents::RestoreHistory(
auto navigation_entries = std::make_unique<
std::vector<std::unique_ptr<content::NavigationEntry>>>();
blink::UserAgentOverride ua_override;
ua_override.ua_string_override = GetUserAgent();
for (const auto& entry : entries) {
content::NavigationEntry* nav_entry = nullptr;
if (!gin::Converter<content::NavigationEntry*>::FromV8(isolate, entry,
@@ -2645,11 +2657,15 @@ void WebContents::RestoreHistory(
std::to_string(index) + ".");
return;
}
nav_entry->SetIsOverridingUserAgent(
!ua_override.ua_string_override.empty());
navigation_entries->push_back(
std::unique_ptr<content::NavigationEntry>(nav_entry));
}
if (!navigation_entries->empty()) {
web_contents()->SetUserAgentOverride(ua_override, false);
web_contents()->GetController().Restore(
index, content::RestoreType::kRestored, navigation_entries.get());
web_contents()->GetController().LoadIfNecessary();
@@ -4153,31 +4169,22 @@ void WebContents::DevToolsAppendToFile(const std::string& url,
}
void WebContents::DevToolsRequestFileSystems() {
auto file_system_paths = GetAddedFileSystemPaths(GetDevToolsWebContents());
if (file_system_paths.empty()) {
inspectable_web_contents_->CallClientFunction(
"DevToolsAPI", "fileSystemsLoaded", base::Value(base::Value::List()));
return;
const std::string empty_str;
content::WebContents* const dtwc = GetDevToolsWebContents();
const base::Value::Dict& added_paths = GetAddedFileSystems(dtwc);
auto filesystems = base::Value::List::with_capacity(added_paths.size());
for (const auto path_and_type : added_paths) {
const auto& [path, type_val] = path_and_type;
const auto& type = type_val.is_string() ? type_val.GetString() : empty_str;
const std::string file_system_id =
RegisterFileSystem(dtwc, base::FilePath::FromUTF8Unsafe(path));
filesystems.Append(CreateFileSystemValue(
CreateFileSystemStruct(dtwc, file_system_id, path, type)));
}
std::vector<FileSystem> file_systems;
for (const auto& file_system_path : file_system_paths) {
base::FilePath path =
base::FilePath::FromUTF8Unsafe(file_system_path.first);
std::string file_system_id =
RegisterFileSystem(GetDevToolsWebContents(), path);
FileSystem file_system =
CreateFileSystemStruct(GetDevToolsWebContents(), file_system_id,
file_system_path.first, file_system_path.second);
file_systems.push_back(file_system);
}
base::Value::List file_system_value;
for (const auto& file_system : file_systems)
file_system_value.Append(CreateFileSystemValue(file_system));
inspectable_web_contents_->CallClientFunction(
"DevToolsAPI", "fileSystemsLoaded",
base::Value(std::move(file_system_value)));
"DevToolsAPI", "fileSystemsLoaded", base::Value{std::move(filesystems)});
}
void WebContents::DevToolsAddFileSystem(
@@ -4239,8 +4246,11 @@ void WebContents::DevToolsIndexPath(
OnDevToolsIndexingDone(request_id, file_system_path);
return;
}
if (devtools_indexing_jobs_.contains(request_id))
auto& indexing_job = devtools_indexing_jobs_[request_id];
if (indexing_job)
return;
std::vector<std::string> excluded_folders;
std::optional<base::Value> parsed_excluded_folders =
base::JSONReader::Read(excluded_folders_message);
@@ -4250,19 +4260,18 @@ void WebContents::DevToolsIndexPath(
excluded_folders.push_back(folder_path.GetString());
}
}
devtools_indexing_jobs_[request_id] =
scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob>(
devtools_file_system_indexer_->IndexPath(
file_system_path, excluded_folders,
base::BindRepeating(
&WebContents::OnDevToolsIndexingWorkCalculated,
weak_factory_.GetWeakPtr(), request_id, file_system_path),
base::BindRepeating(&WebContents::OnDevToolsIndexingWorked,
weak_factory_.GetWeakPtr(), request_id,
file_system_path),
base::BindRepeating(&WebContents::OnDevToolsIndexingDone,
weak_factory_.GetWeakPtr(), request_id,
file_system_path)));
indexing_job = devtools_file_system_indexer_->IndexPath(
file_system_path, excluded_folders,
base::BindRepeating(&WebContents::OnDevToolsIndexingWorkCalculated,
weak_factory_.GetWeakPtr(), request_id,
file_system_path),
base::BindRepeating(&WebContents::OnDevToolsIndexingWorked,
weak_factory_.GetWeakPtr(), request_id,
file_system_path),
base::BindRepeating(&WebContents::OnDevToolsIndexingDone,
weak_factory_.GetWeakPtr(), request_id,
file_system_path));
}
void WebContents::DevToolsStopIndexing(int request_id) {

View File

@@ -9,8 +9,6 @@
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/functional/callback_forward.h"
@@ -638,6 +636,13 @@ class WebContents final : public ExclusiveAccessContext,
void DraggableRegionsChanged(
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
content::WebContents* contents) override;
#if BUILDFLAG(ENABLE_PRINTING)
void PrintCrossProcessSubframe(
content::WebContents* web_contents,
const gfx::Rect& rect,
int document_cookie,
content::RenderFrameHost* subframe_host) const override;
#endif
// content::WebContentsObserver:
void BeforeUnloadFired(bool proceed) override;

View File

@@ -156,8 +156,8 @@ WebFrameMain::WebFrameMain(content::RenderFrameHost* rfh)
if (!render_frame_detached_)
GetFrameTreeNodeIdMap().emplace(frame_tree_node_id_, this);
DCHECK(!GetFrameTokenMap().contains(frame_token_));
GetFrameTokenMap().emplace(frame_token_, this);
const auto [_, inserted] = GetFrameTokenMap().emplace(frame_token_, this);
DCHECK(inserted);
// WebFrameMain should only be created for active or unloading frames.
DCHECK(GetLifecycleState(rfh) == LifecycleState::kActive ||
@@ -194,8 +194,8 @@ void WebFrameMain::UpdateRenderFrameHost(content::RenderFrameHost* rfh) {
// Ensure that RFH being swapped in doesn't already exist as its own
// WebFrameMain instance.
frame_token_ = rfh->GetGlobalFrameToken();
DCHECK(!GetFrameTokenMap().contains(frame_token_));
GetFrameTokenMap().emplace(frame_token_, this);
const auto [_, inserted] = GetFrameTokenMap().emplace(frame_token_, this);
DCHECK(inserted);
render_frame_disposed_ = false;
TeardownMojoConnection();

View File

@@ -5,7 +5,6 @@
#ifndef ELECTRON_SHELL_BROWSER_API_GPU_INFO_ENUMERATOR_H_
#define ELECTRON_SHELL_BROWSER_API_GPU_INFO_ENUMERATOR_H_
#include <memory>
#include <stack>
#include <string>

View File

@@ -5,7 +5,6 @@
#include "shell/browser/api/message_port.h"
#include <string>
#include <unordered_set>
#include <utility>
#include "base/containers/to_vector.h"
@@ -20,6 +19,7 @@
#include "shell/common/gin_helper/event_emitter_caller.h"
#include "shell/common/node_includes.h"
#include "shell/common/v8_util.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
#include "third_party/blink/public/common/messaging/transferable_message.h"
#include "third_party/blink/public/common/messaging/transferable_message_mojom_traits.h"
#include "third_party/blink/public/mojom/messaging/transferable_message.mojom.h"
@@ -226,7 +226,8 @@ std::vector<blink::MessagePortChannel> MessagePort::DisentanglePorts(
if (ports.empty())
return {};
std::unordered_set<MessagePort*> visited;
absl::flat_hash_set<MessagePort*> visited;
visited.reserve(ports.size());
// Walk the incoming array - if there are any duplicate ports, or null ports
// or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec).

View File

@@ -29,7 +29,7 @@ namespace electron {
// A non-blink version of blink::MessagePort.
class MessagePort final : public gin::Wrappable<MessagePort>,
public gin_helper::CleanedUpAtExit,
public mojo::MessageReceiver {
private mojo::MessageReceiver {
public:
~MessagePort() override;
static gin::Handle<MessagePort> Create(v8::Isolate* isolate);

View File

@@ -443,13 +443,13 @@ void ElectronBrowserClient::RegisterPendingSiteInstance(
content::SiteInstance* pending_site_instance) {
// Remember the original web contents for the pending renderer process.
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
auto* pending_process = pending_site_instance->GetProcess();
pending_processes_[pending_process->GetID()] = web_contents;
const auto pending_process_id = pending_site_instance->GetProcess()->GetID();
pending_processes_[pending_process_id] = web_contents;
if (rfh->GetParent())
renderer_is_subframe_.insert(pending_process->GetID());
renderer_is_subframe_.insert(pending_process_id);
else
renderer_is_subframe_.erase(pending_process->GetID());
renderer_is_subframe_.erase(pending_process_id);
}
void ElectronBrowserClient::AppendExtraCommandLineSwitches(

View File

@@ -12,6 +12,7 @@
#include "base/barrier_closure.h"
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/containers/to_vector.h"
#include "base/files/file_path.h"
#include "base/no_destructor.h"
#include "base/path_service.h"
@@ -49,6 +50,7 @@
#include "shell/browser/electron_download_manager_delegate.h"
#include "shell/browser/electron_permission_manager.h"
#include "shell/browser/file_system_access/file_system_access_permission_context_factory.h"
#include "shell/browser/media/media_device_id_salt.h"
#include "shell/browser/net/resolve_proxy_helper.h"
#include "shell/browser/protocol_registry.h"
#include "shell/browser/serial/serial_chooser_context.h"
@@ -308,14 +310,53 @@ bool DoesDeviceMatch(const base::Value& device,
return false;
}
// partition_id => browser_context
struct PartitionKey {
PartitionKey(const std::string_view partition, bool in_memory)
: type_{Type::Partition}, location_{partition}, in_memory_{in_memory} {}
explicit PartitionKey(const base::FilePath& file_path)
: type_{Type::Path},
location_{file_path.AsUTF8Unsafe()},
in_memory_{false} {}
friend auto operator<=>(const PartitionKey&, const PartitionKey&) = default;
private:
enum class Type { Partition, Path };
Type type_;
std::string location_;
bool in_memory_;
};
[[nodiscard]] auto& ContextMap() {
static base::NoDestructor<
std::map<PartitionKey, std::unique_ptr<ElectronBrowserContext>>>
map;
return *map;
}
} // namespace
// static
ElectronBrowserContext::BrowserContextMap&
ElectronBrowserContext::browser_context_map() {
static base::NoDestructor<ElectronBrowserContext::BrowserContextMap>
browser_context_map;
return *browser_context_map;
std::vector<ElectronBrowserContext*> ElectronBrowserContext::BrowserContexts() {
return base::ToVector(ContextMap(),
[](auto& iter) { return iter.second.get(); });
}
bool ElectronBrowserContext::IsValidContext(const void* context) {
return std::ranges::any_of(ContextMap(), [context](const auto& iter) {
return iter.second.get() == context;
});
}
// static
void ElectronBrowserContext::DestroyAllContexts() {
auto& map = ContextMap();
// Avoid UAF by destroying the default context last. See ba629e3 for info.
const auto extracted = map.extract(PartitionKey{"", false});
map.clear();
}
ElectronBrowserContext::ElectronBrowserContext(
@@ -365,10 +406,10 @@ ElectronBrowserContext::ElectronBrowserContext(
BrowserContextDependencyManager::GetInstance()
->CreateBrowserContextServices(this);
extension_system_ = static_cast<extensions::ElectronExtensionSystem*>(
auto* extension_system = static_cast<extensions::ElectronExtensionSystem*>(
extensions::ExtensionSystem::Get(this));
extension_system_->InitForRegularProfile(true /* extensions_enabled */);
extension_system_->FinishInitialization();
extension_system->InitForRegularProfile(true /* extensions_enabled */);
extension_system->FinishInitialization();
}
#endif
}
@@ -377,11 +418,6 @@ ElectronBrowserContext::~ElectronBrowserContext() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
NotifyWillBeDestroyed();
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
// the DestroyBrowserContextServices() call below frees this.
extension_system_ = nullptr;
#endif
// Notify any keyed services of browser context destruction.
BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
this);
@@ -834,34 +870,29 @@ ElectronBrowserContext* ElectronBrowserContext::From(
const std::string& partition,
bool in_memory,
base::Value::Dict options) {
PartitionKey key(partition, in_memory);
ElectronBrowserContext* browser_context = browser_context_map()[key].get();
if (browser_context) {
return browser_context;
auto& context = ContextMap()[PartitionKey(partition, in_memory)];
if (!context) {
context.reset(new ElectronBrowserContext{std::cref(partition), in_memory,
std::move(options)});
}
return context.get();
}
auto* new_context = new ElectronBrowserContext(std::cref(partition),
in_memory, std::move(options));
browser_context_map()[key] =
std::unique_ptr<ElectronBrowserContext>(new_context);
return new_context;
// static
ElectronBrowserContext* ElectronBrowserContext::GetDefaultBrowserContext(
base::Value::Dict options) {
return ElectronBrowserContext::From("", false, std::move(options));
}
ElectronBrowserContext* ElectronBrowserContext::FromPath(
const base::FilePath& path,
base::Value::Dict options) {
PartitionKey key(path);
ElectronBrowserContext* browser_context = browser_context_map()[key].get();
if (browser_context) {
return browser_context;
auto& context = ContextMap()[PartitionKey(path)];
if (!context) {
context.reset(
new ElectronBrowserContext{std::cref(path), false, std::move(options)});
}
auto* new_context =
new ElectronBrowserContext(std::cref(path), false, std::move(options));
browser_context_map()[key] =
std::unique_ptr<ElectronBrowserContext>(new_context);
return new_context;
return context.get();
}
} // namespace electron

View File

@@ -13,13 +13,8 @@
#include <variant>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/media_stream_request.h"
#include "content/public/browser/resource_context.h"
#include "electron/buildflags/buildflags.h"
#include "electron/shell/browser/media/media_device_id_salt.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/mojom/ssl_config.mojom.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
@@ -43,20 +38,15 @@ namespace storage {
class SpecialStoragePolicy;
}
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
namespace extensions {
class ElectronExtensionSystem;
}
#endif
namespace electron {
class CookieChangeNotifier;
class ElectronDownloadManagerDelegate;
class ElectronPermissionManager;
class CookieChangeNotifier;
class MediaDeviceIDSalt;
class ProtocolRegistry;
class ResolveProxyHelper;
class WebViewManager;
class ProtocolRegistry;
using DisplayMediaResponseCallbackJs =
base::OnceCallback<void(gin::Arguments* args)>;
@@ -69,28 +59,13 @@ class ElectronBrowserContext : public content::BrowserContext {
ElectronBrowserContext(const ElectronBrowserContext&) = delete;
ElectronBrowserContext& operator=(const ElectronBrowserContext&) = delete;
// partition_id => browser_context
struct PartitionKey {
PartitionKey(const std::string_view partition, bool in_memory)
: type_{Type::Partition}, location_{partition}, in_memory_{in_memory} {}
[[nodiscard]] static std::vector<ElectronBrowserContext*> BrowserContexts();
explicit PartitionKey(const base::FilePath& file_path)
: type_{Type::Path},
location_{file_path.AsUTF8Unsafe()},
in_memory_{false} {}
[[nodiscard]] static bool IsValidContext(const void* context);
friend auto operator<=>(const PartitionKey&, const PartitionKey&) = default;
private:
enum class Type { Partition, Path };
Type type_;
std::string location_;
bool in_memory_;
};
using BrowserContextMap =
std::map<PartitionKey, std::unique_ptr<ElectronBrowserContext>>;
// Get or create the default BrowserContext.
static ElectronBrowserContext* GetDefaultBrowserContext(
base::Value::Dict options = {});
// Get or create the BrowserContext according to its |partition| and
// |in_memory|. The |options| will be passed to constructor when there is no
@@ -105,7 +80,7 @@ class ElectronBrowserContext : public content::BrowserContext {
static ElectronBrowserContext* FromPath(const base::FilePath& path,
base::Value::Dict options = {});
static BrowserContextMap& browser_context_map();
static void DestroyAllContexts();
void SetUserAgent(const std::string& user_agent);
std::string GetUserAgent() const;
@@ -150,18 +125,6 @@ class ElectronBrowserContext : public content::BrowserContext {
ValueMapPrefStore* in_memory_pref_store() const {
return in_memory_pref_store_.get();
}
base::WeakPtr<ElectronBrowserContext> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
extensions::ElectronExtensionSystem* extension_system() {
// Guard usages of extension_system() with !IsOffTheRecord()
// There is no extension system for in-memory sessions
DCHECK(!IsOffTheRecord());
return extension_system_;
}
#endif
ProtocolRegistry* protocol_registry() const {
return protocol_registry_.get();
@@ -237,11 +200,6 @@ class ElectronBrowserContext : public content::BrowserContext {
bool use_cache_ = true;
int max_cache_size_ = 0;
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
// Owned by the KeyedService system.
raw_ptr<extensions::ElectronExtensionSystem> extension_system_;
#endif
// Shared URLLoaderFactory.
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
@@ -252,8 +210,6 @@ class ElectronBrowserContext : public content::BrowserContext {
// In-memory cache that holds objects that have been granted permissions.
DevicePermissionMap granted_devices_;
base::WeakPtrFactory<ElectronBrowserContext> weak_factory_{this};
};
} // namespace electron

View File

@@ -344,9 +344,6 @@ int ElectronBrowserMainParts::PreCreateThreads() {
// Force MediaCaptureDevicesDispatcher to be created on UI thread.
MediaCaptureDevicesDispatcher::GetInstance();
// Force MediaCaptureDevicesDispatcher to be created on UI thread.
MediaCaptureDevicesDispatcher::GetInstance();
#if BUILDFLAG(IS_MAC)
ui::InitIdleMonitor();
Browser::Get()->ApplyForcedRTL();
@@ -557,11 +554,9 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() {
// Shutdown the DownloadManager before destroying Node to prevent
// DownloadItem callbacks from crashing.
for (auto& iter : ElectronBrowserContext::browser_context_map()) {
auto* download_manager = iter.second.get()->GetDownloadManager();
if (download_manager) {
for (auto* browser_context : ElectronBrowserContext::BrowserContexts()) {
if (auto* download_manager = browser_context->GetDownloadManager())
download_manager->Shutdown();
}
}
// Shutdown utility process created with Electron API before
@@ -601,11 +596,7 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() {
node_bindings_->set_uv_env(nullptr);
node_env_.reset();
auto default_context_key = ElectronBrowserContext::PartitionKey("", false);
std::unique_ptr<ElectronBrowserContext> default_context = std::move(
ElectronBrowserContext::browser_context_map()[default_context_key]);
ElectronBrowserContext::browser_context_map().clear();
default_context.reset();
ElectronBrowserContext::DestroyAllContexts();
fake_browser_process_->PostMainMessageLoopRun();
content::DevToolsAgentHost::StopRemoteDebuggingPipeHandler();

View File

@@ -6,7 +6,6 @@
#include <string>
#include <string_view>
#include <tuple>
#include <utility>
#include "base/files/file_util.h"

View File

@@ -5,8 +5,6 @@
#ifndef ELECTRON_SHELL_BROWSER_ELECTRON_WEB_CONTENTS_UTILITY_HANDLER_IMPL_H_
#define ELECTRON_SHELL_BROWSER_ELECTRON_WEB_CONTENTS_UTILITY_HANDLER_IMPL_H_
#include <vector>
#include "base/memory/weak_ptr.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/web_contents_observer.h"

Some files were not shown because too many files have changed in this diff Show More