Skip to content

test: cover webContents editing commands, device emulation and menu roles - #55903

Merged
jkleinsc merged 5 commits into
mainfrom
claude/webcontents-edit-emulation-role-specs
Nov 18, 2026
Merged

jkleinsc merged 5 commits into
mainfrom
claude/webcontents-edit-emulation-role-specs

Conversation

@claude

@claude claude Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Requested by David Babenko-Sanders · Slack thread

Description of Change

These specs cover the webContents editing commands, device emulation, image animation policy and menu role actions that the C++ coverage report showed as unexercised. A new serial "editing commands" suite in api-web-contents.spec.ts drives a focused textarea and checks its value and selection after selectAll(), unselect(), delete(), undo()/redo(), cut(), copy(), paste() and replace() (both with a selection and with only a caret inside a word), checks that pasteAndMatchStyle() drops the bold markup that paste() keeps in a contenteditable, and checks that scrollToBottom() and scrollToTop() move a tall page to its end and back. A device emulation test checks that enableDeviceEmulation() with a mobile screen changes the screen size, devicePixelRatio and layout viewport the page sees and that disableDeviceEmulation() restores them, and two setImageAnimationPolicy() tests capture a looping red/green GIF to show it animates by default and stays on its first frame with 'noAnimation'. In api-menu-item.spec.ts, the "MenuItem role execution" suite now runs the undo, redo, cut, copy, paste, pasteAndMatchStyle, delete and selectAll roles against a textarea, and checks that the close role closes the window, togglefullscreen enters and leaves fullscreen, zoomIn/zoomOut/resetZoom change the zoom level and toggleSpellChecker flips the session's spellchecker setting; the edit and window roles are skipped on macOS, where they are handled natively. The minimize role is left out because minimizing does not work on Linux CI (the existing Windows-only test still covers it), and replaceMisspelling() because it could not be validated in this environment. centerSelection() is covered by the fix PR #55909, which makes it work on Windows and Linux and adds a cross-platform test for it. For DevTools, new tests check that toggleDevTools() opens closed DevTools and closes open ones, that isDevToolsFocused() is false while DevTools are closed, true once detached or docked DevTools take focus in a shown window and false again after they close (in a serial suite), and that inspectSharedWorker() and inspectServiceWorker() open DevTools for a shared worker and a service worker started from a page on a local HTTP server. Because DevTools specs time out under the spec runner in this container (an existing setDevToolsTitle() test does too), these were validated with a standalone Electron script that makes the same calls and assertions. The new specs were validated passing 3× in a row against 47.0.0-nightly.20261117, with no regressions in the rest of api-web-contents.spec.ts or api-menu-item.spec.ts.

Checklist

Release Notes

🤖 Generated with Claude Code

https://claude.ai/code/session_01KX1hkNiiBq2fQEsXWusxpm

Notes: none

@dsanders11 dsanders11 added the target/46-x-y PR should also be added to the "46-x-y" branch. label Nov 18, 2026
@dsanders11
dsanders11 marked this pull request as ready for review November 18, 2026 07:19

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment thread spec/api-web-contents.spec.ts Resolved
Comment thread spec/api-web-contents.spec.ts Resolved
Comment thread spec/api-web-contents.spec.ts Resolved
- Make sampleColor() report 'red' or 'green' only for a clearly red or
  green pixel, independent of BGRA/RGBA channel order, so an unpainted
  page no longer counts as a frame.
- Wait for the first frame before sampling the noAnimation case, and
  fail it only if the green frame is ever painted.
- Run setImageAnimationPolicy() serially since it captures the screen.
- Give the toggleDevTools() and worker inspection tests a fresh persisted
  partition each, so they never inherit an undocked dock state from the
  default session's Preferences and always dock into the hidden window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KX1hkNiiBq2fQEsXWusxpm

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I reviewed this from a standalone clone, and commit 7b9594c fixes all three issues from my earlier review. I found nothing new.

  • setImageAnimationPolicy() is now in a { tags: ['serial'] } suite. sampleColor now counts a pixel as 'red' or 'green' only when the other channels are low, so unpainted white comes back as 'other'. The 'noAnimation' test also waits for the red frame before it starts sampling.
  • toggleDevTools() tests now use a fresh persist:<name>-<uuid> partition, so they start without an inherited undocked state. Every other new test that needs focus, the clipboard or capturePage is in a serial suite.
  • I did not run the specs. Whether the new DevTools and pixel-sampling tests are reliable on every platform will only show in CI.
Extended reasoning...

The change only adds tests: about 546 lines across spec/api-web-contents.spec.ts and spec/api-menu-item.spec.ts, with no production code or security-sensitive code. The latest commit addresses the three inline comments from my earlier review: the serial tag on the image animation suite, stricter color classification, and persisted per-test DevTools partitions. No CODEOWNERS entry covers spec/, and the bug hunt finished with no findings.

@jkleinsc
jkleinsc merged commit 34f7c90 into main Nov 18, 2026
74 checks passed
@jkleinsc
jkleinsc deleted the claude/webcontents-edit-emulation-role-specs branch November 18, 2026 18:15
@release-clerk

release-clerk Bot commented Nov 18, 2026

Copy link
Copy Markdown

No Release Notes

@trop

trop Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "46-x-y", please check out #55925

@trop trop Bot added in-flight/46-x-y merged/46-x-y PR was merged to the "46-x-y" branch. and removed target/46-x-y PR should also be added to the "46-x-y" branch. in-flight/46-x-y labels Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

47-x-y merged/46-x-y PR was merged to the "46-x-y" branch. semver/none

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants