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 http2 = require('http2'); 81cb0ef41Sopenharmony_ciconst Countdown = require('../common/countdown'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst server = http2.createServer(); 111cb0ef41Sopenharmony_ciconst largeBuffer = Buffer.alloc(1e4); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci// Verify that a dependency cycle may exist, but that it doesn't crash anything 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciserver.on('stream', common.mustCall((stream) => { 161cb0ef41Sopenharmony_ci stream.respond(); 171cb0ef41Sopenharmony_ci setImmediate(() => { 181cb0ef41Sopenharmony_ci stream.end(largeBuffer); 191cb0ef41Sopenharmony_ci }); 201cb0ef41Sopenharmony_ci}, 3)); 211cb0ef41Sopenharmony_ciserver.on('session', common.mustCall((session) => { 221cb0ef41Sopenharmony_ci session.on('priority', (id, parent, weight, exclusive) => { 231cb0ef41Sopenharmony_ci assert.strictEqual(weight, 16); 241cb0ef41Sopenharmony_ci assert.strictEqual(exclusive, false); 251cb0ef41Sopenharmony_ci switch (id) { 261cb0ef41Sopenharmony_ci case 1: 271cb0ef41Sopenharmony_ci assert.strictEqual(parent, 5); 281cb0ef41Sopenharmony_ci break; 291cb0ef41Sopenharmony_ci case 3: 301cb0ef41Sopenharmony_ci assert.strictEqual(parent, 1); 311cb0ef41Sopenharmony_ci break; 321cb0ef41Sopenharmony_ci case 5: 331cb0ef41Sopenharmony_ci assert.strictEqual(parent, 3); 341cb0ef41Sopenharmony_ci break; 351cb0ef41Sopenharmony_ci default: 361cb0ef41Sopenharmony_ci assert.fail('should not happen'); 371cb0ef41Sopenharmony_ci } 381cb0ef41Sopenharmony_ci }); 391cb0ef41Sopenharmony_ci})); 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => { 421cb0ef41Sopenharmony_ci const client = http2.connect(`http://localhost:${server.address().port}`); 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci const countdown = new Countdown(3, () => { 451cb0ef41Sopenharmony_ci client.close(); 461cb0ef41Sopenharmony_ci server.close(); 471cb0ef41Sopenharmony_ci }); 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci { 501cb0ef41Sopenharmony_ci const req = client.request(); 511cb0ef41Sopenharmony_ci req.priority({ parent: 5 }); 521cb0ef41Sopenharmony_ci req.resume(); 531cb0ef41Sopenharmony_ci req.on('close', () => countdown.dec()); 541cb0ef41Sopenharmony_ci } 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ci { 571cb0ef41Sopenharmony_ci const req = client.request(); 581cb0ef41Sopenharmony_ci req.priority({ parent: 1 }); 591cb0ef41Sopenharmony_ci req.resume(); 601cb0ef41Sopenharmony_ci req.on('close', () => countdown.dec()); 611cb0ef41Sopenharmony_ci } 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci { 641cb0ef41Sopenharmony_ci const req = client.request(); 651cb0ef41Sopenharmony_ci req.priority({ parent: 3 }); 661cb0ef41Sopenharmony_ci req.resume(); 671cb0ef41Sopenharmony_ci req.on('close', () => countdown.dec()); 681cb0ef41Sopenharmony_ci } 691cb0ef41Sopenharmony_ci})); 70