From 9ac644d7f73bef6926ba260c6129b6541bc3b737 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Sat, 17 Jul 2021 09:46:38 +0000 Subject: [PATCH] Bug 1719182 [wpt PR 29579] - Updated PR for URL empty query and fragment tests, a=testonly Automatic update from web-platform-tests Test URLs with empty query and fragment Closes https://github.com/whatwg/url/issues/539. Closes https://github.com/web-platform-tests/wpt/pull/25829 by superseding it. Co-authored-by: Daijiro Wachi -- wpt-commits: 6315c7757a6675f39262167c8196ce562f2a6778 wpt-pr: 29579 --- .../tests/url/resources/a-element-origin.js | 2 ++ testing/web-platform/tests/url/resources/a-element.js | 2 ++ .../web-platform/tests/url/resources/urltestdata.json | 11 +++++++++++ testing/web-platform/tests/url/url-constructor.any.js | 2 +- testing/web-platform/tests/url/url-origin.any.js | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/testing/web-platform/tests/url/resources/a-element-origin.js b/testing/web-platform/tests/url/resources/a-element-origin.js index 3b8cb1cbbe7c..cb7d4a895c40 100644 --- a/testing/web-platform/tests/url/resources/a-element-origin.js +++ b/testing/web-platform/tests/url/resources/a-element-origin.js @@ -16,6 +16,8 @@ function runURLTests(urltests) { for(var i = 0, l = urltests.length; i < l; i++) { var expected = urltests[i] if (typeof expected === "string" || !("origin" in expected)) continue + // skip without base because you cannot unset the baseURL of a document + if (expected.base === null) continue; test(function() { var url = bURL(expected.input, expected.base) diff --git a/testing/web-platform/tests/url/resources/a-element.js b/testing/web-platform/tests/url/resources/a-element.js index f64531bc8bd5..553855a870c5 100644 --- a/testing/web-platform/tests/url/resources/a-element.js +++ b/testing/web-platform/tests/url/resources/a-element.js @@ -16,6 +16,8 @@ function runURLTests(urltests) { for(var i = 0, l = urltests.length; i < l; i++) { var expected = urltests[i] if (typeof expected === "string") continue // skip comments + // skip without base because you cannot unset the baseURL of a document + if (expected.base === null) continue; test(function() { var url = bURL(expected.input, expected.base) diff --git a/testing/web-platform/tests/url/resources/urltestdata.json b/testing/web-platform/tests/url/resources/urltestdata.json index a56b30caf98c..e346f87c3db4 100644 --- a/testing/web-platform/tests/url/resources/urltestdata.json +++ b/testing/web-platform/tests/url/resources/urltestdata.json @@ -8016,5 +8016,16 @@ "protocol": "abc:", "search": "", "username": "" + }, + "Empty query and fragment with blank should throw an error", + { + "input": "#", + "base": null, + "failure": true + }, + { + "input": "?", + "base": null, + "failure": true } ] diff --git a/testing/web-platform/tests/url/url-constructor.any.js b/testing/web-platform/tests/url/url-constructor.any.js index 3f4af56d2a96..dfa98092fa64 100644 --- a/testing/web-platform/tests/url/url-constructor.any.js +++ b/testing/web-platform/tests/url/url-constructor.any.js @@ -1,7 +1,7 @@ // META: timeout=long function bURL(url, base) { - return new URL(url, base || "about:blank") + return base ? new URL(url, base) : new URL(url) } function runURLTests(urltests) { diff --git a/testing/web-platform/tests/url/url-origin.any.js b/testing/web-platform/tests/url/url-origin.any.js index d9ef64c73b8b..9c1f97ed2e59 100644 --- a/testing/web-platform/tests/url/url-origin.any.js +++ b/testing/web-platform/tests/url/url-origin.any.js @@ -1,7 +1,7 @@ promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runURLTests), "Loading data…"); function bURL(url, base) { - return new URL(url, base || "about:blank") + return base ? new URL(url, base) : new URL(url) } function runURLTests(urltests) {