Skip to content

feat: support strict CSP (follow-up to #1193)#1240

Open
mathuo wants to merge 9 commits intomasterfrom
csp-followup
Open

feat: support strict CSP (follow-up to #1193)#1240
mathuo wants to merge 9 commits intomasterfrom
csp-followup

Conversation

@mathuo
Copy link
Copy Markdown
Owner

@mathuo mathuo commented May 6, 2026

Builds on @hyperNURb's #1193 (preserves all original commits/authorship) and addresses the items blocking that PR.

What this PR adds on top of #1193

  1. Merge with master — resolves the two conflicts (packages/dockview-core/src/dockview/options.ts imports + __generated__/dockview-core-exports.txt). Brings in the unrelated ReactComponentBridge test-flake fix (ce02eea24) so CI's test job stops failing.
  2. fix(dockview-core): avoid duplicating rules from external stylesheetsaddStyles previously appended a <link> for href-bearing sheets and fell through to inject inline <style> elements for the same sheet, which both duplicates rules (same-origin sheets) and triggers the security-warning path (cross-origin sheets). Flagged by the Copilot review on feat: support strict CSP #1193. Now we continue past the inline-injection block once the <link> has been appended, and the existing test is tightened to assert no <style> is produced for an href sheet.
  3. Format — runs prettier on dom.ts and dom.spec.ts so format:check passes.
  4. test(dockview-core): cover CSP nonce wiring
    • New popoutWindow.spec.ts (3 tests) drives PopoutWindow.open() with a mocked window.open and verifies the nonce option flows through addStyles into the <style> elements in the popout document, for both string and (targetDocument) => string forms.
    • New options.spec.ts asserts 'nonce' ∈ PROPERTY_KEYS_DOCKVIEW, which is the contract that lets the React and Vue wrappers auto-forward the option without explicit prop wiring (validates the description's claim that React/Vue are covered).

Test plan

  • yarn nx run dockview-core:format:check — clean
  • yarn nx run dockview-core:lint — 0 errors
  • yarn nx run dockview-core:test — 867/867 pass (+14 from new tests)
  • Verified the addStyles test would have caught the duplicate-rules bug (checked by reverting the continue locally — <style> length goes from 0 → 1)

🤖 Generated with Claude Code

hyperNURb and others added 9 commits April 16, 2026 15:54
Resolve conflicts in:
- packages/dockview-core/src/dockview/options.ts (kept both new
  imports from master and the CspNonce import from this branch)
- __generated__/dockview-core-exports.txt (regenerated via npm run gen)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… in addStyles

When a stylesheet has an href, addStyles already appends a <link> to
the target document. Previously it then also fell through and tried
to read cssRules to inject inline <style> elements for the same
sheet, which both duplicates the rules (same-origin sheets) and
logs a security warning (cross-origin sheets).

Continue past the inline-injection block once the <link> has been
appended. Also runs prettier on dom.ts and dom.spec.ts to satisfy
format:check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add three integration tests around PopoutWindow.open() that mock
window.open and verify the nonce option flows all the way into the
<style> elements injected into the popout document, both for
string nonces and for the (targetDocument) => string callback form.

Also adds a small contract test asserting that 'nonce' is in
PROPERTY_KEYS_DOCKVIEW, which is what makes the React and Vue
wrappers auto-forward the option without explicit prop wiring.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 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.

2 participants