gecko-dev/testing/web-platform/tests/credential-management/support
Nicolás Peña 33785a170e Bug 1890555 [wpt PR 45628] - Reland "[FedCM] Enable CORS in ID assertion endpoint", a=testonly
Automatic update from web-platform-tests
Reland "[FedCM] Enable CORS in ID assertion endpoint"

This reverts commit 4b1c288aef71451a32e057cac8413c26a665ee32.

Reason for revert: IDPs are now ready for this change

Original change's description:
> Revert "[FedCM] Enable CORS in ID assertion endpoint"
>
> This reverts commit b2cb1b55ae3c4f7b88a74a0ceb697646fde03a5b.
>
> Reason for revert: Causing issues to a real IDP
>
> Original change's description:
> > [FedCM] Enable CORS in ID assertion endpoint
> >
> > I2S: https://groups.google.com/a/chromium.org/g/blink-dev/c/gYoQJsaiD9E
> >
> > Bug: 40284123
> > Change-Id: I61989f1e7a7578c2f59d87815e3ec2b51b7fc5be
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5370086
> > Reviewed-by: Nasko Oskov <nasko@chromium.org>
> > Reviewed-by: Christian Dullweber <dullweber@chromium.org>
> > Reviewed-by: Mathias Bynens <mathias@chromium.org>
> > Commit-Queue: Nicolás Peña <npm@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1274203}
>
> Bug: 40284123
> Change-Id: I4a518b55396d5aba676f0a15c9a515451dc11e86
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5381316
> Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
> Reviewed-by: Mathias Bynens <mathias@chromium.org>
> Commit-Queue: Nicolás Peña <npm@chromium.org>
> Reviewed-by: Nasko Oskov <nasko@chromium.org>
> Reviewed-by: Christian Dullweber <dullweber@chromium.org>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Cr-Commit-Position: refs/heads/main@{#1276213}

Bug: 40284123
Change-Id: I64c8ceb82b3f49bc41e7b592d890699db67a2c6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5440132
Reviewed-by: Mathias Bynens <mathias@chromium.org>
Reviewed-by: Christian Dullweber <dullweber@chromium.org>
Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1284723}

--

wpt-commits: b1eacf12d9e205919a9363a179f14d6e8bc3bd71
wpt-pr: 45628
2024-04-15 08:50:47 +00:00
..
fedcm Bug 1890555 [wpt PR 45628] - Reland "[FedCM] Enable CORS in ID assertion endpoint", a=testonly 2024-04-15 08:50:47 +00:00
README.md
digital-identity-helper.js Bug 1888303 [wpt PR 45397] - [digital credential] Move IdentityRequestProvider to a separate dict, a=testonly 2024-04-08 07:54:59 +00:00
digital-identity-iframe.html
echoing-nester.html
fedcm-helper.sub.js Bug 1888257 [wpt PR 45387] - [FedCM] Explicitly clear state when needed, a=testonly 2024-04-10 09:24:34 +00:00
fedcm-iframe-level2.html
fedcm-iframe.html
fedcm-mock.js
fedcm-mojojs-helper.js
federatedcredential-get.html
fencedframe-mark-signedin.html Bug 1888258 [wpt PR 45388] - [FedCM] Always notify opener that we're done loading, a=testonly 2024-04-08 07:54:49 +00:00
iframe-mark-signedin.html
mark_signedin
mark_signedin.sub.headers
mark_signedout
mark_signedout.sub.headers
otpcredential-helper.js
otpcredential-iframe.html
passwordcredential-get.html
set_cookie Bug 1887933 [wpt PR 45325] - [FedCM] Close the popup window after setting cookie, a=testonly 2024-03-28 14:10:01 +00:00
set_cookie.headers

README.md

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.