11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst {
61cb0ef41Sopenharmony_ci  PerformanceObserver,
71cb0ef41Sopenharmony_ci  performance: {
81cb0ef41Sopenharmony_ci    timerify,
91cb0ef41Sopenharmony_ci  },
101cb0ef41Sopenharmony_ci} = require('perf_hooks');
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst assert = require('assert');
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciconst {
151cb0ef41Sopenharmony_ci  setTimeout: sleep
161cb0ef41Sopenharmony_ci} = require('timers/promises');
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_cilet check = false;
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciasync function doIt() {
211cb0ef41Sopenharmony_ci  await sleep(100);
221cb0ef41Sopenharmony_ci  check = true;
231cb0ef41Sopenharmony_ci  return check;
241cb0ef41Sopenharmony_ci}
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ciconst obs = new PerformanceObserver(common.mustCall((list) => {
271cb0ef41Sopenharmony_ci  const entry = list.getEntries()[0];
281cb0ef41Sopenharmony_ci  assert.strictEqual(entry.name, 'doIt');
291cb0ef41Sopenharmony_ci  assert(check);
301cb0ef41Sopenharmony_ci  obs.disconnect();
311cb0ef41Sopenharmony_ci}));
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ciobs.observe({ type: 'function' });
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ciconst timerified = timerify(doIt);
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ciconst res = timerified();
381cb0ef41Sopenharmony_ciassert(res instanceof Promise);
391cb0ef41Sopenharmony_cires.then(common.mustCall(assert));
40