Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipboard access in webviews in Codespaces #115935

Open
Tyriar opened this issue Feb 5, 2021 · 8 comments
Open

Clipboard access in webviews in Codespaces #115935

Tyriar opened this issue Feb 5, 2021 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug github-codespaces webview Webview issues webview-views Webview views in the sidebar and panel
Milestone

Comments

@Tyriar
Copy link
Member

Tyriar commented Feb 5, 2021

Right now using navigator.clipboard gets rejected inside a webview editor in a Codespace.

@mjbvz mjbvz added github-codespaces webview-views Webview views in the sidebar and panel labels Feb 26, 2021
@mjbvz mjbvz added this to the June 2021 milestone May 21, 2021
@mjbvz mjbvz modified the milestones: June 2021, July 2021 Jun 30, 2021
@mjbvz mjbvz modified the milestones: July 2021, August 2021 Jul 29, 2021
@mjbvz mjbvz added the webview Webview issues label Aug 12, 2021
@mjbvz
Copy link
Collaborator

mjbvz commented Aug 12, 2021

@Tyriar I just tested this in Chrome on GitHub.dev using an extension with creates a webview that runs:

setInterval(async () => {
    try {
        const c = await navigator.clipboard.readText();
        console.log(c)
    } catch (e) {
        console.error(e);
    }
}, 1000);

This fails if the webview is not focused but works properly when the document is focused

@Tyriar Are you still running into this? If so, can you share more details about how to reproduce

@Tyriar
Copy link
Member Author

Tyriar commented Aug 13, 2021

Codespaces had blocked SharedArrayBuffer due to not including the needed headers, I haven't used Luna Paint in it for a month or so so not sure

@mjbvz
Copy link
Collaborator

mjbvz commented Aug 23, 2021

@Tyriar Did you get a chance to test this now that Luna Paint is running on web?

@Tyriar
Copy link
Member Author

Tyriar commented Aug 24, 2021

Can't test yet as I get a CSP problem when I try to load in github.dev/codespaces

Refused to connect to 'https://....loca.lt/package.json' because it violates the following Content Security Policy directive: "connect-src 'self'

Need to publish first

@Tyriar
Copy link
Member Author

Tyriar commented Aug 24, 2021

Got it working by installing the vsix, both copy and paste don't work in codespaces and there are no errors in the console when I do them.

@Tyriar
Copy link
Member Author

Tyriar commented Aug 24, 2021

It would be nice to get some testing around clipboard access in custom webviews as it's broken several times now

@mjbvz
Copy link
Collaborator

mjbvz commented Aug 24, 2021

What browser are you using? A minimal example works fine for me in chrome.

However on safari I see:

The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission

There is never a visible prompt so I'm not sure what safari needs here

@Tyriar
Copy link
Member Author

Tyriar commented Aug 24, 2021

This was in latest Edge on Windows

@mjbvz mjbvz modified the milestones: August 2021, On Deck Aug 25, 2021
@mjbvz mjbvz added the bug Issue identified by VS Code Team member as probable bug label Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug github-codespaces webview Webview issues webview-views Webview views in the sidebar and panel
Projects
None yet
Development

No branches or pull requests

2 participants