async clipboard api (navigator.clipboard) does not have permissions in nw frame
See original GitHub issueNWJS Version : 0.35.5 Operating System : Linux/All
Expected behavior
The async clipboard api navigator.clipboard.readText()
should work without having to do anything extra to get permission in NW frames.
Optional: As a bonus it would be great if you can use navigator.clipboard.readText without it being connected to a UI event.
Actual behavior
Nothing happens, promise never resolves. It is the same behavior if you used normal browser and just never clicked the permission prompt to block or allow access to the clipboard.
How to reproduce
The following should output the clipboard buffer to console after clicking on the button:
var el = document.createElement('input');
el.type='button';
el.value='click me';
el.onclick = function() {
navigator.clipboard.readText().then((text) => { console.log(text); }, (err) => { console.error('Failed:', err); });
};
document.getElementsByTagName('body')[0].appendChild(el);
Also this example async clipboard api page should work: https://googlechrome.github.io/samples/async-clipboard/
As a bonus it would be great if you can use navigator.clipboard.readText without it being connected to a UI event (press button). In that case just running:
navigator.clipboard.readText().then((text) => { console.log(text); }, (err) => { console.error('Failed:', err); });
Should output the clipboard to console. Although it would be very nice, it isn’t part of the API spec.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top GitHub Comments
Ok. Thanks. But I even have node-remote for all URLs. These are pages I can import node modules, but can’t use the async clipboard api.
*://*/*
Seems like this is working now for me.