Skip to content

Register test iframes with their own window IDs - #347731

Merged
Bryan Chen (bryanchen-d) merged 1 commit into
mainfrom
copilot/vscode/register-test-iframes
Nov 12, 2026
Merged

Bryan Chen (bryanchen-d) merged 1 commit into
mainfrom
copilot/vscode/register-test-iframes

Conversation

@bryanchen-d

Copy link
Copy Markdown
Collaborator

Test-only alternative to #347523 for the stale animation frame problem.

Mechanism

scheduleAtNextAnimationFrame in dom.ts keeps its queue and its "frame requested" flag per window ID. Iframes that tests create are never registered, so their windows have no vscodeWindowId and all of them share the same undefined slot. When a test removes its iframe while a frame is still pending for it, that frame never runs, the flag for the shared slot stays set, and every later test iframe in the same renderer stops getting animation frames.

Main CI runs the whole unit suite in one renderer, so this shows up there and in product builds depending on test order, for example the auxiliary-window clipping assertions in WorkbenchSizeService and OverlayWebview (the WebKit failures in build 495183). PR CI only runs affected tests, so it rarely sees it.

Change

  • New registerTestIframe(iframe) helper in src/vs/base/test/browser/testWindow.ts. It gives the iframe window a unique ID with ensureCodeWindow and registers it with registerWindow, which is what the auxiliary window service does for real windows. Disposing the registration fires onDidUnregisterWindow, which clears that window's animation frame state.
  • 24 test files that create iframes now register them right after attaching them and dispose the registration with the test.
  • Not changed: chatMarkdownContentPart.test.ts and chatListRenderer.test.ts. Their srcdoc iframes navigate after creation, which replaces the window object, so a registration would not stick.

This doesn't cover the other way the flag gets stuck, a test faking requestAnimationFrame with sinon (build 495093). #347524 fixed that test, and #347523 fixes both cases in dom.ts.

Validation

  • Local Electron unit run of the 24 files together: on main, 595 passing and 2 failing (OverlayWebview "auxiliary webview clipping refreshes after cloned theme styles propagate" and WorkbenchSizeService "cloned auxiliary-window styles receive initial sizes and live updates"). With this change, 597 passing and 0 failing.
  • tsc --noEmit on src reports no errors in the touched files. eslint is clean.

Authored with Copilot

Copilot AI balanced review requested due to automatic review settings November 11, 2026 21:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the test-only iframe state-isolation change.

No open issues 🎉

What changed in this PR

This test-only change isolates iframe animation-frame state so removing an iframe with a pending frame cannot stall later tests in the same renderer. Production scheduling behavior is unchanged.

Changes:

  • Adds registerTestIframe to assign unique window IDs and register iframe windows.
  • Updates 24 test files to register attached iframes and dispose their registrations during cleanup.
  • Leaves navigating srcdoc iframes and fake-clock animation-frame handling outside this change.
File Description
src/​vs/​workbench/​services/​themes/​test/​browser/​workbenchSizeService.test.ts Registers the auxiliary sizing iframe.
src/​vs/​workbench/​services/​contextmenu/​test/​electron-browser/​contextmenuService.test.ts Registers the native context-menu test iframe.
src/​vs/​workbench/​contrib/​webview/​test/​browser/​overlayWebview.test.ts Registers the auxiliary clipping iframe.
src/​vs/​workbench/​contrib/​terminal/​test/​browser/​xterm/​xtermTerminal.test.ts Registers three terminal test iframes.
src/​vs/​workbench/​contrib/​issue/​test/​electron-browser/​issueReporterMediaImport.test.ts Registers the media-import reparenting iframe.
src/​vs/​workbench/​contrib/​issue/​test/​browser/​issueReporterOverlay.test.ts Registers the overlay reparenting iframe.
src/​vs/​workbench/​contrib/​issue/​test/​browser/​issueFormService.test.ts Registers the issue-form auxiliary iframe.
src/​vs/​workbench/​contrib/​issue/​test/​browser/​baseIssueReporterService.test.ts Registers the reporter test iframe.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​widget/​input/​chatInputNoticeWidget.test.ts Registers the input-notice test iframe.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​widget/​chatWindowBlurListener.test.ts Registers the secondary-window test iframe.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​widget/​chatPetWidgetService.test.ts Registers the chat-pet test iframe.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​widget/​chatEditorOverflowWidgetsHost.test.ts Registers the overflow-host test iframe.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​widget/​chatContentParts/​chatMcpAppModel.test.ts Registers the MCP app test iframe.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​widget/​chatContentParts/​chatActivityLabelTransition.test.ts Registers the label-animation test iframe.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​widget/​chatClipboard.test.ts Registers the clipboard test iframe.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​voiceClient/​voiceGlow.test.ts Registers the voice-glow test iframe.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​dictationDownloadRing.test.ts Registers the download-ring test iframe.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​chatImageActions.test.ts Registers the image-copy test iframe.
src/​vs/​sessions/​contrib/​terminal/​test/​browser/​chatWindowTerminalActions.test.ts Registers the terminal-action test iframe.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​responseSelectionSideChatController.test.ts Registers the response-selection test iframe.
src/​vs/​sessions/​contrib/​aquarium/​test/​browser/​aquariumOverlay.test.ts Registers the aquarium test iframe.
src/​vs/​editor/​test/​browser/​controller/​nativeEditContextUtils.test.ts Registers the focus-tracker test iframe.
src/​vs/​editor/​contrib/​suggest/​test/​browser/​suggestWidget.test.ts Registers the suggestion-widget test iframe.
src/​vs/​base/​test/​browser/​ui/​contextview/​contextview.test.ts Registers two context-view test iframes with cleanup.
src/​vs/​base/​test/​browser/​testWindow.ts Adds the shared disposable iframe-registration helper.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the test iframe registration changes.

No open issues 🎉

Review effort: Balanced

Tests that create iframes and use their contentWindow leave vscodeWindowId undefined, so every such
window shares one slot in per-window state such as the dom.ts animation frame queue. If one test removes
an iframe while a frame is pending for it, later unregistered iframes in the same renderer never get their
scheduled frames, which made the auxiliary-window clipping tests fail depending on test order.

Add registerTestIframe, which gives the iframe window a unique ID and registers it like the auxiliary
window service does, and use it in the tests that create iframes.

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the test-only iframe isolation change.

No open issues 🎉

Review effort: Balanced

@bryanchen-d
Bryan Chen (bryanchen-d) marked this pull request as ready for review November 11, 2026 23:55
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Anthony Kim (@anthonykim1)

Matched files:

  • src/vs/workbench/contrib/terminal/test/browser/xterm/xtermTerminal.test.ts

@bryanchen-d
Bryan Chen (bryanchen-d) merged commit 99206a4 into main Nov 12, 2026
53 of 54 checks passed
@bryanchen-d
Bryan Chen (bryanchen-d) deleted the copilot/vscode/register-test-iframes branch November 12, 2026 00:03
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants