Skip to content

fix: remove foreignObject from bubble canvas clone to prevent tainted canvas#321

Merged
takaokouji merged 1 commit intodevelopfrom
fix/screenshot-tainted-canvas
Mar 16, 2026
Merged

fix: remove foreignObject from bubble canvas clone to prevent tainted canvas#321
takaokouji merged 1 commit intodevelopfrom
fix/screenshot-tainted-canvas

Conversation

@takaokouji
Copy link

Summary

  • fix: include comment bubbles in blocks screenshot export #320 で追加したバブルキャンバスのクローンに <foreignObject> 要素(コメント編集用 <textarea>)が含まれていた
  • SVG を blob URL 経由でロードする際、foreignObject 内の HTML がクロスオリジンコンテンツとして扱われ、canvas.toBlob()SecurityError: Tainted canvases may not be exported が発生
  • クローンから foreignObject 要素を除去して解決(表示テキストは <text> 要素に既にあるため影響なし)

Changes

  • packages/scratch-gui/src/lib/blocks-screenshot.js: バブルキャンバスクローンから foreignObject を除去
  • packages/scratch-gui/test/unit/lib/blocks-screenshot.test.js: foreignObject 除去のテスト追加

Definition of Done

  • ユニットテスト pass (21/21)
  • lint pass
  • CI green
  • ブラウザ確認: スクリーンショットがエラーなくダウンロードされる

Fixes #319

🤖 Generated with Claude Code

… canvas

The cloned bubble canvas contained <foreignObject> elements with HTML
<textarea> for comment editing. When the SVG is loaded via blob URL,
these cause a SecurityError (tainted canvas) on canvas.toBlob().
Remove foreignObject elements from the clone since the visible comment
text is already in <text> elements.

Fixes #319

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link

@takaokouji takaokouji merged commit 9ae396f into develop Mar 16, 2026
16 of 17 checks passed
@takaokouji takaokouji deleted the fix/screenshot-tainted-canvas branch March 16, 2026 03:47
github-actions bot pushed a commit that referenced this pull request Mar 16, 2026
…t-tainted-canvas

fix: remove foreignObject from bubble canvas clone to prevent tainted canvas
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.

fix: コメントバブルがブロックスクリーンショットに含まれない

1 participant