Skip to content

Enforce secure nested-document lifecycle for Code OSS webviews #267

Description

@wieslawsoltes

Current nested-document lifecycle checkpoint — 20 September 2026

Exact merged heads: WebScene a46b62e14eb197603f7e227c1558afb9088633b0; AppScene 97702daeb9ad71341ced7226f0aa966dc77ea53c; unchanged Code OSS 645f29cc3176500b4b5762ba887cf2a7f0ffdf2c; local vscode-demo e4b98e5470cd7856aff3dfd6843c8e125d7db933 (clean, intentionally unpushed). Open consolidations remain WebScene #76 085bba760fa571c8f08ea866dc5dd1ec27c4d376, AppScene #65 ce66ef6ceb776b3f14e129f853bfc08b5c5e608c, and vscode-demo #1; do not merge them. One-agent mode is active.

Cancelable beforeunload, ordered unload teardown, bounded per-frame same/cross-document history and reload, restricted cross-origin WindowProxy, sandbox/navigation/document lifecycle and related resource foundations remain merged. No nested-lifecycle implementation worktree is active.

Joint top-level session history, POST reload and bfcache remain future infrastructure rather than a proven Code OSS blocker. The current owner stays open for cumulative unchanged Markdown/notebook/custom-editor/webview security, lifecycle, WPT, memory, performance and package acceptance.

Parent epic: #264. Top-level release epic: #227.

Proven gap

After service-worker readiness, unchanged browser/pre/index.html creates a nested iframe, sets a sandbox and Permissions Policy, navigates it to fake.html, reads contentWindow/contentDocument, then calls document.open(), write(), and close() with extension HTML. Updates replace the active frame. The prelude observes DOMContentLoaded/load/beforeunload, posts messages across the frame, uses ResizeObserver, preserves scroll, and removes stale frames.

WebScene's capability record at b81f594c explicitly limits iframe support to an initial same-origin document and leaves navigated src/srcdoc, history, sandboxing, origin transitions, cross-origin access control, complete load/error order, repeated-navigation teardown, and arbitrary iframe rendering outside the claim. No CSP enforcement implementation was found in the audited runtime. #253 owns the sandbox DOMTokenList and token semantics; this issue owns the resulting browsing-context, document, origin, CSP, Permissions Policy, navigation, and replacement behavior.

Dependencies and boundaries

Acceptance

  • Selected HTML iframe/navigation, WindowProxy, origin, CSP, sandbox, Permissions Policy, DOM parsing/writing, and lifecycle WPTs pass with checked-in Chromium results and explicit exclusions.
  • Native top-level + nested fixtures cover src, srcdoc, fake.html, base URL, initial about:blank, realm/constructor identity, contentWindow/contentDocument, parent/top/frameElement, same-origin access, opaque sandbox origins, cross-origin denial, postMessage target/origin, CSP nonces/sources, permissions, and links/download/navigation admission.
  • open/write/close, update replacement, reload, detach during load, error, beforeunload/pagehide, observer disconnect, and shutdown produce browser-order events and reject callbacks from stale generations.
  • 100 create/load/write/replace/reload/detach cycles leave zero old realms, WindowProxy targets, documents, observers, ports, fetches, and scene nodes. A 1 MiB HTML update reaches load and first stable scene at p95 <= 250 ms; retained growth after warm-up <= 8 MiB.
  • Markdown CSP blocks disallowed scripts/resources while permitting its nonce, styles, images, and local-resource origins; sandbox flags never silently broaden access.
  • The same contracts cover notebook output, custom editor, webview view/panel, release notes, chat/MCP, Mermaid, and Simple Browser documents.

Proposed PR stack

  1. navigation and WindowProxy/realm identity;
  2. document open/write/close and replacement lifecycle;
  3. origin/CSP/Permissions Policy enforcement;
  4. teardown/performance/WPT and unchanged webview acceptance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vscode-oss/plannedPlanned for the AppScene/WebScene VS Code OSS integration

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions