Commit Graph

30392 Commits

Author SHA1 Message Date
Samuel Attard
f6e164dadf chore: migrate api-ipc-main-spec.ts to vitest 2026-04-13 00:59:00 -07:00
Samuel Attard
68883ece6f chore: migrate api-in-app-purchase-spec.ts to vitest 2026-04-13 00:59:00 -07:00
Samuel Attard
c9625bea13 chore: migrate api-image-view-spec.ts to vitest 2026-04-13 00:59:00 -07:00
Samuel Attard
c28e50d10f chore: migrate api-global-shortcut-spec.ts to vitest 2026-04-13 00:59:00 -07:00
Samuel Attard
f945aa5e39 chore: migrate api-dialog-spec.ts to vitest 2026-04-13 00:58:59 -07:00
Samuel Attard
046631a8fe chore: migrate api-desktop-capturer-spec.ts to vitest 2026-04-13 00:58:59 -07:00
Samuel Attard
f124d7f261 chore: migrate api-debugger-spec.ts to vitest 2026-04-13 00:58:59 -07:00
Samuel Attard
5d6ebd6e4a chore: migrate api-crash-reporter-spec.ts to vitest 2026-04-13 00:58:59 -07:00
Samuel Attard
827ad50c53 chore: migrate api-corner-smoothing-spec.ts to vitest 2026-04-13 00:58:58 -07:00
Samuel Attard
c46433d1cd chore: migrate api-context-bridge-spec.ts to vitest 2026-04-13 00:58:58 -07:00
Samuel Attard
515adf3399 chore: migrate api-content-tracing-spec.ts to vitest 2026-04-13 00:58:58 -07:00
Samuel Attard
8d7d778ab7 chore: migrate api-clipboard-spec.ts to vitest 2026-04-13 00:58:57 -07:00
Samuel Attard
93d9fe675d chore: migrate api-browser-window-spec.ts to vitest 2026-04-13 00:58:57 -07:00
Samuel Attard
d64680ff0d chore: migrate api-browser-view-spec.ts to vitest 2026-04-13 00:58:57 -07:00
Samuel Attard
689d8ddc11 chore: migrate api-autoupdater-msix-spec.ts to vitest 2026-04-13 00:58:56 -07:00
Samuel Attard
22b79ba2f9 chore: migrate api-autoupdater-darwin-spec.ts to vitest 2026-04-13 00:58:56 -07:00
Samuel Attard
02541f8606 chore: migrate api-auto-updater-spec.ts to vitest 2026-04-13 00:58:56 -07:00
Samuel Attard
034ac4fc04 chore: migrate api-app-spec.ts to vitest 2026-04-13 00:58:56 -07:00
Samuel Attard
d8fe4fd091 chore: prepare spec helpers and vitest setup for migration 2026-04-13 00:58:55 -07:00
Samuel Attard
7a446b0f84 build: add vitest runner infrastructure for Electron main-process tests
Adds spec/_vitest_runner/, a custom vitest pool that spawns each worker
as a full Electron main process (not a node-mode fork) so tests can use
real Electron APIs. Each worker gets a pool-owned mkdtemp userData dir
that is cleaned up on worker stop. File-level parallelism is enabled;
intra-file concurrency stays off to match current mocha behaviour.

