diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/async-hooks/test-httpparser.request.js | 8 | ||||
-rw-r--r-- | test/async-hooks/test-httpparser.response.js | 8 | ||||
-rw-r--r-- | test/parallel/test-http-parser-bad-ref.js | 5 | ||||
-rw-r--r-- | test/parallel/test-http-parser-lazy-loaded.js | 7 | ||||
-rw-r--r-- | test/parallel/test-http-parser.js | 5 | ||||
-rw-r--r-- | test/parallel/test-process-versions.js | 10 | ||||
-rw-r--r-- | test/parallel/test-trace-events-metadata.js | 7 | ||||
-rw-r--r-- | test/sequential/test-async-wrap-getasyncid.js | 2 | ||||
-rw-r--r-- | test/sequential/test-http-max-http-headers.js | 8 | ||||
-rw-r--r-- | test/sequential/test-http-regr-gh-2928.js | 3 |
10 files changed, 26 insertions, 37 deletions
diff --git a/test/async-hooks/test-httpparser.request.js b/test/async-hooks/test-httpparser.request.js index cb56419137..2e62e6eaa9 100644 --- a/test/async-hooks/test-httpparser.request.js +++ b/test/async-hooks/test-httpparser.request.js @@ -10,13 +10,7 @@ const { checkInvocations } = require('./hook-checks'); const hooks = initHooks(); hooks.enable(); -// The hooks.enable() must come before require('internal/test/binding') -// because internal/test/binding schedules a process warning on nextTick. -// If this order is not preserved, the hooks check will fail because it -// will not be notified about the nextTick creation but will see the -// callback event. -const { internalBinding } = require('internal/test/binding'); -const { HTTPParser } = internalBinding('http_parser'); +const { HTTPParser } = require('_http_common'); const REQUEST = HTTPParser.REQUEST; diff --git a/test/async-hooks/test-httpparser.response.js b/test/async-hooks/test-httpparser.response.js index b1f804ef7d..5933b61b79 100644 --- a/test/async-hooks/test-httpparser.response.js +++ b/test/async-hooks/test-httpparser.response.js @@ -11,13 +11,7 @@ const hooks = initHooks(); hooks.enable(); -// The hooks.enable() must come before require('internal/test/binding') -// because internal/test/binding schedules a process warning on nextTick. -// If this order is not preserved, the hooks check will fail because it -// will not be notified about the nextTick creation but will see the -// callback event. -const { internalBinding } = require('internal/test/binding'); -const { HTTPParser } = internalBinding('http_parser'); +const { HTTPParser } = require('_http_common'); const RESPONSE = HTTPParser.RESPONSE; const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; diff --git a/test/parallel/test-http-parser-bad-ref.js b/test/parallel/test-http-parser-bad-ref.js index 5b002b2ce0..0b132d69a2 100644 --- a/test/parallel/test-http-parser-bad-ref.js +++ b/test/parallel/test-http-parser-bad-ref.js @@ -2,12 +2,11 @@ // Run this program with valgrind or efence with --expose_gc to expose the // problem. -// Flags: --expose_gc --expose-internals +// Flags: --expose_gc require('../common'); const assert = require('assert'); -const { internalBinding } = require('internal/test/binding'); -const { HTTPParser } = internalBinding('http_parser'); +const { HTTPParser } = require('_http_common'); const kOnHeaders = HTTPParser.kOnHeaders | 0; const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; diff --git a/test/parallel/test-http-parser-lazy-loaded.js b/test/parallel/test-http-parser-lazy-loaded.js index c1eb29fb16..6d6b2ddd25 100644 --- a/test/parallel/test-http-parser-lazy-loaded.js +++ b/test/parallel/test-http-parser-lazy-loaded.js @@ -3,6 +3,7 @@ 'use strict'; const { internalBinding } = require('internal/test/binding'); +const { getOptionValue } = require('internal/options'); // Monkey patch before requiring anything class DummyParser { @@ -11,7 +12,11 @@ class DummyParser { } } DummyParser.REQUEST = Symbol(); -internalBinding('http_parser').HTTPParser = DummyParser; + +const binding = + getOptionValue('--http-parser') === 'legacy' ? + internalBinding('http_parser') : internalBinding('http_parser_llhttp'); +binding.HTTPParser = DummyParser; const common = require('../common'); const assert = require('assert'); diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js index 36f41f79e5..5503b2284b 100644 --- a/test/parallel/test-http-parser.js +++ b/test/parallel/test-http-parser.js @@ -19,14 +19,11 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -// Flags: --expose-internals - 'use strict'; const { mustCall, mustNotCall } = require('../common'); const assert = require('assert'); -const { internalBinding } = require('internal/test/binding'); -const { methods, HTTPParser } = internalBinding('http_parser'); +const { methods, HTTPParser } = require('_http_common'); const { REQUEST, RESPONSE } = HTTPParser; const kOnHeaders = HTTPParser.kOnHeaders | 0; diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js index ba7b9e70b2..48560961f4 100644 --- a/test/parallel/test-process-versions.js +++ b/test/parallel/test-process-versions.js @@ -3,7 +3,8 @@ const common = require('../common'); const assert = require('assert'); const expected_keys = ['ares', 'modules', 'node', - 'uv', 'v8', 'zlib', 'nghttp2', 'napi']; + 'uv', 'v8', 'zlib', 'nghttp2', 'napi', + 'http_parser', 'llhttp']; if (common.hasCrypto) { expected_keys.push('openssl'); @@ -16,9 +17,6 @@ if (common.hasIntl) { expected_keys.push('unicode'); } -expected_keys.push( - process.versions.llhttp === undefined ? 'http_parser' : 'llhttp'); - expected_keys.sort(); const actual_keys = Object.keys(process.versions).sort(); @@ -27,8 +25,8 @@ assert.deepStrictEqual(actual_keys, expected_keys); const commonTemplate = /^\d+\.\d+\.\d+(?:-.*)?$/; assert(commonTemplate.test(process.versions.ares)); -assert(commonTemplate.test(process.versions.llhttp === undefined ? - process.versions.http_parser : process.versions.llhttp)); +assert(commonTemplate.test(process.versions.llhttp)); +assert(commonTemplate.test(process.versions.http_parser)); assert(commonTemplate.test(process.versions.node)); assert(commonTemplate.test(process.versions.uv)); assert(commonTemplate.test(process.versions.zlib)); diff --git a/test/parallel/test-trace-events-metadata.js b/test/parallel/test-trace-events-metadata.js index 0db8555838..863b2175f6 100644 --- a/test/parallel/test-trace-events-metadata.js +++ b/test/parallel/test-trace-events-metadata.js @@ -36,9 +36,10 @@ proc.once('exit', common.mustCall(() => { assert(traces.some((trace) => trace.name === 'node' && - (trace.args.process.versions.http_parser === - process.versions.http_parser || - trace.args.process.versions.llhttp === process.versions.llhttp) && + trace.args.process.versions.http_parser === + process.versions.http_parser && + trace.args.process.versions.llhttp === + process.versions.llhttp && trace.args.process.versions.node === process.versions.node && trace.args.process.versions.v8 === diff --git a/test/sequential/test-async-wrap-getasyncid.js b/test/sequential/test-async-wrap-getasyncid.js index 16868de558..2ad602e482 100644 --- a/test/sequential/test-async-wrap-getasyncid.js +++ b/test/sequential/test-async-wrap-getasyncid.js @@ -148,7 +148,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check { - const { HTTPParser } = internalBinding('http_parser'); + const { HTTPParser } = require('_http_common'); testInitialized(new HTTPParser(HTTPParser.REQUEST), 'HTTPParser'); } diff --git a/test/sequential/test-http-max-http-headers.js b/test/sequential/test-http-max-http-headers.js index fad7f7d1d6..1dece8beed 100644 --- a/test/sequential/test-http-max-http-headers.js +++ b/test/sequential/test-http-max-http-headers.js @@ -1,11 +1,13 @@ +// Flags: --expose-internals 'use strict'; - -const assert = require('assert'); const common = require('../common'); +const assert = require('assert'); const http = require('http'); const net = require('net'); const MAX = 8 * 1024; // 8KB +const { getOptionValue } = require('internal/options'); + // Verify that we cannot receive more than 8KB of headers. function once(cb) { @@ -27,7 +29,7 @@ function finished(client, callback) { function fillHeaders(headers, currentSize, valid = false) { // llhttp counts actual header name/value sizes, excluding the whitespace and // stripped chars. - if (process.versions.hasOwnProperty('llhttp')) { + if (getOptionValue('--http-parser') === 'llhttp') { // OK, Content-Length, 0, X-CRASH, aaa... headers += 'a'.repeat(MAX - currentSize); } else { diff --git a/test/sequential/test-http-regr-gh-2928.js b/test/sequential/test-http-regr-gh-2928.js index 3794eddaa0..aa2e2bc9ac 100644 --- a/test/sequential/test-http-regr-gh-2928.js +++ b/test/sequential/test-http-regr-gh-2928.js @@ -6,9 +6,8 @@ const common = require('../common'); const assert = require('assert'); const httpCommon = require('_http_common'); -const { internalBinding } = require('internal/test/binding'); const is_reused_symbol = require('internal/freelist').symbols.is_reused_symbol; -const { HTTPParser } = internalBinding('http_parser'); +const { HTTPParser } = require('_http_common'); const net = require('net'); const COUNT = httpCommon.parsers.max + 1; |