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

Appearance settings

Commit dfe4237

Browse filesBrowse files
daeyeonRafaelGSS
authored andcommitted
perf_hooks: align toStringTag with other Web Performance implementations
This gets `Symbol.toStringTag` on Web Performance APIs to be aligned with the other runtime implementations. Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com> PR-URL: #45157 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Feng Yu <F3n67u@outlook.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e60d905 commit dfe4237
Copy full SHA for dfe4237

File tree

Expand file treeCollapse file tree

4 files changed

+33
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+33
-12
lines changed
Open diff view settings
Collapse file

‎lib/internal/perf/resource_timing.js‎

Copy file name to clipboardExpand all lines: lib/internal/perf/resource_timing.js
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ class PerformanceResourceTiming extends PerformanceEntry {
2929
throw new ERR_ILLEGAL_CONSTRUCTOR();
3030
}
3131

32-
get [SymbolToStringTag]() {
33-
return 'PerformanceResourceTiming';
34-
}
35-
3632
get name() {
3733
validateInternalField(this, kRequestedUrl, 'PerformanceResourceTiming');
3834
return this[kRequestedUrl];
@@ -185,6 +181,11 @@ ObjectDefineProperties(PerformanceResourceTiming.prototype, {
185181
encodedBodySize: kEnumerableProperty,
186182
decodedBodySize: kEnumerableProperty,
187183
toJSON: kEnumerableProperty,
184+
[SymbolToStringTag]: {
185+
__proto__: null,
186+
configurable: true,
187+
value: 'PerformanceResourceTiming',
188+
},
188189
});
189190

190191
function createPerformanceResourceTiming(requestedUrl, initiatorType, timingInfo, cacheMode = '') {
Collapse file

‎lib/internal/perf/usertiming.js‎

Copy file name to clipboardExpand all lines: lib/internal/perf/usertiming.js
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ class PerformanceMark {
9898
return this[kDetail];
9999
}
100100

101-
get [SymbolToStringTag]() {
102-
return 'PerformanceMark';
103-
}
104-
105101
toJSON() {
106102
return {
107103
name: this.name,
@@ -116,6 +112,11 @@ ObjectSetPrototypeOf(PerformanceMark, PerformanceEntry);
116112
ObjectSetPrototypeOf(PerformanceMark.prototype, PerformanceEntry.prototype);
117113
ObjectDefineProperties(PerformanceMark.prototype, {
118114
detail: kEnumerableProperty,
115+
[SymbolToStringTag]: {
116+
__proto__: null,
117+
configurable: true,
118+
value: 'PerformanceMark',
119+
},
119120
});
120121

121122
class PerformanceMeasure extends PerformanceEntry {
@@ -127,13 +128,14 @@ class PerformanceMeasure extends PerformanceEntry {
127128
validateInternalField(this, kDetail, 'PerformanceMeasure');
128129
return this[kDetail];
129130
}
130-
131-
get [SymbolToStringTag]() {
132-
return 'PerformanceMeasure';
133-
}
134131
}
135132
ObjectDefineProperties(PerformanceMeasure.prototype, {
136133
detail: kEnumerableProperty,
134+
[SymbolToStringTag]: {
135+
__proto__: null,
136+
configurable: true,
137+
value: 'PerformanceMeasure',
138+
},
137139
});
138140

139141
function createPerformanceMeasure(name, start, duration, detail) {
Collapse file

‎test/parallel/test-perf-hooks-resourcetiming.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-perf-hooks-resourcetiming.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ assert(PerformanceResourceTiming);
1717
assert(performance.clearResourceTimings);
1818
assert(performance.markResourceTiming);
1919

20+
assert.deepStrictEqual(
21+
Object.getOwnPropertyDescriptor(PerformanceResourceTiming.prototype, Symbol.toStringTag),
22+
{ configurable: true, enumerable: false, value: 'PerformanceResourceTiming', writable: false },
23+
);
24+
2025
function createTimingInfo({
2126
startTime = 0,
2227
redirectStartTime = 0,
Collapse file

‎test/parallel/test-perf-hooks-usertiming.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-perf-hooks-usertiming.js
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
PerformanceObserver,
77
PerformanceEntry,
88
PerformanceMark,
9+
PerformanceMeasure,
910
performance,
1011
performance: {
1112
nodeTiming,
@@ -18,6 +19,18 @@ assert(PerformanceMark);
1819
assert(performance.mark);
1920
assert(performance.measure);
2021

22+
[PerformanceMark, PerformanceMeasure].forEach((c) => {
23+
assert.deepStrictEqual(
24+
Object.getOwnPropertyDescriptor(c.prototype, Symbol.toStringTag),
25+
{
26+
configurable: true,
27+
enumerable: false,
28+
writable: false,
29+
value: c.name,
30+
}
31+
);
32+
});
33+
2134
[undefined, 'a', 'null', 1, true].forEach((i) => {
2235
const m = performance.mark(i);
2336
assert(m instanceof PerformanceEntry);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.