11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst async_hooks = require('async_hooks'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciif (!common.isMainThread) 71cb0ef41Sopenharmony_ci common.skip('Worker bootstrapping works differently -> different async IDs'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst initCalls = []; 101cb0ef41Sopenharmony_ciconst resolveCalls = []; 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciasync_hooks.createHook({ 131cb0ef41Sopenharmony_ci init: common.mustCall((id, type, triggerId, resource) => { 141cb0ef41Sopenharmony_ci assert.strictEqual(type, 'PROMISE'); 151cb0ef41Sopenharmony_ci initCalls.push({ id, triggerId, resource }); 161cb0ef41Sopenharmony_ci }, 2), 171cb0ef41Sopenharmony_ci promiseResolve: common.mustCall((id) => { 181cb0ef41Sopenharmony_ci assert.strictEqual(initCalls[resolveCalls.length].id, id); 191cb0ef41Sopenharmony_ci resolveCalls.push(id); 201cb0ef41Sopenharmony_ci }, 2) 211cb0ef41Sopenharmony_ci}).enable(); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ciconst a = Promise.resolve(42); 241cb0ef41Sopenharmony_cia.then(common.mustCall()); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ciassert.strictEqual(initCalls[0].triggerId, 1); 271cb0ef41Sopenharmony_ciassert.strictEqual(initCalls[1].triggerId, initCalls[0].id); 28