From b0b70ec6b7e432738c3d3419d472e29df45c385d Mon Sep 17 00:00:00 2001 From: Ashwin Naren Date: Tue, 2 Sep 2025 10:19:10 -0700 Subject: [PATCH] Throw `SyntaxError` from `Location::SetHref` (#39051) It was originally throwing a TypeError, which was making WPT fail. Testing: Many happy WPT subtests Fixes: #39050 --------- Signed-off-by: Ashwin Naren Co-authored-by: Sam <16504129+sagudev@users.noreply.github.com> --- components/script/dom/location.rs | 8 +- .../navigating-across-documents/008.html.ini | 3 - .../navigating-across-documents/009.html.ini | 3 - .../empty-iframe-load-event.html.ini | 6 + .../navigate-to-unparseable-url.html.ini | 3 - ...tion-unload-cross-origin.sub.window.js.ini | 3 - ...avigation-unload-same-origin.window.js.ini | 3 - .../replace-before-load/a-click.html.ini | 3 - tests/wpt/meta/url/failure.html.ini | 588 ------------------ 9 files changed, 10 insertions(+), 610 deletions(-) delete mode 100644 tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/008.html.ini delete mode 100644 tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/009.html.ini create mode 100644 tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/empty-iframe-load-event.html.ini delete mode 100644 tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-cross-origin.sub.window.js.ini delete mode 100644 tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.js.ini delete mode 100644 tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html.ini diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs index cf8dbe9397d..9d3f463e92e 100644 --- a/components/script/dom/location.rs +++ b/components/script/dom/location.rs @@ -412,14 +412,14 @@ impl LocationMethods for Location { // Step 1: If this Location object's relevant Document is null, then return. if self.has_document() { // Note: no call to self.check_same_origin_domain() - // Step 2: Parse the given value relative to the entry settings object. - // If that failed, throw a TypeError exception. + // Step 2: Let url be the result of encoding-parsing a URL given the given value, relative to the entry settings object. + // Step 3: If url is failure, then throw a "SyntaxError" DOMException. let base_url = self.entry_settings_object().api_base_url(); let url = match base_url.join(&value.0) { Ok(url) => url, - Err(e) => return Err(Error::Type(format!("Couldn't parse URL: {}", e))), + Err(e) => return Err(Error::Syntax(Some(format!("Couldn't parse URL: {}", e)))), }; - // Step 3: Location-object navigate to the resulting URL record. + // Step 4: Location-object navigate this to url. self.navigate( url, NavigationHistoryBehavior::Push, diff --git a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/008.html.ini b/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/008.html.ini deleted file mode 100644 index c253f779d78..00000000000 --- a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/008.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[008.html] - [Link with onclick form submit to javascript url and href navigation ] - expected: FAIL diff --git a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/009.html.ini b/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/009.html.ini deleted file mode 100644 index 3fb21c9b2c6..00000000000 --- a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/009.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[009.html] - [Link with onclick form submit to javascript url with document.write and href navigation ] - expected: FAIL diff --git a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/empty-iframe-load-event.html.ini b/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/empty-iframe-load-event.html.ini new file mode 100644 index 00000000000..3e07e6b7d1f --- /dev/null +++ b/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/empty-iframe-load-event.html.ini @@ -0,0 +1,6 @@ +[empty-iframe-load-event.html] + [Check execution order from nested timeout] + expected: FAIL + + [Check execution order on load handler] + expected: FAIL diff --git a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigate-to-unparseable-url.html.ini b/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigate-to-unparseable-url.html.ini index 27889a98fb5..8d5926a9158 100644 --- a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigate-to-unparseable-url.html.ini +++ b/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigate-to-unparseable-url.html.ini @@ -1,6 +1,3 @@ [navigate-to-unparseable-url.html] - [location.href setter throws a SyntaxError DOMException for unparseable URLs] - expected: FAIL - [ tag navigate fails for unparseable URLs] expected: FAIL diff --git a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-cross-origin.sub.window.js.ini b/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-cross-origin.sub.window.js.ini deleted file mode 100644 index 4ecd6d9f753..00000000000 --- a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-cross-origin.sub.window.js.ini +++ /dev/null @@ -1,3 +0,0 @@ -[navigation-unload-cross-origin.sub.window.html] - [Cross-origin navigation started from unload handler must be ignored] - expected: FAIL diff --git a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.js.ini b/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.js.ini deleted file mode 100644 index 7dc346632a4..00000000000 --- a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.js.ini +++ /dev/null @@ -1,3 +0,0 @@ -[navigation-unload-same-origin.window.html] - [Same-origin navigation started from unload handler must be ignored] - expected: FAIL diff --git a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html.ini b/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html.ini deleted file mode 100644 index 60a4fa51f8a..00000000000 --- a/tests/wpt/meta/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[a-click.html] - [aElement.click() before the load event must NOT replace] - expected: FAIL diff --git a/tests/wpt/meta/url/failure.html.ini b/tests/wpt/meta/url/failure.html.ini index e49fb61f308..6a4b85e1ca9 100644 --- a/tests/wpt/meta/url/failure.html.ini +++ b/tests/wpt/meta/url/failure.html.ini @@ -131,519 +131,6 @@ [window.open(): foo://ho|st/ should throw] expected: FAIL - [Location's href: http://ho%7Cst/ should throw] - expected: FAIL - - [Location's href: file://%43%7C should throw] - expected: FAIL - - [Location's href: file://%43| should throw] - expected: FAIL - - [Location's href: file://C%7C should throw] - expected: FAIL - - [Location's href: file://%43%7C/ should throw] - expected: FAIL - - [Location's href: https://%43%7C/ should throw] - expected: FAIL - - [Location's href: asdf://%43|/ should throw] - expected: FAIL - - [Location's href: http://0..0x300/ should throw] - expected: FAIL - - [Location's href: http://0..0x300./ should throw] - expected: FAIL - - [Location's href: http://1.2.3.08 should throw] - expected: FAIL - - [Location's href: http://1.2.3.08. should throw] - expected: FAIL - - [Location's href: http://1.2.3.09 should throw] - expected: FAIL - - [Location's href: http://09.2.3.4 should throw] - expected: FAIL - - [Location's href: http://09.2.3.4. should throw] - expected: FAIL - - [Location's href: http://01.2.3.4.5 should throw] - expected: FAIL - - [Location's href: http://01.2.3.4.5. should throw] - expected: FAIL - - [Location's href: http://0x1.2.3.4.5 should throw] - expected: FAIL - - [Location's href: http://0x1.2.3.4.5. should throw] - expected: FAIL - - [Location's href: http://foo.1.2.3.4 should throw] - expected: FAIL - - [Location's href: http://foo.1.2.3.4. should throw] - expected: FAIL - - [Location's href: http://foo.2.3.4 should throw] - expected: FAIL - - [Location's href: http://foo.2.3.4. should throw] - expected: FAIL - - [Location's href: http://foo.09 should throw] - expected: FAIL - - [Location's href: http://foo.09. should throw] - expected: FAIL - - [Location's href: http://foo.0x4 should throw] - expected: FAIL - - [Location's href: http://foo.0x4. should throw] - expected: FAIL - - [Location's href: http://0999999999999999999/ should throw] - expected: FAIL - - [Location's href: http://foo.0x should throw] - expected: FAIL - - [Location's href: http://foo.0XFfFfFfFfFfFfFfFfFfAcE123 should throw] - expected: FAIL - - [Location's href: http://💩.123/ should throw] - expected: FAIL - - [Location's href: sc://a|b/ should throw] - expected: FAIL - - [Location's href: http://a\x01b/ should throw] - expected: FAIL - - [Location's href: http://a\x02b/ should throw] - expected: FAIL - - [Location's href: http://a\x03b/ should throw] - expected: FAIL - - [Location's href: http://a\x04b/ should throw] - expected: FAIL - - [Location's href: http://a\x05b/ should throw] - expected: FAIL - - [Location's href: http://a\x06b/ should throw] - expected: FAIL - - [Location's href: http://a\x07b/ should throw] - expected: FAIL - - [Location's href: http://a\x08b/ should throw] - expected: FAIL - - [Location's href: http://a\x0bb/ should throw] - expected: FAIL - - [Location's href: http://a\x0cb/ should throw] - expected: FAIL - - [Location's href: http://a\x0eb/ should throw] - expected: FAIL - - [Location's href: http://a\x0fb/ should throw] - expected: FAIL - - [Location's href: http://a\x10b/ should throw] - expected: FAIL - - [Location's href: http://a\x11b/ should throw] - expected: FAIL - - [Location's href: http://a\x12b/ should throw] - expected: FAIL - - [Location's href: http://a\x13b/ should throw] - expected: FAIL - - [Location's href: http://a\x14b/ should throw] - expected: FAIL - - [Location's href: http://a\x15b/ should throw] - expected: FAIL - - [Location's href: http://a\x16b/ should throw] - expected: FAIL - - [Location's href: http://a\x17b/ should throw] - expected: FAIL - - [Location's href: http://a\x18b/ should throw] - expected: FAIL - - [Location's href: http://a\x19b/ should throw] - expected: FAIL - - [Location's href: http://a\x1ab/ should throw] - expected: FAIL - - [Location's href: http://a\x1bb/ should throw] - expected: FAIL - - [Location's href: http://a\x1cb/ should throw] - expected: FAIL - - [Location's href: http://a\x1db/ should throw] - expected: FAIL - - [Location's href: http://a\x1eb/ should throw] - expected: FAIL - - [Location's href: http://a\x1fb/ should throw] - expected: FAIL - - [Location's href: http://a|b/ should throw] - expected: FAIL - - [Location's href: http://ab/ should throw] - expected: FAIL - - [Location's href: http://ho%01st/ should throw] - expected: FAIL - - [Location's href: http://ho%02st/ should throw] - expected: FAIL - - [Location's href: http://ho%03st/ should throw] - expected: FAIL - - [Location's href: http://ho%04st/ should throw] - expected: FAIL - - [Location's href: http://ho%05st/ should throw] - expected: FAIL - - [Location's href: http://ho%06st/ should throw] - expected: FAIL - - [Location's href: http://ho%07st/ should throw] - expected: FAIL - - [Location's href: http://ho%08st/ should throw] - expected: FAIL - - [Location's href: http://ho%0Bst/ should throw] - expected: FAIL - - [Location's href: http://ho%0Cst/ should throw] - expected: FAIL - - [Location's href: http://ho%0Est/ should throw] - expected: FAIL - - [Location's href: http://ho%0Fst/ should throw] - expected: FAIL - - [Location's href: http://ho%10st/ should throw] - expected: FAIL - - [Location's href: http://ho%11st/ should throw] - expected: FAIL - - [Location's href: http://ho%12st/ should throw] - expected: FAIL - - [Location's href: http://ho%13st/ should throw] - expected: FAIL - - [Location's href: http://ho%14st/ should throw] - expected: FAIL - - [Location's href: http://ho%15st/ should throw] - expected: FAIL - - [Location's href: http://ho%16st/ should throw] - expected: FAIL - - [Location's href: http://ho%17st/ should throw] - expected: FAIL - - [Location's href: http://ho%18st/ should throw] - expected: FAIL - - [Location's href: http://ho%19st/ should throw] - expected: FAIL - - [Location's href: http://ho%1Ast/ should throw] - expected: FAIL - - [Location's href: http://ho%1Bst/ should throw] - expected: FAIL - - [Location's href: http://ho%1Cst/ should throw] - expected: FAIL - - [Location's href: http://ho%1Dst/ should throw] - expected: FAIL - - [Location's href: http://ho%1Est/ should throw] - expected: FAIL - - [Location's href: http://ho%1Fst/ should throw] - expected: FAIL - - [Location's href: http://ho%7Fst/ should throw] - expected: FAIL - - [Location's href: file://example:1/ should throw] - expected: FAIL - - [Location's href: file://example:test/ should throw] - expected: FAIL - - [Location's href: file://example%/ should throw] - expected: FAIL - - [Location's href: file://[example\]/ should throw] - expected: FAIL - - [Location's href: http://user:pass@/ should throw] - expected: FAIL - - [Location's href: http://foo:-80/ should throw] - expected: FAIL - - [Location's href: http://user@/www.example.com should throw] - expected: FAIL - - [Location's href: http://@/www.example.com should throw] - expected: FAIL - - [Location's href: http://a:b@/www.example.com should throw] - expected: FAIL - - [Location's href: http://@:www.example.com should throw] - expected: FAIL - - [Location's href: https://� should throw] - expected: FAIL - - [Location's href: https://%EF%BF%BD should throw] - expected: FAIL - - [Location's href: http://a.b.c.xn--pokxncvks should throw] - expected: FAIL - - [Location's href: http://10.0.0.xn--pokxncvks should throw] - expected: FAIL - - [Location's href: http://a.b.c.XN--pokxncvks should throw] - expected: FAIL - - [Location's href: http://a.b.c.Xn--pokxncvks should throw] - expected: FAIL - - [Location's href: http://10.0.0.XN--pokxncvks should throw] - expected: FAIL - - [Location's href: http://10.0.0.xN--pokxncvks should throw] - expected: FAIL - - [Location's href: https://x x:12 should throw] - expected: FAIL - - [Location's href: http://[www.google.com\]/ should throw] - expected: FAIL - - [Location's href: sc://@/ should throw] - expected: FAIL - - [Location's href: sc://te@s:t@/ should throw] - expected: FAIL - - [Location's href: sc://:/ should throw] - expected: FAIL - - [Location's href: sc://:12/ should throw] - expected: FAIL - - [Location's href: sc://a\x00b/ should throw] - expected: FAIL - - [Location's href: sc://a b/ should throw] - expected: FAIL - - [Location's href: sc://ab should throw] - expected: FAIL - - [Location's href: sc://a[b/ should throw] - expected: FAIL - - [Location's href: sc://a\\b/ should throw] - expected: FAIL - - [Location's href: sc://a\]b/ should throw] - expected: FAIL - - [Location's href: sc://a^b should throw] - expected: FAIL - - [Location's href: http://a\x00b/ should throw] - expected: FAIL - - [Location's href: http://a b/ should throw] - expected: FAIL - - [Location's href: http://a%b/ should throw] - expected: FAIL - - [Location's href: http://ab should throw] - expected: FAIL - - [Location's href: http://a[b/ should throw] - expected: FAIL - - [Location's href: http://a\]b/ should throw] - expected: FAIL - - [Location's href: http://a^b should throw] - expected: FAIL - - [Location's href: http://ho%00st/ should throw] - expected: FAIL - - [Location's href: http://ho%09st/ should throw] - expected: FAIL - - [Location's href: http://ho%0Ast/ should throw] - expected: FAIL - - [Location's href: http://ho%0Dst/ should throw] - expected: FAIL - - [Location's href: http://ho%20st/ should throw] - expected: FAIL - - [Location's href: http://ho%23st/ should throw] - expected: FAIL - - [Location's href: http://ho%25st/ should throw] - expected: FAIL - - [Location's href: http://ho%2Fst/ should throw] - expected: FAIL - - [Location's href: http://ho%3Ast/ should throw] - expected: FAIL - - [Location's href: http://ho%3Cst/ should throw] - expected: FAIL - - [Location's href: http://ho%3Est/ should throw] - expected: FAIL - - [Location's href: http://ho%3Fst/ should throw] - expected: FAIL - - [Location's href: http://ho%40st/ should throw] - expected: FAIL - - [Location's href: http://ho%5Bst/ should throw] - expected: FAIL - - [Location's href: http://ho%5Cst/ should throw] - expected: FAIL - - [Location's href: http://ho%5Dst/ should throw] - expected: FAIL - - [Location's href: ftp://example.com%80/ should throw] - expected: FAIL - - [Location's href: ftp://example.com%A0/ should throw] - expected: FAIL - - [Location's href: https://example.com%80/ should throw] - expected: FAIL - - [Location's href: https://example.com%A0/ should throw] - expected: FAIL - - [Location's href: https://0x100000000/test should throw] - expected: FAIL - - [Location's href: https://256.0.0.1/test should throw] - expected: FAIL - - [Location's href: file://%43%3A should throw] - expected: FAIL - - [Location's href: https://[0::0::0\] should throw] - expected: FAIL - - [Location's href: https://[0:.0\] should throw] - expected: FAIL - - [Location's href: https://[0:0:\] should throw] - expected: FAIL - - [Location's href: https://[0:1:2:3:4:5:6:7.0.0.0.1\] should throw] - expected: FAIL - - [Location's href: https://[0:1.00.0.0.0\] should throw] - expected: FAIL - - [Location's href: https://[0:1.290.0.0.0\] should throw] - expected: FAIL - - [Location's href: https://[0:1.23.23\] should throw] - expected: FAIL - - [Location's href: http://? should throw] - expected: FAIL - - [Location's href: http://# should throw] - expected: FAIL - - [Location's href: non-special://[:80/ should throw] - expected: FAIL - - [Location's href: http://[::127.0.0.0.1\] should throw] - expected: FAIL - - [Location's href: file://­/p should throw] - expected: FAIL - - [Location's href: file://%C2%AD/p should throw] - expected: FAIL - - [Location's href: file://xn--/p should throw] - expected: FAIL - - [Location's href: http://0x100.2.3.4 should throw] - expected: FAIL - - [Location's href: http://0x100.2.3.4. should throw] - expected: FAIL - - [Location's href: https://\x00y should throw] - expected: FAIL - - [Location's href: https://￿y should throw] - expected: FAIL - [XHR: should throw] expected: FAIL @@ -652,78 +139,3 @@ [window.open(): should throw] expected: FAIL - - [Location's href: https://­/ should throw] - expected: FAIL - - [Location's href: https://%C2%AD/ should throw] - expected: FAIL - - [Location's href: https://xn--/ should throw] - expected: FAIL - - [Location's href: data://:443 should throw] - expected: FAIL - - [Location's href: data://test:test should throw] - expected: FAIL - - [Location's href: data://[:1\] should throw] - expected: FAIL - - [Location's href: javascript://:443 should throw] - expected: FAIL - - [Location's href: javascript://test:test should throw] - expected: FAIL - - [Location's href: javascript://[:1\] should throw] - expected: FAIL - - [Location's href: mailto://:443 should throw] - expected: FAIL - - [Location's href: mailto://test:test should throw] - expected: FAIL - - [Location's href: mailto://[:1\] should throw] - expected: FAIL - - [Location's href: intent://:443 should throw] - expected: FAIL - - [Location's href: intent://test:test should throw] - expected: FAIL - - [Location's href: intent://[:1\] should throw] - expected: FAIL - - [Location's href: urn://:443 should throw] - expected: FAIL - - [Location's href: urn://test:test should throw] - expected: FAIL - - [Location's href: urn://[:1\] should throw] - expected: FAIL - - [Location's href: turn://:443 should throw] - expected: FAIL - - [Location's href: turn://test:test should throw] - expected: FAIL - - [Location's href: turn://[:1\] should throw] - expected: FAIL - - [Location's href: stun://:443 should throw] - expected: FAIL - - [Location's href: stun://test:test should throw] - expected: FAIL - - [Location's href: stun://[:1\] should throw] - expected: FAIL - - [Location's href: non-special://host\\a should throw] - expected: FAIL