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.onBefore(async function() { }); 81cb0ef41Sopenharmony_ci}, /The "beforeHook" argument must be of type function/); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciassert.throws(() => { 111cb0ef41Sopenharmony_ci promiseHooks.onBefore(async function*() { }); 121cb0ef41Sopenharmony_ci}, /The "beforeHook" argument must be of type function/); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_cilet seen; 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst stop = promiseHooks.onBefore(common.mustCall((promise) => { 171cb0ef41Sopenharmony_ci seen = promise; 181cb0ef41Sopenharmony_ci}, 1)); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciconst promise = Promise.resolve().then(() => { 211cb0ef41Sopenharmony_ci assert.strictEqual(seen, promise); 221cb0ef41Sopenharmony_ci stop(); 231cb0ef41Sopenharmony_ci}); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_cipromise.then(); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ciassert.strictEqual(seen, undefined); 28