tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 5901f1af290ff676d02e345ade3d04acf7856709
parent 803cdba74549c43b66a01ff9454e89f4cf9c6f44
Author: Mike West <mkwst@chromium.org>
Date:   Thu, 27 Nov 2025 15:27:34 +0000

Bug 2002585 [wpt PR 56301] - [Origin API] Drop string parsers beyond `.from(...)`., a=testonly

Automatic update from web-platform-tests
[Origin API] Drop string parsers beyond `.from(...)`.

Earlier versions of this API parsed strings into `Origin` objects via
the constructor, `fromURL()` and `parse()`. We've since coalesced all of
these into `Origin.from(...)` after discussion in [1].

This CL removes these variants from our implementation, and adjusts
tests accordingly.

[1]: https://github.com/whatwg/html/pull/11846

Bug: 434131026
Change-Id: I8be1e1a0923b2cd48dcc7a0f80358237ecc9b88c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7204253
Commit-Queue: Mike West <mkwst@chromium.org>
Reviewed-by: Antonio Sartori <antoniosartori@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1550470}

--

wpt-commits: 9aa13c356b3bee9ced909da99c4de1373dfd8087
wpt-pr: 56301

Diffstat:
Mtesting/web-platform/tests/html/browsers/origin/tentative/api/origin-comparison.any.js | 20+++++++++++---------
Dtesting/web-platform/tests/html/browsers/origin/tentative/api/origin-fromURL.any.js | 71-----------------------------------------------------------------------
Dtesting/web-platform/tests/html/browsers/origin/tentative/api/origin.any.js | 80-------------------------------------------------------------------------------
Mtesting/web-platform/tests/interfaces/origin.tentative.idl | 4+---
4 files changed, 12 insertions(+), 163 deletions(-)

