11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// Regression test for https://github.com/nodejs/node/issues/13262
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst common = require('../common');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst async_hooks = require('async_hooks');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciif (!common.isMainThread)
101cb0ef41Sopenharmony_ci  common.skip('Worker bootstrapping works differently -> different async IDs');
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_cilet seenId, seenResource;
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciasync_hooks.createHook({
151cb0ef41Sopenharmony_ci  init: common.mustCall((id, provider, triggerAsyncId, resource) => {
161cb0ef41Sopenharmony_ci    seenId = id;
171cb0ef41Sopenharmony_ci    seenResource = resource;
181cb0ef41Sopenharmony_ci    assert.strictEqual(provider, 'Immediate');
191cb0ef41Sopenharmony_ci    assert.strictEqual(triggerAsyncId, 1);
201cb0ef41Sopenharmony_ci  }),
211cb0ef41Sopenharmony_ci  before: common.mustNotCall(),
221cb0ef41Sopenharmony_ci  after: common.mustNotCall(),
231cb0ef41Sopenharmony_ci  destroy: common.mustCall((id) => {
241cb0ef41Sopenharmony_ci    assert.strictEqual(seenId, id);
251cb0ef41Sopenharmony_ci  })
261cb0ef41Sopenharmony_ci}).enable();
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ciconst immediate = setImmediate(common.mustNotCall());
291cb0ef41Sopenharmony_ciassert.strictEqual(immediate, seenResource);
301cb0ef41Sopenharmony_ciclearImmediate(immediate);
31