11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif (!common.hasCrypto) 51cb0ef41Sopenharmony_ci common.skip('missing crypto'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst assert = require('assert'); 81cb0ef41Sopenharmony_ciconst http2 = require('http2'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci// Verify that setTimeout callback verifications work correctly 111cb0ef41Sopenharmony_ciconst verifyCallbacks = (server) => { 121cb0ef41Sopenharmony_ci const testTimeout = 10; 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci [true, 1, {}, [], null, 'test'].forEach((notFunction) => { 151cb0ef41Sopenharmony_ci assert.throws( 161cb0ef41Sopenharmony_ci () => server.setTimeout(testTimeout, notFunction), 171cb0ef41Sopenharmony_ci { 181cb0ef41Sopenharmony_ci name: 'TypeError', 191cb0ef41Sopenharmony_ci code: 'ERR_INVALID_ARG_TYPE', 201cb0ef41Sopenharmony_ci } 211cb0ef41Sopenharmony_ci ); 221cb0ef41Sopenharmony_ci }); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci // No callback 251cb0ef41Sopenharmony_ci const returnedVal = server.setTimeout(testTimeout); 261cb0ef41Sopenharmony_ci assert.strictEqual(returnedVal.timeout, testTimeout); 271cb0ef41Sopenharmony_ci}; 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci// Test with server 301cb0ef41Sopenharmony_ci{ 311cb0ef41Sopenharmony_ci const server = http2.createServer(); 321cb0ef41Sopenharmony_ci verifyCallbacks(server); 331cb0ef41Sopenharmony_ci} 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci// Test with secure server 361cb0ef41Sopenharmony_ci{ 371cb0ef41Sopenharmony_ci const secureServer = http2.createSecureServer({}); 381cb0ef41Sopenharmony_ci verifyCallbacks(secureServer); 391cb0ef41Sopenharmony_ci} 40