11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif (!common.hasCrypto) 51cb0ef41Sopenharmony_ci common.skip('missing crypto'); 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ciconst h2 = require('http2'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst server = h2.createServer(); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci// We use the lower-level API here 121cb0ef41Sopenharmony_ciserver.on('stream', common.mustCall((stream, headers, flags) => { 131cb0ef41Sopenharmony_ci stream.respond(); 141cb0ef41Sopenharmony_ci stream.end('ok'); 151cb0ef41Sopenharmony_ci})); 161cb0ef41Sopenharmony_ciserver.on('session', common.mustCall((session) => { 171cb0ef41Sopenharmony_ci session.on('remoteSettings', common.mustCall(2)); 181cb0ef41Sopenharmony_ci})); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => { 211cb0ef41Sopenharmony_ci const client = h2.connect(`http://localhost:${server.address().port}`); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci [ 241cb0ef41Sopenharmony_ci ['headerTableSize', -1, RangeError], 251cb0ef41Sopenharmony_ci ['headerTableSize', 2 ** 32, RangeError], 261cb0ef41Sopenharmony_ci ['initialWindowSize', -1, RangeError], 271cb0ef41Sopenharmony_ci ['initialWindowSize', 2 ** 32, RangeError], 281cb0ef41Sopenharmony_ci ['maxFrameSize', 1, RangeError], 291cb0ef41Sopenharmony_ci ['maxFrameSize', 2 ** 24, RangeError], 301cb0ef41Sopenharmony_ci ['maxConcurrentStreams', -1, RangeError], 311cb0ef41Sopenharmony_ci ['maxConcurrentStreams', 2 ** 32, RangeError], 321cb0ef41Sopenharmony_ci ['maxHeaderListSize', -1, RangeError], 331cb0ef41Sopenharmony_ci ['maxHeaderListSize', 2 ** 32, RangeError], 341cb0ef41Sopenharmony_ci ['maxHeaderSize', -1, RangeError], 351cb0ef41Sopenharmony_ci ['maxHeaderSize', 2 ** 32, RangeError], 361cb0ef41Sopenharmony_ci ['enablePush', 'a', TypeError], 371cb0ef41Sopenharmony_ci ['enablePush', 1, TypeError], 381cb0ef41Sopenharmony_ci ['enablePush', 0, TypeError], 391cb0ef41Sopenharmony_ci ['enablePush', null, TypeError], 401cb0ef41Sopenharmony_ci ['enablePush', {}, TypeError], 411cb0ef41Sopenharmony_ci ].forEach(([name, value, errorType]) => 421cb0ef41Sopenharmony_ci assert.throws( 431cb0ef41Sopenharmony_ci () => client.settings({ [name]: value }), 441cb0ef41Sopenharmony_ci { 451cb0ef41Sopenharmony_ci code: 'ERR_HTTP2_INVALID_SETTING_VALUE', 461cb0ef41Sopenharmony_ci name: errorType.name 471cb0ef41Sopenharmony_ci } 481cb0ef41Sopenharmony_ci ) 491cb0ef41Sopenharmony_ci ); 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci [1, true, {}, []].forEach((invalidCallback) => 521cb0ef41Sopenharmony_ci assert.throws( 531cb0ef41Sopenharmony_ci () => client.settings({}, invalidCallback), 541cb0ef41Sopenharmony_ci { 551cb0ef41Sopenharmony_ci name: 'TypeError', 561cb0ef41Sopenharmony_ci code: 'ERR_INVALID_ARG_TYPE', 571cb0ef41Sopenharmony_ci } 581cb0ef41Sopenharmony_ci ) 591cb0ef41Sopenharmony_ci ); 601cb0ef41Sopenharmony_ci 611cb0ef41Sopenharmony_ci client.settings({ maxFrameSize: 1234567 }); 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci const req = client.request(); 641cb0ef41Sopenharmony_ci req.on('response', common.mustCall()); 651cb0ef41Sopenharmony_ci req.resume(); 661cb0ef41Sopenharmony_ci req.on('close', common.mustCall(() => { 671cb0ef41Sopenharmony_ci server.close(); 681cb0ef41Sopenharmony_ci client.close(); 691cb0ef41Sopenharmony_ci })); 701cb0ef41Sopenharmony_ci})); 71