3
3
4
4
const {
5
5
ObjectDefineProperties,
6
- ObjectSetPrototypeOf,
7
- ReflectConstruct,
8
6
Symbol,
9
7
SymbolToStringTag,
10
8
} = primordials ;
11
- const { initPerformanceEntry, PerformanceEntry } = require ( 'internal/perf/performance_entry' ) ;
12
- const assert = require ( 'internal/assert' ) ;
13
- const { enqueue, bufferResourceTiming } = require ( 'internal/perf/observe' ) ;
14
9
const {
15
10
codes : {
16
11
ERR_ILLEGAL_CONSTRUCTOR ,
17
12
} ,
18
13
} = require ( 'internal/errors' ) ;
14
+ const { PerformanceEntry, kSkipThrow } = require ( 'internal/perf/performance_entry' ) ;
15
+ const assert = require ( 'internal/assert' ) ;
16
+ const { enqueue, bufferResourceTiming } = require ( 'internal/perf/observe' ) ;
19
17
const { validateInternalField } = require ( 'internal/validators' ) ;
20
18
const { kEnumerableProperty } = require ( 'internal/util' ) ;
21
19
@@ -25,8 +23,12 @@ const kTimingInfo = Symbol('kTimingInfo');
25
23
const kInitiatorType = Symbol ( 'kInitiatorType' ) ;
26
24
27
25
class PerformanceResourceTiming extends PerformanceEntry {
28
- constructor ( ) {
29
- throw new ERR_ILLEGAL_CONSTRUCTOR ( ) ;
26
+ constructor ( skipThrowSymbol = undefined , name = undefined , type = undefined ) {
27
+ if ( skipThrowSymbol !== kSkipThrow ) {
28
+ throw new ERR_ILLEGAL_CONSTRUCTOR ( ) ;
29
+ }
30
+
31
+ super ( skipThrowSymbol , name , type ) ;
30
32
}
31
33
32
34
get name ( ) {
@@ -189,16 +191,17 @@ ObjectDefineProperties(PerformanceResourceTiming.prototype, {
189
191
} ) ;
190
192
191
193
function createPerformanceResourceTiming ( requestedUrl , initiatorType , timingInfo , cacheMode = '' ) {
192
- return ReflectConstruct ( function PerformanceResourceTiming ( ) {
193
- initPerformanceEntry ( this , requestedUrl , 'resource' ) ;
194
- this [ kInitiatorType ] = initiatorType ;
195
- this [ kRequestedUrl ] = requestedUrl ;
196
- // https://fetch.spec.whatwg.org/#fetch-timing-info
197
- // This class is using timingInfo assuming it's already validated.
198
- // The spec doesn't say to validate it in the class construction.
199
- this [ kTimingInfo ] = timingInfo ;
200
- this [ kCacheMode ] = cacheMode ;
201
- } , [ ] , PerformanceResourceTiming ) ;
194
+ const resourceTiming = new PerformanceResourceTiming ( kSkipThrow , requestedUrl , 'resource' ) ;
195
+
196
+ resourceTiming [ kInitiatorType ] = initiatorType ;
197
+ resourceTiming [ kRequestedUrl ] = requestedUrl ;
198
+ // https://fetch.spec.whatwg.org/#fetch-timing-info
199
+ // This class is using timingInfo assuming it's already validated.
200
+ // The spec doesn't say to validate it in the class construction.
201
+ resourceTiming [ kTimingInfo ] = timingInfo ;
202
+ resourceTiming [ kCacheMode ] = cacheMode ;
203
+
204
+ return resourceTiming ;
202
205
}
203
206
204
207
// https://w3c.github.io/resource-timing/#dfn-mark-resource-timing
@@ -221,7 +224,6 @@ function markResourceTiming(
221
224
cacheMode ,
222
225
) ;
223
226
224
- ObjectSetPrototypeOf ( resource , PerformanceResourceTiming . prototype ) ;
225
227
enqueue ( resource ) ;
226
228
bufferResourceTiming ( resource ) ;
227
229
return resource ;
0 commit comments