2017-09-05 15:02:48 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
|
|
common.skip('missing crypto');
|
|
|
|
|
2017-10-07 20:23:47 -07:00
|
|
|
const assert = require('assert');
|
2017-09-05 15:02:48 -07:00
|
|
|
const http2 = require('http2');
|
|
|
|
|
|
|
|
// Verify that setTimeout callback verifications work correctly
|
2017-10-07 20:23:47 -07:00
|
|
|
const verifyCallbacks = (server) => {
|
|
|
|
const testTimeout = 10;
|
2017-09-05 15:02:48 -07:00
|
|
|
|
2019-04-02 03:46:17 +02:00
|
|
|
[true, 1, {}, [], null, 'test'].forEach((notFunction) => {
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(
|
2017-10-07 20:23:47 -07:00
|
|
|
() => server.setTimeout(testTimeout, notFunction),
|
2019-04-02 03:46:17 +02:00
|
|
|
{
|
2019-12-25 18:02:16 +01:00
|
|
|
name: 'TypeError',
|
2022-01-24 19:39:16 +03:30
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
2019-04-02 03:46:17 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2017-10-07 20:23:47 -07:00
|
|
|
|
|
|
|
// No callback
|
|
|
|
const returnedVal = server.setTimeout(testTimeout);
|
|
|
|
assert.strictEqual(returnedVal.timeout, testTimeout);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Test with server
|
2017-09-05 15:02:48 -07:00
|
|
|
{
|
|
|
|
const server = http2.createServer();
|
2017-10-07 20:23:47 -07:00
|
|
|
verifyCallbacks(server);
|
2017-09-05 15:02:48 -07:00
|
|
|
}
|
|
|
|
|
2017-10-07 20:23:47 -07:00
|
|
|
// Test with secure server
|
2017-09-05 15:02:48 -07:00
|
|
|
{
|
2017-10-07 20:23:47 -07:00
|
|
|
const secureServer = http2.createSecureServer({});
|
|
|
|
verifyCallbacks(secureServer);
|
2017-09-05 15:02:48 -07:00
|
|
|
}
|