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

Change how invalid base URLs are tested #10955

Merged
merged 2 commits into from
May 14, 2018
Merged

Conversation

domenic
Copy link
Member

@domenic domenic commented May 10, 2018

Fixes #8707. Supercedes #10917, which it is based on.

This keeps the tests inside urltestdata.json, but adds a new requirement on consumers of that file that they should also test their base URL parsing logic by reusing the data in a different way.

It also rearranges the various cases from 90efdbe under several different headings.

/cc @GPHemsley and @TimothyGu especially to review the changes to the README to see if they're clear on how to maintain and improve coverage. Existing harnesses will lose coverage from this change, since urltestdata.json no longer tests the a, a/, and a// base URLs directly. But if they implement the tweak suggested in the README, they will gain coverage, testing not only those URLs as bases but also lots of others already in the file.

Fixes #8707. Supercedes #10917, which it is based on.

This keeps the tests inside urltestdata.json, but adds a new requirement on consumers of that file that they should also test their base URL parsing logic by reusing the data in a different way.

It also rearranges the various cases from 90efdbe under several different headings.
Copy link
Contributor

@GPHemsley GPHemsley left a comment

Choose a reason for hiding this comment

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

You've got invalid JSON here.

@@ -6521,27 +6521,34 @@
"search": "?a",
"hash": "#%GH"
},
"Bad bases",
"URLs that require a non-about:blank base. (Also serve as invalid base tests.)"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is missing a trailing comma.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I should actually test my changes against jsdom/whatwg-url as I do for everyone else's to this file -_-

"base": "a:b",
"failure": true
},
"Other base URL tests, that must succeed"
Copy link
Contributor

Choose a reason for hiding this comment

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

So is this.

@domenic
Copy link
Member Author

domenic commented May 14, 2018

JSON fixed; confirmed working in jsdom/whatwg-url#116. Filed nodejs/node#20720 to alert Node.js folks. Will merge this after Travis finishes.

@domenic domenic merged commit 88b7588 into master May 14, 2018
@domenic domenic deleted the move-url-invalid-base-tests branch May 14, 2018 17:48
domenic added a commit to jsdom/whatwg-url that referenced this pull request May 14, 2018
domenic added a commit to jsdom/whatwg-url that referenced this pull request May 14, 2018
@GPHemsley
Copy link
Contributor

I'd wanted to test these changes before I commented on the clarity of the readme... I'm not entirely clear on what's changing.

Are you saying that the base URL needs to be parsed the same as the input? And that failing to parse the base URL should fail the whole thing? If so, I think I already do that...

@domenic
Copy link
Member Author

domenic commented May 15, 2018

Sorry, I didn't realize :(.

That's basically what I'm saying, yes. I imagine most people already do this, but the test cases were previously not testing it explicitly. They had a few examples of invalid base URLs, but now we're encouraging testing all invalid URLs as invalid base URLs.

rmisev added a commit to upa-url/upa that referenced this pull request May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants