| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 11e9789 commit 1f7c2a9
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -246,19 +246,26 @@ and can be queried with `performance.getEntries`, | |||
| 246 | 246 | observation is performed, the entries should be cleared from the global | |
| 247 | 247 | Performance Timeline manually with `performance.clearMarks`. | |
| 248 | 248 | ||
| 249 | - ### `performance.markResourceTiming(timingInfo, requestedUrl, initiatorType, global, cacheMode)` | ||
| 249 | + ### `performance.markResourceTiming(timingInfo, requestedUrl, initiatorType, global, cacheMode, bodyInfo, responseStatus[, deliveryType])` | ||
| 250 | 250 | ||
| 251 | 251 | <!-- YAML | |
| 252 | 252 | added: | |
| 253 | 253 | - v18.2.0 | |
| 254 | 254 | - v16.17.0 | |
| 255 | + changes: | ||
| 256 | + - version: REPLACEME | ||
| 257 | + pr-url: https://github.com/nodejs/node/pull/51589 | ||
| 258 | + description: Added bodyInfo, responseStatus, and deliveryType arguments. | ||
| 255 | 259 | --> | |
| 256 | 260 | ||
| 257 | 261 | * `timingInfo` {Object} [Fetch Timing Info][] | |
| 258 | 262 | * `requestedUrl` {string} The resource url | |
| 259 | 263 | * `initiatorType` {string} The initiator name, e.g: 'fetch' | |
| 260 | 264 | * `global` {Object} | |
| 261 | 265 | * `cacheMode` {string} The cache mode must be an empty string ('') or 'local' | |
| 266 | + * `bodyInfo` {Object} [Fetch Response Body Info][] | ||
| 267 | + * `responseStatus` {number} The response's status code | ||
| 268 | + * `deliveryType` {string} The delivery type. **Default:** `''`. | ||
| 262 | 269 | ||
| 263 | 270 | _This property is an extension by Node.js. It is not available in Web browsers._ | |
| 264 | 271 | ||
@@ -1911,6 +1918,7 @@ dns.promises.resolve('localhost'); | |||
| 1911 | 1918 | ``` | |
| 1912 | 1919 | ||
| 1913 | 1920 | [Async Hooks]: async_hooks.md | |
| 1921 | + [Fetch Response Body Info]: https://fetch.spec.whatwg.org/#response-body-info | ||
| 1914 | 1922 | [Fetch Timing Info]: https://fetch.spec.whatwg.org/#fetch-timing-info | |
| 1915 | 1923 | [High Resolution Time]: https://www.w3.org/TR/hr-time-2 | |
| 1916 | 1924 | [Performance Timeline]: https://w3c.github.io/performance-timeline/ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,8 @@ const kCacheMode = Symbol('kCacheMode'); | |||
| 21 | 21 | const kRequestedUrl = Symbol('kRequestedUrl'); | |
| 22 | 22 | const kTimingInfo = Symbol('kTimingInfo'); | |
| 23 | 23 | const kInitiatorType = Symbol('kInitiatorType'); | |
| 24 | + const kDeliveryType = Symbol('kDeliveryType'); | ||
| 25 | + const kResponseStatus = Symbol('kResponseStatus'); | ||
| 24 | 26 | ||
| 25 | 27 | class PerformanceResourceTiming extends PerformanceEntry { | |
| 26 | 28 | constructor(skipThrowSymbol = undefined, name = undefined, type = undefined) { | |
@@ -136,6 +138,16 @@ class PerformanceResourceTiming extends PerformanceEntry { | |||
| 136 | 138 | return this[kTimingInfo].encodedBodySize + 300; | |
| 137 | 139 | } | |
| 138 | 140 | ||
| 141 | + get deliveryType() { | ||
| 142 | + validateInternalField(this, kTimingInfo, 'PerformanceResourceTiming'); | ||
| 143 | + return this[kDeliveryType]; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + get responseStatus() { | ||
| 147 | + validateInternalField(this, kTimingInfo, 'PerformanceResourceTiming'); | ||
| 148 | + return this[kResponseStatus]; | ||
| 149 | + } | ||
| 150 | + | ||
| 139 | 151 | toJSON() { | |
| 140 | 152 | validateInternalField(this, kInitiatorType, 'PerformanceResourceTiming'); | |
| 141 | 153 | return { | |
@@ -160,6 +172,8 @@ class PerformanceResourceTiming extends PerformanceEntry { | |||
| 160 | 172 | transferSize: this.transferSize, | |
| 161 | 173 | encodedBodySize: this.encodedBodySize, | |
| 162 | 174 | decodedBodySize: this.decodedBodySize, | |
| 175 | + deliveryType: this.deliveryType, | ||
| 176 | + responseStatus: this.responseStatus, | ||
| 163 | 177 | }; | |
| 164 | 178 | } | |
| 165 | 179 | } | |
@@ -182,6 +196,8 @@ ObjectDefineProperties(PerformanceResourceTiming.prototype, { | |||
| 182 | 196 | transferSize: kEnumerableProperty, | |
| 183 | 197 | encodedBodySize: kEnumerableProperty, | |
| 184 | 198 | decodedBodySize: kEnumerableProperty, | |
| 199 | + deliveryType: kEnumerableProperty, | ||
| 200 | + responseStatus: kEnumerableProperty, | ||
| 185 | 201 | toJSON: kEnumerableProperty, | |
| 186 | 202 | [SymbolToStringTag]: { | |
| 187 | 203 | __proto__: null, | |
@@ -190,7 +206,15 @@ ObjectDefineProperties(PerformanceResourceTiming.prototype, { | |||
| 190 | 206 | }, | |
| 191 | 207 | }); | |
| 192 | 208 | ||
| 193 | - function createPerformanceResourceTiming(requestedUrl, initiatorType, timingInfo, cacheMode = '') { | ||
| 209 | + function createPerformanceResourceTiming( | ||
| 210 | + requestedUrl, | ||
| 211 | + initiatorType, | ||
| 212 | + timingInfo, | ||
| 213 | + cacheMode = '', | ||
| 214 | + bodyInfo, | ||
| 215 | + responseStatus, | ||
| 216 | + deliveryType, | ||
| 217 | + ) { | ||
| 194 | 218 | const resourceTiming = new PerformanceResourceTiming(kSkipThrow, requestedUrl, 'resource'); | |
| 195 | 219 | ||
| 196 | 220 | resourceTiming[kInitiatorType] = initiatorType; | |
@@ -200,6 +224,8 @@ function createPerformanceResourceTiming(requestedUrl, initiatorType, timingInfo | |||
| 200 | 224 | // The spec doesn't say to validate it in the class construction. | |
| 201 | 225 | resourceTiming[kTimingInfo] = timingInfo; | |
| 202 | 226 | resourceTiming[kCacheMode] = cacheMode; | |
| 227 | + resourceTiming[kDeliveryType] = deliveryType; | ||
| 228 | + resourceTiming[kResponseStatus] = responseStatus; | ||
| 203 | 229 | ||
| 204 | 230 | return resourceTiming; | |
| 205 | 231 | } | |
@@ -211,6 +237,9 @@ function markResourceTiming( | |||
| 211 | 237 | initiatorType, | |
| 212 | 238 | global, | |
| 213 | 239 | cacheMode, | |
| 240 | + bodyInfo, | ||
| 241 | + responseStatus, | ||
| 242 | + deliveryType = '', | ||
| 214 | 243 | ) { | |
| 215 | 244 | // https://w3c.github.io/resource-timing/#dfn-setup-the-resource-timing-entry | |
| 216 | 245 | assert( | |
@@ -222,6 +251,9 @@ function markResourceTiming( | |||
| 222 | 251 | initiatorType, | |
| 223 | 252 | timingInfo, | |
| 224 | 253 | cacheMode, | |
| 254 | + bodyInfo, | ||
| 255 | + responseStatus, | ||
| 256 | + deliveryType, | ||
| 225 | 257 | ); | |
| 226 | 258 | ||
| 227 | 259 | enqueue(resource); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,6 +86,9 @@ function createTimingInfo({ | |||
| 86 | 86 | initiatorType, | |
| 87 | 87 | customGlobal, | |
| 88 | 88 | cacheMode, | |
| 89 | + {}, | ||
| 90 | + 200, | ||
| 91 | + '', | ||
| 89 | 92 | ); | |
| 90 | 93 | ||
| 91 | 94 | assert(resource instanceof PerformanceEntry); | |
@@ -128,6 +131,9 @@ function createTimingInfo({ | |||
| 128 | 131 | initiatorType, | |
| 129 | 132 | customGlobal, | |
| 130 | 133 | cacheMode, | |
| 134 | + {}, | ||
| 135 | + 200, | ||
| 136 | + '', | ||
| 131 | 137 | ); | |
| 132 | 138 | ||
| 133 | 139 | assert(resource instanceof PerformanceEntry); | |
@@ -155,6 +161,8 @@ function createTimingInfo({ | |||
| 155 | 161 | assert.strictEqual(resource.encodedBodySize, 0); | |
| 156 | 162 | assert.strictEqual(resource.decodedBodySize, 0); | |
| 157 | 163 | assert.strictEqual(resource.transferSize, 0); | |
| 164 | + assert.strictEqual(resource.deliveryType, ''); | ||
| 165 | + assert.strictEqual(resource.responseStatus, 200); | ||
| 158 | 166 | assert.deepStrictEqual(resource.toJSON(), { | |
| 159 | 167 | name: requestedUrl, | |
| 160 | 168 | entryType: 'resource', | |
@@ -177,6 +185,8 @@ function createTimingInfo({ | |||
| 177 | 185 | transferSize: 0, | |
| 178 | 186 | encodedBodySize: 0, | |
| 179 | 187 | decodedBodySize: 0, | |
| 188 | + responseStatus: 200, | ||
| 189 | + deliveryType: '', | ||
| 180 | 190 | }); | |
| 181 | 191 | assert.strictEqual(util.inspect(performance.getEntries()), `[ | |
| 182 | 192 | PerformanceResourceTiming { | |
@@ -200,7 +210,9 @@ function createTimingInfo({ | |||
| 200 | 210 | responseEnd: 0, | |
| 201 | 211 | transferSize: 0, | |
| 202 | 212 | encodedBodySize: 0, | |
| 203 | - decodedBodySize: 0 | ||
| 213 | + decodedBodySize: 0, | ||
| 214 | + deliveryType: '', | ||
| 215 | + responseStatus: 200 | ||
| 204 | 216 | } | |
| 205 | 217 | ]`); | |
| 206 | 218 | assert.strictEqual(util.inspect(resource), `PerformanceResourceTiming { | |
@@ -224,7 +236,9 @@ function createTimingInfo({ | |||
| 224 | 236 | responseEnd: 0, | |
| 225 | 237 | transferSize: 0, | |
| 226 | 238 | encodedBodySize: 0, | |
| 227 | - decodedBodySize: 0 | ||
| 239 | + decodedBodySize: 0, | ||
| 240 | + deliveryType: '', | ||
| 241 | + responseStatus: 200 | ||
| 228 | 242 | }`); | |
| 229 | 243 | ||
| 230 | 244 | assert(resource instanceof PerformanceEntry); | |
@@ -252,6 +266,9 @@ function createTimingInfo({ | |||
| 252 | 266 | initiatorType, | |
| 253 | 267 | customGlobal, | |
| 254 | 268 | cacheMode, | |
| 269 | + {}, | ||
| 270 | + 200, | ||
| 271 | + '', | ||
| 255 | 272 | ); | |
| 256 | 273 | ||
| 257 | 274 | assert(resource instanceof PerformanceEntry); | |
@@ -307,6 +324,9 @@ function createTimingInfo({ | |||
| 307 | 324 | initiatorType, | |
| 308 | 325 | customGlobal, | |
| 309 | 326 | cacheMode, | |
| 327 | + {}, | ||
| 328 | + 200, | ||
| 329 | + '' | ||
| 310 | 330 | ); | |
| 311 | 331 | ||
| 312 | 332 | assert(resource instanceof PerformanceEntry); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,10 +34,19 @@ const cacheMode = ''; | |||
| 34 | 34 | ||
| 35 | 35 | async function main() { | |
| 36 | 36 | performance.setResourceTimingBufferSize(1); | |
| 37 | - performance.markResourceTiming(createTimingInfo(1), requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 37 | + const args = [ | ||
| 38 | + requestedUrl, | ||
| 39 | + initiatorType, | ||
| 40 | + globalThis, | ||
| 41 | + cacheMode, | ||
| 42 | + {}, // body info | ||
| 43 | + 200, | ||
| 44 | + '', | ||
| 45 | + ]; | ||
| 46 | + performance.markResourceTiming(createTimingInfo(1), ...args); | ||
| 38 | 47 | // Trigger a resourcetimingbufferfull event. | |
| 39 | - performance.markResourceTiming(createTimingInfo(2), requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 40 | - performance.markResourceTiming(createTimingInfo(3), requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 48 | + performance.markResourceTiming(createTimingInfo(2), ...args); | ||
| 49 | + performance.markResourceTiming(createTimingInfo(3), ...args); | ||
| 41 | 50 | assert.strictEqual(performance.getEntriesByType('resource').length, 1); | |
| 42 | 51 | ||
| 43 | 52 | // Clear resource timings on resourcetimingbufferfull event. | |
@@ -65,10 +74,10 @@ async function main() { | |||
| 65 | 74 | ||
| 66 | 75 | performance.clearResourceTimings(); | |
| 67 | 76 | performance.setResourceTimingBufferSize(1); | |
| 68 | - performance.markResourceTiming(createTimingInfo(4), requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 77 | + performance.markResourceTiming(createTimingInfo(4), ...args); | ||
| 69 | 78 | // Trigger a resourcetimingbufferfull event. | |
| 70 | - performance.markResourceTiming(createTimingInfo(5), requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 71 | - performance.markResourceTiming(createTimingInfo(6), requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 79 | + performance.markResourceTiming(createTimingInfo(5), ...args); | ||
| 80 | + performance.markResourceTiming(createTimingInfo(6), ...args); | ||
| 72 | 81 | ||
| 73 | 82 | // Increase the buffer size on resourcetimingbufferfull event. | |
| 74 | 83 | await new Promise((resolve) => { | |
@@ -96,10 +105,10 @@ async function main() { | |||
| 96 | 105 | ||
| 97 | 106 | performance.clearResourceTimings(); | |
| 98 | 107 | performance.setResourceTimingBufferSize(2); | |
| 99 | - performance.markResourceTiming(createTimingInfo(7), requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 100 | - performance.markResourceTiming(createTimingInfo(8), requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 108 | + performance.markResourceTiming(createTimingInfo(7), ...args); | ||
| 109 | + performance.markResourceTiming(createTimingInfo(8), ...args); | ||
| 101 | 110 | // Trigger a resourcetimingbufferfull event. | |
| 102 | - performance.markResourceTiming(createTimingInfo(9), requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 111 | + performance.markResourceTiming(createTimingInfo(9), ...args); | ||
| 103 | 112 | ||
| 104 | 113 | // Decrease the buffer size on resourcetimingbufferfull event. | |
| 105 | 114 | await new Promise((resolve) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,21 +30,28 @@ const initiatorType = ''; | |||
| 30 | 30 | const cacheMode = ''; | |
| 31 | 31 | ||
| 32 | 32 | async function main() { | |
| 33 | + const args = [ | ||
| 34 | + timingInfo, | ||
| 35 | + requestedUrl, | ||
| 36 | + initiatorType, | ||
| 37 | + globalThis, | ||
| 38 | + cacheMode, | ||
| 39 | + ]; | ||
| 33 | 40 | // Invalid buffer size values are converted to 0. | |
| 34 | 41 | const invalidValues = [ null, undefined, true, false, -1, 0.5, Infinity, NaN, '', 'foo', {}, [], () => {} ]; | |
| 35 | 42 | for (const value of invalidValues) { | |
| 36 | 43 | performance.setResourceTimingBufferSize(value); | |
| 37 | - performance.markResourceTiming(timingInfo, requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 44 | + performance.markResourceTiming(...args); | ||
| 38 | 45 | assert.strictEqual(performance.getEntriesByType('resource').length, 0); | |
| 39 | 46 | performance.clearResourceTimings(); | |
| 40 | 47 | } | |
| 41 | 48 | // Wait for the buffer full event to be cleared. | |
| 42 | 49 | await waitBufferFullEvent(); | |
| 43 | 50 | ||
| 44 | 51 | performance.setResourceTimingBufferSize(1); | |
| 45 | - performance.markResourceTiming(timingInfo, requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 52 | + performance.markResourceTiming(...args); | ||
| 46 | 53 | // Trigger a resourcetimingbufferfull event. | |
| 47 | - performance.markResourceTiming(timingInfo, requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 54 | + performance.markResourceTiming(...args); | ||
| 48 | 55 | assert.strictEqual(performance.getEntriesByType('resource').length, 1); | |
| 49 | 56 | await waitBufferFullEvent(); | |
| 50 | 57 | ||
@@ -56,14 +63,14 @@ async function main() { | |||
| 56 | 63 | performance.clearResourceTimings(); | |
| 57 | 64 | assert.strictEqual(performance.getEntriesByType('resource').length, 0); | |
| 58 | 65 | // Trigger a resourcetimingbufferfull event. | |
| 59 | - performance.markResourceTiming(timingInfo, requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 66 | + performance.markResourceTiming(...args); | ||
| 60 | 67 | // New entry is not added to the global buffer. | |
| 61 | 68 | assert.strictEqual(performance.getEntriesByType('resource').length, 0); | |
| 62 | 69 | await waitBufferFullEvent(); | |
| 63 | 70 | ||
| 64 | 71 | // Apply a new buffer size limit | |
| 65 | 72 | performance.setResourceTimingBufferSize(1); | |
| 66 | - performance.markResourceTiming(timingInfo, requestedUrl, initiatorType, globalThis, cacheMode); | ||
| 73 | + performance.markResourceTiming(...args); | ||
| 67 | 74 | assert.strictEqual(performance.getEntriesByType('resource').length, 1); | |
| 68 | 75 | } | |
| 69 | 76 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,14 +23,10 @@ | |||
| 23 | 23 | "idlharness.any.js": { | |
| 24 | 24 | "fail": { | |
| 25 | 25 | "expected": [ | |
| 26 | - "PerformanceResourceTiming interface: attribute deliveryType", | ||
| 27 | 26 | "PerformanceResourceTiming interface: attribute firstInterimResponseStart", | |
| 28 | - "PerformanceResourceTiming interface: attribute responseStatus", | ||
| 29 | 27 | "PerformanceResourceTiming interface: attribute renderBlockingStatus", | |
| 30 | 28 | "PerformanceResourceTiming interface: attribute contentType", | |
| 31 | - "PerformanceResourceTiming interface: resource must inherit property \"deliveryType\" with the proper type", | ||
| 32 | 29 | "PerformanceResourceTiming interface: resource must inherit property \"firstInterimResponseStart\" with the proper type", | |
| 33 | - "PerformanceResourceTiming interface: resource must inherit property \"responseStatus\" with the proper type", | ||
| 34 | 30 | "PerformanceResourceTiming interface: resource must inherit property \"renderBlockingStatus\" with the proper type", | |
| 35 | 31 | "PerformanceResourceTiming interface: resource must inherit property \"contentType\" with the proper type", | |
| 36 | 32 | "PerformanceResourceTiming interface: default toJSON operation on resource" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,7 +27,7 @@ runner.setInitScript(` | |||
| 27 | 27 | finalNetworkResponseStartTime: 0, | |
| 28 | 28 | encodedBodySize: 0, | |
| 29 | 29 | decodedBodySize: 0, | |
| 30 | - }, 'https://nodejs.org', '', global, ''); | ||
| 30 | + }, 'https://nodejs.org', '', global, '', {}, 200, ''); | ||
| 31 | 31 | `); | |
| 32 | 32 | ||
| 33 | 33 | runner.runJsTests(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,7 @@ runner.setInitScript(` | |||
| 25 | 25 | finalNetworkResponseStartTime: 0, | |
| 26 | 26 | encodedBodySize: 0, | |
| 27 | 27 | decodedBodySize: 0, | |
| 28 | - }, 'https://nodejs.org', '', global, ''); | ||
| 28 | + }, 'https://nodejs.org', '', global, '', {}, 200, ''); | ||
| 29 | 29 | `); | |
| 30 | 30 | ||
| 31 | 31 | runner.runJsTests(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments