From dd26db26f43ef50cbdd3304ab604e4cd7ace75ca Mon Sep 17 00:00:00 2001 From: Jonathan Hao Date: Tue, 21 Mar 2023 10:19:01 -0700 Subject: [PATCH] [Local Network Access] Fix and assert undefined server in WPTs I found this bug when I was working on enabling the same-origin exemption. Server defined outside of the target object is useless. The URL will be resolved to the default HTTPS local. Since we always explicitly define servers in LNA WPTs, asserting it so we don't make the same mistake again. Change-Id: I8f397a6ae4c442fb283ba7c2fca86c89f2aa322b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4355133 Reviewed-by: Titouan Rigoudy Commit-Queue: Titouan Rigoudy Cr-Commit-Position: refs/heads/main@{#1120002} --- fetch/local-network-access/redirect.https.window.js | 2 +- fetch/local-network-access/resources/support.sub.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fetch/local-network-access/redirect.https.window.js b/fetch/local-network-access/redirect.https.window.js index f8a53ad1889e617..edbd5a19fbc963c 100644 --- a/fetch/local-network-access/redirect.https.window.js +++ b/fetch/local-network-access/redirect.https.window.js @@ -365,8 +365,8 @@ promise_test(t => fetchTest(t, { server: Server.HTTPS_LOCAL, treatAsPublic: true, }, - server: Server.HTTPS_PRIVATE, target: { + server: Server.HTTPS_PRIVATE, behavior: { preflight: PreflightBehavior.noPnaHeader(token()), response: ResponseBehavior.allowCrossOrigin(), diff --git a/fetch/local-network-access/resources/support.sub.js b/fetch/local-network-access/resources/support.sub.js index c07fd2c2acee689..0cf3d2532e7ffd5 100644 --- a/fetch/local-network-access/resources/support.sub.js +++ b/fetch/local-network-access/resources/support.sub.js @@ -205,6 +205,7 @@ function sourceResolveOptions({ server, treatAsPublic }) { // - `response`: The result of calling one of `ResponseBehavior`'s methods. // - `redirect`: A URL to which the target should redirect GET requests. function preflightUrl({ server, behavior }) { + assert_not_equals(server, undefined, 'server'); const options = {...server}; if (behavior) { const { preflight, response, redirect } = behavior;