Open Bug 1676643 Opened 4 years ago Updated 2 years ago

Add support for testing the clipboard in the WPT-framework

Categories

(Testing :: web-platform-tests, enhancement, P2)

enhancement

Tracking

(Not tracked)

People

(Reporter: mbrodesser-Igalia, Unassigned)

References

(Blocks 1 open bug)

Details

This can be read as an introduction.

Currently, the clipboard isn't testable in WPT. Also not for mozilla-only tests using SpecialPowers. The latter, because SpecialPowers.getClipboardData uses custom code to retrieve data from the clipboard.

In order to be able to write WPT reading from the clipboard and writing to it, there are two potential options:

  1. Use execCommand("paste") and execCommand("copy").
  2. Use the asynchronous clipboard API and the permissions API.

1) requires permissions using the web-extension permissions clipboardRead and clipboardWrite. Currently, they are presumably not conveniently accessible from WPT. See this mochitest.

2) requires passing clipboard-read and clipboard-write (note the difference to 1)) to the permissions API. The latter apparently isn't implemented in Gecko. Moreover, navigator.clipboard.read() and navigator.clipboard.write() are required, but not implemented in Gecko.

As long as neither 1) nor 2) are conveniently useable, clipboard tests are likely to be written as Mochitests.

Follow-ups should be:

  • Improving the test-coverage of the clipboard.
  • Transforming Mochitests testing the clipboard to WPT.
Component: DOM: Events → web-platform-tests
Product: Core → Testing

There are some other options here like having a WebDriver endpoint specifically for clipboard access (this could be limited in some way so that it would only allow access to things copied in the same WebDriver session or so).

Some notes from :annevk, for the record:

"Note that we don't plan to support clipboard-write (or clipboard-read), I don't think we really need either to support read() and write()"
"I think for paste we should do what Safari should does. Which is that it works with a user gesture + the user selecting "Paste" from the single-item menu that appears and the read and write APIs can be the same, essentially"

The easiest thing here is probably to have a way (e.g. a WebDriver command) to auto-accept the user gesture for tests.

Severity: -- → S3
Priority: -- → P2
You need to log in before you can comment on or make changes to this bug.