diff options
author | Rich Trott <rtrott@gmail.com> | 2018-06-04 13:10:09 +0000 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-06-07 10:58:01 -0700 |
commit | 44d1a46a4277083803024eed2fb37d70c7d2bbcc (patch) | |
tree | abe08ca9e95572a44d735a76fd095fd86cc49f0f /test/parallel/test-url-parse-invalid-input.js | |
parent | 6dbd6f6c7d0fe5629c921a2fe618ce9c00544294 (diff) | |
download | android-node-v8-44d1a46a4277083803024eed2fb37d70c7d2bbcc.tar.gz android-node-v8-44d1a46a4277083803024eed2fb37d70c7d2bbcc.tar.bz2 android-node-v8-44d1a46a4277083803024eed2fb37d70c7d2bbcc.zip |
test: make url-parse-invalid-input engine agnostic
test-url-parse-invalid-input checks the message of an error that is
generated by the JavaScript engine. Error messages that change in the
underlying JavaScript engine should not be breaking changes in Node.js
and therefore should not cause tests to fail. Remove the message check
and replace it with a check of the type of the Error object along with
the absence of a `code` property. (If a `code` property were present, it
would indicate that the error was coming from Node.js rather than the
JavaScript engine.)
This also makes this test usable without modification in the ChakraCore
fork of Node.js.
PR-URL: https://github.com/nodejs/node/pull/21132
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'test/parallel/test-url-parse-invalid-input.js')
-rw-r--r-- | test/parallel/test-url-parse-invalid-input.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/parallel/test-url-parse-invalid-input.js b/test/parallel/test-url-parse-invalid-input.js index 0f113862c7..aad8462bfc 100644 --- a/test/parallel/test-url-parse-invalid-input.js +++ b/test/parallel/test-url-parse-invalid-input.js @@ -26,4 +26,12 @@ const url = require('url'); }); assert.throws(() => { url.parse('http://%E0%A4%A@fail'); }, - /^URIError: URI malformed$/); + (e) => { + // The error should be a URIError. + if (!(e instanceof URIError)) + return false; + + // The error should be from the JS engine and not from Node.js. + // JS engine errors do not have the `code` property. + return e.code === undefined; + }); |