| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f368d69 commit 0f749a3
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,37 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const { | ||
| 6 | + performance, | ||
| 7 | + PerformanceObserver, | ||
| 8 | + } = require('perf_hooks'); | ||
| 9 | + const { | ||
| 10 | + executionAsyncId, | ||
| 11 | + triggerAsyncId, | ||
| 12 | + executionAsyncResource, | ||
| 13 | + } = require('async_hooks'); | ||
| 14 | + | ||
| 15 | + // Test Non-Buffered PerformanceObserver retains async context | ||
| 16 | + { | ||
| 17 | + const observer = | ||
| 18 | + new PerformanceObserver(common.mustCall(callback)); | ||
| 19 | + | ||
| 20 | + const initialAsyncId = executionAsyncId(); | ||
| 21 | + let asyncIdInTimeout; | ||
| 22 | + let asyncResourceInTimeout; | ||
| 23 | + | ||
| 24 | + function callback(list) { | ||
| 25 | + assert.strictEqual(triggerAsyncId(), initialAsyncId); | ||
| 26 | + assert.strictEqual(executionAsyncId(), asyncIdInTimeout); | ||
| 27 | + assert.strictEqual(executionAsyncResource(), asyncResourceInTimeout); | ||
| 28 | + observer.disconnect(); | ||
| 29 | + } | ||
| 30 | + observer.observe({ entryTypes: ['mark'] }); | ||
| 31 | + | ||
| 32 | + setTimeout(() => { | ||
| 33 | + asyncIdInTimeout = executionAsyncId(); | ||
| 34 | + asyncResourceInTimeout = executionAsyncResource(); | ||
| 35 | + performance.mark('test1'); | ||
| 36 | + }, 0); | ||
| 37 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments