33
44const {
55 ObjectDefineProperties,
6- ObjectSetPrototypeOf,
7- ReflectConstruct,
86 Symbol,
97 SymbolToStringTag,
108} = primordials ;
11- const { initPerformanceEntry, PerformanceEntry } = require ( 'internal/perf/performance_entry' ) ;
12- const assert = require ( 'internal/assert' ) ;
13- const { enqueue, bufferResourceTiming } = require ( 'internal/perf/observe' ) ;
149const {
1510 codes : {
1611 ERR_ILLEGAL_CONSTRUCTOR ,
1712 } ,
1813} = 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' ) ;
1917const { validateInternalField } = require ( 'internal/validators' ) ;
2018const { kEnumerableProperty } = require ( 'internal/util' ) ;
2119
@@ -25,8 +23,12 @@ const kTimingInfo = Symbol('kTimingInfo');
2523const kInitiatorType = Symbol ( 'kInitiatorType' ) ;
2624
2725class 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 ) ;
3032 }
3133
3234 get name ( ) {
@@ -189,16 +191,17 @@ ObjectDefineProperties(PerformanceResourceTiming.prototype, {
189191} ) ;
190192
191193function 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 ;
202205}
203206
204207// https://w3c.github.io/resource-timing/#dfn-mark-resource-timing
@@ -221,7 +224,6 @@ function markResourceTiming(
221224 cacheMode ,
222225 ) ;
223226
224- ObjectSetPrototypeOf ( resource , PerformanceResourceTiming . prototype ) ;
225227 enqueue ( resource ) ;
226228 bufferResourceTiming ( resource ) ;
227229 return resource ;
0 commit comments