Closed Bug 1468880 Opened 6 years ago Closed 6 years ago

[wpt-sync] Sync PR 11511 - [testdriver.js] Implement `bless` method

Categories

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

enhancement

Tracking

(firefox63 fixed)

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: mozilla.org, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream error])

Sync web-platform-tests PR 11511 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/11511
Details from upstream follow.

Mike Pennisi <mike@mikepennisi.com> wrote:
>  [testdriver.js] Implement `bless` method
>  
>  A common use case for the testdriver.js library is to create a task that
>  was triggered by user interaction [1]. Doing so using the current API
>  requires a fair amount of logic which is unrelated to the behavior under
>  test. This has a number of drawbacks:
>  
>  - it makes tests less descriptive
>  - it makes tests less uniform both in terms of implementation and in
>    terms of user experience (in non-automated scenarios, human operators
>    may be prompted to provide the necessary input)
>  - it makes tests more susceptible to bugs
>  
>  Define a utility method as a consistent and concise way to facilitate
>  the common use case. Require descriptive text via the `intent` parameter
>  in order to encourage test authors to explicitly describe the rationale
>  for requesting additional privileges.
>  
>  [1] https://html.spec.whatwg.org/#triggered-by-user-activation
>  
>  ---
>  
>  @kereliuk @gsnedders This is based on my experience applying testdriver.js to tests that rely on media playback. In every case, I've been using the library for one of two purposes:
>  
>  - create a trusted task (i.e. to call `element.play()` or `new AudioContext`)
>  - signal engagement with the document (to ensure the UA observes the `autoplay` attribute)
>  
>  testharness.js is exactly what's needed to serve these purposes. The thing is, the WebDriver-inspired API it offers is much more precise than what's necessary for this. Every test needs to perform similar setup to get what it needs:
>  
>  - Create a button
>  - Add a click handler
>  - Insert the button into the document
>  - Request a click interaction
>  - Create a Promise which wraps a "click" event listener
>  
>  None of this is particularly challenging, but it adds noise and a source of inconsistency between tests.
>  
>  My use case is narrowly circumscribed, so I took a look at the existing usages of testdriver.js:
>  
>  test                                                                                                     | purpose
>  ---------------------------------------------------------------------------------------------------------|----------------------
>  [bluetooth/resources/bluetooth-helpers.js](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/bluetooth/resources/bluetooth-helpers.js)                                                               | create a trusted task
>  [feature-policy/resources/autoplay.js](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/feature-policy/resources/autoplay.js)                                                                   | signal engagement
>  [fetch/sec-metadata/window-open.tentative.https.sub.html](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/fetch/sec-metadata/window-open.tentative.https.sub.html)                                                | create a trusted task
>  [html/editing/focus/focus-01.html](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/html/editing/focus/focus-01.html)                                                                       | simulate a key press
>  [html/editing/focus/focus-02.html](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/html/editing/focus/focus-02.html)                                                                       | simulate a key press
>  [html/editing/focus/sequential-focus-navigation-and-the-tabindex-attribute/focus-tabindex-negative.html](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/html/editing/focus/sequential-focus-navigation-and-the-tabindex-attribute/focus-tabindex-negative.html) | simulate a key press
>  [html/editing/focus/sequential-focus-navigation-and-the-tabindex-attribute/focus-tabindex-order.html](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/html/editing/focus/sequential-focus-navigation-and-the-tabindex-attribute/focus-tabindex-order.html)    | simulate a key press
>  [html/editing/focus/sequential-focus-navigation-and-the-tabindex-attribute/focus-tabindex-positive.html](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/html/editing/focus/sequential-focus-navigation-and-the-tabindex-attribute/focus-tabindex-positive.html) | simulate a key press
>  [html/editing/focus/sequential-focus-navigation-and-the-tabindex-attribute/focus-tabindex-zero.html](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/html/editing/focus/sequential-focus-navigation-and-the-tabindex-attribute/focus-tabindex-zero.html)     | simulate a key press
>  [payment-request/payment-request-abort-method.https.html](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/payment-request/payment-request-abort-method.https.html)                                                | create a trusted task
>  [picture-in-picture/resources/picture-in-picture-helpers.js](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/picture-in-picture/resources/picture-in-picture-helpers.js)                                             | create a trusted task
>  [uievents/order-of-events/mouse-events/click-cancel.html](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/uievents/order-of-events/mouse-events/click-cancel.html)                                                | simulate a click
>  [webusb/resources/usb-helpers.js](https://github.com/web-platform-tests/wpt/blob/cf261625e2d230ab219eec966f4abe26e3401b64/webusb/resources/usb-helpers.js)                                                                        | create a trusted task
>  
>  Note how many of those applications are themselves abstractions around the general pattern. I know we're only just beginning to deploy this library, but even now, it seems like an extension to the testdriver.js API is warranted.
>  
>  If you agree, I'll be happy to finish up this patch, adding tests and documentation and refactoring those tests. What do you think?
>  
>
Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]
Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]
Whiteboard: [wptsync downstream] → [wptsync downstream error]
Failed to get results from try push
Pushed by james@hoppipolla.co.uk:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e0c78da25880
[wpt PR 11511] - [testdriver.js] Implement `bless` method, a=testonly
https://hg.mozilla.org/integration/mozilla-inbound/rev/d7b449aa4ab1
[wpt PR 11511] - Update wpt metadata, a=testonly
https://hg.mozilla.org/mozilla-central/rev/e0c78da25880
https://hg.mozilla.org/mozilla-central/rev/d7b449aa4ab1
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.