1'use strict'; 2 3const common = require('../common'); 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6 7const assert = require('assert'); 8const https = require('https'); 9const tls = require('tls'); 10 11const dftProtocol = {}; 12 13// Test for immutable `opts` 14{ 15 const opts = common.mustNotMutateObjectDeep({ 16 foo: 'bar', 17 ALPNProtocols: [ 'http/1.1' ], 18 }); 19 const server = https.createServer(opts); 20 21 tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol); 22 assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols), 23 0); 24} 25 26 27// Validate that `createServer` can work with the only argument requestListener 28{ 29 const mustNotCall = common.mustNotCall(); 30 const server = https.createServer(mustNotCall); 31 32 tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol); 33 assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols), 34 0); 35 assert.strictEqual(server.listeners('request').length, 1); 36 assert.strictEqual(server.listeners('request')[0], mustNotCall); 37} 38 39 40// Validate that `createServer` can work with no arguments 41{ 42 const server = https.createServer(); 43 44 assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols), 45 0); 46 assert.strictEqual(server.listeners('request').length, 0); 47} 48