Skip to content

Commit

Permalink
[Local Network Access] Fix and assert undefined server in WPTs
Browse files Browse the repository at this point in the history
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 <titouan@chromium.org>
Commit-Queue: Titouan Rigoudy <titouan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1120002}
  • Loading branch information
johnathan79717 authored and marcoscaceres committed Mar 28, 2023
1 parent 9c3a65d commit dd26db2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fetch/local-network-access/redirect.https.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions fetch/local-network-access/resources/support.sub.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit dd26db2

Please sign in to comment.