Repository: flutter
Issue: Clipboard has permission errors using --wasm on web build
Labels: platform-web,P2,needs repro info,e: web_skwasm,team-web,triaged-web

### Steps to reproduce

I compiled my web app to WASM, and everything works great except now I can't get the Clipboard working. Cross-origin isolation is the problem I assume, but it could just be because without it, WASM isn't working and it works as it did with JavaScript. When running non-WASM and try to paste, the browser asks for permission. Using WASM it never asks for permission, it just fails.

My app is a bit complex. It's a Chrome extension with an iframe that loads a url to a Flutter web app. 

I set up my server to set the required headers for WASM to work.
```
cross-origin-embedder-policy: credentialless
cross-origin-opener-policy: same-origin
cross-origin-resource-policy: same-site
```
And the Chrome extension has this in the manifest:
```
"cross_origin_opener_policy": {
  "value": "same-origin"
},
"cross_origin_embedder_policy": {
  "value": "credentialless"
}
```

I had to add `allow="cross-origin-isolated"` to the iframe for WASM to work, if I remove this, it works, but I don't have WASM any longer. You can also notice I have the clipboard-read; clipboard-write permissions set. It all works perfectly non-WASM.
```
<iframe id='main-iframe' allow="cross-origin-isolated"
    style="position: fixed; top: 10000px; border: none; height:100%; width:100%;" src="http://localhost:8765"
    allow="geolocation; microphone; camera; clipboard-read; clipboard-write">
</iframe>
```

Testing my page for permissions:

```
const permissionStatus = await navigator.permissions.query({ name: 'clipboard-read', allowWithoutGesture: false });
permissionStatus = 'denied'

const permissionStatus = await navigator.permissions.query({ name: 'clipboard-write', allowWithoutGesture: false });
permissionStatus = 'denied'
```

From the dev console:
>The error message "[Violation] Permissions policy violation: The Clipboard API has been blocked..." indicates that your web app is trying to use the Clipboard API (specifically, navigator.clipboard.readText() or navigator.clipboard.writeText(), likely triggered by _1303 and _1304 in your code) but is being prevented by a permissions policy set on the website or by the browser.

`navigator.clipboard.writeText()` from JavaScript and `Clipboard.setData()` both fail the same way, but
if I use the keyboard, cmd-c, cmd-v, that works, but I assume the browser (chrome) is handling the keyboard?

I looked at the TextField code and it just seems to handle the context menu copy/paste, but let me know if I can use what the keyboard uses, but the keyboard doesn't ask for permission on WASM either which is weird, but I assume it's known to be a user action? If I use a right click, copy and cut both give errors. Also calling `Clipboard.setData()`, or `navigator.clipboard.writeText()` directly fails.

The Clipboard API has been blocked because of a permissions policy applied to the current document. See https://goo.gl/EuHzyv for more details.

I've spent a few days now searching for answers and have tried everything. All the different combinations of site-origin, same-origin etc. WASM is great, it runs much faster. Everything works, but I can't ship this until the Clipboard works.

It's a large private app, but if someone with expertise who needs to run my code to test, I could possibly add them as a collaborator on my Github.

Thanks.

### Expected results

`navigator.clipboard.writeText()` and `Clipboard.setData()` should work as per specification and return success.

### Actual results

Both `navigator.clipboard.writeText()` and `Clipboard.setData()` fail.

### Code sample

Please see the description above.

### Screenshots or Video

N/A

### Logs

Please see the description above.

### Flutter Doctor output

```
[✓] Flutter (Channel stable, 3.24.4, on macOS 14.7.1 23H221 darwin-arm64, locale en-US)
    • Flutter version 3.24.4 on channel stable at /Users/milke/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 603104015d (17 hours ago), 2024-10-24 08:01:25 -0700
    • Engine revision db49896cf2
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/macos-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/macos-android-setup for detailed instructions).

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.7.1 23H221 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.7.1 23H221 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 129.0.6668.59

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
```