-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 tests for URL setters #2830
Conversation
Reviewers for this pull request are: @Sebmaster, @domenic, @frewsxcv, @mikewest, @rubys, @sideshowbarker, @smola, @tomalec, @xiaojunwu, and @zcorpan. |
Critic review: https://critic.hoppipolla.co.uk/r/6391 This is an external review system which you may optionally use for the code review of your pull request. In order to help critic track your changes, please do not make in-place history rewrites (e.g. via |
The deviations are only for whatwg/url#104 right? |
That and whatwg/url#113 and whatwg/url#114. |
for (var attr in test_case.expected) { | ||
assert_equals(url[attr], test_case.expected[attr]) | ||
} | ||
}, "Setting <" + test_case.href + ">." + attr + " = '" + test_case.new_value + "' " + test_case.comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't append comment if it's undefined
I ran this against https://github.com/jsdom/whatwg-url and got the following failures:
Some of these may be bugs in jsdom/whatwg-url; after all, we didn't have tests. Some of them are noted as spect violations already. But some of them seem like potential test bugs. For example, I cannot find any spec support for
|
A bunch of tests were fixed by adding a try/catch around the setter line. It seems like the test format does not encode cases where the setter throws, instead just leaving them as expected = result of parsing href. I think it should instead have an explicit |
OK, I found one bug in our scheme parsing state. The remaining list of things where either jsdom/whatwg-url has a bug or the spec is not matched, accounting for the failure to distinguish throwing setters from no-ops as mentioned above, is these four:
I count two spec deviations plus the problem I mentioned above where I can't find where in the spec the port number is removed if empty is the new value. |
Re undefined comment and shadowing The Re exceptions, none of the setters (except |
Yeah, probably; we could just wait to land this until the spec gets updated, of course.
Oh, very interesting. @Sebmaster any reason we implemented this as throws? |
Seems like we've been doing this wrong since jsdom/whatwg-url#36, since we started using the basicURLParse helper in setters which throws 😕 |
FWIW https://url.spec.whatwg.org/#concept-basic-url-parser returns a value that is either an URL record or "failure". Algorithms in this spec don’t have a concept of exceptions or stack unwinding, error handling is based on explicit "return values". |
I’ve added a separate commit to do this. |
This LGTM then with the for-now revert. Will let you merge if you want to do any last-minute touchups or similar. I wish we'd caught the throw vs. silent failure issue when designing the |
A lot of them fail in browsers, but I believe they’re should pass in a spec-conforming implementation. (With a few exceptions noted in comments.)
See #2830 (comment). This can be un-reverted when the following are fixed in the spec: - whatwg/url#113 - whatwg/url#104
As discussed in web-platform-tests/wpt#2830 (comment). This makes the setter tests pass (by having most of them ignore invalid input instead of throwing). It should also make parsing failures during construction throw correctly; previously they were checking a nonexistant urlRecord.failure property. This changes the public API by making the URL-record-returning functions return either a URL record or the string "failure", instead of returning either a URL record or throwing.
As discussed in web-platform-tests/wpt#2830 (comment). This makes the setter tests pass (by having most of them ignore invalid input instead of throwing). It should also make parsing failures during construction throw correctly; previously they were checking a nonexistant urlRecord.failure property. This changes the public API by making the URL-record-returning functions return either a URL record or the string "failure", instead of returning either a URL record or throwing.
As discussed in web-platform-tests/wpt#2830 (comment). This makes the setter tests pass (by having most of them ignore invalid input instead of throwing). It should also make parsing failures during construction throw correctly; previously they were checking a nonexistant urlRecord.failure property. This changes the public API by making the URL-record-returning functions return either a URL record or the string "failure", instead of returning either a URL record or throwing.
See web-platform-tests#2830 (comment). This can be un-reverted when the following are fixed in the spec: - whatwg/url#113 - whatwg/url#104
See web-platform-tests#2830 (comment). This can be un-reverted when the following are fixed in the spec: - whatwg/url#113 - whatwg/url#104
A lot of them fail in browsers, but I believe they’re should pass in a spec-conforming implementation. (With a few exceptions noted in comments.)
CC @domenic