11cb0ef41Sopenharmony_ci// Flags: --expose-gc
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci'use strict';
41cb0ef41Sopenharmony_ciconst common = require('../common');
51cb0ef41Sopenharmony_ciif (!common.hasCrypto)
61cb0ef41Sopenharmony_ci  common.skip('missing crypto');
71cb0ef41Sopenharmony_ciconst http2 = require('http2');
81cb0ef41Sopenharmony_ciconst makeDuplexPair = require('../common/duplexpair');
91cb0ef41Sopenharmony_ciconst tick = require('../common/tick');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci// This tests that running garbage collection while an Http2Session has
121cb0ef41Sopenharmony_ci// a write *scheduled*, it will survive that garbage collection.
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci{
151cb0ef41Sopenharmony_ci  // This creates a session and schedules a write (for the settings frame).
161cb0ef41Sopenharmony_ci  let client = http2.connect('http://localhost:80', {
171cb0ef41Sopenharmony_ci    createConnection: common.mustCall(() => makeDuplexPair().clientSide)
181cb0ef41Sopenharmony_ci  });
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci  // First, wait for any nextTicks() and their responses
211cb0ef41Sopenharmony_ci  // from the `connect()` call to run.
221cb0ef41Sopenharmony_ci  tick(10, () => {
231cb0ef41Sopenharmony_ci    // This schedules a write.
241cb0ef41Sopenharmony_ci    client.settings(http2.getDefaultSettings());
251cb0ef41Sopenharmony_ci    client = null;
261cb0ef41Sopenharmony_ci    global.gc();
271cb0ef41Sopenharmony_ci  });
281cb0ef41Sopenharmony_ci}
29