Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit587367d

Browse files
committed
perf_hooks: expose webperf global scope interfaces
Exposes `PerformanceEntry`, `PerformanceMark`, `PerformanceMeasure`,`PerformanceObserver`, `PerformanceObserverEntryList`,and `PerformanceResourceTiming` to the global scope.PR-URL:#44483Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent364c0e1 commit587367d

File tree

6 files changed

+86
-73
lines changed

6 files changed

+86
-73
lines changed

‎doc/api/globals.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,68 @@ The `MessagePort` class. See [`MessagePort`][] for more details.
541541

542542
This variable may appear to be global but is not. See[`module`][].
543543

544+
##`PerformanceEntry`
545+
546+
<!-- YAML
547+
added: REPLACEME
548+
-->
549+
550+
<!-- type=global-->
551+
552+
The`PerformanceEntry` class. See[`PerformanceEntry`][] for more details.
553+
554+
##`PerformanceMark`
555+
556+
<!-- YAML
557+
added: REPLACEME
558+
-->
559+
560+
<!-- type=global-->
561+
562+
The`PerformanceMark` class. See[`PerformanceMark`][] for more details.
563+
564+
##`PerformanceMeasure`
565+
566+
<!-- YAML
567+
added: REPLACEME
568+
-->
569+
570+
<!-- type=global-->
571+
572+
The`PerformanceMeasure` class. See[`PerformanceMeasure`][] for more details.
573+
574+
##`PerformanceObserver`
575+
576+
<!-- YAML
577+
added: REPLACEME
578+
-->
579+
580+
<!-- type=global-->
581+
582+
The`PerformanceObserver` class. See[`PerformanceObserver`][] for more details.
583+
584+
##`PerformanceObserverEntryList`
585+
586+
<!-- YAML
587+
added: REPLACEME
588+
-->
589+
590+
<!-- type=global-->
591+
592+
The`PerformanceObserverEntryList` class. See
593+
[`PerformanceObserverEntryList`][] for more details.
594+
595+
##`PerformanceResourceTiming`
596+
597+
<!-- YAML
598+
added: REPLACEME
599+
-->
600+
601+
<!-- type=global-->
602+
603+
The`PerformanceResourceTiming` class. See[`PerformanceResourceTiming`][] for
604+
more details.
605+
544606
##`performance`
545607

546608
<!-- YAML
@@ -899,6 +961,12 @@ A browser-compatible implementation of [`WritableStreamDefaultWriter`][].
899961
[`MessageChannel`]:worker_threads.md#class-messagechannel
900962
[`MessageEvent`]:https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/MessageEvent
901963
[`MessagePort`]:worker_threads.md#class-messageport
964+
[`PerformanceEntry`]:perf_hooks.md#class-performanceentry
965+
[`PerformanceMark`]:perf_hooks.md#class-performancemark
966+
[`PerformanceMeasure`]:perf_hooks.md#class-performancemeasure
967+
[`PerformanceObserverEntryList`]:perf_hooks.md#class-performanceobserverentrylist
968+
[`PerformanceObserver`]:perf_hooks.md#class-performanceobserver
969+
[`PerformanceResourceTiming`]:perf_hooks.md#class-performanceresourcetiming
902970
[`ReadableByteStreamController`]:webstreams.md#class-readablebytestreamcontroller
903971
[`ReadableStreamBYOBReader`]:webstreams.md#class-readablestreambyobreader
904972
[`ReadableStreamBYOBRequest`]:webstreams.md#class-readablestreambyobrequest

‎lib/.eslintrc.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ rules:
7373
message:Use `const { MessageEvent } = require('internal/worker/io');` instead of the global.
7474
-name:MessagePort
7575
message:Use `const { MessagePort } = require('internal/worker/io');` instead of the global.
76+
-name:PerformanceEntry
77+
message:Use `const { PerformanceEntry } = require('perf_hooks');` instead of the global.
78+
-name:PerformanceMark
79+
message:Use `const { PerformanceMark } = require('perf_hooks');` instead of the global.
80+
-name:PerformanceMeasure
81+
message:Use `const { PerformanceMeasure } = require('perf_hooks');` instead of the global.
82+
-name:PerformanceObserverEntryList
83+
message:Use `const { PerformanceObserverEntryList } = require('perf_hooks');` instead of the global.
84+
-name:PerformanceObserver
85+
message:Use `const { PerformanceObserver } = require('perf_hooks');` instead of the global.
86+
-name:PerformanceResourceTiming
87+
message:Use `const { PerformanceResourceTiming } = require('perf_hooks');` instead of the global.
7688
-name:ReadableStream
7789
message:Use `const { ReadableStream } = require('internal/webstreams/readablestream')` instead of the global.
7890
-name:ReadableStreamDefaultReader

‎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
constperf_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)

[8]ページ先頭

©2009-2025 Movatter.jp