| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,6 +53,7 @@ const { | |||
| 53 | 53 | const { | |
| 54 | 54 | customInspectSymbol: kInspect, | |
| 55 | 55 | deprecate, | |
| 56 | + lazyDOMException, | ||
| 56 | 57 | } = require('internal/util'); | |
| 57 | 58 | ||
| 58 | 59 | const { | |
@@ -106,9 +107,10 @@ function queuePending() { | |||
| 106 | 107 | isPending = true; | |
| 107 | 108 | setImmediate(() => { | |
| 108 | 109 | isPending = false; | |
| 109 | - for (const pending of kPending) | ||
| 110 | - pending[kDispatch](); | ||
| 110 | + const pendings = ArrayFrom(kPending.values()); | ||
| 111 | 111 | kPending.clear(); | |
| 112 | + for (const pending of pendings) | ||
| 113 | + pending[kDispatch](); | ||
| 112 | 114 | }); | |
| 113 | 115 | } | |
| 114 | 116 | ||
@@ -168,8 +170,13 @@ class PerformanceObserverEntryList { | |||
| 168 | 170 | (entry) => entry.entryType === type); | |
| 169 | 171 | } | |
| 170 | 172 | ||
| 171 | - getEntriesByName(name) { | ||
| 173 | + getEntriesByName(name, type) { | ||
| 172 | 174 | name = `${name}`; | |
| 175 | + if (type != null /** not nullish */) { | ||
| 176 | + return ArrayPrototypeFilter( | ||
| 177 | + this[kBuffer], | ||
| 178 | + (entry) => entry.name === name && entry.entryType === type); | ||
| 179 | + } | ||
| 173 | 180 | return ArrayPrototypeFilter( | |
| 174 | 181 | this[kBuffer], | |
| 175 | 182 | (entry) => entry.name === name); | |
@@ -208,6 +215,11 @@ class PerformanceObserver { | |||
| 208 | 215 | } = { ...options }; | |
| 209 | 216 | if (entryTypes === undefined && type === undefined) | |
| 210 | 217 | throw new ERR_MISSING_ARGS('options.entryTypes', 'options.type'); | |
| 218 | + if (entryTypes != null && type != null) | ||
| 219 | + throw new ERR_INVALID_ARG_VALUE('options.entryTypes', | ||
| 220 | + entryTypes, | ||
| 221 | + 'options.entryTypes can not set with ' + | ||
| 222 | + 'options.type together'); | ||
| 211 | 223 | ||
| 212 | 224 | switch (this[kType]) { | |
| 213 | 225 | case undefined: | |
@@ -216,11 +228,15 @@ class PerformanceObserver { | |||
| 216 | 228 | break; | |
| 217 | 229 | case kTypeSingle: | |
| 218 | 230 | if (entryTypes !== undefined) | |
| 219 | - throw new ERR_INVALID_ARG_VALUE('options.entryTypes', entryTypes); | ||
| 231 | + throw lazyDOMException( | ||
| 232 | + 'PerformanceObserver can not change to multiple observations', | ||
| 233 | + 'InvalidModificationError'); | ||
| 220 | 234 | break; | |
| 221 | 235 | case kTypeMultiple: | |
| 222 | 236 | if (type !== undefined) | |
| 223 | - throw new ERR_INVALID_ARG_VALUE('options.type', type); | ||
| 237 | + throw lazyDOMException( | ||
| 238 | + 'PerformanceObserver can not change to single observation', | ||
| 239 | + 'InvalidModificationError'); | ||
| 224 | 240 | break; | |
| 225 | 241 | } | |
| 226 | 242 | ||
@@ -271,7 +287,7 @@ class PerformanceObserver { | |||
| 271 | 287 | takeRecords() { | |
| 272 | 288 | const list = this[kBuffer]; | |
| 273 | 289 | this[kBuffer] = []; | |
| 274 | - return new PerformanceObserverEntryList(list); | ||
| 290 | + return list; | ||
| 275 | 291 | } | |
| 276 | 292 | ||
| 277 | 293 | static get supportedEntryTypes() { | |
@@ -287,7 +303,10 @@ class PerformanceObserver { | |||
| 287 | 303 | queuePending(); | |
| 288 | 304 | } | |
| 289 | 305 | ||
| 290 | - [kDispatch]() { this[kCallback](this.takeRecords(), this); } | ||
| 306 | + [kDispatch]() { | ||
| 307 | + this[kCallback](new PerformanceObserverEntryList(this.takeRecords()), | ||
| 308 | + this); | ||
| 309 | + } | ||
| 291 | 310 | ||
| 292 | 311 | [kInspect](depth, options) { | |
| 293 | 312 | if (depth < 0) return this; | |
@@ -367,6 +386,7 @@ function clearEntriesFromBuffer(type, name) { | |||
| 367 | 386 | ||
| 368 | 387 | let head = null; | |
| 369 | 388 | let tail = null; | |
| 389 | + let count = 0; | ||
| 370 | 390 | for (let entry = buffer.head; entry !== null; entry = entry[kBufferNext]) { | |
| 371 | 391 | if (entry.name !== name) { | |
| 372 | 392 | head = head ?? entry; | |
@@ -377,9 +397,11 @@ function clearEntriesFromBuffer(type, name) { | |||
| 377 | 397 | continue; | |
| 378 | 398 | } | |
| 379 | 399 | tail[kBufferNext] = entry[kBufferNext]; | |
| 400 | + count++; | ||
| 380 | 401 | } | |
| 381 | 402 | buffer.head = head; | |
| 382 | 403 | buffer.tail = tail; | |
| 404 | + buffer.count = count; | ||
| 383 | 405 | } | |
| 384 | 406 | ||
| 385 | 407 | function filterBufferMapByNameAndType(name, type) { | |
@@ -469,6 +491,7 @@ function resetBuffer(buffer) { | |||
| 469 | 491 | ||
| 470 | 492 | module.exports = { | |
| 471 | 493 | PerformanceObserver, | |
| 494 | + PerformanceObserverEntryList, | ||
| 472 | 495 | enqueue, | |
| 473 | 496 | hasObserver, | |
| 474 | 497 | clearEntriesFromBuffer, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,10 @@ const { | |||
| 9 | 9 | } = internalBinding('performance'); | |
| 10 | 10 | ||
| 11 | 11 | const { PerformanceEntry } = require('internal/perf/performance_entry'); | |
| 12 | - const { PerformanceObserver } = require('internal/perf/observe'); | ||
| 12 | + const { | ||
| 13 | + PerformanceObserver, | ||
| 14 | + PerformanceObserverEntryList, | ||
| 15 | + } = require('internal/perf/observe'); | ||
| 13 | 16 | const { | |
| 14 | 17 | PerformanceMark, | |
| 15 | 18 | PerformanceMeasure, | |
@@ -27,6 +30,7 @@ module.exports = { | |||
| 27 | 30 | PerformanceMark, | |
| 28 | 31 | PerformanceMeasure, | |
| 29 | 32 | PerformanceObserver, | |
| 33 | + PerformanceObserverEntryList, | ||
| 30 | 34 | monitorEventLoopDelay, | |
| 31 | 35 | createHistogram, | |
| 32 | 36 | performance: new InternalPerformance(), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1 +1,11 @@ | |||
| 1 | - {} | ||
| 1 | + { | ||
| 2 | + "case-sensitivity.any.js": { | ||
| 3 | + "fail": "resource entry type not supported" | ||
| 4 | + }, | ||
| 5 | + "idlharness.any.js": { | ||
| 6 | + "skip": "idlharness cannot recognize Node.js environment" | ||
| 7 | + }, | ||
| 8 | + "webtiming-resolution.any.js": { | ||
| 9 | + "skip": "flaky" | ||
| 10 | + } | ||
| 11 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | require('../common'); | |
| 3 | 3 | const { WPTRunner } = require('../common/wpt'); | |
| 4 | 4 | ||
| 5 | - const runner = new WPTRunner('user-timing'); | ||
| 5 | + const runner = new WPTRunner('performance-timeline'); | ||
| 6 | 6 | ||
| 7 | 7 | // Needed to access to DOMException. | |
| 8 | 8 | runner.setFlags(['--expose-internals']); | |
@@ -12,11 +12,13 @@ runner.setInitScript(` | |||
| 12 | 12 | PerformanceMark, | |
| 13 | 13 | PerformanceMeasure, | |
| 14 | 14 | PerformanceObserver, | |
| 15 | + PerformanceObserverEntryList, | ||
| 15 | 16 | performance, | |
| 16 | 17 | } = require('perf_hooks'); | |
| 17 | 18 | global.PerformanceMark = performance; | |
| 18 | 19 | global.PerformanceMeasure = performance; | |
| 19 | 20 | global.PerformanceObserver = PerformanceObserver; | |
| 21 | + global.PerformanceObserverEntryList = PerformanceObserverEntryList; | ||
| 20 | 22 | global.performance = performance; | |
| 21 | 23 | ||
| 22 | 24 | const { internalBinding } = require('internal/test/binding'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments