#55764: test: deflake DevTools and lifecycle waits in cpp-heap and menu-item specs
Merged
Description of Change
Deflakes two specs that timed out on 46-x-y CI waiting for DevTools lifecycle events:
cpp-heap.spec.ts› "releases the remote DevTools root when DevTools closes" (run 43141951423) aborted on a fixed 10sAbortSignal.timeoutwhile the same test took 5.8s on the previous run of the same runner.api-menu-item.spec.ts› "reloads the parent webContents when called on DevTools webContents" (run 43118476945) hit the 30s test timeout on all four attempts, with no indication of which wait stalled.
spec/cpp-heap.spec.ts
Applies the approach from #55672 to the rest of the file: every remaining fixed AbortSignal.timeout (10s and 20s) is removed so the runner owns the timeout, including its longer budget on sanitizer builds. Each wait now logs to stderr before and after, which the remote control app forwards even when the remote call never returns, so a stall names the pending event instead of surfacing as a bare AbortError. Affected tests:
- releases the remote DevTools root when DevTools closes
- does not retain contexts through cached templates after reload
- caches function templates per isolate on the main thread and skips the cache in workers
- destroys callback holders on worker gc/exit/terminate
- defers guest destruction and emits destroyed only once
- disposes frame wrappers when an attached guest wrapper is destroyed
- disposes frame wrappers when a background page wrapper is destroyed
- retains WebContents through their WebContentsView until native destruction
- invalidates native methods while a destroyed JS wrapper remains reachable
spec/api-menu-item.spec.ts
- Both reload-role helpers register
did-finish-loadbefore triggering the reload instead of afterdid-start-loadingresolves. - The DevTools webContents variant opens DevTools with
{ mode: 'detach', activate: false }. It previously used plainopenDevTools(), which docks according to whichever mode an earlier test left behind, into a hidden window with an unsized view, and takes focus. The reload role routes to the inspected page viaDevToolsOwnerOr()regardless of dock state, so coverage is unchanged. - It asserts
devToolsWebContentsis non-null before use, and reports viaonTestFailedwhich step it was waiting on if the test fails.
Checklist
- PR description included
- tests are changed or added
-
npm run lint:jsandoxfmt --checkpass on the changed specs
Release Notes
Notes: none
🤖 Generated with Claude Code
Backports
Semver Impact
Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron