From 7353e2c9603bd4e320920eed2a4cd02ca279879a Mon Sep 17 00:00:00 2001 From: Christian Biesinger Date: Wed, 9 Aug 2023 10:59:22 +0000 Subject: [PATCH] Bug 1846847 [wpt PR 41301] - [FedCM] Don't omit schemes when formatting URLs, a=testonly MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Automatic update from web-platform-tests [FedCM] Don't omit schemes when formatting URLs We use the result of this function to construct a GURL, so we can't omit any schemes. In practice, this affects http: right now, but this patch also ensures that the "omit https" and "omit file" bits are also not set to be more futureproof. R=npm@chromium.org Bug: 1468681 Change-Id: Idac394102133f030dad899e9017fb5e3f0cb4b77 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4742567 Reviewed-by: Nicolás Peña Commit-Queue: Christian Biesinger Auto-Submit: Christian Biesinger Cr-Commit-Position: refs/heads/main@{#1179216} -- wpt-commits: 107a058ec9f3dd4073c643a4d1b50e60ad21ec53 wpt-pr: 41301 --- .../credential-management/fedcm-iframe.https.html | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/testing/web-platform/tests/credential-management/fedcm-iframe.https.html b/testing/web-platform/tests/credential-management/fedcm-iframe.https.html index 43fe39f7bcb2..964ebf4c44df 100644 --- a/testing/web-platform/tests/credential-management/fedcm-iframe.https.html +++ b/testing/web-platform/tests/credential-management/fedcm-iframe.https.html @@ -10,9 +10,11 @@ import {fedcm_test, set_fedcm_cookie} from './support/fedcm-helper.sub.js'; const host = get_host_info(); -const remoteBaseURL = - host.HTTPS_REMOTE_ORIGIN + - window.location.pathname.replace(/\/[^\/]*$/, '/'); +// This regex removes the filename from the path so that we just get +// the directory. +const basePath = window.location.pathname.replace(/\/[^\/]*$/, '/'); +const remoteBaseURL = host.HTTPS_REMOTE_ORIGIN + basePath; +const localhostBaseURL = "http://localhost:" + host.HTTP_PORT + basePath; async function createIframeAndWaitForMessage(test, iframeUrl, setPermissionPolicy) { const messageWatcher = new EventWatcher(test, window, "message"); @@ -58,4 +60,14 @@ fedcm_test(async t => { assert_equals(message.errorType, "NotAllowedError"); }, "FedCM disabled in 2 level deep nested iframe where innermost iframe does not have permission policy"); +fedcm_test(async t => { + // This is only an iframe because there's no other way to have this URL + // loaded from localhost. + const message = await createIframeAndWaitForMessage( + t, localhostBaseURL + "support/fedcm-iframe.html", + /*setPermissionPolicy=*/true); + assert_equals(message.result, "Pass"); + assert_equals(message.token, "token"); +}, "FedCM should work in non-HTTPS URLs on localhost"); + -- 2.11.4.GIT