commit ee3fe6cf1f060b02a4a743e63bc03eeb4b8f48fe
parent e9d2ff003b4b98d42f09ff2dd7fd09145da7f511
Author: suresh potti <sureshpotti@microsoft.com>
Date: Wed, 15 Oct 2025 08:43:23 +0000
Bug 1993925 [wpt PR 55360] - [FedCM] IdentityProvider.resolve() should take `any`, a=testonly
Automatic update from web-platform-tests
[FedCM] IdentityProvider.resolve() should take `any`
Low-Coverage-Reason: OTHER
Bug: 448408132
Change-Id: If4842bcfc1eeadb3ebdda85ca3cbc90624a63a0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7012967
Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
Commit-Queue: suresh potti <sureshpotti@microsoft.com>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Reviewed-by: Giovanni Ortuno Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1528201}
--
wpt-commits: 7e31fb713266ebf63cb7acf20d206da860f35934
wpt-pr: 55360
Diffstat:
4 files changed, 209 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/fedcm/fedcm-flexible-token/resolve-flexible-tokens.https.html b/testing/web-platform/tests/fedcm/fedcm-flexible-token/resolve-flexible-tokens.https.html
@@ -0,0 +1,107 @@
+<!DOCTYPE html>
+<title>FedCM: IdentityProvider.resolve() with flexible token formats</title>
+<meta name="timeout" content="long">
+<link rel="help" href="https://fedidcg.github.io/FedCM">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+
+<script type="module">
+import {fedcm_test,
+ request_options_with_mediation_required,
+ select_manifest,
+ fedcm_get_and_select_first_account} from '../support/fedcm-helper.sub.js';
+
+// Test 1: String token
+fedcm_test(async t => {
+ const options = request_options_with_mediation_required('manifest_continue_on_flexible_tokens.json');
+ options.identity.providers[0].params = {
+ accountId: "jane_doe",
+ tokenType: "string",
+ tokenValue: "account=jane_doe"
+ };
+
+ await select_manifest(t, options);
+ const cred = await fedcm_get_and_select_first_account(t, options);
+ assert_equals(cred.token, "account=jane_doe");
+}, "IdentityProvider.resolve() with string token");
+
+// Test 2: Positive number token
+fedcm_test(async t => {
+ const options = request_options_with_mediation_required('manifest_continue_on_flexible_tokens.json');
+ options.identity.providers[0].params = {
+ accountId: "jane_doe",
+ tokenType: "number",
+ tokenValue: 42
+ };
+
+ await select_manifest(t, options);
+ const cred = await fedcm_get_and_select_first_account(t, options);
+ assert_equals(cred.token, 42);
+}, "IdentityProvider.resolve() with positive number token");
+
+// Test 3: Boolean token(true)
+fedcm_test(async t => {
+ const options = request_options_with_mediation_required('manifest_continue_on_flexible_tokens.json');
+ options.identity.providers[0].params = {
+ accountId: "jane_doe",
+ tokenType: "boolean",
+ tokenValue: true
+ };
+
+ await select_manifest(t, options);
+ const cred = await fedcm_get_and_select_first_account(t, options);
+ assert_equals(cred.token, true);
+}, "IdentityProvider.resolve() with boolean(true) token");
+
+// Test 4: Null token
+fedcm_test(async t => {
+ const options = request_options_with_mediation_required('manifest_continue_on_flexible_tokens.json');
+ options.identity.providers[0].params = {
+ accountId: "jane_doe",
+ tokenType: "null",
+ tokenValue: null
+ };
+
+ await select_manifest(t, options);
+ const cred = await fedcm_get_and_select_first_account(t, options);
+ assert_equals(cred.token, null);
+}, "IdentityProvider.resolve() with null token");
+
+// Test 5: Object token
+fedcm_test(async t => {
+ const options = request_options_with_mediation_required('manifest_continue_on_flexible_tokens.json');
+ options.identity.providers[0].params = {
+ accountId: "jane_doe",
+ tokenType: "object",
+ tokenValue: {id: 42, name: "test", active: true}
+ };
+
+ await select_manifest(t, options);
+ const cred = await fedcm_get_and_select_first_account(t, options);
+ assert_equals(cred.token.id, 42);
+ assert_equals(cred.token.name, "test");
+ assert_equals(cred.token.active, true);
+}, "IdentityProvider.resolve() with object token");
+
+// Test 6: Array token
+fedcm_test(async t => {
+ const options = request_options_with_mediation_required('manifest_continue_on_flexible_tokens.json');
+ options.identity.providers[0].params = {
+ accountId: "jane_doe",
+ tokenType: "array",
+ tokenValue: [1, "test", true, null, {key: "value"}]
+ };
+
+ await select_manifest(t, options);
+ const cred = await fedcm_get_and_select_first_account(t, options);
+ assert_equals(cred.token.length, 5);
+ assert_equals(cred.token[0], 1);
+ assert_equals(cred.token[1], "test");
+ assert_equals(cred.token[2], true);
+ assert_equals(cred.token[3], null);
+ assert_equals(cred.token[4].key, "value");
+}, "IdentityProvider.resolve() with array token");
+
+</script>
+\ No newline at end of file
diff --git a/testing/web-platform/tests/fedcm/support/continue_on_flexible_tokens.py b/testing/web-platform/tests/fedcm/support/continue_on_flexible_tokens.py
@@ -0,0 +1,22 @@
+import importlib
+import urllib.parse
+import json
+error_checker = importlib.import_module("fedcm.support.request-params-check")
+
+def main(request, response):
+ request_error = error_checker.tokenCheck(request)
+ if (request_error):
+ return request_error
+
+ response.headers.set(b"Content-Type", b"application/json")
+ response.headers.set(b"Access-Control-Allow-Origin", request.headers.get(b"Origin"))
+ response.headers.set(b"Access-Control-Allow-Credentials", "true")
+
+ account = request.POST.get(b"account_id").decode("utf-8")
+ params = request.POST.get(b"params")
+
+ resolve_url = "resolve_flexible_tokens.html?selected=%s¶ms=%s" % (
+ account,
+ urllib.parse.quote(params.decode("utf-8"))
+ )
+ return "{\"continue_on\": \"%s\"}" % resolve_url
+\ No newline at end of file
diff --git a/testing/web-platform/tests/fedcm/support/manifest_continue_on_flexible_tokens.json b/testing/web-platform/tests/fedcm/support/manifest_continue_on_flexible_tokens.json
@@ -0,0 +1,6 @@
+{
+ "accounts_endpoint": "accounts_no_approved_clients.py",
+ "client_metadata_endpoint": "client_metadata.py",
+ "id_assertion_endpoint": "continue_on_flexible_tokens.py",
+ "login_url": "login.html"
+}
+\ No newline at end of file
diff --git a/testing/web-platform/tests/fedcm/support/resolve_flexible_tokens.html b/testing/web-platform/tests/fedcm/support/resolve_flexible_tokens.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<script>
+async function doResolve() {
+ let urlParams = new URLSearchParams(document.location.search);
+ let options = {};
+
+ const paramsStr = urlParams.get("params");
+ const params = JSON.parse(decodeURIComponent(paramsStr));
+
+ // Extract values from params
+ const accountId = params.accountId;
+ const tokenType = params.tokenType;
+ const tokenValue = params.tokenValue;
+
+ // Set accountId option if present
+ if (accountId) {
+ options.accountId = accountId;
+ }
+
+ let token;
+
+ // Process token based on tokenType
+ switch (tokenType) {
+ case "number":
+ token = parseFloat(tokenValue);
+ break;
+
+ case "boolean":
+ token = tokenValue === true || tokenValue === "true";
+ break;
+
+ case "null":
+ token = null;
+ break;
+
+ case "object":
+ if (typeof tokenValue === "object") {
+ token = tokenValue;
+ } else {
+ try {
+ token = JSON.parse(tokenValue);
+ } catch (e) {
+ token = { value: tokenValue };
+ }
+ }
+ break;
+
+ case "array":
+ if (Array.isArray(tokenValue)) {
+ token = tokenValue;
+ } else {
+ try {
+ token = JSON.parse(tokenValue);
+ } catch (e) {
+ token = [tokenValue];
+ }
+ }
+ break;
+
+ case "string":
+ default:
+ token = String(tokenValue);
+ break;
+ }
+
+ IdentityProvider.resolve(token, options);
+}
+
+window.onload = doResolve;
+</script>
+\ No newline at end of file