url, test: synchronize web-platform-test url tests#11079
url, test: synchronize web-platform-test url tests#11079joyeecheung wants to merge 7 commits intonodejs:masterfrom
Conversation
54cea70 to
701e92b
Compare
|
Completed. Request review from @nodejs/url A few tests are out of sync/not sync'ed:
The test data is out of sync too, I've updated There are some tests commented out because we are not compatible yet, the major blocker is #10454 (PR: #10967) and the encoding of space to |
|
Force pushed because of filename mistakes. |
There was a problem hiding this comment.
Perhaps remove the commented out code sections?
There was a problem hiding this comment.
I think just commenting them out would make it easier to update and easier to compare with the upstream, maybe just me though
There was a problem hiding this comment.
nit: template string may be better here
There was a problem hiding this comment.
Just copy-pasting the upstream. I think they don't do ES.Next features for browser compatibility?
There was a problem hiding this comment.
Can we upstream these to web-platform-tests? I can do it if that'd be easier.
There was a problem hiding this comment.
I can give it a try first :D. These test cases don't have base so is urltestdata.json the right place to go?
There was a problem hiding this comment.
Yeah. No base is just a base of about:blank, so just add that.
There was a problem hiding this comment.
Why is this commented out?
There was a problem hiding this comment.
"??a=b&c=d" is broken at the moment, can make another PR to skip specific test cases later I think (though the whole condition doesn't have to be commented out. I'll change that)
test/common.js
Outdated
There was a problem hiding this comment.
I'd rather have a more featureful test(), perhaps one like
(fn, desc) => {
try {
fn();
} catch (err) {
if (err instanceof Error)
err.message = `In ${desc}:\n ${err.message}`;
throw err;
}
}|
Rebased and updated URL search parameters constructor tests to w3c/web-platform-tests/405394a now that #11060 has been merged. EDIT: oops, I mean 405394a for search params tests |
TimothyGu
left a comment
There was a problem hiding this comment.
There is also the issue of attribution. According to the W3C 3-clause BSD License (the alternative does not allow modification of source), we "must retain the original copyright notice". I don't think we are doing that currently.
There was a problem hiding this comment.
You can condense these three lines into
const { URL, URLSearchParams } = require('url');
test/common.js
Outdated
There was a problem hiding this comment.
The signature of assert_unreached() in WPT is (description), but assert.fail() in Node.js is (actual, expected, message, operator). Maybe
(description) => assert.fail('reached', 'unreached', `Reached unreachable code: ${description}`, 'is')?
There was a problem hiding this comment.
According to the docs
If message is falsy, the error message is set as the values of actual and expected separated by the provided operator. Otherwise, the error message is the value of message.
Probably just
assert.fail(undefined, undefined, `Reached unreachable code: ${description}`);There was a problem hiding this comment.
@joyeecheung, yeah, that'd work as well. IMO the 2 undefineds look a bit too long to be aesthetically pleasing, but up to you.
|
@TimothyGu Thanks for catching the copyright notice, looks like url-tests.json is doing that with So I'll put this in other files too. @jasnell is it the right way to do it? |
|
Yes, our JSON parsing does not recognize regular javascript style comments so including it in a property like this is good. |
|
New CI: https://ci.nodejs.org/job/node-test-pull-request/6165/ @TimothyGu Does this LGTY? |
|
Aborted CI, only |
|
Landed in 10b687b |
* attributon of WPT in url-setter-tests * add WPT test utilities * synchronize WPT URLSearchParams tests * synchronize WPT url tests * split whatwg-url-inspect test * port historical url tests from WPT * protocol setter and special URLs Refs: web-platform-tests/wpt#4413 Refs: whatwg/url#104 PR-URL: #11079 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
* attributon of WPT in url-setter-tests * add WPT test utilities * synchronize WPT URLSearchParams tests * synchronize WPT url tests * split whatwg-url-inspect test * port historical url tests from WPT * protocol setter and special URLs Refs: web-platform-tests/wpt#4413 Refs: whatwg/url#104 Backport-of: nodejs#11079
* attributon of WPT in url-setter-tests * add WPT test utilities * synchronize WPT URLSearchParams tests * synchronize WPT url tests * split whatwg-url-inspect test * port historical url tests from WPT * protocol setter and special URLs Refs: web-platform-tests/wpt#4413 Refs: whatwg/url#104 Backport-of: nodejs#11079
* attributon of WPT in url-setter-tests * add WPT test utilities * synchronize WPT URLSearchParams tests * synchronize WPT url tests * split whatwg-url-inspect test * port historical url tests from WPT * protocol setter and special URLs Refs: web-platform-tests/wpt#4413 Refs: whatwg/url#104 Backport-of: #11079
* attributon of WPT in url-setter-tests * add WPT test utilities * synchronize WPT URLSearchParams tests * synchronize WPT url tests * split whatwg-url-inspect test * port historical url tests from WPT * protocol setter and special URLs Refs: web-platform-tests/wpt#4413 Refs: whatwg/url#104 PR-URL: nodejs#11079 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
This is still a WIP, I'll update all the URLSearchParams tests first, then see how we can synchronize other tests. But I would like to get some feedback from @nodejs/url just to make sure I'm on the right direction.This is an attempt to synchronize the tests of our WHATWG URL implementation with the tests in https://github.com/w3c/web-platform-tests/tree/master/url. #9484 ported some of the URLSearchParams tests into our code base, but it is somewhat hard to see how up-to-date we are compared with the upstream tests.
In this PR, the upstream tests are placed like this
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test, url-whatwg