mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 17:01:08 +00:00

Refs: https://github.com/nodejs/node/issues/14985 PR-URL: https://github.com/nodejs/node/pull/16082 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
43 lines
997 B
JavaScript
43 lines
997 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const http2 = require('http2');
|
|
|
|
// Verify that setTimeout callback verifications work correctly
|
|
const verifyCallbacks = (server) => {
|
|
const testTimeout = 10;
|
|
const notFunctions = [true, 1, {}, [], null, 'test'];
|
|
const invalidCallBackError = {
|
|
type: TypeError,
|
|
code: 'ERR_INVALID_CALLBACK',
|
|
message: 'Callback must be a function'
|
|
};
|
|
|
|
notFunctions.forEach((notFunction) =>
|
|
common.expectsError(
|
|
() => server.setTimeout(testTimeout, notFunction),
|
|
invalidCallBackError
|
|
)
|
|
);
|
|
|
|
// No callback
|
|
const returnedVal = server.setTimeout(testTimeout);
|
|
assert.strictEqual(returnedVal.timeout, testTimeout);
|
|
};
|
|
|
|
// Test with server
|
|
{
|
|
const server = http2.createServer();
|
|
verifyCallbacks(server);
|
|
}
|
|
|
|
// Test with secure server
|
|
{
|
|
const secureServer = http2.createSecureServer({});
|
|
verifyCallbacks(secureServer);
|
|
}
|