diff --git a/fetch/private-network-access/mixed-content-fetch.tentative.https.window.js b/fetch/private-network-access/mixed-content-fetch.tentative.https.window.js index 54485dc7047402..6f7d765617c9c1 100644 --- a/fetch/private-network-access/mixed-content-fetch.tentative.https.window.js +++ b/fetch/private-network-access/mixed-content-fetch.tentative.https.window.js @@ -1,10 +1,10 @@ // META: script=/common/utils.js // META: script=resources/support.sub.js // -// Spec: https://wicg.github.io/private-network-access +// Spec: https://wicg.github.io/local-network-access // // These tests verify that secure contexts can fetch non-secure subresources -// from more private address spaces, avoiding mixed context checks, as long as +// from more local address spaces, avoiding mixed context checks, as long as // they specify a valid `targetAddressSpace` fetch option that matches the // target server's address space. @@ -16,9 +16,9 @@ setup(() => { // Given `addressSpace`, returns the other three possible IP address spaces. function otherAddressSpaces(addressSpace) { switch (addressSpace) { - case "local": return ["unknown", "private", "public"]; - case "private": return ["unknown", "local", "public"]; - case "public": return ["unknown", "local", "private"]; + case "loopback": return ["unknown", "local", "public"]; + case "local": return ["unknown", "loopback", "public"]; + case "public": return ["unknown", "loopback", "local"]; } } @@ -169,64 +169,66 @@ function makeNoBypassTests({ source, target }) { }, fetchOptions: { targetAddressSpace: correctAddressSpace }, expected: FetchTestResult.FAILURE, - }), prefix + 'not a private network request.'); + }), prefix + 'not a local network request.'); } -// Source: local secure context. +// Source: loopback secure context. // -// Fetches to the local and private address spaces cannot use +// Fetches to the loopback and local address spaces cannot use // `targetAddressSpace` to bypass mixed content, as they are not otherwise -// blocked by Private Network Access. +// blocked by Local Network Access. -makeNoBypassTests({ source: "local", target: "local" }); -makeNoBypassTests({ source: "local", target: "private" }); -makeNoBypassTests({ source: "local", target: "public" }); +makeNoBypassTests({ source: "loopback", target: "loopback" }); +makeNoBypassTests({ source: "loopback", target: "local" }); +makeNoBypassTests({ source: "loopback", target: "public" }); -// Source: private secure context. +// Source: local secure context. // -// Fetches to the local address space requires the right `targetAddressSpace` +// Fetches to the loopback address space requires the right `targetAddressSpace` // option, as well as a successful preflight response carrying a PNA-specific // header. // -// Fetches to the private address space cannot use `targetAddressSpace` to -// bypass mixed content, as they are not otherwise blocked by Private Network +// Fetches to the local address space cannot use `targetAddressSpace` to +// bypass mixed content, as they are not otherwise blocked by Local Network // Access. -makeTests({ source: "private", target: "local" }); +makeTests({ source: "local", target: "loopback" }); -makeNoBypassTests({ source: "private", target: "private" }); -makeNoBypassTests({ source: "private", target: "public" }); +makeNoBypassTests({ source: "local", target: "local" }); +makeNoBypassTests({ source: "local", target: "public" }); // Source: public secure context. // -// Fetches to the local and private address spaces require the right +// Fetches to the loopback and local address spaces require the right // `targetAddressSpace` option, as well as a successful preflight response // carrying a PNA-specific header. +makeTests({ source: "public", target: "loopback" }); makeTests({ source: "public", target: "local" }); -makeTests({ source: "public", target: "private" }); makeNoBypassTests({ source: "public", target: "public" }); -// These tests verify that documents fetched from the `local` address space yet -// carrying the `treat-as-public-address` CSP directive are treated as if they -// had been fetched from the `public` address space. +// These tests verify that documents fetched from the `loopback` address space +// yet carrying the `treat-as-public-address` CSP directive are treated as if +// they had been fetched from the `public` address space. -promise_test_parallel(t => fetchTest(t, { - source: { - server: Server.HTTPS_LOCAL, - treatAsPublic: true, - }, - target: { - server: Server.HTTP_LOCAL, - behavior: { - preflight: PreflightBehavior.optionalSuccess(token()), - response: ResponseBehavior.allowCrossOrigin(), - }, - }, - fetchOptions: { targetAddressSpace: "private" }, - expected: FetchTestResult.FAILURE, -}), 'https-treat-as-public to http-local: wrong targetAddressSpace "private".'); +promise_test_parallel( + t => fetchTest(t, { + source: { + server: Server.HTTPS_LOCAL, + treatAsPublic: true, + }, + target: { + server: Server.HTTP_LOCAL, + behavior: { + preflight: PreflightBehavior.optionalSuccess(token()), + response: ResponseBehavior.allowCrossOrigin(), + }, + }, + fetchOptions: {targetAddressSpace: 'local'}, + expected: FetchTestResult.FAILURE, + }), + 'https-treat-as-public to http-loopback: wrong targetAddressSpace "local".'); promise_test_parallel(t => fetchTest(t, { source: { @@ -240,9 +242,9 @@ promise_test_parallel(t => fetchTest(t, { response: ResponseBehavior.allowCrossOrigin(), }, }, - fetchOptions: { targetAddressSpace: "local" }, + fetchOptions: { targetAddressSpace: "loopback" }, expected: FetchTestResult.SUCCESS, -}), "https-treat-as-public to http-local: success."); +}), "https-treat-as-public to http-loopback: success."); promise_test_parallel(t => fetchTest(t, { source: { @@ -256,9 +258,9 @@ promise_test_parallel(t => fetchTest(t, { response: ResponseBehavior.allowCrossOrigin(), }, }, - fetchOptions: { targetAddressSpace: "local" }, + fetchOptions: { targetAddressSpace: "loopback" }, expected: FetchTestResult.FAILURE, -}), 'https-treat-as-public to http-private: wrong targetAddressSpace "local".'); +}), 'https-treat-as-public to http-local: wrong targetAddressSpace "loopback".'); promise_test_parallel(t => fetchTest(t, { source: { @@ -272,6 +274,6 @@ promise_test_parallel(t => fetchTest(t, { response: ResponseBehavior.allowCrossOrigin(), }, }, - fetchOptions: { targetAddressSpace: "private" }, + fetchOptions: { targetAddressSpace: "local" }, expected: FetchTestResult.SUCCESS, -}), "https-treat-as-public to http-private: success."); +}), "https-treat-as-public to http-local: success."); diff --git a/fetch/private-network-access/resources/support.sub.js b/fetch/private-network-access/resources/support.sub.js index 210184ec4b654e..c07fd2c2acee68 100644 --- a/fetch/private-network-access/resources/support.sub.js +++ b/fetch/private-network-access/resources/support.sub.js @@ -75,20 +75,20 @@ async function postMessageAndAwaitReply(target, message) { // Maps protocol (without the trailing colon) and address space to port. const SERVER_PORTS = { "http": { - "local": {{ports[http][0]}}, - "private": {{ports[http-private][0]}}, + "loopback": {{ports[http][0]}}, + "local": {{ports[http-private][0]}}, "public": {{ports[http-public][0]}}, }, "https": { - "local": {{ports[https][0]}}, - "private": {{ports[https-private][0]}}, + "loopback": {{ports[https][0]}}, + "local": {{ports[https-private][0]}}, "public": {{ports[https-public][0]}}, }, "ws": { - "local": {{ports[ws][0]}}, + "loopback": {{ports[ws][0]}}, }, "wss": { - "local": {{ports[wss][0]}}, + "loopback": {{ports[wss][0]}}, }, }; @@ -126,14 +126,14 @@ class Server { }; } - static HTTP_LOCAL = Server.get("http", "local"); - static HTTP_PRIVATE = Server.get("http", "private"); + static HTTP_LOCAL = Server.get("http", "loopback"); + static HTTP_PRIVATE = Server.get("http", "local"); static HTTP_PUBLIC = Server.get("http", "public"); - static HTTPS_LOCAL = Server.get("https", "local"); - static HTTPS_PRIVATE = Server.get("https", "private"); + static HTTPS_LOCAL = Server.get("https", "loopback"); + static HTTPS_PRIVATE = Server.get("https", "local"); static HTTPS_PUBLIC = Server.get("https", "public"); - static WS_LOCAL = Server.get("ws", "local"); - static WSS_LOCAL = Server.get("wss", "local"); + static WS_LOCAL = Server.get("ws", "loopback"); + static WSS_LOCAL = Server.get("wss", "loopback"); }; // Resolves a URL relative to the current location, returning an absolute URL.