Skip to content

Commit d2a2985

Browse files
committed
perf_hooks: expose webperf global scope interfaces
Exposes `PerformanceEntry`, `PerformanceMark`, `PerformanceMeasure`, `PerformanceObserver`, `PerformanceObserverEntryList`, and `PerformanceResourceTiming` to the global scope.
1 parent a0363be commit d2a2985

File tree

4 files changed

+6
-73
lines changed

4 files changed

+6
-73
lines changed

lib/internal/bootstrap/browser.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ exposeInterface(globalThis, 'Blob', buffer.Blob);
7575
// https://www.w3.org/TR/hr-time-2/#the-performance-attribute
7676
const perf_hooks = require('perf_hooks');
7777
exposeInterface(globalThis, 'Performance', perf_hooks.Performance);
78+
exposeInterface(globalThis, 'PerformanceEntry', perf_hooks.PerformanceEntry);
79+
exposeInterface(globalThis, 'PerformanceMark', perf_hooks.PerformanceMark);
80+
exposeInterface(globalThis, 'PerformanceMeasure', perf_hooks.PerformanceMeasure);
81+
exposeInterface(globalThis, 'PerformanceObserver', perf_hooks.PerformanceObserver);
82+
exposeInterface(globalThis, 'PerformanceObserverEntryList', perf_hooks.PerformanceObserverEntryList);
83+
exposeInterface(globalThis, 'PerformanceResourceTiming', perf_hooks.PerformanceResourceTiming);
7884
defineReplaceableAttribute(globalThis, 'performance',
7985
perf_hooks.performance);
8086

test/wpt/test-performance-timeline.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,6 @@ const runner = new WPTRunner('performance-timeline');
77
runner.pretendGlobalThisAs('Window');
88
runner.brandCheckGlobalScopeAttribute('performance');
99
runner.setInitScript(`
10-
const {
11-
PerformanceEntry,
12-
PerformanceObserver,
13-
PerformanceObserverEntryList,
14-
} = require('perf_hooks');
15-
Object.defineProperty(global, 'PerformanceEntry', {
16-
value: PerformanceEntry,
17-
enumerable: false,
18-
writable: true,
19-
configurable: true,
20-
});
21-
Object.defineProperty(global, 'PerformanceObserver', {
22-
value: PerformanceObserver,
23-
enumerable: false,
24-
writable: true,
25-
configurable: true,
26-
});
27-
Object.defineProperty(global, 'PerformanceObserverEntryList', {
28-
value: PerformanceObserverEntryList,
29-
enumerable: false,
30-
writable: true,
31-
configurable: true,
32-
});
33-
3410
// Create a dummy resource timing entry to mimic how the browser would
3511
// record the initial page load.
3612
performance.markResourceTiming({

test/wpt/test-resource-timing.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,6 @@ const runner = new WPTRunner('resource-timing');
66

77
runner.pretendGlobalThisAs('Window');
88
runner.setInitScript(`
9-
const {
10-
PerformanceEntry,
11-
PerformanceResourceTiming,
12-
} = require('perf_hooks');
13-
Object.defineProperty(global, 'PerformanceEntry', {
14-
value: PerformanceEntry,
15-
enumerable: false,
16-
writable: true,
17-
configurable: true,
18-
});
19-
Object.defineProperty(global, 'PerformanceResourceTiming', {
20-
value: PerformanceResourceTiming,
21-
enumerable: false,
22-
writable: true,
23-
configurable: true,
24-
});
25-
269
global.resource = performance.markResourceTiming({
2710
startTime: 0,
2811
endTime: 0,

test/wpt/test-user-timing.js

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,5 @@ const runner = new WPTRunner('user-timing');
77

88
runner.pretendGlobalThisAs('Window');
99
runner.brandCheckGlobalScopeAttribute('performance');
10-
runner.setInitScript(`
11-
const {
12-
PerformanceEntry,
13-
PerformanceMark,
14-
PerformanceMeasure,
15-
PerformanceObserver,
16-
} = require('perf_hooks');
17-
Object.defineProperty(global, 'PerformanceEntry', {
18-
value: PerformanceEntry,
19-
enumerable: false,
20-
writable: true,
21-
configurable: true,
22-
});
23-
Object.defineProperty(global, 'PerformanceMark', {
24-
value: PerformanceMark,
25-
enumerable: false,
26-
writable: true,
27-
configurable: true,
28-
});
29-
Object.defineProperty(global, 'PerformanceMeasure', {
30-
value: PerformanceMeasure,
31-
enumerable: false,
32-
writable: true,
33-
configurable: true,
34-
});
35-
Object.defineProperty(global, 'PerformanceObserver', {
36-
value: PerformanceObserver,
37-
enumerable: false,
38-
writable: true,
39-
configurable: true,
40-
});
41-
`);
4210

4311
runner.runJsTests();

0 commit comments

Comments
 (0)