diff options
author | James M Snell <jasnell@gmail.com> | 2016-03-23 23:04:15 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-05-01 21:31:14 -0700 |
commit | fa542ebcfd93c4d3e933f3dee986679f412c58b7 (patch) | |
tree | 47672d2bc67cd4fa995d4e2ad156ddfffd316329 /test/known_issues | |
parent | 9f8d0ea6db2ff88422d1df69dbfed1dc766f8dbc (diff) | |
download | android-node-v8-fa542ebcfd93c4d3e933f3dee986679f412c58b7.tar.gz android-node-v8-fa542ebcfd93c4d3e933f3dee986679f412c58b7.tar.bz2 android-node-v8-fa542ebcfd93c4d3e933f3dee986679f412c58b7.zip |
test: add failing url parse tests as known_issue
url resolve and parse do not currently adhere to the same url
spec parsing rules that browsers use, which leads to some
issues. This addition to test/known_issues creates a set of
tests based on the w3c/whatwg test suite from:
Refs: https://github.com/w3c/web-platform-tests/tree/master/url
PR-URL: https://github.com/nodejs/node/pull/5885
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'test/known_issues')
-rw-r--r-- | test/known_issues/test-url-parse-conformance.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/known_issues/test-url-parse-conformance.js b/test/known_issues/test-url-parse-conformance.js new file mode 100644 index 0000000000..d70a322d6b --- /dev/null +++ b/test/known_issues/test-url-parse-conformance.js @@ -0,0 +1,57 @@ +'use strict'; + +// Refs: https://github.com/nodejs/node/issues/5832 + +const common = require('../common'); +const url = require('url'); +const assert = require('assert'); +const path = require('path'); + +const tests = require(path.join(common.fixturesDir, 'url-tests.json')); + +var failed = 0; +var attempted = 0; + +tests.forEach((test) => { + attempted++; + // Skip comments + if (typeof test === 'string') return; + var parsed; + + try { + // Attempt to parse + parsed = url.parse(url.resolve(test.base, test.input)); + if (test.failure) { + // If the test was supposed to fail and we didn't get an + // error, treat it as a failure. + failed++; + } else { + // Test was not supposed to fail, so we're good so far. Now + // check the results of the parse. + var username, password; + try { + assert.strictEqual(test.href, parsed.href); + assert.strictEqual(test.protocol, parsed.protocol); + username = parsed.auth ? parsed.auth.split(':', 2)[0] : ''; + password = parsed.auth ? parsed.auth.split(':', 2)[1] : ''; + assert.strictEqual(test.username, username); + assert.strictEqual(test.password, password); + assert.strictEqual(test.host, parsed.host); + assert.strictEqual(test.hostname, parsed.hostname); + assert.strictEqual(+test.port, +parsed.port); + assert.strictEqual(test.pathname, parsed.pathname || '/'); + assert.strictEqual(test.search, parsed.search || ''); + assert.strictEqual(test.hash, parsed.hash || ''); + } catch (err) { + // For now, we're just interested in the number of failures. + failed++; + } + } + } catch (err) { + // If Parse failed and it wasn't supposed to, treat it as a failure. + if (!test.failure) + failed++; + } +}); + +assert.ok(failed === 0, `${failed} failed tests (out of ${attempted})`); |