Automatic update from web-platform-tests url: Implement URL.canParse. The WPT is adjusted slightly since it currently exercises behavior it was presumably not intended to -- namely, the quirk we have on Windows where URLs which begin with a single letter and a colon are interpreted as file URLs relative to the given drive letter. The particulars of URL parsing are adequately tested elsewhere, and this test serves to demonstrate that URL.canParse(...) behaves the same way that new URL(...) does. Bug: 1425839 Change-Id: I13c425c1eaea791da2ccd2a1486112b5c2d6ad0b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4936216 Reviewed-by: Domenic Denicola <domenic@chromium.org> Commit-Queue: Jeremy Roman <jbroman@chromium.org> Cr-Commit-Position: refs/heads/main@{#1210014} -- wpt-commits: c2d7e70b52cbd9a5b938aa32f37078d7a71e0b21 wpt-pr: 42548
43 lines
768 B
JavaScript
43 lines
768 B
JavaScript
// This intentionally does not use resources/urltestdata.json to preserve resources.
|
|
[
|
|
{
|
|
"url": undefined,
|
|
"base": undefined,
|
|
"expected": false
|
|
},
|
|
{
|
|
"url": "aaa:b",
|
|
"base": undefined,
|
|
"expected": true
|
|
},
|
|
{
|
|
"url": undefined,
|
|
"base": "aaa:b",
|
|
"expected": false
|
|
},
|
|
{
|
|
"url": "aaa:/b",
|
|
"base": undefined,
|
|
"expected": true
|
|
},
|
|
{
|
|
"url": undefined,
|
|
"base": "aaa:/b",
|
|
"expected": true
|
|
},
|
|
{
|
|
"url": "https://test:test",
|
|
"base": undefined,
|
|
"expected": false
|
|
},
|
|
{
|
|
"url": "a",
|
|
"base": "https://b/",
|
|
"expected": true
|
|
}
|
|
].forEach(({ url, base, expected }) => {
|
|
test(() => {
|
|
assert_equals(URL.canParse(url, base), expected);
|
|
}, `URL.canParse(${url}, ${base})`);
|
|
});
|