servo/tests/wpt/web-platform-tests/credential-management/support
2020-03-28 11:05:43 +00:00
..
echoing-nester.html
federatedcredential-get.html
otpcredential-helper.js Update web-platform-tests to revision cf8a15a334c6eb3b044b3db8a933436c2365819d 2020-03-28 11:05:43 +00:00
otpcredential-iframe.html Update web-platform-tests to revision cf8a15a334c6eb3b044b3db8a933436c2365819d 2020-03-28 11:05:43 +00:00
passwordcredential-get.html
README.md Update web-platform-tests to revision cf8a15a334c6eb3b044b3db8a933436c2365819d 2020-03-28 11:05:43 +00:00

CredentialManagement Testing

OTPCredential Testing

In this test suite otpcredential-helper.js is a testing framework that enables engines to test OTPCredential by intercepting the connection between the browser and the underlying operating system and mock its behavior.

Usage:

  1. Include <script src="./support/otpcredential-helper.js"></script> in your test
  2. Set expectations
await expect(receive).andReturn(() => {
  // mock behavior
})
  1. Call navigator.credentials.get({otp: {transport: ["sms"]}})
  2. Verify results

The mocking API is browser agnostic and is designed such that other engines could implement it too.

Here are the symbols that are exposed to tests that need to be implemented per engine:

  • function receive(): the main/only function that can be mocked
  • function expect(): the main/only function that enables us to mock it
  • enum State {kSuccess, kTimeout}: allows you to mock success/failures