trisquel-icecat/icecat/testing/web-platform/tests/credential-management/support
2025-07-17 09:32:21 -06:00
..
fedcm icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
echoing-nester.html icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
fedcm-helper.sub.js icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
fedcm-helper.sub.js.headers icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
fedcm-iframe-level2.html icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
fedcm-iframe.html icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
fedcm-mock.js icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
fedcm-mojojs-helper.js icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
federatedcredential-get.html icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
fencedframe-mark-signedin.html icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
iframe-mark-signedin.html icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
mark_signedin icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
mark_signedin.sub.headers icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
mark_signedout icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
mark_signedout.sub.headers icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
otpcredential-helper.js icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
otpcredential-iframe.html icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
passwordcredential-get.html icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
README.md icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
set_cookie icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
set_cookie.headers icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06: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 the following in your test:
<script src="/resources/test-only-api.js"></script>
<script src="support/otpcredential-helper.js"></script>
  1. 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

FedCM Testing

fedcm-mojojs-helper.js exposes fedcm_mojo_mock_test which is a specialized promise_test which comes pre-setup with the appropriate mocking infrastructure to emulate platform federated auth backend. The mock is passed to the test function as the second parameter.

Example usage:

<script type="module">
  import {fedcm_mojo_mock_test} from './support/fedcm-mojojs-helper.js';

  fedcm_mojo_mock_test(async (t, mock) => {
    mock.returnToken("https://idp.test/fedcm.json", "a_token");
    assert_equals("a_token", await navigator.credentials.get(options));
  }, "Successfully obtaining a token using mock.");
</script>

The chromium implementation uses the MojoJS shim.