diff --git a/testing/web-platform/tests/html/browsers/origin/tentative/api/origin-comparison.any.js b/testing/web-platform/tests/html/browsers/origin/tentative/api/origin-comparison.any.js @@ -1,8 +1,10 @@ // META: title=`Origin` comparison test(t => { - const opaqueA = new Origin("null"); - const opaqueB = new Origin("null"); + const opaqueA = new Origin(); + const opaqueB = new Origin(); + assert_true(opaqueA.opaque); + assert_true(opaqueB.opaque); assert_true(opaqueA.isSameOrigin(opaqueA), "Opaque origin should be same-origin with itself."); assert_true(opaqueA.isSameSite(opaqueA), "Opaque origin should be same-site with itself."); @@ -11,11 +13,11 @@ test(t => { }, "Comparison of opaque origins."); test(t => { - const a = new Origin("https://a.example"); - const a_a = new Origin("https://a.a.example"); - const b_a = new Origin("https://b.a.example"); - const b = new Origin("https://b.example"); - const b_b = new Origin("https://b.b.example"); + const a = Origin.from("https://a.example"); + const a_a = Origin.from("https://a.a.example"); + const b_a = Origin.from("https://b.a.example"); + const b = Origin.from("https://b.example"); + const b_b = Origin.from("https://b.b.example"); assert_true(a.isSameOrigin(a), "Origin should be same-origin with itself."); assert_false(a.isSameOrigin(a_a), "Origins with different subdomains should not be same-origin."); @@ -37,8 +39,8 @@ test(t => { }, "Comparison of tuple origins."); test(t => { - const http = new Origin("http://a.example"); - const https = new Origin("https://a.example"); + const http = Origin.from("http://a.example"); + const https = Origin.from("https://a.example"); assert_false(http.isSameOrigin(https), "http is not same-site with https"); assert_false(https.isSameOrigin(http), "https is not same-site with http"); diff --git a/testing/web-platform/tests/html/browsers/origin/tentative/api/origin-fromURL.any.js b/testing/web-platform/tests/html/browsers/origin/tentative/api/origin-fromURL.any.js @@ -1,71 +0,0 @@ -// META: title=`Origin.fromURL()` - -// -// URLs with opaque origins: -// -const opaqueURLs = [ - "about:blank", - "data:text/plain,opaque", - "weird-protocol:whatever", - "weird-hierarchical-protocol://host/path?etc", - "blob:weird-protocol:whatever", - "blob:weird-hierarchical-protocol://host/path?etc", -]; -for (const opaque of opaqueURLs) { - test(t => { - const origin = Origin.fromURL(opaque); - assert_true(origin.opaque, "Origin should be opaque."); - }, `Origin.fromURL for opaque URL as string '${opaque}'.`); - - test(t => { - const origin = Origin.fromURL(new URL(opaque)); - assert_true(origin.opaque, "Origin should be opaque."); - }, `Origin.fromURL for opaque URL as URL '${opaque}'.`); -} - -// -// Invalid serializations: -// -const invalidSerializations = [ - "", - "invalid", -]; - -for (const invalid of invalidSerializations) { - test(t => { - assert_equals(null, Origin.fromURL(invalid)); - }, `Origin.fromURL returns null for '${invalid}'.`); -} - -// -// Tuple origins: -// -const tupleSerializations = [ - "http://site.example", - "https://site.example", - "https://site.example:123", - "http://sub.site.example", - "https://sub.site.example", - "https://sub.site.example:123", - "https://xn--mlauted-m2a.example", - "ftp://ftp.example", - "ws://ws.example", - "wss://wss.example", - "https://trailing.slash/", - "https://user:pass@site.example", - "https://has.a.port:1234/and/path", - "https://ümlauted.example", - "file:///path/to/a/file.txt", - "blob:https://example.com/some-guid", - "ftp://example.com/", - "https://example.com/path?query#fragment", - "https://127.0.0.1/", - "https://[::1]/", -]; - -for (const tuple of tupleSerializations) { - test(t => { - const origin = Origin.fromURL(tuple); - assert_false(origin.opaque, "Origin should not be opaque."); - }, `Origin constructed from '${tuple}' is a tuple origin.`); -} diff --git a/testing/web-platform/tests/html/browsers/origin/tentative/api/origin.any.js b/testing/web-platform/tests/html/browsers/origin/tentative/api/origin.any.js @@ -1,80 +0,0 @@ -// META: title=`Origin` Construction and Parsing - -// -// Opaque origins: -// -test(t => { - const origin = new Origin(); - assert_true(origin.opaque, "Origin should be opaque."); -}, "Default-constructed Origin is opaque."); - -test(t => { - const origin = new Origin("null"); - assert_true(origin.opaque, "Origin should be opaque."); -}, "Origin constructed with 'null' is opaque."); - -test(t => { - const origin = Origin.parse("null"); - assert_true(origin.opaque, "Origin should be opaque."); -}, "Origin parsed from 'null' is opaque."); - -// -// Invalid serializations: -// -const invalidSerializations = [ - "", - "invalid", - "about:blank", - "https://trailing.slash/", - "https://user:pass@site.example", - "https://has.a.port:1234/and/path", - "https://ümlauted.example", - "https://has.a.fragment/#frag", - "https://invalid.port:123456789", - "blob:https://blob.example/guid-goes-here", -]; - -for (const invalid of invalidSerializations) { - test(t => { - assert_throws_js(TypeError, () => new Origin(invalid), "Constructor should throw TypeError for invalid origin."); - }, `Origin constructor throws for '${invalid}'.`); - - test(t => { - assert_equals(Origin.parse(invalid), null, "parse() should return null for invalid origin."); - }, `Origin.parse returns null for '${invalid}'.`); -} - -// -// Tuple origins: -// -const tupleSerializations = [ - "http://site.example", - "https://site.example", - "https://site.example:123", - "http://sub.site.example", - "https://sub.site.example", - "https://sub.site.example:123", - "https://xn--mlauted-m2a.example", - "ftp://ftp.example", - "ws://ws.example", - "wss://wss.example", -]; - -for (const tuple of tupleSerializations) { - test(t => { - const origin = new Origin(tuple); - assert_false(origin.opaque, "Origin should not be opaque."); - }, `Origin constructed from '${tuple}' is a tuple origin.`); - - test(t => { - const origin = Origin.parse(tuple); - assert_false(origin.opaque, "Origin should not be opaque."); - }, `Origin parsed from '${tuple}' is a tuple origin.`); - - test(t => { - const a = new Origin(tuple); - const b = Origin.parse(tuple); - assert_true(a.isSameOrigin(b)); - assert_true(b.isSameOrigin(a)); - }, `Origins parsed and constructed from '${tuple}' are equivalent.`); -} diff --git a/testing/web-platform/tests/interfaces/origin.tentative.idl b/testing/web-platform/tests/interfaces/origin.tentative.idl @@ -2,10 +2,8 @@ [Exposed=*] interface Origin { constructor(); - constructor(USVString serializedOrigin); - static Origin? parse(USVString serializedOrigin); - static Origin? fromURL(USVString serializedURL); + static Origin from(any value); readonly attribute boolean opaque;