1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

LibWeb/Tests: Support URL tests with an input base

This commit is contained in:
Shannon Booth 2023-09-17 13:41:14 +12:00 committed by Andreas Kling
parent ef27750982
commit 791ad12031
2 changed files with 20 additions and 16 deletions

View file

@ -1,4 +1,4 @@
ftp://serenityos.org:21
new URL('ftp://serenityos.org:21', undefined)
protocol => 'ftp:'
username => ''
password => ''
@ -8,7 +8,7 @@ port => ''
pathname => '/'
search => ''
hash => ''
http://[0:1:0:1:0:1:0:1]
new URL('http://[0:1:0:1:0:1:0:1]', undefined)
protocol => 'http:'
username => ''
password => ''
@ -18,7 +18,7 @@ port => ''
pathname => '/'
search => ''
hash => ''
http://[1:0:1:0:1:0:1:0]
new URL('http://[1:0:1:0:1:0:1:0]', undefined)
protocol => 'http:'
username => ''
password => ''
@ -28,7 +28,7 @@ port => ''
pathname => '/'
search => ''
hash => ''
http://[1:1:0:0:1:0:0:0]/
new URL('http://[1:1:0:0:1:0:0:0]/', undefined)
protocol => 'http:'
username => ''
password => ''
@ -38,7 +38,7 @@ port => ''
pathname => '/'
search => ''
hash => ''
unknown://serenityos.org:0
new URL('unknown://serenityos.org:0', undefined)
protocol => 'unknown:'
username => ''
password => ''
@ -48,7 +48,7 @@ port => '0'
pathname => ''
search => ''
hash => ''
http://serenityos.org/cat?dog#meow"woof
new URL('http://serenityos.org/cat?dog#meow"woof', undefined)
protocol => 'http:'
username => ''
password => ''

View file

@ -1,9 +1,13 @@
<script src="../include.js"></script>
<script>
test(() => {
function printURL(input) {
println(input);
const url = new URL(input);
function printURL(input, base) {
if (base === undefined)
println(`new URL('${input}', ${base})`);
else
println(`new URL('${input}', '${base}')`);
const url = new URL(input, base);
println(`protocol => '${url.protocol}'`);
println(`username => '${url.username}'`);
println(`password => '${url.password}'`);
@ -16,14 +20,14 @@
}
for (url of [
'ftp://serenityos.org:21',
'http://[0:1:0:1:0:1:0:1]',
'http://[1:0:1:0:1:0:1:0]',
'http://[1:1:0:0:1:0:0:0]/',
'unknown://serenityos.org:0',
'http://serenityos.org/cat?dog#meow"woof',
{ input: 'ftp://serenityos.org:21' },
{ input: 'http://[0:1:0:1:0:1:0:1]' },
{ input: 'http://[1:0:1:0:1:0:1:0]' },
{ input: 'http://[1:1:0:0:1:0:0:0]/' },
{ input: 'unknown://serenityos.org:0' },
{ input: 'http://serenityos.org/cat?dog#meow"woof' },
]) {
printURL(url);
printURL(url.input, url.base);
}
});
</script>