Skip to content

Enforce owner-backed stylesheet replacement rejection semantics #366

Closed

Description

@wieslawsoltes

Parent: #239
CSS epic: #235

Proven gap

After #330, #359, and #362, WebScene's owner-backed stylesheet objects support live rule reflection and mutation but do not expose replaceSync() or replace(). A browser-compatible implementation cannot use these APIs to mutate a <style> or linked sheet: CSSOM permits replacement only for constructed stylesheets.

The focused WPT CSSStyleSheet-constructable-replace-on-regular-sheet.html and a direct Chrome 153 control establish the required behavior for owner-backed sheets:

  • replaceSync(cssText) synchronously throws NotAllowedError;
  • replace(cssText) returns a realm-local Promise rejected with NotAllowedError;
  • missing required arguments and Symbol conversion follow Web IDL (replaceSync throws TypeError; replace rejects with TypeError);
  • neither operation changes the existing rules, computed style, rule identity, owner DOM text, or invalidation/publication state;
  • the same rejection applies after the owner is detached and the retained sheet no longer has an associated document.

Focused scope

  • Add exact constructed-only replacement guards to existing owner-backed stylesheet wrappers.
  • Preserve live top-level/nested rules, owner detach/reattach behavior, main/iframe realm isolation, and all existing staged-publication bounds.
  • Prove denied replacement performs no stylesheet publication or style/layout invalidation.
  • Keep constructed stylesheet creation, successful replacement, adoptedStyleSheets, imported child sheets, stylesheet metadata/branding, namespaces, and other CSSOM reflection outside this slice.

Missing primitive and ownership boundary

Successful replace / replaceSync remains blocked on a native owner-independent stylesheet identity plus per-document and shadow-root adoption registries. Current native wrappers and __webSceneStageRules publication are keyed to connected <style> / <link> owner nodes. Treating an owner-backed wrapper as constructed would incorrectly allow mutation of a regular sheet and could not model multi-root adoption or teardown. This child therefore implements only the exact regular-sheet rejection semantics and does not expose a misleading constructed-sheet constructor.

Ownership and non-overlap

Planned paths:

  • experiments/WebScene.NativeEngine.Probe/native/webscene_stylesheet_cssom_compatibility.h;
  • experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_browser_dom_tests.inc;
  • new tests/WebPlatformSubset/contracts/cssom-owner-stylesheet-replacement.html;
  • new dedicated WebPlatformSubset profile.

These paths are disjoint from open docs PR #76, #248 File System Access directories, #266 resource work, AppScene, and vscode-demo.

Acceptance

  • Chromium/native contract matches synchronous replaceSync throws, asynchronous replace rejections, Web IDL argument conversion, realm-local Promise/error objects, detached-owner behavior, and unchanged rule/style state.
  • Denied replacement preserves sheet/rule/list identity and owner text without stylesheet publication, style invalidation, layout, or scene work.
  • A 64-rule, 20-cycle denied-replacement workload stays within the focused timing budget with zero replacement-triggered invalidation/publication.
  • A 100-cycle main/iframe create, reject, detach, and navigation gate retains <= 8 MiB V8 heap and <= 64 MiB RSS after warm-up and drains native CSS rules/pending replacements.

Activity

  1. added
    vscode-oss/planned
    on Sep 18, 2026
  2. wieslawsoltes commented on Sep 18, 2026

    @wieslawsoltes
    CollaboratorAuthor

    Implementation is open as PR #369 at exact base d521dd05f217eb1a43604b357346197d60b5b294, head bce745d100f4e4b950cc20b12fcd3b0a1bfc5106.

    The focused four-path change adds exact constructed-only guards for existing owner-backed sheets: replaceSync throws synchronously, replace returns a rejected Promise, missing/Symbol arguments follow Web IDL, and attached/detached main/iframe rules remain unchanged. It does not expose a constructed-sheet constructor or claim adoption support.

    Current evidence:

    • Chrome 153 direct contract: 6/6;
    • native WebPlatformSubset contract: 6/6;
    • direct native correctness filter: pass;
    • 64-rule / 20-cycle denial p95/max: 0.023/0.295 ms, with exact zero layout, publication, scene-build, native-rule, and pending-scene deltas;
    • 100-cycle main/iframe lifecycle: 200 async rejections, flat V8 heap, RSS +17.74 MiB, drained native rules/wrappers.

    The branch was rebased after #367; its four paths remain disjoint from #248, #266, open docs PR #76, AppScene, and vscode-demo.

  3. wieslawsoltes commented on Sep 18, 2026

    @wieslawsoltes
    CollaboratorAuthor

    PR #369 is rebased after disjoint #368 at exact base 83b2c4e8b3c1cc71e4f4a8f67b8db470a9031f15, head 24dd08dd6e14607a17ffbf80aa64834f947307b5. Local direct correctness/performance and native 6/6 were rerun unchanged at this head; the PR body carries the updated evidence.

    Merge is held for runner coordination. All three exact-head Linux workflows hit the same self-hosted-host exhaustion outside this change: CI fails setup-dotnet extraction, portable V8 completes adapter/cold-process contracts then cannot write/link CMake temp files, and native document configures Clang then cannot write Rust temp artifacts. Every failure reports No space left on device; exact predecessor #368 passed Linux/macOS CI minutes earlier. Exact-head macOS remains queued/running. No code workaround or scope expansion is planned.

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/planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions