Compare commits

..

46 Commits

Author SHA1 Message Date
Keeley Hammond
e83192adba ci: revert CI git cache removal (#40964)
* Revert "ci: increase "gclient sync" output timeout (#40963)"

This reverts commit be4eb4e8a7.

* Revert "build: remove CI cache of git cache (#40953)"

This reverts commit b39ebb8625.
2024-01-11 13:51:19 -08:00
Keeley Hammond
be4eb4e8a7 ci: increase "gclient sync" output timeout (#40963)
ci: increase gclient output timeout
2024-01-11 11:56:22 -08:00
Samuel Attard
8b9eb518a9 build: fix windows remote exec of python actions (#40958) 2024-01-11 07:17:35 -08:00
Shelley Vohr
d5d162b622 fix: InAppPurchase pre-emptive deallocation (#40938)
* fix: InAppPurchase pre-emptive deallocation

* test: try re-enabling IAP tests
2024-01-11 13:32:29 +01:00
Samuel Attard
b39ebb8625 build: remove CI cache of git cache (#40953) 2024-01-11 23:29:49 +13:00
electron-roller[bot]
2e4e6f10de chore: bump chromium to 122.0.6236.2 (main) (#40871)
* chore: bump chromium in DEPS to 122.0.6223.0

* 5129828: Removes special cases for selenium-atoms dependencies.

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

* chore: fixup patch indices

* 5139789: Deduplicate BrowserContext's ResourceContext

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

* 5148579: Simplify SelectFileDialog::Listener

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

* 5134038: Code Health: Use string_view in base::i18n::BreakIterator::SetText

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

* 5137427: Code Health: Use string_view in SpellCheck::SpellCheckWord

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

* [libcxx] adds ranges::fold_left_with_iter and ranges::fold_left

Notable things in this commit:

* refactors `__indirect_binary_left_foldable`, making it slightly
different (but equivalent) to _`indirect-binary-left-foldable`_, which
improves readability (a [patch to the Working Paper][patch] was made)
* omits `__cpo` namespace, since it is not required for implementing
niebloids (a cleanup should happen in 2024)
* puts tests ensuring invocable robustness and dangling correctness
inside the correctness testing to ensure that the algorithms' results
are still correct

[patch]: https://github.com/cplusplus/draft/pull/6734

* chore: bump chromium in DEPS to 122.0.6224.0

* 5154766: [Refresh 2023] [GTK] Fix gap above toolbar with fractional scaling

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

* chore: fixup patch indices

* 5094458: Remove extra CGColorSpace parameters from skia and ui helpers

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

* chore: bump chromium in DEPS to 122.0.6226.0

* chore: update patches

* chore: bump chromium in DEPS to 122.0.6227.0

* chore: update patches

* chore: bump chromium in DEPS to 122.0.6228.0

* chore: update patches

* chore: bump chromium in DEPS to 122.0.6230.0

* chore: bump chromium in DEPS to 122.0.6232.0

* chore: bump chromium in DEPS to 122.0.6234.0

* chore: bump chromium in DEPS to 122.0.6236.2

* chore: update patches

* fix: remove --disable-color-correct-renderering

Per https://electronhq.slack.com/archives/CB6CG54DB/p1698444047862459 it is not used any more and was never documented.

* chore: add WEB_PRINTING to content permission converter

Unused in non-cros so no need to document

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/5136178

* chore: Views is now vec<raw_ptr> instead of raw<T*>

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/5140028

* spec: add Iterator to global intrinsics

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>
2024-01-11 19:33:40 +13:00
Charles Kerr
f36ceae024 chore: migrate base::StringPiece to std::string_view (#40915)
* chore: migrate from base::StringPiece to std::string_view in keyboard_util.cc

* chore: migrate from base::StringPiece to std::string_view in error_thrower.cc

* chore: migrate from base::StringPiece to std::string_view in electron_api_web_contents.cc

* chore: migrate from base::StringPiece to std::string_view in gin_helper/dictionary.h

* chore: migrate from base::StringPiece to std::string_view in electron_api_url_loader.cc

* chore: phase out internal use of base:::StringPiece

`base::StringPiece` is being phased out upstream. Its code has been
removed upstream and it's just a typedef for `std::string_view`.

They haven't removed the typedef yet, so this PR tries to get ahead
of future breakage by migrating "internal" use (i.e. leaving alone the
places where the `base::StringPiece` name is coming from an upstream
method that we override).

Xref: https://bugs.chromium.org/p/chromium/issues/detail?id=691162

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4294483

Xref: https://docs.google.com/document/d/1d4RnD1uAE2t4iANR0nXy82ASIPGsPuw2mpO6v6T7JKs
2024-01-10 19:00:37 -06:00
Milan Burda
892c9d78a3 chore: replace absl::optional<T> with std::optional<T> (#40928)
* chore: replace absl::optional<T> with std::optional<T>

* IWYU
2024-01-10 16:23:35 -06:00
Charles Kerr
fac964ac0d refactor: migrate deprecated LazyInstance code to NoDestructor (#40927)
* refactor: do not use deprecated NoDestructor in javascript_environment.cc

* refactor: do not use deprecated NoDestructor in window_list.cc
2024-01-10 14:01:49 -06:00
David Sanders
c2c64d27fd ci: fix missing inputs for release project board automation (#40726) 2024-01-10 13:25:11 +01:00
Samuel Attard
d5c658545a chore: fix content tracing flake (#40939)
* chore: fix contentTracing test

* cry
2024-01-11 01:13:36 +13:00
Samuel Attard
ebf9a49fba build: use container runner for arm tests (#40875)
* build: use aks arm64 test runners

* build: better image

* build: even more stuff

* build: arm par

* build: use aks arm32

* build: arm32 par

* build: get test timings from abs paths

* build: avoid realpath, use echo
2024-01-10 13:12:19 +13:00
Samuel Attard
3afb012ad1 build: add infra for reclient support (#40850)
* chore: add patch to always set macos platform for x-build

* build: add infra for reclient support

* build: override reclient version

* build: use RBE in CI

* chore: hardcode reclient fix version

* build: lower process count on macOS

* build: use large macOS instance for testing-arm64

* Revert "build: use large macOS instance for testing-arm64"

This reverts commit 6844adfd00a5230e68234112dfd84caa50d3f621.

* build: login in via helper not writing file

* chore: update patches

* build: use recelint from DEPS

* build: fix windows reproxy cfg

* build: use reclient in appveyor

* build: update WOA job too

* build: force another build

* build: do not checkout reclient
2024-01-10 10:19:42 +13:00
Shelley Vohr
c184b93fc5 fix: crash using powerMonitor before ready event (#40888)
* fix: crash using powerMonitor before ready event

* refactor: continue using DBusBluezManagerWrapperLinux
2024-01-09 09:41:42 +01:00
Charles Kerr
7b4d490bfe perf: use fixed-size arrays for the font cache (#40898)
refactor: use fixed-size arrays for the font cache

Since we know at compile time which [family x script] combos we want to
cache, we can hold the cache in fixed std::arrays instead of in nested
std::unordered_maps.
2024-01-08 10:31:02 +01:00
Calvin
37630a6128 fix: wide string concatenation (#40892)
* fix: wide string concatenation

* Use wstring_views to keep length in context

* forgot a space, oopsies
2024-01-07 22:02:20 -08:00
Shelley Vohr
3a22fd3216 docs: add missing vibrancy breaking change (#40893)
docs: add missing vibranch change
2024-01-07 13:56:52 -08:00
Charles Kerr
73e7125041 chore: do not inject DXVA_Decoding trace category (#40891)
This doesn't need to be injected. Looks like it was an accident in
60ca38fb for https://github.com/electron/electron/pull/38465 .
2024-01-05 17:54:41 -06:00
Tamás Zahola
cc1b64e01c fix: macOS maximize button shouldn't be disabled just because the window is non-fullscreenable (#40705)
* fix: macOS maximize button shouldn't be disabled just because the window is non-fullscreenable

* add test

* fix test by enabling maximize button if `resizable && (maximizable || fullscreenable)` instead of `(resizable && maximizable) && fullscreenable`
2024-01-05 12:15:35 -05:00
Charles Kerr
22970f573b perf: use flat_set, flat_map for small, trivially-moved containers (#40817)
* refactor: use base::flat_map in ElectronMenuModel

* refactor: use base::flat_map in BuildSubmenuFromModel()

* refactor: use base::flat_map in GetDialogsMap()

* refactor: use base::flat_map in DesktopCapturer

* refactor: use base::flat_map, flat_set in ElectronBrowserClient

* refactor: use base::flat_map in ProxyingURLLoaderFactory

* refactor: use base::flat_map in MapToCommonId()

* refactor: use base::flat_map for g_map_id

* refactor: use base::flat_map for ViewsDelegate::AppbarAutohideEdgeMap

* refactor: use base::flat_map for App::app_metrics_

* refactor: use base::flat_map for PowerSaveBlocker::wake_lock_types_

* refactor: use base::flat_map for NativeImage::hicons_

* refactor: use base::flat_map for MenuViews::menu_runners_

* refactor: use base::flat_map for WebViewManager::web_contents_embedder_map_

* refactor: use base::flat_map for InspectableWebContents::extensions_api_

* refactor: use base::flat_set for libnotify GetServerCapabilities()

* refactor: use base::flat_set for InspectableWebContents::loaders_

* refactor: use base::flat_set for ElectronRendererClient::environments_

refactor: use base::flat_set for ElectronRendererClient::injected_frames_

* refactor: use base::flat_set for WebWorkerObserver::environments_
2024-01-05 12:18:31 +01:00
Brandon Fowler
5086071294 feat: add transparent webpreference to webview (#40301)
* feat: add transparent option to WebContents

* feat: add transparent attribute to webview

* test: add tests for webview transparent attribute

* docs: add transparent attribute to webview docs

* fix: run tests on macOS only

* refactor: remove unneeded html tag

* fix: only apply transparent option to guests

* refactor: correct comment

* refactor: use opaque instead

Retains current webview behaviour by default.

* fix: correct variable name to guest_opaque_

* refactor: use transparent webpreference

* docs: remove unused web preference

* fix: uncomment condition for transparency test

* docs: converted to list format and linked to MDN

* fix: make webviews transparent by default again

* fix: rebase error

---------

Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
2024-01-05 13:00:27 +09:00
Devraj Mehta
8c71e2adc9 feat: add net module to utility process (#40017)
* chore: initial prototype of net api from utility process

* chore: update url loader to work on both browser and utility processes

* chore: add net files to utility process bundle

* chore: re-add app ready check but only on main process

* chore: replace browser thread dcheck's with sequence checker

* refactor: move url loader from browser to common

* refactor: move net-client-request.ts from browser to common

* docs: add utility process to net api docs

* refactor: move net module app ready check to browser only

* refactor: switch import from main to common after moving to common

* test: add basic net module test for utility process

* refactor: switch browser pid with utility pid

* refactor: move electron_api_net from browser to common

* chore: add fetch to utility net module

* chore: add isOnline and online to utility net module

* refactor: move net spec helpers into helper file

* refactor: break apart net module tests

Adds two additional net module test files: `api-net-session-spec.ts` for
tests that depend on a session being available (aka depend on running on
the main process) and `api-net-custom-protocols-spec.ts` for custom
protocol tests. This enables running `api-net-spec.ts` in the utility
process.

* test: add utility process mocha runner to run net module tests

* docs: add utility process to net module classes

* refactor: update imports in lib/utility to use electron/utility

* chore: check browser context before using in main process

Since the browser context supplied to the SimpleURLLoaderWrapper can now
be null for use in the UtilityProcess, adding a null check for the main
process before use to get a more sensible error if something goes wrong.

Co-authored-by: Cheng Zhao <github@zcbenz.com>

* chore: remove test debugging

* chore: remove unnecessary header include

* docs: add utility process net module limitations

* test: run net module tests in utility process individually

* refactor: clean up prior utility process net tests

* chore: add resolveHost to utility process net module

* chore: replace resolve host dcheck with sequence checker

* test: add net module tests for net.resolveHost

* docs: remove utility process limitation for resolveHost

---------

Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Cheng Zhao <github@zcbenz.com>
2024-01-04 16:20:37 -05:00
Charles Kerr
f229201f41 refactor: make NativeWindow getter methods const (#40804)
* refactor: make NativeWindow getter methods const

* fixup! refactor: make NativeWindow getter methods const

make GetZOrderLevel() const

* fixup! refactor: make NativeWindow getter methods const

fix oops
2024-01-04 09:51:59 -06:00
Mathew Bino
3a06047e61 docs: note accelerator case insensitivity (#40783)
* Fix PR#38673

As requested in PR#38673 , a line has been added that explicitly states that accelerators are case sensitive

* Update docs/api/accelerator.md

Co-authored-by: Erick Zhao <erick@hotmail.ca>

* Update accelerator.md

---------

Co-authored-by: Erick Zhao <erick@hotmail.ca>
2024-01-04 10:06:12 -05:00
Jeremy Rose
84ba0c6c7d fix: BrowserView and <webview> should be transparent by default (#40866) 2024-01-04 10:04:56 -05:00
Keeley Hammond
0672f59f26 chore: add disclaimer to release timeline (#40717)
* chore: add disclaimer to release timeline

* Update docs/tutorial/electron-timelines.md

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

---------

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2024-01-04 10:01:40 -05:00
Cheng Zhao
dfce1a9eb4 fix: ignore all NODE_ envs from foreign parent in node process (#40770)
* fix: ignore all NODE_ envs from foreign parent

* fix: recognize ad-hoc signed binary
2024-01-04 16:34:08 +09:00
Shelley Vohr
baca2e302d chore: drop ada ICU requirement for parsing hostnames (#40860) 2024-01-03 13:58:28 -05:00
electron-roller[bot]
8c89137ecd chore: bump chromium to 122.0.6194.0 (main) (#40750)
* chore: bump chromium in DEPS to 122.0.6180.0

* chore: update render_widget_host_view_base.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5079532

minor manual changes to match upstream changes

* chore: update printing.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5094777

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5054299

Update patch to upstream changes in print_view_manager_base.cc.
CC @codebytere for 👀

* chore: update feat_add_onclose_to_messageport.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5083156

no manual changes; patch applied with fuzz 1

* chore: update build_do_not_depend_on_packed_resource_integrity.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5087072

minor manual changes to match upstream changes

* chore: update port_autofill_colors_to_the_color_pipeline.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4960481

no manual changes; patch applied with fuzz 2

* chore: update revert_api_dcheck-fail_when_we_reenter_v8_while_terminating.patch

Xref: https://chromium-review.googlesource.com/c/v8/v8/+/5076902
Xref: https://chromium-review.googlesource.com/c/v8/v8/+/5096253

The `bailout_value` variable, which allowed us to fail gracefully in
these macros, has been removed upstream. This raises the temperature
on https://github.com/electron/electron/issues/40741 ...

Since we don't have a bailout value, return a default-constructed
instance of whatever the return type is of the function that invokes
the macro.

* Remove performActionOnRemotePage

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5068017

It appears it is not used by anything within Chromium or outside.

* perf: in SubmenuButton ctor, move() the PressedCallback

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5066872

The copy construtor is more expensive and has been removed upstream

* chore: update constructor call for ElectronExtensionsRendererClient::dispatcher_

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5055146

* chore: handle CAPTURED_SURFACE_CONTROL in Converter<blink::PermissionType>::ToV8()

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5096614

* chore: e patches all

* chore: bump chromium to 122.0.6181.0

* chore: e patches all

* refactor: Add lookup for per-RenderFrame SpellCheckProvider

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5075094

Previously we could pass a routing ID into the spellcheck methods.
This ID arg has been replaced with a SpellCheckHost& arg.

We can get the SpellCheckHost from an accessor in SpellCheckProvider,
which was already being created on a per-render-frame basis in
RenderClientBase.

This commit adds a RenderFrame-to-SpellCheckProvider accessor
in RenderClientBase so that it can be used to get that needed
SpellCheckHost.

* chore: make lint happy

* chore: restore the will_cause_resize arg to WebContents::ExitFullscreen

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5074445

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5031312

upstream reverted this change

* chore: bump chromium in DEPS to 122.0.6182.0

* chore: update patches

* chore: fix virtual function names that were renamed upstream

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5115241

* chore: handle new blink::PermissionType::SMART_CARD in PermissionType converter

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5049989

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

* fixup! chore: update build_do_not_depend_on_packed_resource_integrity.patch

* chore: remove revert_api_dcheck-fail_when_we_reenter_v8_while_terminating.patch

The previous experiment of removing the DCHECK in 35093783 was a huge
failure. We either need to either:

A) use upstream as-is and fix the DCHECK failure, or
B) revert https://chromium-review.googlesource.com/c/v8/v8/+/5076902 too
C) find some other workaround

This commit is the first half of option A, removing the patch to use
upstream as-is.

* chore: bump chromium in DEPS to 122.0.6184.0

* chore: bump chromium in DEPS to 122.0.6186.0

* chore; update mas_avoid_private_macos_api_usage.patch.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5085619

minor manual changes to match upstream changes

* chore: update build_do_not_depend_on_packed_resource_integrity.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5120922

minor manual changes to match upstream changes

* chore: update fix_move_autopipsettingshelper_behind_branding_buildflag.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5041595

no manual changes; patch applied with fuzz 1

* chore: e patches all

* chore: add refactor_update_node-platform_to_match_v8-platform_api_changes.patch

* chore: bump chromium in DEPS to 122.0.6188.0

* chore: bump chromium in DEPS to 122.0.6190.0

* chore: bump chromium in DEPS to 122.0.6192.0

* chore: bump chromium in DEPS to 122.0.6194.0

* Remove an unnecessary DCHECK which causes Lacros to crash.

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

* [FixIt Week] Add shared regular profile function that includes ash

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

* Simplify the PrintManagerHost::ScriptedPrint() call

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

* [local compile hints] Add tests

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

* chore: update patches

* fixup! chore: add refactor_update_node-platform_to_match_v8-platform_api_changes.patch

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

* Remove //ui/ozone/buildflags.h

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

* fixup! Remove //ui/ozone/buildflags.h

* fixup! Remove //ui/ozone/buildflags.h

* chore: update patches

* fixup! refactor: Add lookup for per-RenderFrame SpellCheckProvider

* fixup! Remove //ui/ozone/buildflags.h

* Add permission policy verification in PermissionControllerImpl

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

* fix: ensure spellcheck interface is registered for frame

* [exceptions] Unify pending and scheduled exceptions

https://chromium-review.googlesource.com/c/v8/v8/+/5050065

* fix: dchecks in node.js tests

* fix: try adding termination check

* chore: document breaking iframe change

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2024-01-03 09:52:49 +01:00
Jeremy Rose
be4e4ff11b fix: make grant_file_protocol_extra_privileges fuse also block CORS fetches (#40801) 2024-01-02 13:06:33 -08:00
Bruno Henrique da Silva
a208d45aca fix: titlebar incorrectly displayed on frameless windows (#40749)
* fix: titlebar incorrectly displayed on frameless windows

* fix: enable transparency for Mica windows

* Refactor ShouldWindowContentsBeTransparent

---------

Co-authored-by: clavin <clavin@electronjs.org>
2024-01-02 13:59:47 -05:00
Charles Kerr
7995c56fb0 refactor: use a FixedFlatMap for v8 converting ui::MenuSourceType (#40786) 2023-12-20 17:44:17 -06:00
Nikhil Simon Toppo
ab2a4fd836 docs: corrected the ipcMain import path (#40764)
Update tutorial-3-preload.md

corrected the import path for ipcMain
2023-12-19 12:30:48 -06:00
Keeley Hammond
95d094d75b fix: add partition alloc check for MacOS 13/14+ (#40757) 2023-12-14 13:47:31 -08:00
Jeremy Rose
ba97679901 ci: re-comment pdb.zip download in appveyor.yml (#40758) 2023-12-14 12:24:05 +01:00
Jeremy Rose
15c6014324 feat: replace BrowserView with WebContentsView (#35658) 2023-12-13 13:01:03 -08:00
Tamás Zahola
a94fb2cb5d fix: don't reject loadURL() promise from did-fail-load - use did-finish-load instead (#40661) 2023-12-12 11:45:14 -08:00
Kishanjay
80d85c0e8e fix: incorrectly mapped toggleDevTools in custom menu fiddle (#40703) 2023-12-12 11:36:34 -08:00
Jeremy Rose
66b2f697ea build: remove dcheck.patch (#40744)
chore: remove dcheck.patch
2023-12-12 12:01:02 +01:00
Robo
83f15bd957 chore: cleanup tests creating crashpad handler in the test runner process (#40668)
* chore: cleanup tests creating crashpad handler in the test runner process

* ci: logging

* ci: enable logging

* ci: more logging

* ci: run all tests

* ci: more logging

* ci: increase timeout

* Revert "ci: increase timeout"

This reverts commit 870f74455d.

* Revert "ci: more logging"

This reverts commit 46837f8b3a.

* Revert "ci: run all tests"

This reverts commit 6a7889ce67.

* Revert "ci: more logging"

This reverts commit 351473ab43.

* Revert "ci: enable logging"

This reverts commit 194109ed5a.

* Revert "ci: logging"

This reverts commit 9a3396fc7a.

* chore: disable flaky ia32 tests
2023-12-12 19:38:42 +09:00
Keeley Hammond
a6417cc265 build: remove font flooding in devtools patch (#40746) 2023-12-12 10:13:31 +01:00
electron-roller[bot]
08a51f3339 chore: bump chromium to 121.0.6159.0 (main) (#40632)
* chore: bump chromium in DEPS to 121.0.6154.0

* chore: bump chromium in DEPS to 121.0.6155.0

* fix patches

* chore: update patches

* patch out reference to GetOcclusionTracker

* un-flag PIPOcclusionTracker

* chore: bump chromium in DEPS to 121.0.6157.0

* fix conflicts

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

* add PIP occlusion tracker sources to chromium_src

* 5037591: Replace feature_list's Initialize* methods with Init*.

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

* 4811903: Move //content/browser/renderer_host/input/synthetic_gesture_controller to //content/common/input

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

* 4917953: usb: Add usb-unrestricted to permission policy

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

* 5072395: Remove unused `creation_context` parameter from blink/public APIs

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

* 5052035: [X11] Change AtomCache from a singleton to owned by Connection

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

* fix v8/.patches

* node script/gen-libc++-filenames.js

* 5035771: Remove the SetImage method of ImageButton

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

* fixup! 5052035: [X11] Change AtomCache from a singleton to owned by Connection

* fixup! 5035771: Remove the SetImage method of ImageButton

* chore: bump chromium in DEPS to 121.0.6159.0

* 4505903: [Extensions] Add lastAccessed property to chrome.tabs.Tab

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

* update patches

* don't duplicate tabs API types

this causes weird memory bugs if the two get out of sync

* fix UAF in TrayIconCocoa

not sure why this is popping up just now ... this has been broken for ages afaict

* Revert "don't duplicate tabs API types"

This reverts commit 80dff2efaa.

This is failing tests with extensions API schema check failures, so
revert for now. we'll fix it later.

* revert v8 change causing node crashes

* chore: reduce diffs in revert_api_dcheck-fail_when_we_reenter_v8_while_terminating.patch

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2023-12-11 14:58:26 -06:00
electron-roller[bot]
890a557eed chore: bump node to v20.10.0 (main) (#40675)
* chore: bump node in DEPS to v20.10.0

* chore: update feat_initialize_asar_support.patch

no code changes; patch just needed an update due to nearby upstream changes

Xref: https://github.com/nodejs/node/pull/49986

* chore: update pass_all_globals_through_require.patch

no manual changes; patch applied with fuzz

Xref: https://github.com/nodejs/node/pull/49657

* chore: update refactor_allow_embedder_overriding_of_internal_fs_calls

Xref: https://github.com/nodejs/node/pull/49912

no code changes; patch just needed an update due to nearby upstream changes

* chore: update chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch

Xref: https://github.com/nodejs/node/pull/49986

minor manual changes needed to sync with upstream change

* update fix_expose_the_built-in_electron_module_via_the_esm_loader.patch

Xref: https://github.com/nodejs/node/pull/50096
Xref: https://github.com/nodejs/node/pull/50314
in lib/internal/modules/esm/load.js, update the code that checks for
`format === 'electron'`. I'd like 👀 on this

Xref: https://github.com/nodejs/node/pull/49657
add braces in lib/internal/modules/esm/translators.js to sync with upstream

* fix: lazyload fs in esm loaders to apply asar patches

* https://github.com/nodejs/node/pull/50127
* https://github.com/nodejs/node/pull/50096

* esm: jsdoc for modules code

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

* test: set test-cli-node-options as flaky

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

* deps: update c-ares to 1.20.1

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

* esm: bypass CommonJS loader under --default-type=module

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

* deps: update uvwasi to 0.0.19

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

* lib,test: do not hardcode Buffer.kMaxLength

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

* crypto: account for disabled SharedArrayBuffer

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

* test: fix edge snapshot stack traces

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

* src: generate snapshot with --predictable

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

* chore: fixup patch indices

* fs: throw errors from sync branches instead of separate implementations

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

* crypto: ensure valid point on elliptic curve in SubtleCrypto.importKey

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

* esm: detect ESM syntax in ambiguous JavaScrip

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

* fixup! test: fix edge snapshot stack traces

* esm: unflag extensionless ES module JavaScript and Wasm in module scope

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

* [tagged-ptr] Arrowify objects

https://chromium-review.googlesource.com/c/v8/v8/+/4705331

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2023-12-11 21:09:50 +01:00
Felipe C
5094cb4115 fix: wrong default port in docs (#40665)
fix: wrong default port
2023-12-11 11:43:06 -05:00
Yureka
2eb13d377e docs: fix year typos in electron-timelines.md (#40728) 2023-12-07 19:14:54 -08:00
David Sanders
93fdc8d33c ci: roll back the link release project board to repo automation (#40716)
* ci: roll back the link release project board to repo automation

* ci: add workflow_dispatch
2023-12-06 20:58:41 -08:00
216 changed files with 1177 additions and 1349 deletions

View File

@@ -1,6 +1,12 @@
name: Branch Created
on:
workflow_dispatch:
inputs:
branch-name:
description: Branch name (e.g. `29-x-y`)
required: true
type: string
create:
permissions: {}
@@ -8,7 +14,7 @@ permissions: {}
jobs:
release-branch-created:
name: Release Branch Created
if: ${{ github.event.ref_type == 'branch' && endsWith(github.event.ref, '-x-y') && !startsWith(github.event.ref, 'roller') }}
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.ref_type == 'branch' && endsWith(github.event.ref, '-x-y') && !startsWith(github.event.ref, 'roller')) }}
permissions:
contents: read
pull-requests: write
@@ -18,10 +24,10 @@ jobs:
- name: Determine Major Version
id: check-major-version
run: |
if [[ ${{ github.event.ref }} =~ ^([0-9]+)-x-y$ ]]; then
if [[ ${{ github.event.inputs.branch-name || github.event.ref }} =~ ^([0-9]+)-x-y$ ]]; then
echo "MAJOR=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
else
echo "Not a release branch: ${{ github.event.ref }}"
echo "Not a release branch: ${{ github.event.inputs.branch-name || github.event.ref }}"
fi
- name: New Release Branch Tasks
if: ${{ steps.check-major-version.outputs.MAJOR }}
@@ -93,7 +99,9 @@ jobs:
project-number: 64
# TODO - Set to public once GitHub fixes their GraphQL bug
# public: true
link-to-repository: electron/electron
# TODO - Enable once GitHub doesn't require overly broad, read
# and write permission for repo "Contents" to link
# link-to-repository: electron/electron
template-view: ${{ steps.generate-project-metadata.outputs.template-view }}
title: ${{ steps.generate-project-metadata.outputs.major }}-x-y
token: ${{ steps.generate-token.outputs.token }}
@@ -108,8 +116,10 @@ jobs:
id: find-prev-release-board
with:
title: ${{ steps.generate-project-metadata.outputs.prev-prev-major }}-x-y
token: ${{ steps.generate-token.outputs.token }}
- name: Close Previous Release Project Board
if: ${{ steps.check-major-version.outputs.MAJOR }}
uses: dsanders11/project-actions/close-project@3a81985616963f32fae17d1d1b406c631f3201a1 # v1.1.0
with:
project-number: ${{ steps.find-prev-release-board.outputs.number }}
token: ${{ steps.generate-token.outputs.token }}

2
DEPS
View File

@@ -4,7 +4,7 @@ vars = {
'chromium_version':
'122.0.6236.2',
'node_version':
'v20.9.0',
'v20.10.0',
'nan_version':
'e14bdcd1f72d62bca1d541b66da43130384ec213',
'squirrel.mac_version':

View File

@@ -4,7 +4,7 @@
Accelerators are strings that can contain multiple modifiers and a single key code,
combined by the `+` character, and are used to define keyboard shortcuts
throughout your application.
throughout your application. Accelerators are case insensitive.
Examples:

View File

@@ -221,7 +221,9 @@ windows. Popups are disabled by default.
```
A `string` which is a comma separated list of strings which specifies the web preferences to be set on the webview.
The full list of supported preference strings can be found in [BrowserWindow](browser-window.md#new-browserwindowoptions).
The full list of supported preference strings can be found in [BrowserWindow](browser-window.md#new-browserwindowoptions). In addition, webview supports the following preferences:
* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the [color scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.
The string follows the same format as the features string in `window.open`.
A name by itself is given a `true` boolean value.

View File

@@ -102,7 +102,7 @@ const template = [
})(),
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.toggleDevTools()
focusedWindow.webContents.toggleDevTools()
}
}
},

View File

@@ -14,10 +14,10 @@ process:
Electron will listen for V8 inspector protocol messages on the specified `port`,
an external debugger will need to connect on this port. The default `port` is
`5858`.
`9229`.
```shell
electron --inspect=5858 your/app
electron --inspect=9229 your/app
```
### `--inspect-brk=[port]`

View File

@@ -333,24 +333,31 @@ WebContents.prototype.loadFile = function (filePath, options = {}) {
}));
};
type LoadError = { errorCode: number, errorDescription: string, url: string };
WebContents.prototype.loadURL = function (url, options) {
const p = new Promise<void>((resolve, reject) => {
const resolveAndCleanup = () => {
removeListeners();
resolve();
};
const rejectAndCleanup = (errorCode: number, errorDescription: string, url: string) => {
let error: LoadError | undefined;
const rejectAndCleanup = ({ errorCode, errorDescription, url }: LoadError) => {
const err = new Error(`${errorDescription} (${errorCode}) loading '${typeof url === 'string' ? url.substr(0, 2048) : url}'`);
Object.assign(err, { errno: errorCode, code: errorDescription, url });
removeListeners();
reject(err);
};
const finishListener = () => {
resolveAndCleanup();
if (error) {
rejectAndCleanup(error);
} else {
resolveAndCleanup();
}
};
const failListener = (event: Electron.Event, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean) => {
if (isMainFrame) {
rejectAndCleanup(errorCode, errorDescription, validatedURL);
if (!error && isMainFrame) {
error = { errorCode, errorDescription, url: validatedURL };
}
};
@@ -368,7 +375,7 @@ WebContents.prototype.loadURL = function (url, options) {
// considered navigation events but are triggered with isSameDocument.
// We can ignore these to allow virtual routing on page load as long
// as the routing does not leave the document
return rejectAndCleanup(-3, 'ERR_ABORTED', url);
return rejectAndCleanup({ errorCode: -3, errorDescription: 'ERR_ABORTED', url });
}
browserInitiatedInPageNavigation = navigationStarted && isSameDocument;
navigationStarted = true;
@@ -383,7 +390,10 @@ WebContents.prototype.loadURL = function (url, options) {
// TODO(jeremy): enumerate all the cases in which this can happen. If
// the only one is with a bad scheme, perhaps ERR_INVALID_ARGUMENT
// would be more appropriate.
rejectAndCleanup(-2, 'ERR_FAILED', url);
if (!error) {
error = { errorCode: -2, errorDescription: 'ERR_FAILED', url: url };
}
finishListener();
};
const finishListenerWhenUserInitiatedNavigation = () => {
if (!browserInitiatedInPageNavigation) {

View File

@@ -1,5 +1,4 @@
build_gn.patch
dcheck.patch
accelerator.patch
blink_file_path.patch
blink_local_frame.patch

View File

@@ -1,36 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Thu, 20 Sep 2018 17:44:38 -0700
Subject: dcheck.patch
This disables some debug checks which currently fail when running the Electron
test suite. In general there should be sustained effort to have all debug checks
enabled. If you want to help, choose one of the diffs below and remove it. Then
build Electron (debug configuration) and make sure all tests pass on the CI
systems. Unfortunately the tests don't always cover the check failures, so it's
good to also run some non-trivial Electron app to verify.
Apart from getting rid of a whole diff, you may also be able to replace one diff
with another which enables at least some of the previously disabled checks. For
example, the checks might be disabled for a whole build target, but actually
only one or two specific checks fail. Then it's better to simply comment out the
failing checks and allow the rest of the target to have them enabled.
diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc
index 2ca479b9fb0b41b66220c524e242d4927c138f1f..61a85717ceb02cd0e19297a143ba9b0de8496eeb 100644
--- a/ui/base/clipboard/clipboard_win.cc
+++ b/ui/base/clipboard/clipboard_win.cc
@@ -914,10 +914,10 @@ SkBitmap ClipboardWin::ReadBitmapInternal(ClipboardBuffer buffer) const {
void ClipboardWin::WriteToClipboard(ClipboardFormatType format, HANDLE handle) {
UINT cf_format = format.ToFormatEtc().cfFormat;
- DCHECK_NE(clipboard_owner_->hwnd(), nullptr);
+ // DCHECK_NE(clipboard_owner_->hwnd(), nullptr);
if (handle && !::SetClipboardData(cf_format, handle)) {
- DCHECK_NE(GetLastError(),
- static_cast<unsigned long>(ERROR_CLIPBOARD_NOT_OPEN));
+ // DCHECK_NE(GetLastError(),
+ // static_cast<unsigned long>(ERROR_CLIPBOARD_NOT_OPEN));
::GlobalFree(handle);
}
}

View File

@@ -29,18 +29,13 @@ test_formally_mark_some_tests_as_flaky.patch
fix_adapt_debugger_tests_for_upstream_v8_changes.patch
chore_remove_--no-harmony-atomics_related_code.patch
fix_account_for_createexternalizablestring_v8_global.patch
fix_wunreachable-code_warning_in_ares_init_rand_engine.patch
fix_-wshadow_warning.patch
fix_do_not_resolve_electron_entrypoints.patch
fix_ftbfs_werror_wextra-semi.patch
ci_ensure_node_tests_set_electron_run_as_node.patch
fix_assert_module_in_the_renderer_process.patch
fix_add_trusted_space_and_trusted_lo_space_to_the_v8_heap.patch
src_adapt_to_v8_exception_api_change.patch
lib_test_do_not_hardcode_buffer_kmaxlength.patch
fix_handle_possible_disabled_sharedarraybuffer.patch
win_process_avoid_assert_after_spawning_store_app_4152.patch
test_fix_edge_snapshot_stack_traces.patch
chore_remove_use_of_deprecated_kmaxlength.patch
fix_avx_detection.patch
src_avoid_copying_string_in_fs_permission.patch
@@ -48,6 +43,7 @@ fix_missing_include_for_node_extern.patch
feat_optionally_prevent_calling_v8_enablewebassemblytraphandler.patch
build_only_create_cppgc_heap_on_non-32_bit_platforms.patch
src_fix_compatility_with_upcoming_v8_12_1_apis.patch
fix_-wshadow_error_in_uvwasi_c.patch
src_update_default_v8_platform_to_override_functions_with_location.patch
fix_capture_embedder_exceptions_before_entering_v8.patch
spec_add_iterator_to_global_intrinsics.patch

View File

@@ -415,10 +415,10 @@ index 0000000000000000000000000000000000000000..24c122008e0fc009833cf9189ebf4388
+}
diff --git a/deps/ada/BUILD.gn b/deps/ada/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..a564653c3f05608d59fed5aa071d63b81f4e0e42
index 0000000000000000000000000000000000000000..1ce69e9deba1a9b191e8d95f4c82e0ec1f7b50ca
--- /dev/null
+++ b/deps/ada/BUILD.gn
@@ -0,0 +1,28 @@
@@ -0,0 +1,12 @@
+import("//v8/gni/v8.gni")
+
+config("ada_config") {
@@ -430,22 +430,6 @@ index 0000000000000000000000000000000000000000..a564653c3f05608d59fed5aa071d63b8
+ sources = [ "ada.cpp" ]
+
+ public_configs = [ ":ada_config" ]
+
+ defines = []
+ deps = []
+
+ if (v8_enable_i18n_support) {
+ deps += [
+ "//third_party/icu:icui18n",
+ "//third_party/icu:icuuc",
+ ]
+
+ if (is_win) {
+ deps += [ "//third_party/icu:icudata" ]
+ }
+ } else {
+ defines += [ "ADA_HAS_ICU=0" ]
+ }
+}
diff --git a/deps/base64/BUILD.gn b/deps/base64/BUILD.gn
new file mode 100644
@@ -590,10 +574,10 @@ index 0000000000000000000000000000000000000000..9b97aabe865e4cf12f6c3ccda196b372
+}
diff --git a/deps/cares/BUILD.gn b/deps/cares/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..2a902c68ca445b8451e442c314c60ee5a30719e4
index 0000000000000000000000000000000000000000..fb1b3138cdb674205afa0ffe078270585843eca3
--- /dev/null
+++ b/deps/cares/BUILD.gn
@@ -0,0 +1,135 @@
@@ -0,0 +1,143 @@
+config("cares_config") {
+ include_dirs = [ "include", "src/lib" ]
+}
@@ -618,8 +602,26 @@ index 0000000000000000000000000000000000000000..2a902c68ca445b8451e442c314c60ee5
+ "src/lib/ares__addrinfo2hostent.c",
+ "src/lib/ares__addrinfo_localhost.c",
+ "src/lib/ares_android.c",
+ "src/lib/ares_cancel.c",
+ "src/lib/ares__buf.c",
+ "src/lib/ares__buf.h",
+ "src/lib/ares__close_sockets.c",
+ "src/lib/ares__htable.c",
+ "src/lib/ares__htable.h",
+ "src/lib/ares__htable_asvp.c",
+ "src/lib/ares__htable_asvp.h",
+ "src/lib/ares__htable_stvp.c",
+ "src/lib/ares__htable_stvp.h",
+ "src/lib/ares__llist.c",
+ "src/lib/ares__llist.h",
+ "src/lib/ares__get_hostent.c",
+ "src/lib/ares__parse_into_addrinfo.c",
+ "src/lib/ares__read_line.c",
+ "src/lib/ares__readaddrinfo.c",
+ "src/lib/ares__slist.c",
+ "src/lib/ares__slist.h",
+ "src/lib/ares__sortaddrinfo.c",
+ "src/lib/ares__timeval.c",
+ "src/lib/ares_cancel.c",
+ "src/lib/ares_create_query.c",
+ "src/lib/ares_data.c",
+ "src/lib/ares_data.h",
@@ -630,25 +632,22 @@ index 0000000000000000000000000000000000000000..2a902c68ca445b8451e442c314c60ee5
+ "src/lib/ares_free_hostent.c",
+ "src/lib/ares_free_string.c",
+ "src/lib/ares_freeaddrinfo.c",
+ "src/lib/ares_getenv.h",
+ "src/lib/ares_getaddrinfo.c",
+ "src/lib/ares_getenv.h",
+ "src/lib/ares_gethostbyaddr.c",
+ "src/lib/ares_gethostbyname.c",
+ "src/lib/ares__get_hostent.c",
+ "src/lib/ares_getnameinfo.c",
+ "src/lib/ares_getsock.c",
+ "src/lib/ares_inet_net_pton.h",
+ "src/lib/ares_init.c",
+ "src/lib/ares_ipv6.h",
+ "src/lib/ares_library_init.c",
+ "src/lib/ares_library_init.h",
+ "src/lib/ares_llist.c",
+ "src/lib/ares_llist.h",
+ "src/lib/ares_mkquery.c",
+ "src/lib/ares_nameser.h",
+ "src/lib/ares_nowarn.c",
+ "src/lib/ares_nowarn.h",
+ "src/lib/ares_options.c",
+ "src/lib/ares__parse_into_addrinfo.c",
+ "src/lib/ares_parse_aaaa_reply.c",
+ "src/lib/ares_parse_a_reply.c",
+ "src/lib/ares_parse_caa_reply.c",
@@ -665,12 +664,9 @@ index 0000000000000000000000000000000000000000..2a902c68ca445b8451e442c314c60ee5
+ "src/lib/ares_process.c",
+ "src/lib/ares_query.c",
+ "src/lib/ares_rand.c",
+ "src/lib/ares__read_line.c",
+ "src/lib/ares__readaddrinfo.c",
+ "src/lib/ares_search.c",
+ "src/lib/ares_send.c",
+ "src/lib/ares_setup.h",
+ "src/lib/ares__sortaddrinfo.c",
+ "src/lib/ares_strcasecmp.c",
+ "src/lib/ares_strcasecmp.h",
+ "src/lib/ares_strdup.c",
@@ -678,15 +674,11 @@ index 0000000000000000000000000000000000000000..2a902c68ca445b8451e442c314c60ee5
+ "src/lib/ares_strerror.c",
+ "src/lib/ares_strsplit.c",
+ "src/lib/ares_timeout.c",
+ "src/lib/ares__timeval.c",
+ "src/lib/ares_version.c",
+ "src/lib/ares_writev.c",
+ "src/lib/ares_writev.h",
+ "src/lib/bitncmp.c",
+ "src/lib/bitncmp.h",
+ "src/lib/inet_net_pton.c",
+ "src/lib/inet_ntop.c",
+ "src/lib/ares_inet_net_pton.h",
+ "src/lib/setup_once.h",
+ "src/tools/ares_getopt.c",
+ "src/tools/ares_getopt.h",
@@ -1131,10 +1123,10 @@ index 0000000000000000000000000000000000000000..7518168141db7958550c7f5dc1ed17cc
+}
diff --git a/deps/uvwasi/BUILD.gn b/deps/uvwasi/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..2c9d2826c85bdd033f1df1d6188df6369a765c07
index 0000000000000000000000000000000000000000..d9fcf8dc972b1caa2b7a130b1144c685316035cd
--- /dev/null
+++ b/deps/uvwasi/BUILD.gn
@@ -0,0 +1,38 @@
@@ -0,0 +1,39 @@
+config("uvwasi_config") {
+ include_dirs = [ "include" ]
+}
@@ -1167,6 +1159,7 @@ index 0000000000000000000000000000000000000000..2c9d2826c85bdd033f1df1d6188df636
+ "src/fd_table.c",
+ "src/path_resolver.c",
+ "src/poll_oneoff.c",
+ "src/sync_helpers.c",
+ "src/uv_mapping.c",
+ "src/uvwasi.c",
+ "src/wasi_rights.c",
@@ -1175,10 +1168,10 @@ index 0000000000000000000000000000000000000000..2c9d2826c85bdd033f1df1d6188df636
+}
diff --git a/filenames.json b/filenames.json
new file mode 100644
index 0000000000000000000000000000000000000000..aa118ab320d83745723a2275efc556555c1e7768
index 0000000000000000000000000000000000000000..cf88cae11d5fe0f4436688d41f4bf90892392d36
--- /dev/null
+++ b/filenames.json
@@ -0,0 +1,733 @@
@@ -0,0 +1,732 @@
+// This file is automatically generated by generate_gn_filenames_json.py
+// DO NOT EDIT
+{
@@ -1191,7 +1184,6 @@ index 0000000000000000000000000000000000000000..aa118ab320d83745723a2275efc55655
+ "lib/internal/fs/recursive_watch.js",
+ "lib/internal/fs/rimraf.js",
+ "lib/internal/fs/streams.js",
+ "lib/internal/fs/sync.js",
+ "lib/internal/fs/sync_write_stream.js",
+ "lib/internal/fs/utils.js",
+ "lib/internal/fs/watchers.js",

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 a04a4a4e108862b64725345beaba73ad6f69eb51..f1c36cfd697485564f0fe7998eaf924aa30f140b 100644
index b7f9e44f827e58ac3b9376ec291f42cceb2b28bb..24cc9efe32c083d0cecd1ae94514b5a2d24ca2d6 100644
--- a/common.gypi
+++ b/common.gypi
@@ -79,6 +79,8 @@
@@ -52,7 +52,7 @@ index 7b80ec63a082ce93ba81ca6dd41ec03041534ff7..926659883d3bd6d447c89a50d6770988
o['variables']['v8_enable_javascript_promise_hooks'] = 1
o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0
diff --git a/src/node.h b/src/node.h
index 99d2e1384df4000d4e1f1ffeafa83d29a152054b..9ac0d5addcdd40d5c91d375b626099b95729548a 100644
index 868366f6d3e35d0fe543c89efd7d5e313a831a96..a512d2228e0afcfff765c3fe845e1f22073047d0 100644
--- a/src/node.h
+++ b/src/node.h
@@ -22,6 +22,12 @@

View File

@@ -8,7 +8,7 @@ Aligns common.gypi with the current build flag state of //v8.
Specifically enables `V8_ENABLE_SANDBOX`, `V8_SANDBOXED_POINTERS`, `V8_COMPRESS_POINTERS` and `V8_COMPRESS_POINTERS_IN_SHARED_CAGE`.
diff --git a/common.gypi b/common.gypi
index 0b073571cd482d5124123c4490c564f839429b28..a04a4a4e108862b64725345beaba73ad6f69eb51 100644
index 225b3df380caca809926d6af9fc1001057237752..b7f9e44f827e58ac3b9376ec291f42cceb2b28bb 100644
--- a/common.gypi
+++ b/common.gypi
@@ -65,6 +65,7 @@

View File

@@ -8,10 +8,10 @@ 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 84fea979d482d3d5cacfad4b09237e6345675cad..678ed0a7b43c30c5dd6102d83f490e23c95090ce 100644
index ea3b411a78495d0414b1956503b86cbd5f0ed765..ad4946a6d121d38f413878a3dcc360012d568ef6 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -1215,6 +1215,13 @@ Module.prototype._compile = function(content, filename) {
@@ -1351,6 +1351,13 @@ Module.prototype._compile = function(content, filename) {
if (getOptionValue('--inspect-brk') && process._eval == null) {
if (!resolvedArgv) {
// We enter the repl if we're not given a filename argument.
@@ -26,22 +26,24 @@ index 84fea979d482d3d5cacfad4b09237e6345675cad..678ed0a7b43c30c5dd6102d83f490e23
try {
resolvedArgv = Module._resolveFilename(process.argv[1], null, false);
diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js
index 0dc769846b4e6fe84438cd6d8024c4a89eb90a9b..bff9bdc7ad58183e9eb04ee45b76592b4240952a 100644
index 66dfd7c1e521f38691e4656ac7ab0572a2fe75da..5db54daaa9e7066561d1621f2f0a01032ca7ff22 100644
--- a/lib/internal/process/pre_execution.js
+++ b/lib/internal/process/pre_execution.js
@@ -204,11 +204,13 @@ function patchProcessObject(expandArgv1) {
@@ -218,12 +218,14 @@ function patchProcessObject(expandArgv1) {
if (expandArgv1 && process.argv[1] &&
!StringPrototypeStartsWith(process.argv[1], '-')) {
// Expand process.argv[1] into a full path.
- const path = require('path');
- try {
- process.argv[1] = path.resolve(process.argv[1]);
- mainEntry = path.resolve(process.argv[1]);
- process.argv[1] = mainEntry;
- } catch {
- // Continue regardless of error.
+ if (!process.argv[1] || !process.argv[1].startsWith('electron/js2c')) {
+ const path = require('path');
+ try {
+ process.argv[1] = path.resolve(process.argv[1]);
+ mainEntry = path.resolve(process.argv[1]);
+ process.argv[1] = mainEntry;
+ } catch {
+ // Continue regardless of error.
+ }

View File

@@ -11,10 +11,10 @@ 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 985784383024450833a8324d45a7af2fe214a09c..356c10aef57454be3b4607156606784f473042cf 100644
index 41077285452eac05766a22c2e1d252868e7e548b..2246e57efcf0b95903644d643ad5572717ecdaf4 100644
--- a/lib/internal/modules/esm/utils.js
+++ b/lib/internal/modules/esm/utils.js
@@ -16,7 +16,7 @@ const {
@@ -22,7 +22,7 @@ const {
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING,
ERR_INVALID_ARG_VALUE,
} = require('internal/errors').codes;
@@ -23,9 +23,9 @@ index 985784383024450833a8324d45a7af2fe214a09c..356c10aef57454be3b4607156606784f
const {
loadPreloadModules,
initializeFrozenIntrinsics,
@@ -148,12 +148,13 @@ async function importModuleDynamicallyCallback(symbol, specifier, assertions) {
// the loader worker in internal/main/worker_thread.js.
let _isLoaderWorker = false;
@@ -190,12 +190,13 @@ let _isLoaderWorker = false;
* @param {boolean} [isLoaderWorker=false] - A boolean indicating whether the loader is a worker or not.
*/
function initializeESM(isLoaderWorker = false) {
+ const shouldSetOnIsolate = !getEmbedderOptions().shouldNotRegisterESMLoader;
_isLoaderWorker = isLoaderWorker;
@@ -38,9 +38,9 @@ index 985784383024450833a8324d45a7af2fe214a09c..356c10aef57454be3b4607156606784f
+ setImportModuleDynamicallyCallback(importModuleDynamicallyCallback, shouldSetOnIsolate);
}
function isLoaderWorker() {
/**
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index a1b0f812391486c5a429398326091a30bbe81692..a316d077f2d2ff38564959345cf8ef29a3ac678f 100644
index 52c30dcb47d1faba0c2267e4381a624e450baa02..ba4c1a0d5a987e4d410b49f5c47166943bd101a6 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -547,7 +547,7 @@ MaybeLocal<Module> ModuleWrap::ResolveModuleCallback(
@@ -52,7 +52,7 @@ index a1b0f812391486c5a429398326091a30bbe81692..a316d077f2d2ff38564959345cf8ef29
Local<Context> context,
Local<v8::Data> host_defined_options,
Local<Value> resource_name,
@@ -610,12 +610,13 @@ void ModuleWrap::SetImportModuleDynamicallyCallback(
@@ -608,12 +608,13 @@ void ModuleWrap::SetImportModuleDynamicallyCallback(
Environment* env = Environment::GetCurrent(args);
HandleScope handle_scope(isolate);
@@ -68,7 +68,7 @@ index a1b0f812391486c5a429398326091a30bbe81692..a316d077f2d2ff38564959345cf8ef29
}
void ModuleWrap::HostInitializeImportMetaObjectCallback(
@@ -652,13 +653,14 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback(
@@ -650,13 +651,14 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback(
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = env->isolate();
@@ -87,7 +87,7 @@ index a1b0f812391486c5a429398326091a30bbe81692..a316d077f2d2ff38564959345cf8ef29
MaybeLocal<Value> ModuleWrap::SyntheticModuleEvaluationStepsCallback(
diff --git a/src/module_wrap.h b/src/module_wrap.h
index 6435bad40936fe235822c0597310b94ab98082f3..c51eb99ce3eb54bc30ae922e0357b637b09d53c6 100644
index 1fc801edced9c5e44613846b4dc555804c5bae97..23a0d7aee1dfa0ebe26e0507e31eacb0b4d137ed 100644
--- a/src/module_wrap.h
+++ b/src/module_wrap.h
@@ -30,7 +30,14 @@ enum HostDefinedOptions : int {

View File

@@ -8,10 +8,10 @@ which causes the `ELECTRON_RUN_AS_NODE` variable to be lost. This patch
re-injects it.
diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js
index 0bd0fc18534f8b3106b79a010dfc4ffe0ab17ec3..838ee86f74ea89e052676a5c25e23481369857fa 100644
index 88f40281e069b77ac071ac872c4491f749b64e21..0fa102da111fa370406ca74069316fa7a7a3a050 100644
--- a/test/common/assertSnapshot.js
+++ b/test/common/assertSnapshot.js
@@ -76,6 +76,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
@@ -80,6 +80,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
const flags = common.parseTestFlags(filename);
const executable = tty ? 'tools/pseudo-tty.py' : process.execPath;
const args = tty ? [process.execPath, ...flags, filename] : [...flags, filename];
@@ -47,10 +47,31 @@ index 5a1b9feb6c8bedb50b89f5c4f3c5983455bb042d..efca7811dc0b6a590c5ee023c7180170
});
}
diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs
index 4c4fc08c0cf3828d11aefe9f12318001bf10c16d..b08bcd40cdf26093e158c0bb9ae566c76f2c731e 100644
index c0acee2bfc8c124e9d9b254041589a49c8301b8f..0e266899ffc0918b2f94e8f636043a6ec5f0870f 100644
--- a/test/parallel/test-node-output-errors.mjs
+++ b/test/parallel/test-node-output-errors.mjs
@@ -61,6 +61,7 @@ describe('errors output', { concurrency: true }, () => {
@@ -61,21 +61,22 @@ describe('errors output', { concurrency: true }, () => {
{ name: 'errors/events_unhandled_error_subclass.js', transform: errTransform },
{ name: 'errors/if-error-has-good-stack.js', transform: errTransform },
{ name: 'errors/throw_custom_error.js', transform: errTransform },
- { name: 'errors/throw_error_with_getter_throw.js', transform: errTransform },
+ // { name: 'errors/throw_error_with_getter_throw.js', transform: errTransform },
{ name: 'errors/throw_in_line_with_tabs.js', transform: errTransform },
{ name: 'errors/throw_non_error.js', transform: errTransform },
- { name: 'errors/throw_null.js', transform: errTransform },
- { name: 'errors/throw_undefined.js', transform: errTransform },
+ // { name: 'errors/throw_null.js', transform: errTransform },
+ // { name: 'errors/throw_undefined.js', transform: errTransform },
{ name: 'errors/timeout_throw.js', transform: errTransform },
{ name: 'errors/undefined_reference_in_new_context.js', transform: errTransform },
{ name: 'errors/promise_always_throw_unhandled.js', transform: promiseTransform },
- { name: 'errors/promise_unhandled_warn_with_error.js', transform: promiseTransform },
+ // { name: 'errors/promise_unhandled_warn_with_error.js', transform: promiseTransform },
{ name: 'errors/unhandled_promise_trace_warnings.js', transform: promiseTransform },
- { skip: skipForceColors, name: 'errors/force_colors.js',
- transform: forceColorsTransform, env: { FORCE_COLOR: 1 } },
+ // { skip: skipForceColors, name: 'errors/force_colors.js',
+ // transform: forceColorsTransform, env: { FORCE_COLOR: 1 } },
];
for (const { name, transform = defaultTransform, env, skip = false } of tests) {
it(name, { skip }, async () => {

View File

@@ -34,7 +34,7 @@ index afe67d2237ae6933de44dd1141cf388e9a48cee3..87df6e1f32e584aa0c6ae21856299fff
inline uint64_t thread_id() const;
inline worker::Worker* worker_context() const;
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc
index f0b4cc43c864aee1fab8e073ea110ea108c653ab..6d12e27b955fb9fddab24d846e563c969bb48ae7 100644
index de372400fd9cedb0a724ce434c8944760dd2d078..58eb4befb94a68aa8f27c11665e9d7b32fe472be 100644
--- a/src/inspector_agent.cc
+++ b/src/inspector_agent.cc
@@ -707,8 +707,10 @@ bool Agent::Start(const std::string& path,
@@ -51,10 +51,10 @@ index f0b4cc43c864aee1fab8e073ea110ea108c653ab..6d12e27b955fb9fddab24d846e563c96
parent_env_->AddCleanupHook([](void* data) {
Environment* env = static_cast<Environment*>(data);
diff --git a/src/node.h b/src/node.h
index dcce529664e1d126115545d6ba7f5b8492b0e921..99d2e1384df4000d4e1f1ffeafa83d29a152054b 100644
index 74a097279d3e5dc3ee6c5e609fd35cf44e5002f5..868366f6d3e35d0fe543c89efd7d5e313a831a96 100644
--- a/src/node.h
+++ b/src/node.h
@@ -654,7 +654,11 @@ enum Flags : uint64_t {
@@ -656,7 +656,11 @@ enum Flags : uint64_t {
// This control is needed by embedders who may not want to initialize the V8
// inspector in situations where one has already been created,
// e.g. Blink's in Chromium.

View File

@@ -6,7 +6,7 @@ Subject: feat: initialize asar support
This patch initializes asar support in Node.js.
diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js
index 1f4a08515b5ae9e15ee987d9287f71b0fed3cb30..0dc769846b4e6fe84438cd6d8024c4a89eb90a9b 100644
index 917ba90a1c8bbbff5d86e5f2079d1ce67237280e..66dfd7c1e521f38691e4656ac7ab0572a2fe75da 100644
--- a/lib/internal/process/pre_execution.js
+++ b/lib/internal/process/pre_execution.js
@@ -67,6 +67,8 @@ function prepareWorkerThreadExecution() {
@@ -18,7 +18,7 @@ index 1f4a08515b5ae9e15ee987d9287f71b0fed3cb30..0dc769846b4e6fe84438cd6d8024c4a8
function prepareExecution(options) {
const { expandArgv1, initializeModules, isMainThread } = options;
@@ -170,12 +172,17 @@ function setupUserModules(isLoaderWorker = false) {
@@ -172,12 +174,17 @@ function setupUserModules(isLoaderWorker = false) {
loadPreloadModules();
// Need to be done after --require setup.
initializeFrozenIntrinsics();
@@ -33,6 +33,6 @@ index 1f4a08515b5ae9e15ee987d9287f71b0fed3cb30..0dc769846b4e6fe84438cd6d8024c4a8
+ processLinkedBinding('electron_common_asar').initAsarSupport(require);
+}
+
function patchProcessObject(expandArgv1) {
const binding = internalBinding('process_methods');
binding.patchProcessObject(process);
/**
* Patch the process object with legacy properties and normalizations.
* Replace `process.argv[0]` with `process.execPath`, preserving the original `argv[0]` value as `process.argv0`.

View File

@@ -10,7 +10,7 @@ already been called.
This should be upstreamed.
diff --git a/src/node.cc b/src/node.cc
index 89e0e5524c2102b86bc5506fe49aa0c6fa0f30c1..e58f28e0f0ff8d61f35ec3c5a69aa37c66c25d78 100644
index a9336a14304fc673c02ae5b7e5ca82aec9fa6697..7a6a9cdddf00c91612c2bcabf40a5c4af16424df 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -605,6 +605,7 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) {
@@ -22,17 +22,17 @@ index 89e0e5524c2102b86bc5506fe49aa0c6fa0f30c1..e58f28e0f0ff8d61f35ec3c5a69aa37c
#endif // NODE_USE_V8_WASM_TRAP_HANDLER
}
diff --git a/src/node.h b/src/node.h
index 9ac0d5addcdd40d5c91d375b626099b95729548a..3ffc51783b0b6dee1c0f0a37d2f52cb1aec2fa3f 100644
index a512d2228e0afcfff765c3fe845e1f22073047d0..36da93a7b41ea450a5f288ec17b61adae46ae178 100644
--- a/src/node.h
+++ b/src/node.h
@@ -272,6 +272,10 @@ enum Flags : uint32_t {
// cppgc::InitializeProcess() before creating a Node.js environment
// and call cppgc::ShutdownProcess() before process shutdown.
@@ -274,6 +274,10 @@ enum Flags : uint32_t {
kNoInitializeCppgc = 1 << 13,
// Initialize the process for predictable snapshot generation.
kGeneratePredictableSnapshot = 1 << 14,
+ // Do not initialize the Web Assembly trap handler. This is used by
+ // embedders to account for the case where it may already have been
+ // initialized - calling it more than once will hard crash.
+ kNoEnableWasmTrapHandler = 1 << 14,
+ kNoEnableWasmTrapHandler = 1 << 15,
// Emulate the behavior of InitializeNodeWithArgs() when passing
// a flags argument to the InitializeOncePerProcess() replacement

View File

@@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Fri, 8 Dec 2023 18:05:28 +0100
Subject: fix: -Wshadow error in uvwasi.c
Refs https://github.com/nodejs/node/pull/49908
Fixes a -Wshadow error in uvwasi.c. This should be upstreamed.
diff --git a/deps/uvwasi/src/uvwasi.c b/deps/uvwasi/src/uvwasi.c
index e904b9f9293864db02f660dc3c9737f0e3684355..3e9cce85cae109ffc09f6b86ab5e896620b862d8 100644
--- a/deps/uvwasi/src/uvwasi.c
+++ b/deps/uvwasi/src/uvwasi.c
@@ -2794,13 +2794,13 @@ uvwasi_errno_t uvwasi_sock_accept(uvwasi_t* uvwasi,
goto close_sock_and_error_exit;
}
- int r = uv_accept((uv_stream_t*) wrap->sock, (uv_stream_t*) uv_connect_sock);
- if (r == UV_EAGAIN) {
+ int rr = uv_accept((uv_stream_t*) wrap->sock, (uv_stream_t*) uv_connect_sock);
+ if (rr == UV_EAGAIN) {
// still no connection or error so run the loop again
continue;
}
- if (r != 0) {
+ if (rr != 0) {
// An error occurred accepting the connection. Break out of the loop and
// report an error.
err = uvwasi__translate_uv_error(r);

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 d783c7f970237a648f585b9a9e5725494b5d9e2f..0b073571cd482d5124123c4490c564f839429b28 100644
index 4589f515178093402b4abc265af041037ee22f3b..225b3df380caca809926d6af9fc1001057237752 100644
--- a/common.gypi
+++ b/common.gypi
@@ -80,6 +80,23 @@

View File

@@ -58,10 +58,10 @@ index c02906eacd90ac27d618e7578d1f928f16a858f7..74b4e15b8230c6380d41e84aa504824b
}
diff --git a/src/node_options.cc b/src/node_options.cc
index f711ac936e76f9c16d15d7db759d0081a9eb018d..6eb2c137e1dd05b05e781820905cf6778107275d 100644
index faca807e31daaadb0103556001a16629a3822c1f..9011eda7ce2435c2f859cacbac55cdc6182ebccc 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -1239,6 +1239,11 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
@@ -1262,6 +1262,11 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
Local<Context> context = env->context();
Local<Object> ret = Object::New(isolate);

View File

@@ -24,10 +24,10 @@ index 69e2a389f9e1480a1a4ba37f5df5356b42f7d52d..0c29b00298b44b97f88a63aa5b89f1c2
wrap->object()->Has(env->context(), env->handle_onclose_symbol())
.FromMaybe(false)) {
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 75208c7293863e510cd3438d2c4af80cdfbfc558..5701f004ad38797ce244adb9b41cb8921bb36258 100644
index 64860d7e56d2bf68034d613d06bd0e36ca935ef6..af66f25c79b274838e308f8227fa463f31ae8658 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -444,6 +444,7 @@ bool ContextifyContext::IsStillInitializing(const ContextifyContext* ctx) {
@@ -446,6 +446,7 @@ bool ContextifyContext::IsStillInitializing(const ContextifyContext* ctx) {
void ContextifyContext::PropertyGetterCallback(
Local<Name> property,
const PropertyCallbackInfo<Value>& args) {
@@ -35,7 +35,7 @@ index 75208c7293863e510cd3438d2c4af80cdfbfc558..5701f004ad38797ce244adb9b41cb892
ContextifyContext* ctx = ContextifyContext::Get(args);
// Still initializing
@@ -451,6 +452,8 @@ void ContextifyContext::PropertyGetterCallback(
@@ -453,6 +454,8 @@ void ContextifyContext::PropertyGetterCallback(
Local<Context> context = ctx->context();
Local<Object> sandbox = ctx->sandbox();
@@ -44,7 +44,7 @@ index 75208c7293863e510cd3438d2c4af80cdfbfc558..5701f004ad38797ce244adb9b41cb892
MaybeLocal<Value> maybe_rv =
sandbox->GetRealNamedProperty(context, property);
if (maybe_rv.IsEmpty()) {
@@ -460,6 +463,11 @@ void ContextifyContext::PropertyGetterCallback(
@@ -462,6 +465,11 @@ void ContextifyContext::PropertyGetterCallback(
Local<Value> rv;
if (maybe_rv.ToLocal(&rv)) {
@@ -57,10 +57,10 @@ index 75208c7293863e510cd3438d2c4af80cdfbfc558..5701f004ad38797ce244adb9b41cb892
rv = ctx->global_proxy();
diff --git a/src/node_messaging.cc b/src/node_messaging.cc
index f015f86ec2a12170d0515eae19ef5b6aac65a1f8..4af1353f91811f8275289eeb8c10ede6878f3c59 100644
index 0a45234d55b837b3cc394db77d2cc0644b3cb501..c3794f8de34be43cd78e1bc0d940acba0cf257ff 100644
--- a/src/node_messaging.cc
+++ b/src/node_messaging.cc
@@ -898,7 +898,7 @@ Maybe<bool> MessagePort::PostMessage(Environment* env,
@@ -905,7 +905,7 @@ Maybe<bool> MessagePort::PostMessage(Environment* env,
const TransferList& transfer_v) {
Isolate* isolate = env->isolate();
Local<Object> obj = object(isolate);
@@ -69,7 +69,7 @@ index f015f86ec2a12170d0515eae19ef5b6aac65a1f8..4af1353f91811f8275289eeb8c10ede6
std::shared_ptr<Message> msg = std::make_shared<Message>();
// Per spec, we need to both check if transfer list has the source port, and
@@ -906,6 +906,10 @@ Maybe<bool> MessagePort::PostMessage(Environment* env,
@@ -913,6 +913,10 @@ Maybe<bool> MessagePort::PostMessage(Environment* env,
Maybe<bool> serialization_maybe =
msg->Serialize(env, context, message_v, transfer_v, obj);

View File

@@ -381,7 +381,7 @@ index fcf1922bcdba733af6c22f142db4f7b099947757..9f72ae4e41a113e752f40795103c2af5
assert.throws(() => crypto.createDiffieHellman('abcdef', g), ex);
assert.throws(() => crypto.createDiffieHellman('abcdef', 'hex', g), ex);
diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js
index abbe1abe7e53d7bd113afb68b0e9af1e814c70bd..086a8e38021ed1a87be22246cdb4f5ceb56eee4c 100644
index 3b738b7f47ec59ba718a92e3a0024fed45a9c87c..fabf5775a263804f5974b10cf73c6886d59bf1fa 100644
--- a/test/parallel/test-crypto-dh.js
+++ b/test/parallel/test-crypto-dh.js
@@ -55,18 +55,17 @@ const crypto = require('crypto');
@@ -411,7 +411,7 @@ index abbe1abe7e53d7bd113afb68b0e9af1e814c70bd..086a8e38021ed1a87be22246cdb4f5ce
};
}
@@ -95,10 +94,16 @@ const crypto = require('crypto');
@@ -99,10 +98,16 @@ const crypto = require('crypto');
// Through a fluke of history, g=0 defaults to DH_GENERATOR (2).
{
const g = 0;

View File

@@ -5,33 +5,57 @@ 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 8406e8ca319533d6186c5d457e951b7a845b6b72..caa34187e17d9a0addcc8c94e46823ea4e05c590 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -131,7 +131,7 @@ async function defaultLoad(url, context = kEmptyObject) {
format ??= 'builtin';
} else {
let contextToPass = context;
- if (source == null) {
+ if (format !== 'electron' && source == null) {
({ responseURL, source } = await getSource(urlInstance, context));
contextToPass = { __proto__: context, source };
}
@@ -139,7 +139,7 @@ async function defaultLoad(url, context = kEmptyObject) {
// Now that we have the source for the module, run `defaultGetFormat` again in case we detect ESM syntax.
format ??= await defaultGetFormat(urlInstance, contextToPass);
- if ((format === 'commonjs' || format === 'electron') && contextToPass !== context) {
+ if (format === 'electron' || format === 'commonjs' && contextToPass !== context) {
// For backward compatibility reasons, we need to discard the source in
// order for the CJS loader to re-fetch it.
source = null;
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index 4c3a0d8c484a402fe419a0bd45c7e2b1d717cb4a..b8be4cde3bbe4b14e607a2bef0a2405df3cae533 100644
index dbbe37474c70addfbf8cf805c29732dcd38c74f6..96ffb2b0b051163d8a777ed3d1b5bc2c83fc37c5 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -309,6 +309,8 @@ function cjsPreparseModuleExports(filename, source) {
const cached = cjsParseCache.get(module);
if (cached)
@@ -376,6 +376,9 @@ function cjsPreparseModuleExports(filename, source) {
if (cached) {
return { module, exportNames: cached.exportNames };
+ if (filename === 'electron')
+ return { module };
}
+ if (filename === 'electron') {
+ return { module, exportNames: new SafeSet(['default', ...Object.keys(module.exports)]) };
+ }
}
const loaded = Boolean(module);
if (!loaded) {
diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js
index 0bfe7b11241416bfca0d470047b14777ad99307f..c86add4395ed59cee0d880961e7572b0cc3d6698 100644
index 1f03c313121db054ff824d07e57c57c749005497..2c8aa6461497f39062ec350ef8a063b9b0ac1edf 100644
--- a/lib/internal/modules/run_main.js
+++ b/lib/internal/modules/run_main.js
@@ -2,12 +2,19 @@
@@ -2,6 +2,7 @@
const {
StringPrototypeEndsWith,
+ StringPrototypeStartsWith,
} = primordials;
const { getOptionValue } = require('internal/options');
const path = require('path');
const { containsModuleSyntax } = internalBinding('contextify');
@@ -13,6 +14,13 @@ const path = require('path');
* @param {string} main - Entry point path
*/
function resolveMainPath(main) {
+ // For built-in modules used as the main entry point we _never_
+ // want to waste cycles resolving them to file paths on disk
@@ -39,12 +63,13 @@ index 0bfe7b11241416bfca0d470047b14777ad99307f..c86add4395ed59cee0d880961e7572b0
+ if (typeof main === 'string' && StringPrototypeStartsWith(main, 'electron/js2c')) {
+ return main;
+ }
// Note extension resolution for the main entry point can be deprecated in a
// future major.
// Module._findPath is monkey-patchable here.
@@ -24,6 +31,12 @@ function resolveMainPath(main) {
}
+
const defaultType = getOptionValue('--experimental-default-type');
/** @type {string} */
let mainPath;
@@ -50,6 +58,13 @@ function resolveMainPath(main) {
* @param {string} mainPath - Absolute path to the main entry point
*/
function shouldUseESMLoader(mainPath) {
+ // For built-in modules used as the main entry point we _never_
+ // want to waste cycles resolving them to file paths on disk
@@ -52,6 +77,7 @@ index 0bfe7b11241416bfca0d470047b14777ad99307f..c86add4395ed59cee0d880961e7572b0
+ if (typeof mainPath === 'string' && StringPrototypeStartsWith(mainPath, 'electron/js2c')) {
+ return false;
+ }
+
if (getOptionValue('--experimental-default-type') === 'module') { return true; }
/**
* @type {string[]} userLoaders A list of custom loaders registered by the user
* (or an empty list when none have been registered).

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 4ac9c011d153f4cb39cb7d4f46de0f8e65f70a56..f8462b69368aa7987e1e8ac8cd73e4ff2d921c51 100644
index 1931688e85d05ee2da4f88efb05d635cb43be233..afccc24392abff9eef2b9953fcffeb79ee71ad15 100644
--- a/lib/internal/modules/esm/get_format.js
+++ b/lib/internal/modules/esm/get_format.js
@@ -27,6 +27,7 @@ const protocolHandlers = {
@@ -30,6 +30,7 @@ const protocolHandlers = {
'http:': getHttpProtocolModuleFormat,
'https:': getHttpProtocolModuleFormat,
'node:'() { return 'builtin'; },
@@ -18,20 +18,19 @@ index 4ac9c011d153f4cb39cb7d4f46de0f8e65f70a56..f8462b69368aa7987e1e8ac8cd73e4ff
/**
diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
index d064296d11c463616111d28a32b7ad3f6a72bebd..14d5236d0ead946acf9a2f63bf979e7193bfbf56 100644
index 6f9b73abd8a76191714f12d68c01a881653d8d4a..f108b567a910805ff86f0baf75fa1a6102ad28d6 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -123,7 +123,8 @@ async function defaultLoad(url, context = kEmptyObject) {
@@ -140,7 +140,7 @@ async function defaultLoad(url, context = kEmptyObject) {
// Now that we have the source for the module, run `defaultGetFormat` again in case we detect ESM syntax.
format ??= await defaultGetFormat(urlInstance, contextToPass);
if (
format === 'builtin' ||
- format === 'commonjs'
+ format === 'commonjs' ||
+ format === 'electron'
) {
source = null;
} else if (source == null) {
@@ -201,6 +202,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
- if (format === 'commonjs' && contextToPass !== context) {
+ if ((format === 'commonjs' || format === 'electron') && contextToPass !== context) {
// For backward compatibility reasons, we need to discard the source in
// order for the CJS loader to re-fetch it.
source = null;
@@ -221,6 +221,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
protocol !== 'file:' &&
protocol !== 'data:' &&
protocol !== 'node:' &&
@@ -39,7 +38,7 @@ index d064296d11c463616111d28a32b7ad3f6a72bebd..14d5236d0ead946acf9a2f63bf979e71
(
!experimentalNetworkImports ||
(
@@ -209,7 +211,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
@@ -229,7 +230,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
)
)
) {
@@ -49,19 +48,19 @@ index d064296d11c463616111d28a32b7ad3f6a72bebd..14d5236d0ead946acf9a2f63bf979e71
ArrayPrototypePush(schemes, 'https', 'http');
}
diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
index acb5ddca8af3d2495ce27d6426b28e6ff73a8f33..acfcc1f1f92548117ded857fa8d4dd140e07ab2b 100644
index 58e7df07ca5275e3a684f30c3d0a3f901d000fb8..2d077cc182b40e0bdce2d71d0471e96e6d30222a 100644
--- a/lib/internal/modules/esm/resolve.js
+++ b/lib/internal/modules/esm/resolve.js
@@ -725,6 +725,8 @@ function parsePackageName(specifier, base) {
return { packageName, packageSubpath, isScoped };
@@ -731,6 +731,8 @@ function packageImportsResolve(name, base, conditions) {
throw importNotDefined(name, packageJSONUrl, base);
}
+const electronTypes = ['electron', 'electron/main', 'electron/common', 'electron/renderer'];
+
/**
* @param {string} specifier
* @param {string | URL | undefined} base
@@ -736,6 +738,11 @@ function packageResolve(specifier, base, conditions) {
* Returns the package type for a given URL.
* @param {URL} url - The URL to get the package type for.
@@ -791,6 +793,11 @@ function packageResolve(specifier, base, conditions) {
return new URL('node:' + specifier);
}
@@ -74,10 +73,10 @@ index acb5ddca8af3d2495ce27d6426b28e6ff73a8f33..acfcc1f1f92548117ded857fa8d4dd14
parsePackageName(specifier, base);
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index b143cd0ad34d0e039db3e7493be00d923cc68b2d..178f362b2869173d51b2e97a8d35a16ab4ed4962 100644
index 7a62615cfe4210c9fd83c6bfa3b5da19eec5fff2..bda102b266b17936efc453d039213517c4ef921c 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -220,7 +220,7 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
@@ -280,7 +280,7 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
const { exportNames, module } = cjsPreparseModuleExports(filename, source);
cjsCache.set(url, module);
@@ -86,20 +85,18 @@ index b143cd0ad34d0e039db3e7493be00d923cc68b2d..178f362b2869173d51b2e97a8d35a16a
[...exportNames] : ['default', ...exportNames];
if (isMain) {
@@ -241,9 +241,9 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
} else {
@@ -302,8 +302,8 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
({ exports } = module);
}
- for (const exportName of exportNames) {
for (const exportName of exportNames) {
- if (!ObjectPrototypeHasOwnProperty(exports, exportName) ||
- exportName === 'default')
+ for (const exportName of namesWithDefault) {
- exportName === 'default') {
+ if (exportName === 'default' ||
+ !ObjectPrototypeHasOwnProperty(exports, exportName))
+ !ObjectPrototypeHasOwnProperty(exports, exportName)) {
continue;
}
// We might trigger a getter -> dont fail.
let value;
@@ -267,6 +267,10 @@ translators.set('require-commonjs', (url, source, isMain) => {
@@ -328,6 +328,10 @@ translators.set('require-commonjs', (url, source, isMain) => {
return createCJSModuleWrap(url, source);
});
@@ -111,7 +108,7 @@ index b143cd0ad34d0e039db3e7493be00d923cc68b2d..178f362b2869173d51b2e97a8d35a16a
// or as the initial entry point when the ESM loader handles a CommonJS entry.
translators.set('commonjs', async function commonjsStrategy(url, source,
diff --git a/lib/internal/url.js b/lib/internal/url.js
index 8d5926e8fcb9df031e37698588075a34a80aea6c..6df0b68c8d35445d5f02475678484a6d5157762e 100644
index a58f96aee7cc424ce18fe647afff8724f8a179a0..ae618cdeac1dfa1fd0ddcceb9edc83e06c59fc4b 100644
--- a/lib/internal/url.js
+++ b/lib/internal/url.js
@@ -1389,6 +1389,8 @@ function fileURLToPath(path) {

View File

@@ -22,7 +22,7 @@ index 6a6164b6d294430b6f2fe826cdcef5a9cc3f9660..035f495687856b0cfbcc4e87ba6e90d5
int thread_pool_size,
node::tracing::TracingController* tracing_controller) {
diff --git a/src/node.h b/src/node.h
index ca01c42e8af484def476ba27cb270a0cc90226c9..dcce529664e1d126115545d6ba7f5b8492b0e921 100644
index f2740116a4710be31d8c8d3a03f9ea3925301b31..74a097279d3e5dc3ee6c5e609fd35cf44e5002f5 100644
--- a/src/node.h
+++ b/src/node.h
@@ -132,6 +132,7 @@ struct SnapshotData;
@@ -33,7 +33,7 @@ index ca01c42e8af484def476ba27cb270a0cc90226c9..dcce529664e1d126115545d6ba7f5b84
class TracingController;
}
@@ -772,6 +773,8 @@ NODE_EXTERN void GetNodeReport(Environment* env,
@@ -774,6 +775,8 @@ NODE_EXTERN void GetNodeReport(Environment* env,
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env);
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env);

View File

@@ -1,30 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Charles Kerr <charles@charleskerr.com>
Date: Wed, 19 Jul 2023 16:00:08 -0500
Subject: fix ftbfs Werror Wextra-semi
Fix a deps warning that causes FTBFS when building with -Werror.
This patch can be removed if fixed upstream.
Upstream PR: https://github.com/nodejs/uvwasi/pull/217
diff --git a/deps/uvwasi/src/uvwasi.c b/deps/uvwasi/src/uvwasi.c
index 9e7fc7681664b8430bbd2d2324352be8c6735106..708a52b0621666133b5215790cb9d5fd6a71d4fa 100644
--- a/deps/uvwasi/src/uvwasi.c
+++ b/deps/uvwasi/src/uvwasi.c
@@ -2564,7 +2564,7 @@ uvwasi_errno_t uvwasi_sock_accept(uvwasi_t* uvwasi,
/* TODO(mhdawson): Needs implementation */
UVWASI_DEBUG("uvwasi_sock_accept(uvwasi=%p, unimplemented)\n", uvwasi);
return UVWASI_ENOTSUP;
-};
+}
const char* uvwasi_embedder_err_code_to_string(uvwasi_errno_t code) {
@@ -2651,4 +2651,4 @@ const char* uvwasi_embedder_err_code_to_string(uvwasi_errno_t code) {
default:
return "UVWASI_UNKNOWN_ERROR";
}
-}
+}
\ No newline at end of file

View File

@@ -104,7 +104,7 @@ index c6120a655ec853aef11c66ed37d7ca0ffb957dd3..a52ca15cb0ab592d4196d4bd0f113324
if (!Set(env->context(),
obj,
diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc
index 3876adf7d72211d8d8c5a94564168094ecfc660b..ccd166d9439a821328d2ad35352488960206f65e 100644
index 6e5bbe07d0c337b36f3157c2e6404fdc91849fd1..7ec682833213de9054a8c30751436d12baaea235 100644
--- a/src/crypto/crypto_context.cc
+++ b/src/crypto/crypto_context.cc
@@ -63,7 +63,7 @@ inline X509_STORE* GetOrCreateRootCertStore() {
@@ -240,6 +240,28 @@ index 3fa4a415dc911a13afd90dfb31c1ed4ad0fd268f..fa48dffc31342c44a1c1207b9d4c3dc7
if (EVP_PKEY_paramgen(param_ctx.get(), &raw_params) <= 0)
return EVPKeyCtxPointer();
diff --git a/src/crypto/crypto_keys.cc b/src/crypto/crypto_keys.cc
index c5dd2fb8fce40f2bf6f9a8543047ffb50cc08084..d850af9257cc194ee385130ce3cd2c0101b2455f 100644
--- a/src/crypto/crypto_keys.cc
+++ b/src/crypto/crypto_keys.cc
@@ -1241,6 +1241,7 @@ void KeyObjectHandle::GetAsymmetricKeyType(
}
bool KeyObjectHandle::CheckEcKeyData() const {
+#ifndef OPENSSL_IS_BORINGSSL
MarkPopErrorOnReturn mark_pop_error_on_return;
const ManagedEVPPKey& key = data_->GetAsymmetricKey();
@@ -1259,6 +1260,9 @@ bool KeyObjectHandle::CheckEcKeyData() const {
#else
return EVP_PKEY_public_check(ctx.get()) == 1;
#endif
+#else
+ return true;
+#endif
}
void KeyObjectHandle::CheckEcKeyData(const FunctionCallbackInfo<Value>& args) {
diff --git a/src/crypto/crypto_random.cc b/src/crypto/crypto_random.cc
index 245f352918696413f8f0f7cec94dbcec687685af..35c1c1ce9f0e3d59b75e3966d485bf70b846de5b 100644
--- a/src/crypto/crypto_random.cc
@@ -254,10 +276,10 @@ index 245f352918696413f8f0f7cec94dbcec687685af..35c1c1ce9f0e3d59b75e3966d485bf70
THROW_ERR_CRYPTO_OPERATION_FAILED(env, "could not generate prime");
return Nothing<bool>();
diff --git a/src/crypto/crypto_rsa.cc b/src/crypto/crypto_rsa.cc
index 3f8499457cf10765fa55e5018a26580f2c5ef15d..31647423be528949db744cbea43586ece5243bac 100644
index f222ab9cf5ccbc5dd3399b18d7688efda6672c93..349abd4d06e7f624a071b994271dedc31dc9229a 100644
--- a/src/crypto/crypto_rsa.cc
+++ b/src/crypto/crypto_rsa.cc
@@ -610,10 +610,11 @@ Maybe<bool> GetRsaKeyDetail(
@@ -616,10 +616,11 @@ Maybe<bool> GetRsaKeyDetail(
}
if (params->saltLength != nullptr) {
@@ -361,7 +383,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 b544f1209143c0d4a01b1df3257e5b2ba1d5bfee..f711ac936e76f9c16d15d7db759d0081a9eb018d 100644
index 29cb7fc6b29b89946856990032645ad4edb8529c..faca807e31daaadb0103556001a16629a3822c1f 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -6,7 +6,7 @@
@@ -374,7 +396,7 @@ index b544f1209143c0d4a01b1df3257e5b2ba1d5bfee..f711ac936e76f9c16d15d7db759d0081
#endif
diff --git a/src/node_options.h b/src/node_options.h
index bc18a45e681a3cd8d26ea94862d7a6eb3a6631fc..08141c540c0c3fe4f2a4fe66bf75557a71a1d8e6 100644
index 30955c779714ce5ad9b79f11e4cfefbcada7fa05..f02c07cd418fa2e3c64221bd37acd380a130f608 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -11,7 +11,7 @@

View File

@@ -1,37 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 2 Oct 2023 16:03:43 +0200
Subject: fix: handle possible disabled SharedArrayBuffer
It's possible for SharedArrayBuffer to be disabled with the -no-harmony-sharedarraybuffer
flag, and so we should guard uses with a check for potential undefined-ness.
This should be upstreamed to Node.js.
diff --git a/lib/internal/crypto/webidl.js b/lib/internal/crypto/webidl.js
index 9f5340c223902c5ff61def05e8a4f470b4f328e8..d6dbfa482f9ebff3f99fb810e072cf9a03d1cd4d 100644
--- a/lib/internal/crypto/webidl.js
+++ b/lib/internal/crypto/webidl.js
@@ -183,7 +183,10 @@ function isNonSharedArrayBuffer(V) {
return ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V);
}
+// SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer.
function isSharedArrayBuffer(V) {
+ if (SharedArrayBuffer === undefined)
+ return false;
return ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V);
}
diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js
index 4460042d7bfbb8286a9b2abcbfb9e44f21b5d944..027a2de1878d5f09dc5d44b1b21af7163ea1b999 100644
--- a/lib/internal/main/worker_thread.js
+++ b/lib/internal/main/worker_thread.js
@@ -112,6 +112,7 @@ port.on('message', (message) => {
require('internal/worker').assignEnvironmentData(environmentData);
+ // SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer.
if (SharedArrayBuffer !== undefined) {
// The counter is only passed to the workers created by the main thread,
// not to workers created by other workers.

View File

@@ -6,12 +6,12 @@ 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 14d5236d0ead946acf9a2f63bf979e7193bfbf56..74136abfb9aae1fc8ab746908be752056b6d7c5a 100644
index f108b567a910805ff86f0baf75fa1a6102ad28d6..8406e8ca319533d6186c5d457e951b7a845b6b72 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -10,7 +10,7 @@ const { kEmptyObject } = require('internal/util');
const { defaultGetFormat } = require('internal/modules/esm/get_format');
const { validateAssertions } = require('internal/modules/esm/assert');
const { validateAttributes, emitImportAssertionWarning } = require('internal/modules/esm/assert');
const { getOptionValue } = require('internal/options');
-const { readFileSync } = require('fs');
+const fs = require('fs');
@@ -38,7 +38,7 @@ index 14d5236d0ead946acf9a2f63bf979e7193bfbf56..74136abfb9aae1fc8ab746908be75205
const match = RegExpPrototypeExec(DATA_URL_PATTERN, url.pathname);
if (!match) {
diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
index acfcc1f1f92548117ded857fa8d4dd140e07ab2b..ce8092b96aee8d09ff382110db4be62dcd760cce 100644
index 2d077cc182b40e0bdce2d71d0471e96e6d30222a..34fd6613fa24d628fc026ac11e5be7217a20fff4 100644
--- a/lib/internal/modules/esm/resolve.js
+++ b/lib/internal/modules/esm/resolve.js
@@ -24,7 +24,7 @@ const {
@@ -50,7 +50,7 @@ index acfcc1f1f92548117ded857fa8d4dd140e07ab2b..ce8092b96aee8d09ff382110db4be62d
const { getOptionValue } = require('internal/options');
// Do not eagerly grab .manifest, it may be in TDZ
const policy = getOptionValue('--experimental-policy') ?
@@ -235,7 +235,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
@@ -257,7 +257,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
}
if (!preserveSymlinks) {
@@ -60,28 +60,19 @@ index acfcc1f1f92548117ded857fa8d4dd140e07ab2b..ce8092b96aee8d09ff382110db4be62d
});
const { search, hash } = resolved;
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index 178f362b2869173d51b2e97a8d35a16ab4ed4962..4c3a0d8c484a402fe419a0bd45c7e2b1d717cb4a 100644
index bda102b266b17936efc453d039213517c4ef921c..dbbe37474c70addfbf8cf805c29732dcd38c74f6 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -25,7 +25,7 @@ function lazyTypes() {
}
@@ -32,7 +32,7 @@ function lazyTypes() {
const { containsModuleSyntax } = internalBinding('contextify');
const assert = require('internal/assert');
-const { readFileSync } = require('fs');
+const fs = require('fs');
const { dirname, extname, isAbsolute } = require('path');
const {
hasEsmSyntax,
@@ -132,7 +132,7 @@ translators.set('module', async function moduleStrategy(url, source, isMain) {
*/
function enrichCJSError(err, content, filename) {
if (err != null && ObjectGetPrototypeOf(err) === SyntaxErrorPrototype &&
- hasEsmSyntax(content || readFileSync(filename, 'utf-8'))) {
+ hasEsmSyntax(content || fs.readFileSync(filename, 'utf-8'))) {
// Emit the warning synchronously because we are in the middle of handling
// a SyntaxError that will throw and likely terminate the process before an
// asynchronous warning would be emitted.
@@ -294,7 +294,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
loadBuiltinModule,
@@ -355,7 +355,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
try {
// We still need to read the FS to detect the exports.
@@ -90,12 +81,12 @@ index 178f362b2869173d51b2e97a8d35a16ab4ed4962..4c3a0d8c484a402fe419a0bd45c7e2b1
} catch {
// Continue regardless of error.
}
@@ -357,7 +357,7 @@ function cjsPreparseModuleExports(filename, source) {
@@ -424,7 +424,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).
- const source = readFileSync(resolved, 'utf-8');
+ const source = fs.readFileSync(resolved, 'utf-8');
const { exportNames: reexportNames } = cjsPreparseModuleExports(resolved, source);
for (const name of reexportNames)
for (const name of reexportNames) {
exportNames.add(name);

View File

@@ -13,7 +13,7 @@ causing the following error:
This should be upstreamed.
diff --git a/src/module_wrap.h b/src/module_wrap.h
index c51eb99ce3eb54bc30ae922e0357b637b09d53c6..55317ced78ee9ceaa13f7e00477c59370eb335fa 100644
index 23a0d7aee1dfa0ebe26e0507e31eacb0b4d137ed..0733017d8e1ac6e60589082b402bd44a98ddc312 100644
--- a/src/module_wrap.h
+++ b/src/module_wrap.h
@@ -7,6 +7,7 @@

View File

@@ -1,50 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Charles Kerr <charles@charleskerr.com>
Date: Thu, 22 Jun 2023 11:59:47 -0500
Subject: fix: Wunreachable-code warning in ares__init_rand_engine()
Fix upstream Win32 FTBFS when building with -Werror,-Wunreachable-code.
This patch can be removed after the fix is picked up in Node.js.
Upstream PR @ https://github.com/c-ares/c-ares/pull/531
diff --git a/deps/cares/src/lib/ares_rand.c b/deps/cares/src/lib/ares_rand.c
index 766c1e6ea9bda1784cfb611dbac66424806cd23a..12d943921e3ba61cbf7a2ed3194fcd5a6c61da8a 100644
--- a/deps/cares/src/lib/ares_rand.c
+++ b/deps/cares/src/lib/ares_rand.c
@@ -55,6 +55,7 @@ BOOLEAN WINAPI SystemFunction036(PVOID RandomBuffer, ULONG RandomBufferLength);
# endif
#endif
+#if !defined(HAVE_ARC4RANDOM_BUF) && !defined(_WIN32)
#define ARES_RC4_KEY_LEN 32 /* 256 bits */
@@ -129,6 +130,7 @@ static void ares_rc4_init(ares_rand_rc4 *rc4_state)
rc4_state->i = 0;
rc4_state->j = 0;
}
+#endif
/* Just outputs the key schedule, no need to XOR with any data since we have none */
static void ares_rc4_prng(ares_rand_rc4 *rc4_state, unsigned char *buf, size_t len)
@@ -166,13 +168,13 @@ static int ares__init_rand_engine(ares_rand_state *state)
return 1;
}
/* Fall-Thru on failure to RC4 */
-#endif
state->type = ARES_RAND_RC4;
ares_rc4_init(&state->state.rc4);
/* Currently cannot fail */
return 1;
+#endif
}
@@ -276,4 +278,3 @@ unsigned short ares__generate_new_id(ares_rand_state *state)
ares__rand_bytes(state, (unsigned char *)&r, sizeof(r));
return r;
}
-

View File

@@ -1,155 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= <targos@protonmail.com>
Date: Thu, 28 Sep 2023 14:50:20 +0200
Subject: lib,test: do not hardcode Buffer.kMaxLength
V8 will soon support typed arrays as large as the maximum array buffer
length. This patch replaces hardcoded values related to
Buffer.kMaxLength with the actual constant.
It also fixes a test that was passing by accident.
Refs: https://github.com/v8/v8/commit/44b299590083b888637c79fb5632806e607ab861
PR-URL: https://github.com/nodejs/node/pull/49876
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
(cherry picked from commit a4fdb1abe0844d86b4cbfcc4051794656e7d746e)
diff --git a/lib/internal/blob.js b/lib/internal/blob.js
index d0e47c1a4397a875c937d43c3b72dbd1e1de35a7..400d2c5fd21bc962a8befc4d80527216baddd6d5 100644
--- a/lib/internal/blob.js
+++ b/lib/internal/blob.js
@@ -24,6 +24,9 @@ const {
concat,
getDataObject,
} = internalBinding('blob');
+const {
+ kMaxLength,
+} = internalBinding('buffer');
const {
TextDecoder,
@@ -62,7 +65,6 @@ const {
} = require('internal/errors');
const {
- isUint32,
validateDictionary,
} = require('internal/validators');
@@ -158,8 +160,8 @@ class Blob {
return src;
});
- if (!isUint32(length))
- throw new ERR_BUFFER_TOO_LARGE(0xFFFFFFFF);
+ if (length > kMaxLength)
+ throw new ERR_BUFFER_TOO_LARGE(kMaxLength);
this[kHandle] = _createBlob(sources_, length);
this[kLength] = length;
diff --git a/test/parallel/test-blob-buffer-too-large.js b/test/parallel/test-blob-buffer-too-large.js
index 2fd8b8754bd593a0da069044d33fcd6bba82f9c9..a9cf53b025bbff58a8d5783e4f807d79f5d68e2b 100644
--- a/test/parallel/test-blob-buffer-too-large.js
+++ b/test/parallel/test-blob-buffer-too-large.js
@@ -3,17 +3,17 @@
const common = require('../common');
const assert = require('assert');
-const { Blob } = require('buffer');
+const { Blob, kMaxLength } = require('buffer');
if (common.isFreeBSD)
common.skip('Oversized buffer make the FreeBSD CI runner crash');
try {
- new Blob([new Uint8Array(0xffffffff), [1]]);
+ new Blob([new Uint8Array(kMaxLength), [1]]);
} catch (e) {
if (
e.message === 'Array buffer allocation failed' ||
- e.message === 'Invalid typed array length: 4294967295'
+ e.message === `Invalid typed array length: ${kMaxLength}`
) {
common.skip(
'Insufficient memory on this platform for oversized buffer test.'
diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js
index c6b728027057ece38c2b7fcc6bf7b18b959125d2..aad9c6bcab69e971c02281928885d94aa21c8199 100644
--- a/test/parallel/test-buffer-alloc.js
+++ b/test/parallel/test-buffer-alloc.js
@@ -4,13 +4,16 @@ const common = require('../common');
const assert = require('assert');
const vm = require('vm');
-const SlowBuffer = require('buffer').SlowBuffer;
+const {
+ SlowBuffer,
+ kMaxLength,
+} = require('buffer');
// Verify the maximum Uint8Array size. There is no concrete limit by spec. The
// internal limits should be updated if this fails.
assert.throws(
- () => new Uint8Array(2 ** 32 + 1),
- { message: 'Invalid typed array length: 4294967297' }
+ () => new Uint8Array(kMaxLength + 1),
+ { message: `Invalid typed array length: ${kMaxLength + 1}` },
);
const b = Buffer.allocUnsafe(1024);
diff --git a/test/parallel/test-buffer-over-max-length.js b/test/parallel/test-buffer-over-max-length.js
index d2df358cc00ca4b238252d6d11bdad3b77fad114..f29d6b62d4aa408fb3a67ffe71b14436fbbff907 100644
--- a/test/parallel/test-buffer-over-max-length.js
+++ b/test/parallel/test-buffer-over-max-length.js
@@ -12,18 +12,8 @@ const bufferMaxSizeMsg = {
name: 'RangeError',
};
-assert.throws(() => Buffer((-1 >>> 0) + 2), bufferMaxSizeMsg);
-assert.throws(() => SlowBuffer((-1 >>> 0) + 2), bufferMaxSizeMsg);
-assert.throws(() => Buffer.alloc((-1 >>> 0) + 2), bufferMaxSizeMsg);
-assert.throws(() => Buffer.allocUnsafe((-1 >>> 0) + 2), bufferMaxSizeMsg);
-assert.throws(() => Buffer.allocUnsafeSlow((-1 >>> 0) + 2), bufferMaxSizeMsg);
-
assert.throws(() => Buffer(kMaxLength + 1), bufferMaxSizeMsg);
assert.throws(() => SlowBuffer(kMaxLength + 1), bufferMaxSizeMsg);
assert.throws(() => Buffer.alloc(kMaxLength + 1), bufferMaxSizeMsg);
assert.throws(() => Buffer.allocUnsafe(kMaxLength + 1), bufferMaxSizeMsg);
assert.throws(() => Buffer.allocUnsafeSlow(kMaxLength + 1), bufferMaxSizeMsg);
-
-// issue GH-4331
-assert.throws(() => Buffer.allocUnsafe(0x100000001), bufferMaxSizeMsg);
-assert.throws(() => Buffer.allocUnsafe(0xFFFFFFFFF), bufferMaxSizeMsg);
diff --git a/test/parallel/test-buffer-tostring-rangeerror.js b/test/parallel/test-buffer-tostring-rangeerror.js
index d2e1e0d6e46438f20d6b8f1196ebd936d4fa3436..0ebea759b5c42be0c294093256ea3cad7034a98b 100644
--- a/test/parallel/test-buffer-tostring-rangeerror.js
+++ b/test/parallel/test-buffer-tostring-rangeerror.js
@@ -1,17 +1,22 @@
'use strict';
require('../common');
-// This test ensures that Node.js throws a RangeError when trying to convert a
-// gigantic buffer into a string.
+// This test ensures that Node.js throws an Error when trying to convert a
+// large buffer into a string.
// Regression test for https://github.com/nodejs/node/issues/649.
const assert = require('assert');
-const SlowBuffer = require('buffer').SlowBuffer;
+const {
+ SlowBuffer,
+ constants: {
+ MAX_STRING_LENGTH,
+ },
+} = require('buffer');
-const len = 1422561062959;
+const len = MAX_STRING_LENGTH + 1;
const message = {
- code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError',
+ code: 'ERR_STRING_TOO_LONG',
+ name: 'Error',
};
assert.throws(() => Buffer(len).toString('utf8'), message);
assert.throws(() => SlowBuffer(len).toString('utf8'), message);

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 19a7d7e671f5abfa55b62290dcf3796a2c4e9013..3161afa33889f1682a1689e76fbcadc397f4b01c 100644
index b077ee386bb40ea32208fc6655de88a3449b7eb2..f408d6c152d6acabea5ff3e262fe344909046595 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -142,6 +142,13 @@ const {
@@ -146,6 +146,13 @@ const {
CHAR_FORWARD_SLASH,
} = require('internal/constants');
@@ -23,8 +23,8 @@ index 19a7d7e671f5abfa55b62290dcf3796a2c4e9013..3161afa33889f1682a1689e76fbcadc3
const {
isProxy,
} = require('internal/util/types');
@@ -1236,10 +1243,12 @@ Module.prototype._compile = function(content, filename) {
if (requireDepth === 0) statCache = new SafeMap();
@@ -1371,10 +1378,12 @@ Module.prototype._compile = function(content, filename) {
if (requireDepth === 0) { statCache = new SafeMap(); }
if (inspectorWrapper) {
result = inspectorWrapper(compiledWrapper, thisValue, exports,
- require, module, filename, dirname);
@@ -37,4 +37,4 @@ index 19a7d7e671f5abfa55b62290dcf3796a2c4e9013..3161afa33889f1682a1689e76fbcadc3
+ dirname, process, localGlobal, localBuffer]);
}
hasLoadedAnyUserCJSModule = true;
if (requireDepth === 0) statCache = null;
if (requireDepth === 0) { statCache = null; }

View File

@@ -22,21 +22,20 @@ index 7a773d5208e250abd8b0efb6dde66c45060bbee4..45e38ca0a122e3b1c5d8d59865f9610c
const binding = internalBinding('builtins');
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 3161afa33889f1682a1689e76fbcadc397f4b01c..84fea979d482d3d5cacfad4b09237e6345675cad 100644
index f408d6c152d6acabea5ff3e262fe344909046595..ea3b411a78495d0414b1956503b86cbd5f0ed765 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -91,7 +91,7 @@ const fs = require('fs');
const internalFS = require('internal/fs/utils');
@@ -96,6 +96,7 @@ const assert = require('internal/assert');
const fs = require('fs');
const path = require('path');
const { sep } = path;
-const { internalModuleStat } = internalBinding('fs');
const { internalModuleStat } = internalBinding('fs');
+const internalFsBinding = internalBinding('fs');
const { safeGetenv } = internalBinding('credentials');
const {
privateSymbols: {
@@ -182,7 +182,7 @@ function stat(filename) {
@@ -195,7 +196,7 @@ function stat(filename) {
const result = statCache.get(filename);
if (result !== undefined) return result;
if (result !== undefined) { return result; }
}
- const result = internalModuleStat(filename);
+ const result = internalFsBinding.internalModuleStat(filename);
@@ -44,19 +43,18 @@ index 3161afa33889f1682a1689e76fbcadc397f4b01c..84fea979d482d3d5cacfad4b09237e63
// Only set cache when `internalModuleStat(filename)` succeeds.
statCache.set(filename, result);
diff --git a/lib/internal/modules/package_json_reader.js b/lib/internal/modules/package_json_reader.js
index c6377faae6f5a827fc9b5c271ebc85f2df2f7177..8143e83ee39a03871642cfd6e7b8671fc4c3454d 100644
index 88c079d10d116107aa34dc9281f64c799c48c0b5..146e2e49dc46c7f5302638f75cca4af548509d77 100644
--- a/lib/internal/modules/package_json_reader.js
+++ b/lib/internal/modules/package_json_reader.js
@@ -8,7 +8,7 @@ const {
const {
@@ -13,6 +13,7 @@ const {
ERR_INVALID_PACKAGE_CONFIG,
} = require('internal/errors').codes;
-const { internalModuleReadJSON } = internalBinding('fs');
const { internalModuleReadJSON } = internalBinding('fs');
+const internalFsBinding = internalBinding('fs');
const { toNamespacedPath } = require('path');
const { resolve, sep, toNamespacedPath } = require('path');
const permission = require('internal/process/permission');
const { kEmptyObject } = require('internal/util');
@@ -48,7 +48,7 @@ function read(jsonPath, { base, specifier, isESM } = kEmptyObject) {
@@ -53,7 +54,7 @@ function read(jsonPath, { base, specifier, isESM } = kEmptyObject) {
const {
0: string,
1: containsKeys,

View File

@@ -6,7 +6,7 @@ Subject: spec: add Iterator to global intrinsics
Ref: https://chromium-review.googlesource.com/c/v8/v8/+/4266490
diff --git a/test/common/globals.js b/test/common/globals.js
index f18b358e657a55efcd7121350be6abe3a4b504bb..27a6ebf31f63c2e5332c7b4944b29481841d02bc 100644
index 8b9b6b34f6abaf713f362e8bcdbd140a86dfa767..7b5643a926d970e0e6c91d52b86ebd857d2cf062 100644
--- a/test/common/globals.js
+++ b/test/common/globals.js
@@ -63,6 +63,7 @@ const intrinsics = new Set([

View File

@@ -55,10 +55,10 @@ index c9a455be8c395a2f231f56e0a54211466362aa1d..448075e354c760a2dbd1dd763f40b7a6
void UntrackContext(v8::Local<v8::Context> context);
diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc
index 92f765eb0a99f92eac3ce77011e0ec787ccfcb8d..7e77c4692b4d9c4c5daa6ba01878a2219646eb62 100644
index f08294a26a43923cfb47dde080e42b5cde0803a5..8d48105cb4822dde19982ce1c132f521ff8b27c9 100644
--- a/src/js_native_api_v8.cc
+++ b/src/js_native_api_v8.cc
@@ -925,11 +925,8 @@ napi_define_class(napi_env env,
@@ -961,11 +961,8 @@ napi_define_class(napi_env env,
env, p->setter, p->data, &setter_tpl));
}

View File

@@ -1,151 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Wed, 18 Oct 2023 10:40:34 +0200
Subject: test: fix edge snapshot stack traces
https://github.com/nodejs/node/pull/49659
diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js
index 838ee86f74ea89e052676a5c25e23481369857fa..3aacfa064561c64c218fcc4e3090f7952cb1d218 100644
--- a/test/common/assertSnapshot.js
+++ b/test/common/assertSnapshot.js
@@ -8,6 +8,10 @@ const assert = require('node:assert/strict');
const stackFramesRegexp = /(?<=\n)(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g;
const windowNewlineRegexp = /\r/g;
+function replaceNodeVersion(str) {
+ return str.replaceAll(process.version, '*');
+}
+
function replaceStackTrace(str, replacement = '$1*$7$8\n') {
return str.replace(stackFramesRegexp, replacement);
}
@@ -84,6 +88,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
module.exports = {
assertSnapshot,
getSnapshotPath,
+ replaceNodeVersion,
replaceFullPaths,
replaceStackTrace,
replaceWindowsLineEndings,
diff --git a/test/fixtures/errors/force_colors.snapshot b/test/fixtures/errors/force_colors.snapshot
index be1d45d0d8e8ba7b637754e32fe379cb2cf1e6ac..21410d492db861876ecfcb82dcc3c1815cba6d09 100644
--- a/test/fixtures/errors/force_colors.snapshot
+++ b/test/fixtures/errors/force_colors.snapshot
@@ -4,11 +4,12 @@ throw new Error('Should include grayed stack trace')
Error: Should include grayed stack trace
at Object.<anonymous> (/test*force_colors.js:1:7)
- at Module._compile (node:internal*modules*cjs*loader:1241:14)
- at Module._extensions..js (node:internal*modules*cjs*loader:1295:10)
- at Module.load (node:internal*modules*cjs*loader:1091:32)
- at Module._load (node:internal*modules*cjs*loader:938:12)
- at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12)
- at node:internal*main*run_main_module:23:47
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
+ at *
Node.js *
diff --git a/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot b/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot
index 2c1e11eeb9eab1bcb101f8f5af909461b26036ec..6a109c904e115503b743d5c4e0418ae693ca9856 100644
--- a/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot
+++ b/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot
@@ -1,3 +1,3 @@
Error: an exception.
at Object.<anonymous> (*typescript-sourcemapping_url_string.ts:3:7)
- at Module._compile (node:internal*modules*cjs*loader:1241:14)
+ *
diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs
index b08bcd40cdf26093e158c0bb9ae566c76f2c731e..bf8eacbac479a2bf5698ed29ede648e149f185b5 100644
--- a/test/parallel/test-node-output-errors.mjs
+++ b/test/parallel/test-node-output-errors.mjs
@@ -10,15 +10,15 @@ const skipForceColors =
process.config.variables.node_shared_openssl ||
(common.isWindows && (Number(os.release().split('.')[0]) !== 10 || Number(os.release().split('.')[2]) < 14393)); // See https://github.com/nodejs/node/pull/33132
-
-function replaceNodeVersion(str) {
- return str.replaceAll(process.version, '*');
-}
-
function replaceStackTrace(str) {
return snapshot.replaceStackTrace(str, '$1at *$7\n');
}
+function replaceForceColorsStackTrace(str) {
+ // eslint-disable-next-line no-control-regex
+ return str.replaceAll(/(\[90m\W+)at .*node:.*/g, '$1at *');
+}
+
describe('errors output', { concurrency: true }, () => {
function normalize(str) {
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
@@ -35,9 +35,12 @@ describe('errors output', { concurrency: true }, () => {
}
const common = snapshot
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths);
- const defaultTransform = snapshot.transform(common, normalize, replaceNodeVersion);
- const errTransform = snapshot.transform(common, normalizeNoNumbers, replaceNodeVersion);
- const promiseTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers, replaceNodeVersion);
+ const defaultTransform = snapshot.transform(common, normalize, snapshot.replaceNodeVersion);
+ const errTransform = snapshot.transform(common, normalizeNoNumbers, snapshot.replaceNodeVersion);
+ const promiseTransform = snapshot.transform(common, replaceStackTrace,
+ normalizeNoNumbers, snapshot.replaceNodeVersion);
+ const forceColorsTransform = snapshot.transform(common, normalize,
+ replaceForceColorsStackTrace, snapshot.replaceNodeVersion);
const tests = [
{ name: 'errors/async_error_eval_cjs.js' },
@@ -57,7 +60,11 @@ describe('errors output', { concurrency: true }, () => {
{ name: 'errors/throw_in_line_with_tabs.js', transform: errTransform },
{ name: 'errors/throw_non_error.js', transform: errTransform },
{ name: 'errors/promise_always_throw_unhandled.js', transform: promiseTransform },
- { skip: skipForceColors, name: 'errors/force_colors.js', env: { FORCE_COLOR: 1 } },
+ !skipForceColors ? {
+ name: 'errors/force_colors.js',
+ transform: forceColorsTransform,
+ env: { FORCE_COLOR: 1 }
+ } : null,
];
for (const { name, transform = defaultTransform, env, skip = false } of tests) {
it(name, { skip }, async () => {
diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs
index 2043fa57f06a8d2326a4ea1ba24341502c8b7471..b01f30765c7de81a4d956b9c1124affea0fc2aef 100644
--- a/test/parallel/test-node-output-sourcemaps.mjs
+++ b/test/parallel/test-node-output-sourcemaps.mjs
@@ -4,10 +4,6 @@ import * as snapshot from '../common/assertSnapshot.js';
import * as path from 'node:path';
import { describe, it } from 'node:test';
-function replaceNodeVersion(str) {
- return str.replaceAll(process.version, '*');
-}
-
describe('sourcemaps output', { concurrency: true }, () => {
function normalize(str) {
const result = str
@@ -16,7 +12,8 @@ describe('sourcemaps output', { concurrency: true }, () => {
.replaceAll('/Users/bencoe/oss/coffee-script-test', '')
.replaceAll(/\/(\w)/g, '*$1')
.replaceAll('*test*', '*')
- .replaceAll('*fixtures*source-map*', '*');
+ .replaceAll('*fixtures*source-map*', '*')
+ .replaceAll(/(\W+).*node:internal\*modules.*/g, '$1*');
if (common.isWindows) {
const currentDeviceLetter = path.parse(process.cwd()).root.substring(0, 1).toLowerCase();
const regex = new RegExp(`${currentDeviceLetter}:/?`, 'gi');
@@ -25,7 +22,8 @@ describe('sourcemaps output', { concurrency: true }, () => {
return result;
}
const defaultTransform = snapshot
- .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize, replaceNodeVersion);
+ .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths,
+ normalize, snapshot.replaceNodeVersion);
const tests = [
{ name: 'source-map/output/source_map_disabled_by_api.js' },

View File

@@ -7,13 +7,13 @@ Instead of disabling the tests, flag them as flaky so they still run
but don't cause CI failures on flakes.
diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status
index fe8ddee7cbf05e0d4dbbe970cdc357ec6841390c..1ba65e26d293e9524e6c756b3a66693d46b4bdfd 100644
index fa425fdcfc475ba2d5ba9a2492ea4481914a7cce..840c2f657467ede0e3737ea1aee55e07e39f353a 100644
--- a/test/parallel/parallel.status
+++ b/test/parallel/parallel.status
@@ -7,6 +7,13 @@ prefix parallel
@@ -5,6 +5,13 @@ prefix parallel
# sample-test : PASS,FLAKY
[true] # This section applies to all platforms
# https://github.com/nodejs/node/issues/49853
test-runner-output: PASS,FLAKY
+test-inspector-multisession-ws: PASS, FLAKY
+test-heapsnapshot-near-heap-limit-by-api-in-worker: PASS, FLAKY
+test-heapsnapshot-near-heap-limit-worker: PASS, FLAKY
@@ -25,7 +25,7 @@ index fe8ddee7cbf05e0d4dbbe970cdc357ec6841390c..1ba65e26d293e9524e6c756b3a66693d
[$system==win32]
# https://github.com/nodejs/node/issues/41206
diff --git a/test/sequential/sequential.status b/test/sequential/sequential.status
index 5cefcb95773bedc80bc462e058a11045be176741..33f50be5898754af696468499bcfa8e3c721434d 100644
index a5e2d38ff31aa8b90f3b99783b16cec086b4f30e..b8afe3d88b5af4756663f45fad81105e9b7f0e7e 100644
--- a/test/sequential/sequential.status
+++ b/test/sequential/sequential.status
@@ -7,6 +7,18 @@ prefix sequential

View File

@@ -1,5 +1,6 @@
[
"abort/test-abort-backtrace",
"es-module/test-vm-compile-function-lineoffset",
"parallel/test-bootstrap-modules",
"parallel/test-child-process-fork-exec-path",
"parallel/test-code-cache",
@@ -21,9 +22,9 @@
"parallel/test-dgram-send-cb-quelches-error",
"parallel/test-fs-utimes-y2K38",
"parallel/test-http2-clean-output",
"parallel/test-http2-https-fallback.js",
"parallel/test-http2-server-unknown-protocol.js",
"parallel/test-tls-alpn-server-client.js",
"parallel/test-http2-https-fallback",
"parallel/test-http2-server-unknown-protocol",
"parallel/test-tls-alpn-server-client",
"parallel/test-https-agent-session-reuse",
"parallel/test-https-options-boolean-check",
"parallel/test-icu-env",

View File

@@ -5,6 +5,7 @@
#include "shell/app/electron_content_client.h"
#include <string>
#include <string_view>
#include <utility>
#include <vector>
@@ -106,12 +107,12 @@ bool IsWidevineAvailable(
}
#endif // BUILDFLAG(ENABLE_WIDEVINE)
void AppendDelimitedSwitchToVector(const base::StringPiece cmd_switch,
void AppendDelimitedSwitchToVector(const std::string_view cmd_switch,
std::vector<std::string>* append_me) {
auto* command_line = base::CommandLine::ForCurrentProcess();
auto switch_value = command_line->GetSwitchValueASCII(cmd_switch);
if (!switch_value.empty()) {
constexpr base::StringPiece delimiter(",", 1);
constexpr std::string_view delimiter{",", 1};
auto tokens =
base::SplitString(switch_value, delimiter, base::TRIM_WHITESPACE,
base::SPLIT_WANT_NONEMPTY);

View File

@@ -7,6 +7,7 @@
#include <iostream>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include "base/apple/bundle_locations.h"
@@ -80,9 +81,9 @@ namespace {
const char kRelauncherProcess[] = "relauncher";
constexpr base::StringPiece kElectronDisableSandbox("ELECTRON_DISABLE_SANDBOX");
constexpr base::StringPiece kElectronEnableStackDumping(
"ELECTRON_ENABLE_STACK_DUMPING");
constexpr std::string_view kElectronDisableSandbox{"ELECTRON_DISABLE_SANDBOX"};
constexpr std::string_view kElectronEnableStackDumping{
"ELECTRON_ENABLE_STACK_DUMPING"};
// Returns true if this subprocess type needs the ResourceBundle initialized
// and resources loaded.
@@ -238,7 +239,7 @@ const char* const ElectronMainDelegate::kNonWildcardDomainNonPortSchemes[] = {
const size_t ElectronMainDelegate::kNonWildcardDomainNonPortSchemesSize =
std::size(kNonWildcardDomainNonPortSchemes);
absl::optional<int> ElectronMainDelegate::BasicStartupComplete() {
std::optional<int> ElectronMainDelegate::BasicStartupComplete() {
auto* command_line = base::CommandLine::ForCurrentProcess();
#if BUILDFLAG(IS_WIN)
@@ -311,7 +312,7 @@ absl::optional<int> ElectronMainDelegate::BasicStartupComplete() {
::switches::kDisableGpuMemoryBufferCompositorResources);
#endif
return absl::nullopt;
return std::nullopt;
}
void ElectronMainDelegate::PreSandboxStartup() {
@@ -398,7 +399,7 @@ void ElectronMainDelegate::SandboxInitialized(const std::string& process_type) {
#endif
}
absl::optional<int> ElectronMainDelegate::PreBrowserMain() {
std::optional<int> ElectronMainDelegate::PreBrowserMain() {
// This is initialized early because the service manager reads some feature
// flags and we need to make sure the feature list is initialized before the
// service manager reads the features.
@@ -408,7 +409,7 @@ absl::optional<int> ElectronMainDelegate::PreBrowserMain() {
#if BUILDFLAG(IS_MAC)
RegisterAtomCrApp();
#endif
return absl::nullopt;
return std::nullopt;
}
base::StringPiece ElectronMainDelegate::GetBrowserV8SnapshotFilename() {

View File

@@ -34,10 +34,10 @@ class ElectronMainDelegate : public content::ContentMainDelegate {
protected:
// content::ContentMainDelegate:
absl::optional<int> BasicStartupComplete() override;
std::optional<int> BasicStartupComplete() override;
void PreSandboxStartup() override;
void SandboxInitialized(const std::string& process_type) override;
absl::optional<int> PreBrowserMain() override;
std::optional<int> PreBrowserMain() override;
content::ContentClient* CreateContentClient() override;
content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentGpuClient* CreateContentGpuClient() override;

View File

@@ -7,6 +7,7 @@
#include <map>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
@@ -60,7 +61,7 @@ namespace {
// See https://nodejs.org/api/cli.html#cli_options
void ExitIfContainsDisallowedFlags(const std::vector<std::string>& argv) {
// Options that are unilaterally disallowed.
static constexpr auto disallowed = base::MakeFixedFlatSet<base::StringPiece>({
static constexpr auto disallowed = base::MakeFixedFlatSet<std::string_view>({
"--enable-fips",
"--force-fips",
"--openssl-config",
@@ -69,7 +70,7 @@ void ExitIfContainsDisallowedFlags(const std::vector<std::string>& argv) {
});
for (const auto& arg : argv) {
const auto key = base::StringPiece(arg).substr(0, arg.find('='));
const auto key = std::string_view{arg}.substr(0, arg.find('='));
if (disallowed.contains(key)) {
LOG(ERROR) << "The Node.js cli flag " << key
<< " is not supported in Electron";

View File

@@ -5,7 +5,9 @@
#include "shell/browser/api/electron_api_app.h"
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
@@ -75,7 +77,6 @@
#include "shell/common/platform_util.h"
#include "shell/common/thread_restrictions.h"
#include "shell/common/v8_value_serializer.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/gfx/image/image.h"
#if BUILDFLAG(IS_WIN)
@@ -157,7 +158,7 @@ struct Converter<JumpListItem::Type> {
private:
static constexpr auto Lookup =
base::MakeFixedFlatMap<base::StringPiece, JumpListItem::Type>({
base::MakeFixedFlatMap<std::string_view, JumpListItem::Type>({
{"file", JumpListItem::Type::kFile},
{"separator", JumpListItem::Type::kSeparator},
{"task", JumpListItem::Type::kTask},
@@ -248,7 +249,7 @@ struct Converter<JumpListCategory::Type> {
private:
static constexpr auto Lookup =
base::MakeFixedFlatMap<base::StringPiece, JumpListCategory::Type>({
base::MakeFixedFlatMap<std::string_view, JumpListCategory::Type>({
{"custom", JumpListCategory::Type::kCustom},
{"frequent", JumpListCategory::Type::kFrequent},
{"recent", JumpListCategory::Type::kRecent},
@@ -414,7 +415,7 @@ struct Converter<net::SecureDnsMode> {
v8::Local<v8::Value> val,
net::SecureDnsMode* out) {
static constexpr auto Lookup =
base::MakeFixedFlatMap<base::StringPiece, net::SecureDnsMode>({
base::MakeFixedFlatMap<std::string_view, net::SecureDnsMode>({
{"automatic", net::SecureDnsMode::kAutomatic},
{"off", net::SecureDnsMode::kOff},
{"secure", net::SecureDnsMode::kSecure},
@@ -440,9 +441,9 @@ IconLoader::IconSize GetIconSizeByString(const std::string& size) {
}
// Return the path constant from string.
int GetPathConstant(base::StringPiece name) {
int GetPathConstant(std::string_view name) {
// clang-format off
constexpr auto Lookup = base::MakeFixedFlatMap<base::StringPiece, int>({
constexpr auto Lookup = base::MakeFixedFlatMap<std::string_view, int>({
{"appData", DIR_APP_DATA},
#if BUILDFLAG(IS_POSIX)
{"cache", base::DIR_CACHE},
@@ -927,7 +928,7 @@ void App::SetAppPath(const base::FilePath& app_path) {
#if !BUILDFLAG(IS_MAC)
void App::SetAppLogsPath(gin_helper::ErrorThrower thrower,
absl::optional<base::FilePath> custom_path) {
std::optional<base::FilePath> custom_path) {
if (custom_path.has_value()) {
if (!custom_path->IsAbsolute()) {
thrower.ThrowError("Path must be absolute");
@@ -1604,7 +1605,7 @@ void ConfigureHostResolver(v8::Isolate* isolate,
// doh_config.
std::vector<net::DnsOverHttpsServerConfig> servers;
for (const std::string& server_template : secure_dns_server_strings) {
absl::optional<net::DnsOverHttpsServerConfig> server_config =
std::optional<net::DnsOverHttpsServerConfig> server_config =
net::DnsOverHttpsServerConfig::FromString(server_template);
if (!server_config.has_value()) {
thrower.ThrowTypeError(std::string("not a valid DoH template: ") +

View File

@@ -5,11 +5,12 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_APP_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_APP_H_
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/task/cancelable_task_tracker.h"
#include "chrome/browser/icon_manager.h"
#include "chrome/browser/process_singleton.h"
@@ -180,7 +181,7 @@ class App : public ElectronBrowserClient::Delegate,
void ChildProcessDisconnected(int pid);
void SetAppLogsPath(gin_helper::ErrorThrower thrower,
absl::optional<base::FilePath> custom_path);
std::optional<base::FilePath> custom_path);
// Get/Set the pre-defined path in PathService.
base::FilePath GetPath(gin_helper::ErrorThrower thrower,
@@ -259,9 +260,8 @@ class App : public ElectronBrowserClient::Delegate,
base::FilePath app_path_;
using ProcessMetricMap =
std::map<int, std::unique_ptr<electron::ProcessMetric>>;
ProcessMetricMap app_metrics_;
// pid -> electron::ProcessMetric
base::flat_map<int, std::unique_ptr<electron::ProcessMetric>> app_metrics_;
bool disable_hw_acceleration_ = false;
bool disable_domain_blocking_for_3DAPIs_ = false;

View File

@@ -17,7 +17,7 @@
namespace electron::api {
void App::SetAppLogsPath(gin_helper::ErrorThrower thrower,
absl::optional<base::FilePath> custom_path) {
std::optional<base::FilePath> custom_path) {
if (custom_path.has_value()) {
if (!custom_path->IsAbsolute()) {
thrower.ThrowError("Path must be absolute");

View File

@@ -826,11 +826,11 @@ bool BaseWindow::GetWindowButtonVisibility() const {
return window_->GetWindowButtonVisibility();
}
void BaseWindow::SetWindowButtonPosition(absl::optional<gfx::Point> position) {
void BaseWindow::SetWindowButtonPosition(std::optional<gfx::Point> position) {
window_->SetWindowButtonPosition(std::move(position));
}
absl::optional<gfx::Point> BaseWindow::GetWindowButtonPosition() const {
std::optional<gfx::Point> BaseWindow::GetWindowButtonPosition() const {
return window_->GetWindowButtonPosition();
}
#endif

View File

@@ -7,7 +7,9 @@
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
#include "content/public/browser/browser_task_traits.h"
@@ -187,8 +189,8 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
std::string GetAlwaysOnTopLevel() const;
void SetWindowButtonVisibility(bool visible);
bool GetWindowButtonVisibility() const;
void SetWindowButtonPosition(absl::optional<gfx::Point> position);
absl::optional<gfx::Point> GetWindowButtonPosition() const;
void SetWindowButtonPosition(std::optional<gfx::Point> position);
std::optional<gfx::Point> GetWindowButtonPosition() const;
bool IsHiddenInMissionControl();
void SetHiddenInMissionControl(bool hidden);
@@ -248,7 +250,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
void RemoveFromParentChildWindows();
template <typename... Args>
void EmitEventSoon(base::StringPiece eventName) {
void EmitEventSoon(std::string_view eventName) {
content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(base::IgnoreResult(&BaseWindow::Emit<Args...>),

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include <optional>
#include <set>
#include <string>
#include <utility>
@@ -17,7 +18,6 @@
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
using content::TracingController;
@@ -58,18 +58,18 @@ namespace {
using CompletionCallback = base::OnceCallback<void(const base::FilePath&)>;
absl::optional<base::FilePath> CreateTemporaryFileOnIO() {
std::optional<base::FilePath> CreateTemporaryFileOnIO() {
base::FilePath temp_file_path;
if (!base::CreateTemporaryFile(&temp_file_path))
return absl::nullopt;
return absl::make_optional(std::move(temp_file_path));
return std::nullopt;
return std::make_optional(std::move(temp_file_path));
}
void StopTracing(gin_helper::Promise<base::FilePath> promise,
absl::optional<base::FilePath> file_path) {
std::optional<base::FilePath> file_path) {
auto resolve_or_reject = base::BindOnce(
[](gin_helper::Promise<base::FilePath> promise,
const base::FilePath& path, absl::optional<std::string> error) {
const base::FilePath& path, std::optional<std::string> error) {
if (error) {
promise.RejectWithErrorMessage(error.value());
} else {
@@ -81,20 +81,20 @@ void StopTracing(gin_helper::Promise<base::FilePath> promise,
auto* instance = TracingController::GetInstance();
if (!instance->IsTracing()) {
std::move(resolve_or_reject)
.Run(absl::make_optional(
.Run(std::make_optional(
"Failed to stop tracing - no trace in progress"));
} else if (file_path) {
auto split_callback = base::SplitOnceCallback(std::move(resolve_or_reject));
auto endpoint = TracingController::CreateFileEndpoint(
*file_path,
base::BindOnce(std::move(split_callback.first), absl::nullopt));
base::BindOnce(std::move(split_callback.first), std::nullopt));
if (!instance->StopTracing(endpoint)) {
std::move(split_callback.second)
.Run(absl::make_optional("Failed to stop tracing"));
.Run(std::make_optional("Failed to stop tracing"));
}
} else {
std::move(resolve_or_reject)
.Run(absl::make_optional(
.Run(std::make_optional(
"Failed to create temporary file for trace data"));
}
}
@@ -105,7 +105,7 @@ v8::Local<v8::Promise> StopRecording(gin_helper::Arguments* args) {
base::FilePath path;
if (args->GetNext(&path) && !path.empty()) {
StopTracing(std::move(promise), absl::make_optional(path));
StopTracing(std::move(promise), std::make_optional(path));
} else {
// use a temporary file.
base::ThreadPool::PostTaskAndReplyWithResult(

View File

@@ -4,6 +4,8 @@
#include "shell/browser/api/electron_api_cookies.h"
#include <string>
#include <string_view>
#include <utility>
#include "base/time/time.h"
@@ -127,13 +129,13 @@ bool MatchesCookie(const base::Value::Dict& filter,
if ((str = filter.FindString("domain")) &&
!MatchesDomain(*str, cookie.Domain()))
return false;
absl::optional<bool> secure_filter = filter.FindBool("secure");
std::optional<bool> secure_filter = filter.FindBool("secure");
if (secure_filter && *secure_filter != cookie.IsSecure())
return false;
absl::optional<bool> session_filter = filter.FindBool("session");
std::optional<bool> session_filter = filter.FindBool("session");
if (session_filter && *session_filter == cookie.IsPersistent())
return false;
absl::optional<bool> httpOnly_filter = filter.FindBool("httpOnly");
std::optional<bool> httpOnly_filter = filter.FindBool("httpOnly");
if (httpOnly_filter && *httpOnly_filter != cookie.IsHttpOnly())
return false;
return true;
@@ -161,7 +163,7 @@ void FilterCookieWithStatuses(
}
// Parse dictionary property to CanonicalCookie time correctly.
base::Time ParseTimeProperty(const absl::optional<double>& value) {
base::Time ParseTimeProperty(const std::optional<double>& value) {
if (!value) // empty time means ignoring the parameter
return base::Time();
if (*value == 0) // FromSecondsSinceUnixEpoch would convert 0 to empty Time
@@ -169,7 +171,7 @@ base::Time ParseTimeProperty(const absl::optional<double>& value) {
return base::Time::FromSecondsSinceUnixEpoch(*value);
}
base::StringPiece InclusionStatusToString(net::CookieInclusionStatus status) {
std::string_view InclusionStatusToString(net::CookieInclusionStatus status) {
if (status.HasExclusionReason(net::CookieInclusionStatus::EXCLUDE_HTTP_ONLY))
return "Failed to create httponly cookie";
if (status.HasExclusionReason(
@@ -321,7 +323,7 @@ v8::Local<v8::Promise> Cookies::Set(v8::Isolate* isolate,
path ? *path : "", ParseTimeProperty(details.FindDouble("creationDate")),
ParseTimeProperty(details.FindDouble("expirationDate")),
ParseTimeProperty(details.FindDouble("lastAccessDate")), secure,
http_only, same_site, net::COOKIE_PRIORITY_DEFAULT, absl::nullopt,
http_only, same_site, net::COOKIE_PRIORITY_DEFAULT, std::nullopt,
&status);
if (!canonical_cookie || !canonical_cookie->IsCanonical()) {

View File

@@ -44,12 +44,12 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
base::StringPiece message_str(reinterpret_cast<const char*>(message.data()),
message.size());
absl::optional<base::Value> parsed_message = base::JSONReader::Read(
std::optional<base::Value> parsed_message = base::JSONReader::Read(
message_str, base::JSON_REPLACE_INVALID_CHARACTERS);
if (!parsed_message || !parsed_message->is_dict())
return;
base::Value::Dict& dict = parsed_message->GetDict();
absl::optional<int> id = dict.FindInt("id");
std::optional<int> id = dict.FindInt("id");
if (!id) {
std::string* method = dict.FindString("method");
if (!method)

View File

@@ -4,11 +4,11 @@
#include "shell/browser/api/electron_api_desktop_capturer.h"
#include <map>
#include <memory>
#include <utility>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
@@ -42,11 +42,11 @@
#if BUILDFLAG(IS_LINUX)
// Private function in ui/base/x/x11_display_util.cc
std::map<x11::RandR::Output, int> GetMonitors(
base::flat_map<x11::RandR::Output, int> GetMonitors(
std::pair<uint32_t, uint32_t> version,
x11::RandR* randr,
x11::Window window) {
std::map<x11::RandR::Output, int> output_to_monitor;
base::flat_map<x11::RandR::Output, int> output_to_monitor;
if (version >= std::pair<uint32_t, uint32_t>{1, 5}) {
if (auto reply = randr->GetMonitors({window}).Sync()) {
for (size_t monitor = 0; monitor < reply->monitors.size(); monitor++) {
@@ -76,12 +76,12 @@ std::vector<uint8_t> GetEDIDProperty(x11::RandR* randr,
// Find the mapping from monitor name atom to the display identifier
// that the screen API uses. Based on the logic in BuildDisplaysFromXRandRInfo
// in ui/base/x/x11_display_util.cc
std::map<int32_t, uint32_t> MonitorAtomIdToDisplayId() {
base::flat_map<int32_t, uint32_t> MonitorAtomIdToDisplayId() {
auto* connection = x11::Connection::Get();
auto& randr = connection->randr();
auto x_root_window = ui::GetX11RootWindow();
std::map<int32_t, uint32_t> monitor_atom_to_display;
base::flat_map<int32_t, uint32_t> monitor_atom_to_display;
auto resources = randr.GetScreenResourcesCurrent({x_root_window}).Sync();
if (!resources) {
@@ -89,7 +89,7 @@ std::map<int32_t, uint32_t> MonitorAtomIdToDisplayId() {
return monitor_atom_to_display;
}
std::map<x11::RandR::Output, int> output_to_monitor =
const auto output_to_monitor =
GetMonitors(connection->randr_version(), &randr, x_root_window);
auto monitors_reply = randr.GetMonitors({x_root_window}).Sync();
@@ -385,8 +385,7 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
// display name atom and the display id is either the EDID or the
// loop index when that display was found (see
// BuildDisplaysFromXRandRInfo in ui/base/x/x11_display_util.cc)
std::map<int32_t, uint32_t> monitor_atom_to_display_id =
MonitorAtomIdToDisplayId();
const auto monitor_atom_to_display_id = MonitorAtomIdToDisplayId();
for (auto& source : screen_sources) {
auto display_id_iter =
monitor_atom_to_display_id.find(source.media_list_source.id.id);

View File

@@ -25,7 +25,7 @@ static NSMenu* __strong applicationMenu_;
ui::Accelerator GetAcceleratorFromKeyEquivalentAndModifierMask(
NSString* key_equivalent,
NSUInteger modifier_mask) {
absl::optional<char16_t> shifted_char;
std::optional<char16_t> shifted_char;
ui::KeyboardCode code = electron::KeyboardCodeFromStr(
base::SysNSStringToUTF8(key_equivalent), &shifted_char);
int modifiers = 0;

View File

@@ -52,24 +52,26 @@ void MenuViews::PopupAt(BaseWindow* window,
auto close_callback = base::AdaptCallbackForRepeating(
base::BindOnce(&MenuViews::OnClosed, weak_factory_.GetWeakPtr(),
window_id, std::move(callback_with_ref)));
menu_runners_[window_id] =
auto& runner = menu_runners_[window_id] =
std::make_unique<MenuRunner>(model(), flags, std::move(close_callback));
menu_runners_[window_id]->RunMenuAt(
native_window->widget(), nullptr, gfx::Rect(location, gfx::Size()),
views::MenuAnchorPosition::kTopLeft, source_type);
runner->RunMenuAt(native_window->widget(), nullptr,
gfx::Rect{location, gfx::Size{}},
views::MenuAnchorPosition::kTopLeft, source_type);
}
void MenuViews::ClosePopupAt(int32_t window_id) {
auto runner = menu_runners_.find(window_id);
if (runner != menu_runners_.end()) {
if (auto iter = menu_runners_.find(window_id); iter != menu_runners_.end()) {
// Close the runner for the window.
runner->second->Cancel();
} else if (window_id == -1) {
// Or just close all opened runners.
for (auto it = menu_runners_.begin(); it != menu_runners_.end();) {
// The iterator is invalidated after the call.
(it++)->second->Cancel();
}
iter->second->Cancel();
return;
}
if (window_id == -1) {
// When -1 is passed in, close all opened runners.
// Note: `Cancel()` invalidaes iters, so move() to a temp before looping
auto tmp = std::move(menu_runners_);
for (auto& [id, runner] : tmp)
runner->Cancel();
}
}

View File

@@ -5,9 +5,9 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_MENU_VIEWS_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_MENU_VIEWS_H_
#include <map>
#include <memory>
#include "base/containers/flat_map.h"
#include "base/memory/weak_ptr.h"
#include "shell/browser/api/electron_api_menu.h"
#include "ui/display/screen.h"
@@ -33,7 +33,7 @@ class MenuViews : public Menu {
void OnClosed(int32_t window_id, base::OnceClosure callback);
// window ID -> open context menu
std::map<int32_t, std::unique_ptr<views::MenuRunner>> menu_runners_;
base::flat_map<int32_t, std::unique_ptr<views::MenuRunner>> menu_runners_;
base::WeakPtrFactory<MenuViews> weak_factory_{this};
};

View File

@@ -125,7 +125,7 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
}
pending_start_promise_ =
absl::make_optional<gin_helper::Promise<void>>(args->isolate());
std::make_optional<gin_helper::Promise<void>>(args->isolate());
v8::Local<v8::Promise> handle = pending_start_promise_->GetHandle();
auto command_line_string =

View File

@@ -5,6 +5,8 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NET_LOG_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NET_LOG_H_
#include <optional>
#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
@@ -16,7 +18,6 @@
#include "net/log/net_log_capture_mode.h"
#include "services/network/public/mojom/net_log.mojom.h"
#include "shell/common/gin_helper/promise.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace gin {
class Arguments;
@@ -67,7 +68,7 @@ class NetLog : public gin::Wrappable<NetLog> {
mojo::Remote<network::mojom::NetLogExporter> net_log_exporter_;
absl::optional<gin_helper::Promise<void>> pending_start_promise_;
std::optional<gin_helper::Promise<void>> pending_start_promise_;
scoped_refptr<base::TaskRunner> file_task_runner_;

View File

@@ -5,8 +5,7 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_POWER_SAVE_BLOCKER_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_POWER_SAVE_BLOCKER_H_
#include <map>
#include "base/containers/flat_map.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "gin/wrappable.h"
@@ -48,8 +47,7 @@ class PowerSaveBlocker : public gin::Wrappable<PowerSaveBlocker> {
bool is_wake_lock_active_ = false;
// Map from id to the corresponding blocker type for each request.
using WakeLockTypeMap = std::map<int, device::mojom::WakeLockType>;
WakeLockTypeMap wake_lock_types_;
base::flat_map<int, device::mojom::WakeLockType> wake_lock_types_;
mojo::Remote<device::mojom::WakeLock> wake_lock_;
};

View File

@@ -4,6 +4,7 @@
#include "shell/browser/api/electron_api_protocol.h"
#include <string_view>
#include <vector>
#include "base/command_line.h"
@@ -193,7 +194,7 @@ const char* const kBuiltinSchemes[] = {
};
// Convert error code to string.
constexpr base::StringPiece ErrorCodeToString(ProtocolError error) {
constexpr std::string_view ErrorCodeToString(ProtocolError error) {
switch (error) {
case ProtocolError::kRegistered:
return "The scheme has been registered";

View File

@@ -5,6 +5,7 @@
#include "shell/browser/api/electron_api_screen.h"
#include <string>
#include <string_view>
#include "base/functional/bind.h"
#include "gin/dictionary.h"
@@ -49,13 +50,13 @@ std::vector<std::string> MetricsToArray(uint32_t metrics) {
}
void DelayEmit(Screen* screen,
base::StringPiece name,
const std::string_view name,
const display::Display& display) {
screen->Emit(name, display);
}
void DelayEmitWithMetrics(Screen* screen,
base::StringPiece name,
const std::string_view name,
const display::Display& display,
const std::vector<std::string>& metrics) {
screen->Emit(name, display, metrics);

View File

@@ -4,6 +4,7 @@
#include "shell/browser/api/electron_api_service_worker_context.h"
#include <string_view>
#include <utility>
#include "chrome/browser/browser_process.h"
@@ -24,7 +25,7 @@ namespace electron::api {
namespace {
constexpr base::StringPiece MessageSourceToString(
constexpr std::string_view MessageSourceToString(
const blink::mojom::ConsoleMessageSource source) {
switch (source) {
case blink::mojom::ConsoleMessageSource::kXml:

View File

@@ -281,7 +281,7 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
url_chain, GURL(),
content::StoragePartitionConfig::CreateDefault(
download_manager->GetBrowserContext()),
GURL(), GURL(), absl::nullopt, mime_type, mime_type, start_time,
GURL(), GURL(), std::nullopt, mime_type, mime_type, start_time,
base::Time(), etag, last_modified, offset, length, std::string(),
download::DownloadItem::INTERRUPTED,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
@@ -432,7 +432,7 @@ v8::Local<v8::Promise> Session::ResolveProxy(gin::Arguments* args) {
v8::Local<v8::Promise> Session::ResolveHost(
std::string host,
absl::optional<network::mojom::ResolveHostParametersPtr> params) {
std::optional<network::mojom::ResolveHostParametersPtr> params) {
gin_helper::Promise<gin_helper::Dictionary> promise(isolate_);
v8::Local<v8::Promise> handle = promise.GetHandle();
@@ -441,7 +441,7 @@ v8::Local<v8::Promise> Session::ResolveHost(
params ? std::move(params.value()) : nullptr,
base::BindOnce(
[](gin_helper::Promise<gin_helper::Dictionary> promise,
int64_t net_error, const absl::optional<net::AddressList>& addrs) {
int64_t net_error, const std::optional<net::AddressList>& addrs) {
if (net_error < 0) {
promise.RejectWithErrorMessage(net::ErrorToString(net_error));
} else {
@@ -1271,7 +1271,7 @@ gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
}
// static
absl::optional<gin::Handle<Session>> Session::FromPath(
std::optional<gin::Handle<Session>> Session::FromPath(
v8::Isolate* isolate,
const base::FilePath& path,
base::Value::Dict options) {
@@ -1280,12 +1280,12 @@ absl::optional<gin::Handle<Session>> Session::FromPath(
if (path.empty()) {
gin_helper::Promise<v8::Local<v8::Value>> promise(isolate);
promise.RejectWithErrorMessage("An empty path was specified");
return absl::nullopt;
return std::nullopt;
}
if (!path.IsAbsolute()) {
gin_helper::Promise<v8::Local<v8::Value>> promise(isolate);
promise.RejectWithErrorMessage("An absolute path was not provided");
return absl::nullopt;
return std::nullopt;
}
browser_context =
@@ -1410,7 +1410,7 @@ v8::Local<v8::Value> FromPath(const base::FilePath& path,
}
base::Value::Dict options;
args->GetNext(&options);
absl::optional<gin::Handle<Session>> session_handle =
std::optional<gin::Handle<Session>> session_handle =
Session::FromPath(args->isolate(), path, std::move(options));
if (session_handle)

View File

@@ -5,6 +5,7 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SESSION_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SESSION_H_
#include <optional>
#include <string>
#include <vector>
@@ -85,7 +86,7 @@ class Session : public gin::Wrappable<Session>,
base::Value::Dict options = {});
// Gets the Session based on |path|.
static absl::optional<gin::Handle<Session>> FromPath(
static std::optional<gin::Handle<Session>> FromPath(
v8::Isolate* isolate,
const base::FilePath& path,
base::Value::Dict options = {});
@@ -101,7 +102,7 @@ class Session : public gin::Wrappable<Session>,
// Methods.
v8::Local<v8::Promise> ResolveHost(
std::string host,
absl::optional<network::mojom::ResolveHostParametersPtr> params);
std::optional<network::mojom::ResolveHostParametersPtr> params);
v8::Local<v8::Promise> ResolveProxy(gin::Arguments* args);
v8::Local<v8::Promise> GetCacheSize();
v8::Local<v8::Promise> ClearCache();

View File

@@ -4,7 +4,6 @@
#include "shell/browser/api/electron_api_system_preferences.h"
#include <map>
#include <string>
#include <utility>
@@ -14,6 +13,7 @@
#import <Security/Security.h>
#include "base/apple/scoped_cftyperef.h"
#include "base/containers/flat_map.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
@@ -81,7 +81,7 @@ namespace {
int g_next_id = 0;
// The map to convert |id| to |int|.
std::map<int, id> g_id_map;
base::flat_map<int, id> g_id_map;
AVMediaType ParseMediaType(const std::string& media_type) {
if (media_type == "camera") {

View File

@@ -2,10 +2,12 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include <iomanip>
#include <string_view>
#include <dwmapi.h>
#include <windows.devices.enumeration.h>
#include <wrl/client.h>
#include <iomanip>
#include "shell/browser/api/electron_api_system_preferences.h"
@@ -98,39 +100,38 @@ std::string SystemPreferences::GetAccentColor() {
std::string SystemPreferences::GetColor(gin_helper::ErrorThrower thrower,
const std::string& color) {
static constexpr auto Lookup =
base::MakeFixedFlatMap<base::StringPiece, int>({
{"3d-dark-shadow", COLOR_3DDKSHADOW},
{"3d-face", COLOR_3DFACE},
{"3d-highlight", COLOR_3DHIGHLIGHT},
{"3d-light", COLOR_3DLIGHT},
{"3d-shadow", COLOR_3DSHADOW},
{"active-border", COLOR_ACTIVEBORDER},
{"active-caption", COLOR_ACTIVECAPTION},
{"active-caption-gradient", COLOR_GRADIENTACTIVECAPTION},
{"app-workspace", COLOR_APPWORKSPACE},
{"button-text", COLOR_BTNTEXT},
{"caption-text", COLOR_CAPTIONTEXT},
{"desktop", COLOR_DESKTOP},
{"disabled-text", COLOR_GRAYTEXT},
{"highlight", COLOR_HIGHLIGHT},
{"highlight-text", COLOR_HIGHLIGHTTEXT},
{"hotlight", COLOR_HOTLIGHT},
{"inactive-border", COLOR_INACTIVEBORDER},
{"inactive-caption", COLOR_INACTIVECAPTION},
{"inactive-caption-gradient", COLOR_GRADIENTINACTIVECAPTION},
{"inactive-caption-text", COLOR_INACTIVECAPTIONTEXT},
{"info-background", COLOR_INFOBK},
{"info-text", COLOR_INFOTEXT},
{"menu", COLOR_MENU},
{"menu-highlight", COLOR_MENUHILIGHT},
{"menu-text", COLOR_MENUTEXT},
{"menubar", COLOR_MENUBAR},
{"scrollbar", COLOR_SCROLLBAR},
{"window", COLOR_WINDOW},
{"window-frame", COLOR_WINDOWFRAME},
{"window-text", COLOR_WINDOWTEXT},
});
static constexpr auto Lookup = base::MakeFixedFlatMap<std::string_view, int>({
{"3d-dark-shadow", COLOR_3DDKSHADOW},
{"3d-face", COLOR_3DFACE},
{"3d-highlight", COLOR_3DHIGHLIGHT},
{"3d-light", COLOR_3DLIGHT},
{"3d-shadow", COLOR_3DSHADOW},
{"active-border", COLOR_ACTIVEBORDER},
{"active-caption", COLOR_ACTIVECAPTION},
{"active-caption-gradient", COLOR_GRADIENTACTIVECAPTION},
{"app-workspace", COLOR_APPWORKSPACE},
{"button-text", COLOR_BTNTEXT},
{"caption-text", COLOR_CAPTIONTEXT},
{"desktop", COLOR_DESKTOP},
{"disabled-text", COLOR_GRAYTEXT},
{"highlight", COLOR_HIGHLIGHT},
{"highlight-text", COLOR_HIGHLIGHTTEXT},
{"hotlight", COLOR_HOTLIGHT},
{"inactive-border", COLOR_INACTIVEBORDER},
{"inactive-caption", COLOR_INACTIVECAPTION},
{"inactive-caption-gradient", COLOR_GRADIENTINACTIVECAPTION},
{"inactive-caption-text", COLOR_INACTIVECAPTIONTEXT},
{"info-background", COLOR_INFOBK},
{"info-text", COLOR_INFOTEXT},
{"menu", COLOR_MENU},
{"menu-highlight", COLOR_MENUHILIGHT},
{"menu-text", COLOR_MENUTEXT},
{"menubar", COLOR_MENUBAR},
{"scrollbar", COLOR_SCROLLBAR},
{"window", COLOR_WINDOW},
{"window-frame", COLOR_WINDOWFRAME},
{"window-text", COLOR_WINDOWTEXT},
});
if (const auto* iter = Lookup.find(color); iter != Lookup.end())
return ToRGBAHex(color_utils::GetSysSkColor(iter->second));

View File

@@ -5,6 +5,7 @@
#include "shell/browser/api/electron_api_tray.h"
#include <string>
#include <string_view>
#include "base/containers/fixed_flat_map.h"
#include "gin/dictionary.h"
@@ -32,7 +33,7 @@ struct Converter<electron::TrayIcon::IconType> {
electron::TrayIcon::IconType* out) {
using Val = electron::TrayIcon::IconType;
static constexpr auto Lookup =
base::MakeFixedFlatMap<base::StringPiece, Val>({
base::MakeFixedFlatMap<std::string_view, Val>({
{"custom", Val::kCustom},
{"error", Val::kError},
{"info", Val::kInfo},
@@ -51,7 +52,7 @@ gin::WrapperInfo Tray::kWrapperInfo = {gin::kEmbedderNativeGin};
Tray::Tray(v8::Isolate* isolate,
v8::Local<v8::Value> image,
absl::optional<UUID> guid)
std::optional<UUID> guid)
: tray_icon_(TrayIcon::Create(guid)) {
SetImage(isolate, image);
tray_icon_->AddObserver(this);
@@ -62,7 +63,7 @@ Tray::~Tray() = default;
// static
gin::Handle<Tray> Tray::New(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> image,
absl::optional<UUID> guid,
std::optional<UUID> guid,
gin::Arguments* args) {
if (!Browser::Get()->is_ready()) {
thrower.ThrowError("Cannot create Tray before app is ready");
@@ -232,7 +233,7 @@ void Tray::SetToolTip(const std::string& tool_tip) {
}
void Tray::SetTitle(const std::string& title,
const absl::optional<gin_helper::Dictionary>& options,
const std::optional<gin_helper::Dictionary>& options,
gin::Arguments* args) {
if (!CheckAlive())
return;

View File

@@ -6,6 +6,7 @@
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_TRAY_H_
#include <memory>
#include <optional>
#include <string>
#include <vector>
@@ -43,7 +44,7 @@ class Tray : public gin::Wrappable<Tray>,
// gin_helper::Constructible
static gin::Handle<Tray> New(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> image,
absl::optional<UUID> guid,
std::optional<UUID> guid,
gin::Arguments* args);
static void FillObjectTemplate(v8::Isolate*, v8::Local<v8::ObjectTemplate>);
@@ -60,7 +61,7 @@ class Tray : public gin::Wrappable<Tray>,
private:
Tray(v8::Isolate* isolate,
v8::Local<v8::Value> image,
absl::optional<UUID> guid);
std::optional<UUID> guid);
~Tray() override;
// TrayIconObserver:
@@ -92,7 +93,7 @@ class Tray : public gin::Wrappable<Tray>,
void SetPressedImage(v8::Isolate* isolate, v8::Local<v8::Value> image);
void SetToolTip(const std::string& tool_tip);
void SetTitle(const std::string& title,
const absl::optional<gin_helper::Dictionary>& options,
const std::optional<gin_helper::Dictionary>& options,
gin::Arguments* args);
std::string GetTitle();
void SetIgnoreDoubleClickEvents(bool ignore);

View File

@@ -182,7 +182,7 @@ View::~View() {
}
void View::AddChildViewAt(gin::Handle<View> child,
absl::optional<size_t> maybe_index) {
std::optional<size_t> maybe_index) {
// TODO(nornagon): !view_ is only for supporting the weird case of
// WebContentsView's view being deleted when the underlying WebContents is
// destroyed (on non-Mac). We should fix that so that WebContentsView always
@@ -292,7 +292,7 @@ std::vector<v8::Local<v8::Value>> View::GetChildren() {
return ret;
}
void View::SetBackgroundColor(absl::optional<WrappedSkColor> color) {
void View::SetBackgroundColor(std::optional<WrappedSkColor> color) {
if (!view_)
return;
view_->SetBackground(color ? views::CreateSolidBackground(*color) : nullptr);

View File

@@ -5,6 +5,8 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_
#include <optional>
#include "base/memory/raw_ptr.h"
#include "gin/handle.h"
#include "shell/common/color_util.h"
@@ -26,14 +28,14 @@ class View : public gin_helper::EventEmitter<View>, public views::ViewObserver {
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
void AddChildViewAt(gin::Handle<View> child, absl::optional<size_t> index);
void AddChildViewAt(gin::Handle<View> child, std::optional<size_t> index);
void RemoveChildView(gin::Handle<View> child);
void SetBounds(const gfx::Rect& bounds);
gfx::Rect GetBounds();
void SetLayout(v8::Isolate* isolate, v8::Local<v8::Object> value);
std::vector<v8::Local<v8::Value>> GetChildren();
void SetBackgroundColor(absl::optional<WrappedSkColor> color);
void SetBackgroundColor(std::optional<WrappedSkColor> color);
void SetVisible(bool visible);
// views::ViewObserver

View File

@@ -6,8 +6,10 @@
#include <limits>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
@@ -128,7 +130,6 @@
#include "shell/common/thread_restrictions.h"
#include "shell/common/v8_value_serializer.h"
#include "storage/browser/file_system/isolated_context.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/messaging/transferable_message_mojom_traits.h"
@@ -205,7 +206,7 @@ struct Converter<printing::mojom::MarginType> {
printing::mojom::MarginType* out) {
using Val = printing::mojom::MarginType;
static constexpr auto Lookup =
base::MakeFixedFlatMap<base::StringPiece, Val>({
base::MakeFixedFlatMap<std::string_view, Val>({
{"custom", Val::kCustomMargins},
{"default", Val::kDefaultMargins},
{"none", Val::kNoMargins},
@@ -222,7 +223,7 @@ struct Converter<printing::mojom::DuplexMode> {
printing::mojom::DuplexMode* out) {
using Val = printing::mojom::DuplexMode;
static constexpr auto Lookup =
base::MakeFixedFlatMap<base::StringPiece, Val>({
base::MakeFixedFlatMap<std::string_view, Val>({
{"longEdge", Val::kLongEdge},
{"shortEdge", Val::kShortEdge},
{"simplex", Val::kSimplex},
@@ -284,7 +285,7 @@ struct Converter<content::SavePageType> {
content::SavePageType* out) {
using Val = content::SavePageType;
static constexpr auto Lookup =
base::MakeFixedFlatMap<base::StringPiece, Val>({
base::MakeFixedFlatMap<std::string_view, Val>({
{"htmlcomplete", Val::SAVE_PAGE_TYPE_AS_COMPLETE_HTML},
{"htmlonly", Val::SAVE_PAGE_TYPE_AS_ONLY_HTML},
{"mhtml", Val::SAVE_PAGE_TYPE_AS_MHTML},
@@ -329,7 +330,7 @@ struct Converter<electron::api::WebContents::Type> {
electron::api::WebContents::Type* out) {
using Val = electron::api::WebContents::Type;
static constexpr auto Lookup =
base::MakeFixedFlatMap<base::StringPiece, Val>({
base::MakeFixedFlatMap<std::string_view, Val>({
{"backgroundPage", Val::kBackgroundPage},
{"browserView", Val::kBrowserView},
{"offscreen", Val::kOffScreen},
@@ -357,7 +358,7 @@ namespace electron::api {
namespace {
constexpr base::StringPiece CursorTypeToString(
constexpr std::string_view CursorTypeToString(
ui::mojom::CursorType cursor_type) {
switch (cursor_type) {
case ui::mojom::CursorType::kPointer:
@@ -496,9 +497,9 @@ void OnCapturePageDone(gin_helper::Promise<gfx::Image> promise,
capture_handle.RunAndReset();
}
absl::optional<base::TimeDelta> GetCursorBlinkInterval() {
std::optional<base::TimeDelta> GetCursorBlinkInterval() {
#if BUILDFLAG(IS_MAC)
absl::optional<base::TimeDelta> system_value(
std::optional<base::TimeDelta> system_value(
ui::TextInsertionCaretBlinkPeriodFromDefaults());
if (system_value)
return *system_value;
@@ -512,7 +513,7 @@ absl::optional<base::TimeDelta> GetCursorBlinkInterval() {
: base::Milliseconds(system_msec);
}
#endif
return absl::nullopt;
return std::nullopt;
}
#if BUILDFLAG(ENABLE_PRINTING)
@@ -822,6 +823,9 @@ WebContents::WebContents(v8::Isolate* isolate,
// Get type
options.Get("type", &type_);
// Get transparent for guest view
options.Get("transparent", &guest_transparent_);
bool b = false;
if (options.Get(options::kOffscreen, &b) && b)
type_ = Type::kOffScreen;
@@ -1101,7 +1105,7 @@ void WebContents::Destroy() {
}
}
void WebContents::Close(absl::optional<gin_helper::Dictionary> options) {
void WebContents::Close(std::optional<gin_helper::Dictionary> options) {
bool dispatch_beforeunload = false;
if (options)
options->Get("waitForBeforeUnload", &dispatch_beforeunload);
@@ -1672,7 +1676,7 @@ void WebContents::HandleNewRenderFrame(
}
void WebContents::OnBackgroundColorChanged() {
absl::optional<SkColor> color = web_contents()->GetBackgroundColor();
std::optional<SkColor> color = web_contents()->GetBackgroundColor();
if (color.has_value()) {
auto* const view = web_contents()->GetRenderWidgetHostView();
static_cast<content::RenderWidgetHostViewBase*>(view)
@@ -2263,7 +2267,7 @@ void WebContents::SetOwnerWindow(NativeWindow* owner_window) {
SetOwnerWindow(GetWebContents(), owner_window);
}
void WebContents::SetOwnerBaseWindow(absl::optional<BaseWindow*> owner_window) {
void WebContents::SetOwnerBaseWindow(std::optional<BaseWindow*> owner_window) {
SetOwnerWindow(GetWebContents(),
owner_window ? (*owner_window)->window() : nullptr);
}
@@ -3166,8 +3170,8 @@ v8::Local<v8::Promise> WebContents::PrintToPDF(const base::Value& settings) {
web_contents()->GetPrimaryMainFrame()->GetLastCommittedURL(),
landscape, display_header_footer, print_background, scale,
paper_width, paper_height, margin_top, margin_bottom, margin_left,
margin_right, absl::make_optional(header_template),
absl::make_optional(footer_template), prefer_css_page_size,
margin_right, std::make_optional(header_template),
std::make_optional(footer_template), prefer_css_page_size,
generate_tagged_pdf, generate_document_outline);
if (absl::holds_alternative<std::string>(print_pages_params)) {
@@ -3777,16 +3781,18 @@ void WebContents::SetImageAnimationPolicy(const std::string& new_policy) {
web_contents()->OnWebPreferencesChanged();
}
void WebContents::SetBackgroundColor(absl::optional<SkColor> maybe_color) {
web_contents()->SetPageBaseBackgroundColor(maybe_color);
void WebContents::SetBackgroundColor(std::optional<SkColor> maybe_color) {
SkColor color = maybe_color.value_or((IsGuest() && guest_transparent_) ||
type_ == Type::kBrowserView
? SK_ColorTRANSPARENT
: SK_ColorWHITE);
web_contents()->SetPageBaseBackgroundColor(color);
content::RenderFrameHost* rfh = web_contents()->GetPrimaryMainFrame();
if (!rfh)
return;
content::RenderWidgetHostView* rwhv = rfh->GetView();
if (rwhv) {
SkColor color =
maybe_color.value_or(IsGuest() ? SK_ColorTRANSPARENT : SK_ColorWHITE);
rwhv->SetBackgroundColor(color);
static_cast<content::RenderWidgetHostViewBase*>(rwhv)
->SetContentBackgroundColor(color);
@@ -4119,7 +4125,7 @@ void WebContents::DevToolsIndexPath(
if (devtools_indexing_jobs_.count(request_id) != 0)
return;
std::vector<std::string> excluded_folders;
absl::optional<base::Value> parsed_excluded_folders =
std::optional<base::Value> parsed_excluded_folders =
base::JSONReader::Read(excluded_folders_message);
if (parsed_excluded_folders && parsed_excluded_folders->is_list()) {
for (const base::Value& folder_path : parsed_excluded_folders->GetList()) {

View File

@@ -7,7 +7,9 @@
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
@@ -164,7 +166,7 @@ class WebContents : public ExclusiveAccessContext,
const char* GetTypeName() override;
void Destroy();
void Close(absl::optional<gin_helper::Dictionary> options);
void Close(std::optional<gin_helper::Dictionary> options);
base::WeakPtr<WebContents> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
bool GetBackgroundThrottling() const override;
@@ -370,7 +372,7 @@ class WebContents : public ExclusiveAccessContext,
// this.emit(name, new Event(sender, message), args...);
template <typename... Args>
bool EmitWithSender(base::StringPiece name,
bool EmitWithSender(const std::string_view name,
content::RenderFrameHost* frame,
electron::mojom::ElectronApiIPC::InvokeCallback callback,
Args&&... args) {
@@ -403,7 +405,7 @@ class WebContents : public ExclusiveAccessContext,
void SetOwnerWindow(NativeWindow* owner_window);
void SetOwnerWindow(content::WebContents* web_contents,
NativeWindow* owner_window);
void SetOwnerBaseWindow(absl::optional<BaseWindow*> owner_window);
void SetOwnerBaseWindow(std::optional<BaseWindow*> owner_window);
// Returns the WebContents managed by this delegate.
content::WebContents* GetWebContents() const;
@@ -474,7 +476,7 @@ class WebContents : public ExclusiveAccessContext,
void CancelDialogs(content::WebContents* web_contents,
bool reset_state) override;
void SetBackgroundColor(absl::optional<SkColor> color);
void SetBackgroundColor(std::optional<SkColor> color);
SkRegion* draggable_region() {
return force_non_draggable_ ? nullptr : draggable_region_.get();
@@ -801,6 +803,9 @@ class WebContents : public ExclusiveAccessContext,
// The type of current WebContents.
Type type_ = Type::kBrowserWindow;
// Weather the guest view should be transparent
bool guest_transparent_ = true;
int32_t id_;
// Request id used for findInPage request.

View File

@@ -66,7 +66,7 @@ gin::Handle<WebContents> WebContentsView::GetWebContents(v8::Isolate* isolate) {
return gin::Handle<WebContents>();
}
void WebContentsView::SetBackgroundColor(absl::optional<WrappedSkColor> color) {
void WebContentsView::SetBackgroundColor(std::optional<WrappedSkColor> color) {
View::SetBackgroundColor(color);
if (api_web_contents_) {
api_web_contents_->SetBackgroundColor(color);

View File

@@ -5,6 +5,8 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_VIEW_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_VIEW_H_
#include <optional>
#include "base/memory/raw_ptr.h"
#include "content/public/browser/web_contents_observer.h"
#include "shell/browser/api/electron_api_view.h"
@@ -36,7 +38,7 @@ class WebContentsView : public View,
// Public APIs.
gin::Handle<WebContents> GetWebContents(v8::Isolate* isolate);
void SetBackgroundColor(absl::optional<WrappedSkColor> color);
void SetBackgroundColor(std::optional<WrappedSkColor> color);
int NonClientHitTest(const gfx::Point& point) override;

View File

@@ -229,7 +229,7 @@ void WebFrameMain::OnRendererConnectionError() {
void WebFrameMain::PostMessage(v8::Isolate* isolate,
const std::string& channel,
v8::Local<v8::Value> message_value,
absl::optional<v8::Local<v8::Value>> transfer) {
std::optional<v8::Local<v8::Value>> transfer) {
blink::TransferableMessage transferable_message;
if (!electron::SerializeV8Value(isolate, message_value,
&transferable_message)) {

View File

@@ -5,6 +5,7 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_FRAME_MAIN_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_FRAME_MAIN_H_
#include <optional>
#include <string>
#include <vector>
@@ -103,7 +104,7 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
void PostMessage(v8::Isolate* isolate,
const std::string& channel,
v8::Local<v8::Value> message_value,
absl::optional<v8::Local<v8::Value>> transfer);
std::optional<v8::Local<v8::Value>> transfer);
int FrameTreeNodeID() const;
std::string Name() const;

View File

@@ -6,6 +6,7 @@
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include "base/containers/contains.h"
@@ -33,7 +34,7 @@
#include "shell/common/gin_helper/dictionary.h"
static constexpr auto ResourceTypes =
base::MakeFixedFlatMap<base::StringPiece,
base::MakeFixedFlatMap<std::string_view,
extensions::WebRequestResourceType>({
{"cspReport", extensions::WebRequestResourceType::CSP_REPORT},
{"font", extensions::WebRequestResourceType::FONT},
@@ -77,7 +78,7 @@ struct UserData : public base::SupportsUserData::Data {
raw_ptr<WebRequest> data;
};
extensions::WebRequestResourceType ParseResourceType(base::StringPiece value) {
extensions::WebRequestResourceType ParseResourceType(std::string_view value) {
if (const auto* iter = ResourceTypes.find(value); iter != ResourceTypes.end())
return iter->second;

View File

@@ -5,10 +5,9 @@
#include "shell/browser/api/process_metric.h"
#include <memory>
#include <optional>
#include <utility>
#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
@@ -34,14 +33,14 @@ mach_port_t TaskForPid(pid_t pid) {
return task;
}
absl::optional<mach_task_basic_info_data_t> GetTaskInfo(mach_port_t task) {
std::optional<mach_task_basic_info_data_t> GetTaskInfo(mach_port_t task) {
if (task == MACH_PORT_NULL)
return absl::nullopt;
return std::nullopt;
mach_task_basic_info_data_t info = {};
mach_msg_type_number_t count = MACH_TASK_BASIC_INFO_COUNT;
kern_return_t kr = task_info(task, MACH_TASK_BASIC_INFO,
reinterpret_cast<task_info_t>(&info), &count);
return (kr == KERN_SUCCESS) ? absl::make_optional(info) : absl::nullopt;
return (kr == KERN_SUCCESS) ? std::make_optional(info) : std::nullopt;
}
} // namespace

View File

@@ -67,7 +67,7 @@ void BadgeManager::BindServiceWorkerReceiver(
std::move(context));
}
std::string BadgeManager::GetBadgeString(absl::optional<int> badge_content) {
std::string BadgeManager::GetBadgeString(std::optional<int> badge_content) {
if (!badge_content)
return "";
@@ -87,9 +87,9 @@ void BadgeManager::SetBadge(blink::mojom::BadgeValuePtr mojo_value) {
return;
}
absl::optional<int> value =
mojo_value->is_flag() ? absl::nullopt
: absl::make_optional(mojo_value->get_number());
std::optional<int> value = mojo_value->is_flag()
? std::nullopt
: std::make_optional(mojo_value->get_number());
electron::Browser::Get()->SetBadgeCount(value);
}

View File

@@ -6,11 +6,11 @@
#define ELECTRON_SHELL_BROWSER_BADGING_BADGE_MANAGER_H_
#include <memory>
#include <optional>
#include <string>
#include "components/keyed_service/core/keyed_service.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/mojom/badging/badging.mojom.h"
#include "url/gurl.h"
@@ -44,7 +44,7 @@ class BadgeManager : public KeyedService, public blink::mojom::BadgeService {
mojo::PendingReceiver<blink::mojom::BadgeService> receiver);
// Determines the text to put on the badge based on some badge_content.
static std::string GetBadgeString(absl::optional<int> badge_content);
static std::string GetBadgeString(std::optional<int> badge_content);
private:
// The BindingContext of a mojo request. Allows mojo calls to be tied back

View File

@@ -161,7 +161,7 @@ void ElectronBluetoothDelegate::ShowDevicePairPrompt(
const std::u16string& device_identifier,
PairPromptCallback callback,
PairingKind pairing_kind,
const absl::optional<std::u16string>& pin) {
const std::optional<std::u16string>& pin) {
auto* web_contents = content::WebContents::FromRenderFrameHost(frame);
if (web_contents) {
auto* permission_manager = static_cast<ElectronPermissionManager*>(

View File

@@ -6,6 +6,7 @@
#define ELECTRON_SHELL_BROWSER_BLUETOOTH_ELECTRON_BLUETOOTH_DELEGATE_H_
#include <memory>
#include <optional>
#include <string>
#include <vector>
@@ -57,7 +58,7 @@ class ElectronBluetoothDelegate : public content::BluetoothDelegate {
const std::u16string& device_identifier,
PairPromptCallback callback,
PairingKind pairing_kind,
const absl::optional<std::u16string>& pin) override;
const std::optional<std::u16string>& pin) override;
blink::WebBluetoothDeviceId GetWebBluetoothDeviceId(
content::RenderFrameHost* frame,
const std::string& device_address) override;

View File

@@ -6,6 +6,7 @@
#define ELECTRON_SHELL_BROWSER_BROWSER_H_
#include <memory>
#include <optional>
#include <string>
#include <vector>
@@ -108,7 +109,7 @@ class Browser : public WindowListObserver {
#endif
// Set/Get the badge count.
bool SetBadgeCount(absl::optional<int> count);
bool SetBadgeCount(std::optional<int> count);
int GetBadgeCount();
#if BUILDFLAG(IS_WIN)
@@ -374,7 +375,7 @@ class Browser : public WindowListObserver {
#if BUILDFLAG(IS_WIN)
void UpdateBadgeContents(HWND hwnd,
const absl::optional<std::string>& badge_content,
const std::optional<std::string>& badge_content,
const std::string& badge_alt_string);
// In charge of running taskbar related APIs.

View File

@@ -49,7 +49,7 @@ bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
return process.WaitForExit(exit_code);
}
absl::optional<std::string> GetXdgAppOutput(
std::optional<std::string> GetXdgAppOutput(
const std::vector<std::string>& argv) {
std::string reply;
int success_code;
@@ -58,9 +58,9 @@ absl::optional<std::string> GetXdgAppOutput(
&success_code);
if (!ran_ok || success_code != EXIT_SUCCESS)
return absl::optional<std::string>();
return std::optional<std::string>();
return absl::make_optional(reply);
return std::make_optional(reply);
}
bool SetDefaultWebClient(const std::string& protocol) {
@@ -126,7 +126,7 @@ std::u16string Browser::GetApplicationNameForProtocol(const GURL& url) {
return base::ASCIIToUTF16(GetXdgAppOutput(argv).value_or(std::string()));
}
bool Browser::SetBadgeCount(absl::optional<int> count) {
bool Browser::SetBadgeCount(std::optional<int> count) {
if (IsUnityRunning() && count.has_value()) {
unity::SetDownloadCount(count.value());
badge_count_ = count.value();

View File

@@ -266,7 +266,7 @@ std::u16string Browser::GetApplicationNameForProtocol(const GURL& url) {
return app_display_name;
}
bool Browser::SetBadgeCount(absl::optional<int> count) {
bool Browser::SetBadgeCount(std::optional<int> count) {
DockSetBadgeText(!count.has_value() || count.value() != 0
? badging::BadgeManager::GetBadgeString(count)
: "");

View File

@@ -516,10 +516,10 @@ v8::Local<v8::Promise> Browser::GetApplicationInfoForProtocol(
return handle;
}
bool Browser::SetBadgeCount(absl::optional<int> count) {
absl::optional<std::string> badge_content;
bool Browser::SetBadgeCount(std::optional<int> count) {
std::optional<std::string> badge_content;
if (count.has_value() && count.value() == 0) {
badge_content = absl::nullopt;
badge_content = std::nullopt;
} else {
badge_content = badging::BadgeManager::GetBadgeString(count);
}
@@ -560,7 +560,7 @@ bool Browser::SetBadgeCount(absl::optional<int> count) {
void Browser::UpdateBadgeContents(
HWND hwnd,
const absl::optional<std::string>& badge_content,
const std::optional<std::string>& badge_content,
const std::string& badge_alt_string) {
SkBitmap badge;
if (badge_content) {

View File

@@ -924,7 +924,7 @@ bool ElectronBrowserClient::HandleExternalProtocol(
network::mojom::WebSandboxFlags sandbox_flags,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const std::optional<url::Origin>& initiating_origin,
content::RenderFrameHost* initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
content::GetUIThreadTaskRunner({})->PostTask(
@@ -1129,7 +1129,7 @@ class FileURLLoaderFactory : public network::SelfDeletingURLLoaderFactory {
void ElectronBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id,
int render_frame_id,
const absl::optional<url::Origin>& request_initiator_origin,
const std::optional<url::Origin>& request_initiator_origin,
NonNetworkURLLoaderFactoryMap* factories) {
auto* render_process_host =
content::RenderProcessHost::FromID(render_process_id);
@@ -1265,7 +1265,7 @@ void ElectronBrowserClient::CreateWebSocket(
WebSocketFactory factory,
const GURL& url,
const net::SiteForCookies& site_for_cookies,
const absl::optional<std::string>& user_agent,
const std::optional<std::string>& user_agent,
mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
handshake_client) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
@@ -1302,7 +1302,7 @@ bool ElectronBrowserClient::WillCreateURLLoaderFactory(
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
std::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*

View File

@@ -5,12 +5,12 @@
#ifndef ELECTRON_SHELL_BROWSER_ELECTRON_BROWSER_CLIENT_H_
#define ELECTRON_SHELL_BROWSER_ELECTRON_BROWSER_CLIENT_H_
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "base/synchronization/lock.h"
@@ -201,7 +201,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
void RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id,
int render_frame_id,
const absl::optional<url::Origin>& request_initiator_origin,
const std::optional<url::Origin>& request_initiator_origin,
NonNetworkURLLoaderFactoryMap* factories) override;
void RegisterNonNetworkServiceWorkerUpdateURLLoaderFactories(
content::BrowserContext* browser_context,
@@ -211,7 +211,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
WebSocketFactory factory,
const GURL& url,
const net::SiteForCookies& site_for_cookies,
const absl::optional<std::string>& user_agent,
const std::optional<std::string>& user_agent,
mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
handshake_client) override;
bool WillInterceptWebSocket(content::RenderFrameHost*) override;
@@ -221,7 +221,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
absl::optional<int64_t> navigation_id,
std::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
@@ -263,7 +263,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
network::mojom::WebSandboxFlags sandbox_flags,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
const std::optional<url::Origin>& initiating_origin,
content::RenderFrameHost* initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
@@ -313,9 +313,9 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
bool IsRendererSubFrame(int process_id) const;
// pending_render_process => web contents.
std::map<int, content::WebContents*> pending_processes_;
base::flat_map<int, content::WebContents*> pending_processes_;
std::set<int> renderer_is_subframe_;
base::flat_set<int> renderer_is_subframe_;
std::unique_ptr<PlatformNotificationService> notification_service_;
std::unique_ptr<NotificationPresenter> notification_presenter_;

View File

@@ -438,7 +438,7 @@ ElectronBrowserContext::GetURLLoaderFactory() {
->WillCreateURLLoaderFactory(
this, nullptr, -1,
content::ContentBrowserClient::URLLoaderFactoryType::kNavigation,
url::Origin(), absl::nullopt, ukm::kInvalidSourceIdObj,
url::Origin(), std::nullopt, ukm::kInvalidSourceIdObj,
&factory_receiver, &header_client, nullptr, nullptr, nullptr,
nullptr);

View File

@@ -7,9 +7,11 @@
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <variant>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/predictors/preconnect_manager.h"
@@ -251,7 +253,7 @@ class ElectronBrowserContext : public content::BrowserContext {
std::unique_ptr<predictors::PreconnectManager> preconnect_manager_;
std::unique_ptr<ProtocolRegistry> protocol_registry_;
absl::optional<std::string> user_agent_;
std::optional<std::string> user_agent_;
base::FilePath path_;
bool in_memory_ = false;
bool use_cache_ = true;

View File

@@ -5,6 +5,7 @@
#include "shell/browser/electron_browser_main_parts.h"
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -64,7 +65,6 @@
#include "shell/common/logging.h"
#include "shell/common/node_bindings.h"
#include "shell/common/node_includes.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/base/idle/idle.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_switches.h"
@@ -308,7 +308,7 @@ int ElectronBrowserMainParts::PreCreateThreads() {
// We must set this env first to make ui::ResourceBundle accept the custom
// locale.
auto env = base::Environment::Create();
absl::optional<std::string> lc_all;
std::optional<std::string> lc_all;
if (!locale.empty()) {
std::string str;
if (env->GetVar("LC_ALL", &str))

View File

@@ -6,6 +6,7 @@
#define ELECTRON_SHELL_BROWSER_ELECTRON_BROWSER_MAIN_PARTS_H_
#include <memory>
#include <optional>
#include <string>
#include "base/functional/callback.h"
@@ -16,7 +17,6 @@
#include "electron/buildflags/buildflags.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/device/public/mojom/geolocation_control.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/display/screen.h"
#include "ui/views/layout/layout_provider.h"
@@ -153,7 +153,7 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
// A place to remember the exit code once the message loop is ready.
// Before then, we just exit() without any intermediate steps.
absl::optional<int> exit_code_;
std::optional<int> exit_code_;
std::unique_ptr<NodeBindings> node_bindings_;

View File

@@ -4,6 +4,8 @@
#include "shell/browser/electron_browser_main_parts.h"
#include <string_view>
#include "base/command_line.h"
#include "base/environment.h"
#include "ui/base/ozone_buildflags.h"
@@ -16,8 +18,8 @@
#include "shell/common/thread_restrictions.h"
#endif
constexpr base::StringPiece kElectronOzonePlatformHint(
"ELECTRON_OZONE_PLATFORM_HINT");
constexpr std::string_view kElectronOzonePlatformHint{
"ELECTRON_OZONE_PLATFORM_HINT"};
#if BUILDFLAG(IS_OZONE_WAYLAND)

View File

@@ -5,6 +5,7 @@
#ifndef ELECTRON_SHELL_BROWSER_EVENT_EMITTER_MIXIN_H_
#define ELECTRON_SHELL_BROWSER_EVENT_EMITTER_MIXIN_H_
#include <string_view>
#include <utility>
#include "gin/handle.h"
@@ -25,7 +26,7 @@ class EventEmitterMixin {
// this.emit(name, new Event(), args...);
// Returns true if event.preventDefault() was called during processing.
template <typename... Args>
bool Emit(base::StringPiece name, Args&&... args) {
bool Emit(const std::string_view name, Args&&... args) {
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Object> wrapper;
@@ -39,7 +40,7 @@ class EventEmitterMixin {
// this.emit(name, args...);
template <typename... Args>
void EmitWithoutEvent(base::StringPiece name, Args&&... args) {
void EmitWithoutEvent(const std::string_view name, Args&&... args) {
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Object> wrapper;

View File

@@ -53,7 +53,7 @@ PdfViewerPrivateIsAllowedLocalFileAccessFunction::
ExtensionFunction::ResponseAction
PdfViewerPrivateIsAllowedLocalFileAccessFunction::Run() {
absl::optional<IsAllowedLocalFileAccess::Params> params =
std::optional<IsAllowedLocalFileAccess::Params> params =
IsAllowedLocalFileAccess::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
@@ -81,7 +81,7 @@ PdfViewerPrivateSetPdfOcrPrefFunction::
// TODO(codebytere): enable when https://crbug.com/1393069 works properly.
ExtensionFunction::ResponseAction PdfViewerPrivateSetPdfOcrPrefFunction::Run() {
absl::optional<SetPdfOcrPref::Params> params =
std::optional<SetPdfOcrPref::Params> params =
SetPdfOcrPref::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
return RespondNow(WithArguments(false));

View File

@@ -40,7 +40,7 @@ ResourcesPrivateGetStringsFunction::~ResourcesPrivateGetStringsFunction() =
default;
ExtensionFunction::ResponseAction ResourcesPrivateGetStringsFunction::Run() {
absl::optional<get_strings::Params> params(
std::optional<get_strings::Params> params(
get_strings::Params::Create(args()));
base::Value::Dict dict;

View File

@@ -198,14 +198,14 @@ bool GetFileResources(const std::vector<std::string>& files,
using ResourcesLoadedCallback =
base::OnceCallback<void(std::vector<InjectedFileSource>,
absl::optional<std::string>)>;
std::optional<std::string>)>;
// Checks the loaded content of extension resources. Invokes `callback` with
// the constructed file sources on success or with an error on failure.
void CheckLoadedResources(std::vector<std::string> file_names,
ResourcesLoadedCallback callback,
std::vector<std::unique_ptr<std::string>> file_data,
absl::optional<std::string> load_error) {
std::optional<std::string> load_error) {
if (load_error) {
std::move(callback).Run({}, std::move(load_error));
return;
@@ -228,7 +228,7 @@ void CheckLoadedResources(std::vector<std::string> file_names,
}
}
std::move(callback).Run(std::move(file_sources), absl::nullopt);
std::move(callback).Run(std::move(file_sources), std::nullopt);
}
// Checks the specified `files` for validity, and attempts to load and localize
@@ -582,7 +582,7 @@ ScriptingExecuteScriptFunction::ScriptingExecuteScriptFunction() = default;
ScriptingExecuteScriptFunction::~ScriptingExecuteScriptFunction() = default;
ExtensionFunction::ResponseAction ScriptingExecuteScriptFunction::Run() {
absl::optional<api::scripting::ExecuteScript::Params> params =
std::optional<api::scripting::ExecuteScript::Params> params =
api::scripting::ExecuteScript::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
injection_ = std::move(params->injection);
@@ -654,7 +654,7 @@ ExtensionFunction::ResponseAction ScriptingExecuteScriptFunction::Run() {
void ScriptingExecuteScriptFunction::DidLoadResources(
std::vector<InjectedFileSource> file_sources,
absl::optional<std::string> load_error) {
std::optional<std::string> load_error) {
if (load_error) {
Respond(Error(std::move(*load_error)));
return;
@@ -749,7 +749,7 @@ ScriptingInsertCSSFunction::ScriptingInsertCSSFunction() = default;
ScriptingInsertCSSFunction::~ScriptingInsertCSSFunction() = default;
ExtensionFunction::ResponseAction ScriptingInsertCSSFunction::Run() {
absl::optional<api::scripting::InsertCSS::Params> params =
std::optional<api::scripting::InsertCSS::Params> params =
api::scripting::InsertCSS::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
@@ -793,7 +793,7 @@ ExtensionFunction::ResponseAction ScriptingInsertCSSFunction::Run() {
void ScriptingInsertCSSFunction::DidLoadResources(
std::vector<InjectedFileSource> file_sources,
absl::optional<std::string> load_error) {
std::optional<std::string> load_error) {
if (load_error) {
Respond(Error(std::move(*load_error)));
return;
@@ -850,7 +850,7 @@ ScriptingRemoveCSSFunction::ScriptingRemoveCSSFunction() = default;
ScriptingRemoveCSSFunction::~ScriptingRemoveCSSFunction() = default;
ExtensionFunction::ResponseAction ScriptingRemoveCSSFunction::Run() {
absl::optional<api::scripting::RemoveCSS::Params> params =
std::optional<api::scripting::RemoveCSS::Params> params =
api::scripting::RemoveCSS::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
@@ -929,7 +929,7 @@ ScriptingRegisterContentScriptsFunction::
~ScriptingRegisterContentScriptsFunction() = default;
ExtensionFunction::ResponseAction ScriptingUpdateContentScriptsFunction::Run() {
absl::optional<api::scripting::UpdateContentScripts::Params> params =
std::optional<api::scripting::UpdateContentScripts::Params> params =
api::scripting::UpdateContentScripts::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
@@ -1087,7 +1087,7 @@ void ScriptingRegisterContentScriptsFunction::OnContentScriptFilesValidated(
}
void ScriptingRegisterContentScriptsFunction::OnContentScriptsRegistered(
const absl::optional<std::string>& error) {
const std::optional<std::string>& error) {
if (error.has_value())
Respond(Error(std::move(*error)));
else
@@ -1102,11 +1102,11 @@ ScriptingGetRegisteredContentScriptsFunction::
ExtensionFunction::ResponseAction
ScriptingGetRegisteredContentScriptsFunction::Run() {
absl::optional<api::scripting::GetRegisteredContentScripts::Params> params =
std::optional<api::scripting::GetRegisteredContentScripts::Params> params =
api::scripting::GetRegisteredContentScripts::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
const absl::optional<api::scripting::ContentScriptFilter>& filter =
const std::optional<api::scripting::ContentScriptFilter>& filter =
params->filter;
std::set<std::string> id_filter;
if (filter && filter->ids) {
@@ -1157,7 +1157,7 @@ ScriptingUnregisterContentScriptsFunction::Run() {
api::scripting::UnregisterContentScripts::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
absl::optional<api::scripting::ContentScriptFilter>& filter = params->filter;
std::optional<api::scripting::ContentScriptFilter>& filter = params->filter;
ExtensionUserScriptLoader* loader =
ExtensionSystem::Get(browser_context())
->user_script_manager()
@@ -1206,7 +1206,7 @@ ScriptingUnregisterContentScriptsFunction::Run() {
}
void ScriptingUnregisterContentScriptsFunction::OnContentScriptsUnregistered(
const absl::optional<std::string>& error) {
const std::optional<std::string>& error) {
if (error.has_value())
Respond(Error(std::move(*error)));
else
@@ -1220,7 +1220,7 @@ ScriptingUpdateContentScriptsFunction::
ExtensionFunction::ResponseAction
ScriptingRegisterContentScriptsFunction::Run() {
absl::optional<api::scripting::RegisterContentScripts::Params> params =
std::optional<api::scripting::RegisterContentScripts::Params> params =
api::scripting::RegisterContentScripts::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
@@ -1341,7 +1341,7 @@ void ScriptingUpdateContentScriptsFunction::OnContentScriptFilesValidated(
}
void ScriptingUpdateContentScriptsFunction::OnContentScriptsUpdated(
const absl::optional<std::string>& error) {
const std::optional<std::string>& error) {
if (error.has_value())
Respond(Error(std::move(*error)));
else

View File

@@ -6,6 +6,7 @@
#define ELECTRON_SHELL_BROWSER_EXTENSIONS_API_SCRIPTING_SCRIPTING_API_H_
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -16,7 +17,6 @@
#include "extensions/browser/script_executor.h"
#include "extensions/common/mojom/code_injection.mojom.h"
#include "extensions/common/user_script.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace extensions {
@@ -49,7 +49,7 @@ class ScriptingExecuteScriptFunction : public ExtensionFunction {
// Called when the resource files to be injected has been loaded.
void DidLoadResources(std::vector<InjectedFileSource> file_sources,
absl::optional<std::string> load_error);
std::optional<std::string> load_error);
// Triggers the execution of `sources` in the appropriate context.
// Returns true on success; on failure, populates `error`.
@@ -78,7 +78,7 @@ class ScriptingInsertCSSFunction : public ExtensionFunction {
// Called when the resource files to be injected has been loaded.
void DidLoadResources(std::vector<InjectedFileSource> file_sources,
absl::optional<std::string> load_error);
std::optional<std::string> load_error);
// Triggers the execution of `sources` in the appropriate context.
// Returns true on success; on failure, populates `error`.
@@ -132,7 +132,7 @@ class ScriptingRegisterContentScriptsFunction : public ExtensionFunction {
scripting::ValidateScriptsResult result);
// Called when content scripts have been registered.
void OnContentScriptsRegistered(const absl::optional<std::string>& error);
void OnContentScriptsRegistered(const std::optional<std::string>& error);
};
class ScriptingGetRegisteredContentScriptsFunction : public ExtensionFunction {
@@ -171,7 +171,7 @@ class ScriptingUnregisterContentScriptsFunction : public ExtensionFunction {
~ScriptingUnregisterContentScriptsFunction() override;
// Called when content scripts have been unregistered.
void OnContentScriptsUnregistered(const absl::optional<std::string>& error);
void OnContentScriptsUnregistered(const std::optional<std::string>& error);
};
class ScriptingUpdateContentScriptsFunction : public ExtensionFunction {
@@ -197,7 +197,7 @@ class ScriptingUpdateContentScriptsFunction : public ExtensionFunction {
scripting::ValidateScriptsResult result);
// Called when content scripts have been updated.
void OnContentScriptsUpdated(const absl::optional<std::string>& error);
void OnContentScriptsUpdated(const std::optional<std::string>& error);
};
} // namespace extensions

View File

@@ -71,7 +71,7 @@ void ZoomModeToZoomSettings(WebContentsZoomController::ZoomMode zoom_mode,
// Returns true if either |boolean| is disengaged, or if |boolean| and
// |value| are equal. This function is used to check if a tab's parameters match
// those of the browser.
bool MatchesBool(const absl::optional<bool>& boolean, bool value) {
bool MatchesBool(const std::optional<bool>& boolean, bool value) {
return !boolean || *boolean == value;
}
@@ -210,7 +210,7 @@ bool TabsExecuteScriptFunction::ShouldRemoveCSS() const {
}
ExtensionFunction::ResponseAction TabsReloadFunction::Run() {
absl::optional<tabs::Reload::Params> params =
std::optional<tabs::Reload::Params> params =
tabs::Reload::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
@@ -233,7 +233,7 @@ ExtensionFunction::ResponseAction TabsReloadFunction::Run() {
}
ExtensionFunction::ResponseAction TabsQueryFunction::Run() {
absl::optional<tabs::Query::Params> params =
std::optional<tabs::Query::Params> params =
tabs::Query::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
@@ -255,8 +255,8 @@ ExtensionFunction::ResponseAction TabsQueryFunction::Run() {
}
std::string title = params->query_info.title.value_or(std::string());
absl::optional<bool> audible = params->query_info.audible;
absl::optional<bool> muted = params->query_info.muted;
std::optional<bool> audible = params->query_info.audible;
std::optional<bool> muted = params->query_info.muted;
base::Value::List result;
@@ -321,7 +321,7 @@ ExtensionFunction::ResponseAction TabsQueryFunction::Run() {
}
ExtensionFunction::ResponseAction TabsGetFunction::Run() {
absl::optional<tabs::Get::Params> params = tabs::Get::Params::Create(args());
std::optional<tabs::Get::Params> params = tabs::Get::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
int tab_id = params->tab_id;
@@ -349,7 +349,7 @@ ExtensionFunction::ResponseAction TabsGetFunction::Run() {
}
ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() {
absl::optional<tabs::SetZoom::Params> params =
std::optional<tabs::SetZoom::Params> params =
tabs::SetZoom::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
@@ -377,7 +377,7 @@ ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() {
}
ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() {
absl::optional<tabs::GetZoomSettings::Params> params =
std::optional<tabs::GetZoomSettings::Params> params =
tabs::GetZoomSettings::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
@@ -393,7 +393,7 @@ ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() {
}
ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() {
absl::optional<tabs::GetZoomSettings::Params> params =
std::optional<tabs::GetZoomSettings::Params> params =
tabs::GetZoomSettings::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
@@ -417,7 +417,7 @@ ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() {
ExtensionFunction::ResponseAction TabsSetZoomSettingsFunction::Run() {
using tabs::ZoomSettings;
absl::optional<tabs::SetZoomSettings::Params> params =
std::optional<tabs::SetZoomSettings::Params> params =
tabs::SetZoomSettings::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
@@ -588,7 +588,7 @@ base::expected<GURL, std::string> PrepareURLForNavigation(
TabsUpdateFunction::TabsUpdateFunction() : web_contents_(nullptr) {}
ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
absl::optional<tabs::Update::Params> params =
std::optional<tabs::Update::Params> params =
tabs::Update::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);

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