11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst { promiseHooks } = require('v8'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciassert.throws(() => { 71cb0ef41Sopenharmony_ci promiseHooks.onInit(async function() { }); 81cb0ef41Sopenharmony_ci}, /The "initHook" argument must be of type function/); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciassert.throws(() => { 111cb0ef41Sopenharmony_ci promiseHooks.onInit(async function*() { }); 121cb0ef41Sopenharmony_ci}, /The "initHook" argument must be of type function/); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_cilet seenPromise; 151cb0ef41Sopenharmony_cilet seenParent; 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciconst stop = promiseHooks.onInit(common.mustCall((promise, parent) => { 181cb0ef41Sopenharmony_ci seenPromise = promise; 191cb0ef41Sopenharmony_ci seenParent = parent; 201cb0ef41Sopenharmony_ci}, 2)); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciconst parent = Promise.resolve(); 231cb0ef41Sopenharmony_ciassert.strictEqual(seenPromise, parent); 241cb0ef41Sopenharmony_ciassert.strictEqual(seenParent, undefined); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ciconst child = parent.then(); 271cb0ef41Sopenharmony_ciassert.strictEqual(seenPromise, child); 281cb0ef41Sopenharmony_ciassert.strictEqual(seenParent, parent); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ciseenPromise = undefined; 311cb0ef41Sopenharmony_ciseenParent = undefined; 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_cistop(); 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ciPromise.resolve(); 361cb0ef41Sopenharmony_ciassert.strictEqual(seenPromise, undefined); 371cb0ef41Sopenharmony_ciassert.strictEqual(seenParent, undefined); 38