Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases for URL empty query and fragment #25829

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions url/resources/a-element-origin.js
Expand Up @@ -5,8 +5,7 @@ function setBase(base) {
}

function bURL(url, base) {
base = base || "about:blank"
setBase(base)
if (base) setBase(base)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work. It will leave the base URL for the document as the URL it is loaded in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we would have to skip this type of test when the base is lacking (and say we do it because you cannot unset the base URL of a document).

var a = document.createElement("a")
a.setAttribute("href", url)
return a
Expand Down
3 changes: 1 addition & 2 deletions url/resources/a-element.js
Expand Up @@ -5,8 +5,7 @@ function setBase(base) {
}

function bURL(url, base) {
base = base || "about:blank"
setBase(base)
if (base) setBase(base)
var a = document.createElement("a")
a.setAttribute("href", url)
return a
Expand Down
9 changes: 9 additions & 0 deletions url/resources/urltestdata.json
Expand Up @@ -7216,5 +7216,14 @@
"protocol": "https:",
"search": "",
"username": "user"
},
"Empty query and fragment with blank should throw an error",
{
"input": "#",
"failure": true
},
{
"input": "?",
"failure": true
}
]
2 changes: 1 addition & 1 deletion url/url-constructor.html
Expand Up @@ -5,7 +5,7 @@
<div id=log></div>
<script>
function bURL(url, base) {
return new URL(url, base || "about:blank")
return base ? new URL(url, base) : new URL(url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does work.

}

function runURLTests(urltests) {
Expand Down
2 changes: 1 addition & 1 deletion url/url-origin.html
Expand Up @@ -7,7 +7,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) {
Expand Down