docs: set clipboard-write permission on the Iframe example - #1296
Open
Danswar wants to merge 2 commits into
Open
docs: set clipboard-write permission on the Iframe example#1296Danswar wants to merge 2 commits into
Danswar wants to merge 2 commits into
Conversation
4 tasks
Danswar
marked this pull request as ready for review
August 8, 2026 16:14
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
clipboard-writeis a Permissions-Policy-gated feature whose default allowlist isself. In a cross-origin Iframe — which is what the documented Iframe integration of app.dfx.swiss is —navigator.clipboard.writeTexttherefore rejects unless the embedding page grants the permission viaallow="clipboard-write"on the Iframe element.With #1287 the app copies via
navigator.clipboard.writeTextand 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 ofclipboard-writedelegation 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 —iframeis 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
npx prettier --check README.md— clean (Markdown is prettier-checked in CI since Apply Prettier to Markdown and check it in CI #1294)