-
Notifications
You must be signed in to change notification settings - Fork 37
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
Should reading the clipboard throw DataError or empty clipboard items? #179
Comments
The Web Editing Working Group just discussed The full IRC log of that discussion<Travis> topic: should reading the clipboard throw DataError or empty clipboard items?<Travis> github: https://github.com//issues/179 <Travis> (reads the issue) <Travis> whsieh_: this is the situation where there IS data on the clipboard, but none of it can be consumed by the webpage...? <Travis> .. seems weird to throw a DataError in the case where there is nothing in the clipboard/pasteboard... <Travis> .. in that case, returning an empty list. <Travis> travis: I like just returning an empty list too--easy for web authors to handle with erroring out... <Travis> whsieh_: In the specific example that snianu (Anupam) gave, I'm not sure if the error is OK. <Travis> .. probably can't resolve on this at this time without further discussion with snianu? <Travis> s/snianu?/snianu. <Travis> johanneswilm: can the JS Editors differentiate between the different error conditions? <Travis> .. could the user re-request? E.g., if the user didn't grant permission? <Travis> whsieh_: recap; there are cases where a website might want to know whether they can try again, or whether they shouldn't try again. <Travis> .. empty list vs throw error could be a way to differentiate. <Travis> johanneswilm: there are two other cases... <Travis> .. one where the user didn't give access, and one where the clipboard is changed after access is granted. <Travis> whsieh_: in the first case, Safari throws "NotAllowed" (from the user denying paste). <Travis> .. in the case where it changed, we also throw an error; but the type of error may not make sense... <Travis> .. could look at changing it? <Travis> (no resolution yet) |
In Gecko, we don't throw error, either, though we have a bug where we return a clipboard item with empty types currently, https://bugzilla.mozilla.org/show_bug.cgi?id=1756955. |
The Web Editing Working Group just discussed The full IRC log of that discussion<Travis> Topic: Should reading clipboard throw or return empty?<Travis> github: https://github.com//issues/179 <Travis> snianu: Seems like a similar issue to 180. <Travis> .. if there's no HTML format in the clipboard, and the author tries to read HTML format, then what? <Travis> .. makes sense to throw a DataError. <Travis> .. even though the clipboard has some data, just not what is desired. <Travis> snianu: If authors are trying to read HTML, but the clipboard has something that's not in the supported types. <Travis> .. the clipboard item won't have any data. <Travis> whsieh: interesting to note: clipboard being empty is a valid system state. <Travis> .. ex: calling clear contents from the OS. The technical truth is that there are no items in the clipboard. <Travis> .. how would authors use this knowledge? <Travis> .. (trying to come up with a scenario) <Travis> .. I guess it makes sense (either way we go) to have some consistency. <Travis> snianu: Currently we throw DataError in Chromium. So does Firefox. <Travis> whsieh: Pretty sure Webkit will return an empty array of items. <Travis> .. I think we can adjust our behavior to match; a DataError seems pretty sensible. |
Throwing seems a little weird to me when there is no data to return. If there truly is no data an empty sequence seems good. And if there is an item but its types cannot be read I could somewhat see wanting to filter such items out, but that might also make it harder to provide decent UI indicating to the user what might have gone wrong. So I'd prolly return the item with no exposed types for that case. |
@evanstade FYI.. |
RESOLUTION: Keep the exception during |
Record when an empty clipboard is encountered during `read()`. Gathering data for w3c/clipboard-apis#179. Bug: 1500440 Change-Id: I7c9c162ec7e17ea18a42683c9720330cbac57b3d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5029806 Reviewed-by: Evan Stade <[email protected]> Commit-Queue: Anupam Snigdha <[email protected]> Cr-Commit-Position: refs/heads/main@{#1225837}
Empty clipboard is a valid system state. Allow `read()` to return an empty ClipboardItem without rejecting the promise if (a) there are no formats on the clipboard. (b) there are unsupported formats on the clipboard. Prevent `write()` from writing empty ClipboardItem by keeping the `TypeError` exception in the ClipboardItem when it's called from JS. It's not clear whether writing empty ClipboardItem should clear the clipboard or write empty data for all supported formats or do nothing. Github issue: w3c/clipboard-apis#179 I2S: https://groups.google.com/a/chromium.org/g/blink-dev/c/FAchVmgepKM/m/-V91uCcCAAAJ?utm_medium=email&utm_source=footer Bug: 1500440 Change-Id: I654cb3e92e30f034cad5812e65776ec173b7dccc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5010104 Reviewed-by: Kent Tamura <[email protected]> Reviewed-by: Sanket Joshi <[email protected]> Commit-Queue: Anupam Snigdha <[email protected]> Reviewed-by: Evan Stade <[email protected]> Cr-Commit-Position: refs/heads/main@{#1234340}
…e is only unsupported items in system clipboard; r=nika This aligns with the current spec. There are some discussion in w3c/clipboard-apis#179. Differential Revision: https://phabricator.services.mozilla.com/D205502
…e is only unsupported items in system clipboard; r=nika This aligns with the current spec. There are some discussion in w3c/clipboard-apis#179. Differential Revision: https://phabricator.services.mozilla.com/D205502
https://w3c.github.io/clipboard-apis/#dom-clipboard-read suggests that reading the clipboard and not returning any items (such as when only unsupported types are on the clipboard) should return an empty list. In Chrome, we throw a
DataError
. Should we return an empty clipboardItem (to match the spec) or change the spec to throwDataError
?@annevk @mbrodesser @BoCupp-Microsoft @whsieh
The text was updated successfully, but these errors were encountered: