Skip to content

docs: set clipboard-write permission on the Iframe example - #1296

Open
Danswar wants to merge 2 commits into
DFXswiss:developfrom
Danswar:docs/iframe-clipboard-write
Open

docs: set clipboard-write permission on the Iframe example#1296
Danswar wants to merge 2 commits into
DFXswiss:developfrom
Danswar:docs/iframe-clipboard-write

Conversation

@Danswar

@Danswar Danswar commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

clipboard-write is a Permissions-Policy-gated feature whose default allowlist is self. In a cross-origin Iframe — which is what the documented Iframe integration of app.dfx.swiss is — navigator.clipboard.writeText therefore rejects unless the embedding page grants the permission via allow="clipboard-write" on the Iframe element.

With #1287 the app copies via navigator.clipboard.writeText and only falls back to the legacy DOM-based mechanism when the Clipboard API is unavailable or the write rejects. Without this attribute, an Iframe integrator's users take the fallback on every copy in Chromium; with it, they get the native path. The attribute is an upgrade, not a prerequisite — copy buttons keep working without it (the fallback is not policy-gated), which is why the docs sentence recommends rather than requires it, and why it is phrased around browser behavior so it is accurate both before and after #1287 lands. Enforcement of clipboard-write delegation is Chromium-specific; Firefox and Safari gate the Clipboard API on user activation instead, so the attribute is a no-op there.

This PR adds the attribute to the Iframe code example and states the recommendation in the Iframe section. It also closes the <iframe> tag in the example — iframe is not a void element, so the previous self-closing form was invalid HTML that would swallow any markup an integrator pasted after it.

The Web Component and React Component integrations load into the host page's own document and need no attribute.

Test plan

@Danswar
Danswar marked this pull request as ready for review August 8, 2026 16:14
@Danswar

Danswar commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

2 review passes. Corrected in the second: the initial rationale overclaimed ("copy buttons cannot use the browser clipboard without it" — the legacy fallback is not policy-gated and keeps working), now stated as the Chromium permissions-policy fact; and the example's self-closing <iframe /> was invalid HTML, now properly closed.

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.

1 participant