@@ -13,13 +13,13 @@ const kTimingInfo = Symbol('kTimingInfo');
13
13
const kInitiatorType = Symbol ( 'kInitiatorType' ) ;
14
14
15
15
class PerformanceResourceTiming extends InternalPerformanceEntry {
16
- constructor ( requestedUrl , start , initiatorType , timingInfo , cacheMode = '' ) {
17
- super ( requestedUrl , 'resource' , start ) ;
18
- // https://w3c.github.io/resource-timing/#dfn-setup-the-resource-timing-entry
19
- assert . ok ( cacheMode === '' || cacheMode === 'local' ) ;
16
+ constructor ( requestedUrl , initiatorType , timingInfo , cacheMode = '' ) {
17
+ super ( requestedUrl , 'resource' ) ;
20
18
this [ kInitiatorType ] = initiatorType ;
21
19
this [ kRequestedUrl ] = requestedUrl ;
22
20
// https://fetch.spec.whatwg.org/#fetch-timing-info
21
+ // This class is using timingInfo assuming it's already validated.
22
+ // The spec doesn't say to validate it in the class construction.
23
23
this [ kTimingInfo ] = timingInfo ;
24
24
this [ kCacheMode ] = cacheMode ;
25
25
}
@@ -111,14 +111,27 @@ class PerformanceResourceTiming extends InternalPerformanceEntry {
111
111
112
112
toJSON ( ) {
113
113
return {
114
- initiatorType : this [ kInitiatorType ] ,
115
- requestedUrl : this [ kRequestedUrl ] ,
116
- cacheMode : this [ kCacheMode ] ,
117
- // TODO(rafaelgss): should return timingInfo as well?
118
114
name : this . name ,
119
115
entryType : this . entryType ,
120
116
startTime : this . startTime ,
121
117
duration : this . duration ,
118
+ initiatorType : this [ kInitiatorType ] ,
119
+ nextHopProtocol : this . nextHopProtocol ,
120
+ workerStart : this . workerStart ,
121
+ redirectStart : this . redirectStart ,
122
+ redirectEnd : this . redirectEnd ,
123
+ fetchStart : this . fetchStart ,
124
+ domainLookupStart : this . domainLookupStart ,
125
+ domainLookupEnd : this . domainLookupEnd ,
126
+ connectStart : this . connectStart ,
127
+ connectEnd : this . connectEnd ,
128
+ secureConnectionStart : this . secureConnectionStart ,
129
+ requestStart : this . requestStart ,
130
+ responseStart : this . responseStart ,
131
+ responseEnd : this . responseEnd ,
132
+ transferSize : this . transferSize ,
133
+ encodedBodySize : this . encodedBodySize ,
134
+ decodedBodySize : this . decodedBodySize ,
122
135
} ;
123
136
}
124
137
}
@@ -131,17 +144,10 @@ function markResourceTiming(
131
144
global ,
132
145
cacheMode ,
133
146
) {
134
- // TODO(rafaelgss): Probably must have some asserts here for:
135
- // - timingInfo
136
- // - requestedUrl
137
- // - initiatorType
138
- // - cacheMode
139
- // 1. Create a PerformanceResourceTiming object entry in global's realm.
140
- // TODO(rafaelgss): why and how should I put `resource` into global object?
147
+ // https://w3c.github.io/resource-timing/#dfn-setup-the-resource-timing-entry
148
+ assert ( cacheMode === '' || cacheMode === 'local' ) ;
141
149
const resource = new PerformanceResourceTiming (
142
150
requestedUrl ,
143
- // TODO(rafaelgss): not sure about that
144
- timingInfo . startTime ,
145
151
initiatorType ,
146
152
timingInfo ,
147
153
cacheMode ,
0 commit comments