Skip to content

Commit

Permalink
[FedCM][Test] Add filename parameter to default_request_options()
Browse files Browse the repository at this point in the history
This CL adds optional filename parameter to default_request_options()
in fedcm-helper.sub.js

BUG=368434

Change-Id: I5a7a270e3e4dcacdf89c336c2d098c4f2c1024d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3964956
Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1062196}
  • Loading branch information
pkotwicz authored and chromium-wpt-export-bot committed Oct 21, 2022
1 parent 811673c commit f1eadcd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<script type="module">
import {default_request_options, fedcm_test, set_fedcm_cookie} from './support/fedcm-helper.sub.js';

const url_prefix = 'https://{{host}}:{{ports[https][0]}}/credential-management/support/fedcm/';

fedcm_test(async t => {
const cred = await navigator.credentials.get(default_request_options());
assert_equals(cred.token, "token");
Expand Down Expand Up @@ -102,8 +100,7 @@
}, 'Test that COEP policy do not apply to FedCM requests');

fedcm_test(async t => {
let test_options = default_request_options();
test_options.identity.providers[0].configURL = url_prefix + 'manifest-not-in-list.json';
let test_options = default_request_options('manifest-not-in-list.json');
const cred = navigator.credentials.get(test_options);
return promise_rejects_dom(t, 'NetworkError', cred);
}, 'Test that the promise is rejected if the manifest is not in the manifest list');
Expand Down
10 changes: 7 additions & 3 deletions credential-management/support/fedcm-helper.sub.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ export function set_fedcm_cookie() {

// Returns FedCM CredentialRequestOptions for which navigator.credentials.get()
// succeeds.
export function default_request_options() {
const manifest_origin = 'https://{{hosts[][]}}:{{ports[https][0]}}';
export function default_request_options(manifest_filename) {
if (manifest_filename === undefined) {
manifest_filename = "manifest.py";
}
const manifest_path = `https://{{host}}:{{ports[https][0]}}/\
credential-management/support/fedcm/${manifest_filename}`;
return {
identity: {
providers: [{
configURL: manifest_origin + '/credential-management/support/fedcm/manifest.py',
configURL: manifest_path,
clientId: '1',
nonce: '2',
}]
Expand Down

0 comments on commit f1eadcd

Please sign in to comment.