Run with: yarn test:vitest
2026-04-13 00:58:55 -07:00
Kunal Dubey
04d9de6f73 fix: avoid window drag during corner resize in MAS build (#50637)
* fix: avoid window drag during corner resize in MAS build

* chore: update chromium patch offsets
2026-04-13 09:54:27 +02:00
Charles Kerr
b8dbe21b38 chore: do not patch fake_desktop_media_list.cc (#50953)
chore: do not patch files we do not use

do not patch fake_desktop_media_list.cc, .h
v43.0.0-nightly.20260413
2026-04-13 09:27:32 +02:00
Samuel Attard
a57dbb55cc ci: split macos-x64 tests into 3 shards (#50968) 2026-04-13 09:26:19 +02:00
David Sanders
860a544534 ci: capture fatal errors in clang problem matcher (#50984) 2026-04-13 09:25:43 +02:00
David Sanders
e31cd64fe5 ci: ignore canceled jobs in audit (#50981)
* ci: ignore canceled jobs in audit

* chore: add another variation
2026-04-13 09:25:26 +02:00
Samuel Attard
10eb512d1d test: run oxfmt on simpleFullScreen test (#50990)
chore: fix oxfmt formatting in api-browser-window-spec

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-12 19:58:02 -07:00
Calvin
052efc9727 chore: add AI tool policy to CONTRIBUTING.md & update PR template (#50451)
* chore: update PR template and add AI tool policy to CONTRIBUTING.md

* sentencesmithing
2026-04-12 19:10:42 -05:00
Shelley Vohr
a007bafaf1 fix: simpleFullScreen exits when web content calls requestFullscreen (#50874)
fix: simpleFullScreen exits when web content calls requestFullscreen

SetHtmlApiFullscreen only checked IsFullscreen() to detect that the
window was already fullscreen, missing the simple-fullscreen case on
macOS. When web content triggered requestFullscreen the code fell
through to SetFullScreen(true) which toggled simple fullscreen off.

Include IsSimpleFullScreen() in the guard so the HTML-API fullscreen
state is updated without touching the window's fullscreen mode.
2026-04-12 19:06:07 -05:00
Robo
ea757689b3 refactor: rm chore_add_electron_objects_to_wrappablepointertag.patch (#50957) 2026-04-12 19:02:40 -05:00
Samuel Attard
2c94aac330 build: add oxfmt for JS/TS formatting and import sorting (#50692)
* build: add oxfmt for code formatting and import sorting

Adds oxfmt as a devDependency alongside oxlint and wires it into the
lint pipeline. The .oxfmtrc.json config matches Electron's current JS
style (single quotes, semicolons, 2-space indent, trailing commas off,
printWidth 100) and configures sortImports with custom groups that
mirror the import/order pathGroups previously enforced by ESLint:
@electron/internal, @electron/*, and {electron,electron/**} each get
their own ordered group ahead of external modules.

- `yarn lint:fmt` runs `oxfmt --check` over JS/TS sources and is
  chained into `yarn lint` so CI enforces it automatically.
- `yarn format` runs `oxfmt --write` for local fix-up.
- lint-staged invokes `oxfmt --write` on staged .js/.ts/.mjs/.cjs
  files before oxlint, so formatting is applied at commit time.

The next commit applies the formatter to the existing codebase so the
check actually passes.

* chore: apply oxfmt formatting to JS and TS sources

Runs `yarn format` across lib/, spec/, script/, build/, default_app/,
and npm/ to bring the codebase in line with the .oxfmtrc.json settings
added in the previous commit. This is a pure formatting pass: import
statements are sorted into the groups defined by the config, method
chains longer than printWidth are broken, single-quoted strings
containing apostrophes are switched to double quotes, and a handful of
single-statement `if` bodies are re-wrapped and get braces added by
`oxlint --fix` to satisfy the `curly: multi-line` rule.

No behavior changes.
2026-04-12 02:03:04 -07:00
Shelley Vohr
dcb844c201 chore: add Claude Code skill for Node.js upgrades (#50910)
Adds a new skill mirroring the Chromium upgrade skill, adapted for
Node.js rolls. Covers patch conflict resolution, build fix workflow,
commit guidelines, and documents high-churn patches and major version
upgrade patterns (V8 bridge patch deletions, BoringSSL complexity).
2026-04-11 20:11:49 -07:00
Charles Kerr
9bc55a255c chore: remove some unnecessary diffs in refactor_expose_file_system_access_blocklist.patch (#50909)
chore: remove some unnecessary diffs in refactor_expose_file_system_access_blocklist.patch
2026-04-11 16:48:47 -05:00
Samuel Attard
12b74eac26 fix: respect iframe sandbox flags for external protocol navigation (#50901) 2026-04-11 16:16:23 -04:00
Charles Kerr
6e7938af1d refactor: migrate api::Extensions to cppgc (#50932)
* refactor: migrate api::Extensions to cppgc

* chore: update patch indices
2026-04-12 01:59:54 +09:00
Charles Kerr
5fded05add fix: dangling raw_ptr api::Protocol::protocol_registry_ (#50829) 2026-04-11 08:53:53 -05:00
Charles Kerr
1879998865 refactor: migrate api::ServiceWorkerContext to cppgc (#50931)
refactor: migrate api::ServiceWorkerContext to cppgc
2026-04-11 18:56:31 +09:00
Samuel Attard
b1b02d9123 fix: restrict window.open features to allowlisted BrowserWindow options (#50902) 2026-04-11 03:43:55 -04:00
Samuel Attard
3f140e1b4b fix: clamp autofill popup bounds to the requesting frame viewport (#50903) 2026-04-11 03:43:43 -04:00
Samuel Attard
3ff923990d fix: validate OSR frame geometry against shared-memory mapping size (#50904) 2026-04-11 03:43:24 -04:00
Samuel Attard
b4e14a9004 fix: use ShowItemInFolder for devtools showItemInFolder embedder message (#50905) 2026-04-11 03:43:14 -04:00
Samuel Attard
61bb03ca75 fix: use audit token instead of PID for parent code-signature check (#50907) 2026-04-11 03:42:52 -04:00
Samuel Attard
1a2029c3a2 fix: apply IsSafeRedirectTarget to net module redirects (#50869) 2026-04-10 19:19:51 -07:00
Samuel Attard
bfa5c93332 refactor: attach translator holder via v8::Function data slot (#50867) 2026-04-10 19:19:34 -07:00
Samuel Attard
f36def6601 fix: scope extension tab-ID resolution to the calling BrowserContext (#50906) 2026-04-10 19:16:21 -07:00
David Sanders
97347c4223 chore: clean up clang-tidy warnings (#50862)
* chore: use emplace and use it correctly

* chore: redundant cast to the same type [google-readability-casting]

* chore: do not create objects with +new [google-objc-avoid-nsobject-new]

* chore: default arguments on virtual or override methods are prohibited [google-default-arguments]

* chore: warning: C-style casts are discouraged; use static_cast [google-readability-casting]

CFLocaleGetValue already returns CFTypeRef so that redundant static_cast was removed

* chore: refactor block to avoid use after move warning from clang-tidy

Looks like clang-tidy couldn't tell these were two mutually exclusive
branches so there was no actual issue, but refactoring is cleaner
anyway since it makes it more DRY.

* chore: C-style casts are discouraged; use static_cast [google-readability-casting]

No cast needed here, everything is already the correct type

* chore: C-style casts are discouraged; use static_cast/const_cast/reinterpret_cast [google-readability-casting]

* chore: use '= default' to define a trivial destructor [modernize-use-equals-default]

* chore: use range-based for loop instead [modernize-loop-convert]

* chore: redundant void argument list [modernize-redundant-void-arg]

* chore: address code review feedback

* chore: use auto

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

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2026-04-10 16:37:57 -07:00
Alexey
8d8847d478 feat: capture JS stack trace on renderer OOM (#50043)
* feat: capture JS stack trace on renderer OOM

When a renderer process approaches its V8 heap limit, capture the
JavaScript stack trace and write it to both a Crashpad crash key
("js-oom-stack") and stderr.

The stack trace is captured via RequestInterrupt rather than directly
inside the NearHeapLimitCallback because CurrentStackTrace is unsafe
to call during OOM — V8 FATALs on optimized (TurboFan) frames that
have had their deoptimization data garbage-collected. RequestInterrupt
defers the capture to the next V8 safe point, where all frames are
guaranteed to have deopt data available. This matches Node.js's
approach of never capturing JS stacks inside the heap limit callback.

The callback is registered once per isolate via an atomic guard in
RendererClientBase::DidCreateScriptContext, preventing the CHECK
failure V8 raises on duplicate AddNearHeapLimitCallback registrations
(which would otherwise occur on page navigations or multiple contexts).

Refs: #46078
Made-with: Cursor

* Update shell/renderer/oom_stack_trace.cc

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* Update shell/renderer/oom_stack_trace.cc

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* test: add crash reporter test for OOM JS stack trace

Add a test that verifies the `electron.v8-oom.stack` crash key contains
the JS stack trace (including function names) when a renderer process
runs out of memory. Also deduplicate the heap info formatting in
oom_stack_trace.cc.

Refs: #46078
Made-with: Cursor

* fix: lint formatting in oom_stack_trace.cc

Made-with: Cursor

* fix: use proper logger API instead of cstdio

* fix: check heap headroom before capturing OOM stack trace

deepak1556: "Should there be check for available heap size [for]
CurrentStackTrace and formatting"

CurrentStackTrace allocates StackTraceInfo + StackFrameInfo on the V8
heap. If the 20 MB bump is partially consumed by the time the interrupt
fires, these allocations trigger a secondary OOM. Guard with a 2 MB
headroom check.

Made-with: Cursor

* fix: handle V8 cage limit when bumping heap for OOM stack capture

deepak1556: "Does this bumping work when we are at the cage limit of
4GB"

V8's pointer compression cage caps the heap at ~4 GB. When
current_heap_limit is already near the ceiling, our 20 MB bump gets
clamped to zero and the interrupt never fires. Detect this and record
heap info as the final crash key instead of waiting for a stack trace
that won't arrive.

Made-with: Cursor

* feat: add V8 heap statistics as OOM crash keys

deepak1556: "V8 seems to capture heap stats as crash keys but it gets
missed today due to the OOM callback override... wonder if we can
include that to get some more heuristics in the dump."

Record heap used/total/limit/available, per-space stats for old_space
and large_object_space, native/detached context counts, and utilization
percentage as crash keys. Also add heap stats in the V8OOMErrorCallback
in node_bindings.cc for the final OOM crash report.

Made-with: Cursor

* feat: support worker thread isolates for OOM stack trace

deepak1556: "You need a separate registration for worker threads via
WorkerScriptReadyForEvaluationOnWorkerThread but that also means the
process global g_registered_isolate would break."

Chromium has one V8 isolate per thread (main + one per web worker), so
thread_local is equivalent to per-isolate storage. Replace the global
atomic + mutex/set with a constinit thread_local OomState* that holds
the isolate pointer and per-isolate is_in_oom flag. The void* data
parameter on AddNearHeapLimitCallback delivers OomState* directly into
callbacks, so the hot path needs no TLS lookup.

Add WorkerScriptReadyForEvaluationOnWorkerThread and
WillDestroyWorkerContextOnWorkerThread overrides to RendererClientBase
so both ElectronRendererClient and ElectronSandboxedRendererClient get
worker OOM registration. Update ElectronRendererClient to call the base
class in both worker lifecycle methods.

Add a web worker OOM test that spawns a dedicated Worker with a memory
leak and verifies the stack trace captures the worker function name.

Made-with: Cursor

* fix: register OOM callback for all script contexts

When context isolation is enabled, ShouldNotifyClient skips
DidCreateScriptContext for the main world, but user JS still runs there
and can OOM. Register in DidInstallConditionalFeatures which fires for
every script context. The TLS dedup guard prevents double-registration
on the same isolate.

Made-with: Cursor

* fix: guard against division by zero and cage size changes in OOM handler

Add a zero-guard on heap_size_limit before computing utilization
percentage — maximizes robustness in an OOM code path.

Add static_assert on kPtrComprCageReservationSize to catch any
upstream V8 change to the cage size at compile time.

Made-with: Cursor

* fix: address review feedback on OOM stack trace PR

- Remove redundant RegisterOomStackTraceCallback from
  electron_render_frame_observer.cc; DidCreateScriptContext is sufficient
  since main world and isolated world share the same isolate
- Replace thread_local OomState* with base::ThreadLocalOwnedPointer
  wrapped in base::NoDestructor per Chromium style for non-trivially
  destructible types
- Change heap-headroom and cage-limit logs from ERROR to INFO since
  users cannot act on these diagnostics
- Add comment explaining why base class is called last in
  WillDestroyWorkerContextOnWorkerThread (OOM deregistration ordering)

Made-with: Cursor

* fix: skip OOM stack trace registration for worklet contexts

Worklets can share a thread and isolate via WorkletThreadHolder's
per-process singleton pattern. With per-thread OOM state, the first
worklet to be destroyed would prematurely remove the callback for
any remaining worklets on the same thread. Skip worklets entirely
to avoid this; can be revisited with ref-counting if needed.

Made-with: Cursor

* fix: prevent dangling raw_ptr<v8::Isolate> in OOM state

The OomState held a raw_ptr<v8::Isolate> that outlived the isolate on
the main thread: gin::IsolateHolder destroyed the isolate during
shutdown, but the OomState (stored in thread-local storage) was only
released later in JavascriptEnvironment::~JavascriptEnvironment. This
triggers a dangling pointer check when building with
enable_dangling_raw_ptr_checks.

Register OomState as a gin::PerIsolateData::DisposeObserver so it
clears the raw_ptr and removes the NearHeapLimitCallback before the
isolate is destroyed, regardless of destructor ordering.

Suggested-by: Deepak Mohan
Made-with: Cursor

* test: verify OOM crash keys end-to-end via crash reporter

Replace stderr-based OOM tests with end-to-end crash dump validation.
Instead of parsing log output, start a crash reporter server, trigger
renderer OOM, and verify the uploaded crash dump contains the expected
`electron.v8-oom.*` annotations — the same code path production crash
reports take.

Consolidate all OOM test scenarios (basic heap leak, JSON.stringify,
web worker) into a single `describe('OOM crash keys')` block inside
api-crash-reporter-spec using the existing crash fixture app with new
renderer-oom-json and renderer-oom-worker crash types.

The web worker test verifies that OOM crash keys are present but does
not assert on the JS function name: the 20 MB heap bump may be
exhausted before V8 reaches a safe point to fire the stack-capture
interrupt, leaving the crash key at "(stack pending)". Increasing the
bump or switching to a synchronous capture strategy would fix this but
is left for a follow-up.

Remove the standalone oom-stack-trace-spec.ts and its fixture app.

Made-with: Cursor

---------

Co-authored-by: Niklas Wenzel <dev@nikwen.de>
2026-04-10 15:13:16 -04:00
Niklas Wenzel
b9825ba835 fix: preference initialization with app.setPath('sessionData') (#50891)
fix: preference initialization with app.setPath('sessionData')
2026-04-11 03:22:09 +09:00
Robo
9be03cbe54 fix: enable blink gc plugin (#50465)
chore: address blink gc plugin errors

Key fixes:
- Replace `base::WeakPtrFactory` with `gin::WeakCellFactory` in
  MenuMac, MenuViews, and NetLog, since weak pointers to cppgc-managed
  objects must go through weak cells
- Replace `v8::Global<v8::Value>` with `cppgc::Persistent<Menu>` for
  the menu reference in BaseWindow
- Stop using `gin_helper::Handle<T>` with cppgc types; use raw `T*`
  and add a `static_assert` to prevent future misuse
- Add proper `Trace()` overrides for Menu, MenuMac, MenuViews, and
  NetLog to ensure cppgc members are visited during garbage collection
- Replace `SelfKeepAlive` prevent-GC mechanism in Menu with a
  `cppgc::Persistent` prevent-GC captured in `BindSelfToClosure`
- Introduce `GC_PLUGIN_IGNORE` macro to suppress
  known-safe violations: mojo::Remote fields, ObjC bridging pointers,
  and intentional persistent self-references
- Mark `ArgumentHolder` as `CPPGC_STACK_ALLOCATED()` in both Electron's
  and gin's function_template.h to silence raw-pointer-to-GC-type
  warnings
2026-04-11 03:21:39 +09:00
Michaela Laurencin
861ef95598 fix: remove decorateURL from default_app (#50852)
remove decorateURL from default_app

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2026-04-10 13:18:26 -05:00
Jan Hannemann
20ed34a2fd feat: add id, groupId, and groupTitle support for Windows notifications (#50328)
* feat: allow to set id and groupId

* feat: use Id's without hash but check length

* feat: adds visual grouping via groupTitle

* test: tests added for id, groupId and groupTitle

* fix: unused vars on Mac and Linux

* fix: remove redundant parameter

* fix: add doc links for id and group

* fix: throw if groupId is missing

* fix: test
2026-04-10 11:01:57 -07:00