Fix: Allow dartpad embed clipboard-write permission for "Copy to clipboard" functionality#178057
Conversation
There was a problem hiding this comment.
Code Review
This pull request correctly adds the clipboard-write permission to Dartpad iframes, which is necessary for the "Copy to clipboard" functionality. The changes are applied consistently across the HTML template, a regular expression for sanity checking, and a test file. I have one suggestion to make the regular expression more robust. Overall, the changes are well-implemented and address the stated issue.
| _sanityCheckExample( | ||
| widgetsDirectory.childFile('Listener-class.html').path, | ||
| r'\s*<iframe\s+class="snippet-dartpad"\s+src="' | ||
| r'\s*<iframe\s+class="snippet-dartpad"\s+allow="clipboard-write"\s+src="' |
There was a problem hiding this comment.
To make this sanity check more robust, consider modifying the regular expression to not depend on the order of HTML attributes. This would prevent the check from failing if the class and allow attributes in the iframe tag are reordered in the future.
| r'\s*<iframe\s+class="snippet-dartpad"\s+allow="clipboard-write"\s+src="' | |
| r'\s*<iframe\s+(?:(?:class="snippet-dartpad"\s+allow="clipboard-write")|(?:allow="clipboard-write"\s+class="snippet-dartpad"))\s+src="' |
|
Hi @jtmcdole, I suspect that this change requires me to update tests in the below files. Let me know if I need to change it or make any other changes. |
|
@mdebbar I'll defer to you and the web team for approving this. @dixita0607 Can you update the PR to see if it affects the test failures? |
|
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@dixita0607 Looks like there are still failures here, any idea why? |
|
@justinmc Apologies for not replying sooner. I plan to check this after a few more days. I hope that's okay. |
|
The changes look good to me, but I'm not sure about the failures. |
jtmcdole
left a comment
There was a problem hiding this comment.
██╗ ██████╗████████╗███╗ ███╗
██║ ██╔════╝╚══██╔══╝████╗ ████║
██║ ██║ ███╗ ██║ ██╔████╔██║
██║ ██║ ██║ ██║ ██║╚██╔╝██║
███████╗╚██████╔╝ ██║ ██║ ╚═╝ ██║
╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
… to clipboard" functionality (flutter/flutter#178057)
… to clipboard" functionality (flutter/flutter#178057)
… to clipboard" functionality (flutter/flutter#178057)
… to clipboard" functionality (flutter/flutter#178057)
flutter/flutter@3134be8...d81cd3e 2026-01-12 [email protected] Migrate doc and code to use sendAnnounce (flutter/flutter#180776) 2026-01-12 [email protected] Roll Packages from 51fe1d9 to e57e7f4 (3 revisions) (flutter/flutter#180846) 2026-01-12 [email protected] Fix: Allow dartpad embed clipboard-write permission for "Copy to clipboard" functionality (flutter/flutter#178057) 2026-01-12 [email protected] Roll Dart SDK from 87fbfd5381b6 to 42fd9ef68c1a (1 revision) (flutter/flutter#180836) 2026-01-12 [email protected] Roll Skia from aefdde600f1e to 487a9943210b (3 revisions) (flutter/flutter#180835) 2026-01-12 [email protected] Bump ffigen (flutter/flutter#180507) 2026-01-12 [email protected] Roll Skia from d42a43daa6cf to aefdde600f1e (1 revision) (flutter/flutter#180829) 2026-01-12 [email protected] Make sure that a LongPressDraggable doesn't crash in 0x0 environment (flutter/flutter#180408) 2026-01-12 [email protected] Make sure that a FlutterLogo doesn't crash in 0x0 environment (flutter/flutter#180617) 2026-01-12 [email protected] Roll Fuchsia Linux SDK from T_HOCpDjLgzi1SUMq... to VYeyMPe1lyCtlcl-V... (flutter/flutter#180825) 2026-01-11 [email protected] Roll Skia from f39cc645b1dd to d42a43daa6cf (2 revisions) (flutter/flutter#180819) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…board" functionality (flutter#178057) This PR allows dartpad embeds to have clipboard-write permission. Dartpad has added a new "Copy to clipboard" option. When it is rendered inside an `iframe`, it gives permission error (affecting flutter's docs website). Changes in this PR fixes it. **Before** - Copying text using the button shows an error in console. <img width="500" alt="before" src="https://github.com/user-attachments/assets/460f6983-5b25-4a9c-9b1e-457f096e4f82" /> **After** - Copying text using the button correctly copies content to the clipboard. (Tested by pasting it) <img width="500" alt="after" src="https://github.com/user-attachments/assets/1796b593-c206-4e56-afdb-b0e16e557055" /> --- fixes: flutter#178056 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md Co-authored-by: Mouad Debbar <[email protected]> Co-authored-by: John "codefu" McDole <[email protected]>
flutter/flutter@3134be8...d81cd3e 2026-01-12 [email protected] Migrate doc and code to use sendAnnounce (flutter/flutter#180776) 2026-01-12 [email protected] Roll Packages from 51fe1d9 to e57e7f4 (3 revisions) (flutter/flutter#180846) 2026-01-12 [email protected] Fix: Allow dartpad embed clipboard-write permission for "Copy to clipboard" functionality (flutter/flutter#178057) 2026-01-12 [email protected] Roll Dart SDK from 87fbfd5381b6 to 42fd9ef68c1a (1 revision) (flutter/flutter#180836) 2026-01-12 [email protected] Roll Skia from aefdde600f1e to 487a9943210b (3 revisions) (flutter/flutter#180835) 2026-01-12 [email protected] Bump ffigen (flutter/flutter#180507) 2026-01-12 [email protected] Roll Skia from d42a43daa6cf to aefdde600f1e (1 revision) (flutter/flutter#180829) 2026-01-12 [email protected] Make sure that a LongPressDraggable doesn't crash in 0x0 environment (flutter/flutter#180408) 2026-01-12 [email protected] Make sure that a FlutterLogo doesn't crash in 0x0 environment (flutter/flutter#180617) 2026-01-12 [email protected] Roll Fuchsia Linux SDK from T_HOCpDjLgzi1SUMq... to VYeyMPe1lyCtlcl-V... (flutter/flutter#180825) 2026-01-11 [email protected] Roll Skia from f39cc645b1dd to d42a43daa6cf (2 revisions) (flutter/flutter#180819) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/flutter@3134be8...d81cd3e 2026-01-12 [email protected] Migrate doc and code to use sendAnnounce (flutter/flutter#180776) 2026-01-12 [email protected] Roll Packages from 51fe1d9 to e57e7f4 (3 revisions) (flutter/flutter#180846) 2026-01-12 [email protected] Fix: Allow dartpad embed clipboard-write permission for "Copy to clipboard" functionality (flutter/flutter#178057) 2026-01-12 [email protected] Roll Dart SDK from 87fbfd5381b6 to 42fd9ef68c1a (1 revision) (flutter/flutter#180836) 2026-01-12 [email protected] Roll Skia from aefdde600f1e to 487a9943210b (3 revisions) (flutter/flutter#180835) 2026-01-12 [email protected] Bump ffigen (flutter/flutter#180507) 2026-01-12 [email protected] Roll Skia from d42a43daa6cf to aefdde600f1e (1 revision) (flutter/flutter#180829) 2026-01-12 [email protected] Make sure that a LongPressDraggable doesn't crash in 0x0 environment (flutter/flutter#180408) 2026-01-12 [email protected] Make sure that a FlutterLogo doesn't crash in 0x0 environment (flutter/flutter#180617) 2026-01-12 [email protected] Roll Fuchsia Linux SDK from T_HOCpDjLgzi1SUMq... to VYeyMPe1lyCtlcl-V... (flutter/flutter#180825) 2026-01-11 [email protected] Roll Skia from f39cc645b1dd to d42a43daa6cf (2 revisions) (flutter/flutter#180819) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This PR allows dartpad embeds to have clipboard-write permission. Dartpad has added a new "Copy to clipboard" option. When it is rendered inside an
iframe, it gives permission error (affecting flutter's docs website). Changes in this PR fixes it.Before
After
fixes: #178056
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.