GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf_hooks: fix webperf idlharness · nodejs/node@364c0e1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • perf_hooks.md
  • lib/internal
    • bootstrap
      • browser.js
    • perf
      • observe.js
      • performance.js
      • performance_entry.js
      • resource_timing.js
      • timerify.js
      • usertiming.js
    • process
      • pre_execution.js
  • test
    • common
      • wpt.js
    • fixtures/wpt
      • README.md
      • interfaces
        • WebCryptoAPI.idl
        • console.idl
        • dom.idl
        • encoding.idl
        • hr-time.idl
        • html.idl
        • performance-timeline.idl
        • resource-timing.idl
        • streams.idl
        • url.idl
        • user-timing.idl
        • webidl.idl
      • resource-timing
        • 304-response-recorded.html
        • CodingConventions.md
        • META.yml
        • SO-XO-SO-redirect-chain-tao.https.html
        • TAO-match.html
        • TAO-port-mismatch-means-crossorigin.html
        • buffer-full-add-after-full-event.html
        • buffer-full-add-entries-during-callback-that-drop.html
        • buffer-full-add-entries-during-callback.html
        • buffer-full-add-then-clear.html
        • buffer-full-decrease-buffer-during-callback.html
        • buffer-full-eventually.html
        • buffer-full-increase-buffer-during-callback.html
        • buffer-full-inspect-buffer-during-callback.html
        • buffer-full-set-to-current-buffer.html
        • buffer-full-store-and-clear-during-callback.html
        • buffer-full-then-decreased.html
        • buffer-full-then-increased.html
        • buffer-full-when-populate-entries.html
        • buffered-flag.any.js
        • cached-image-gets-single-entry.html
        • clear-resource-timings.html
        • connection-reuse.html
        • connection-reuse.https.html
        • cors-preflight.any.js
        • cross-origin-iframe.html
        • cross-origin-redirects.html
        • cross-origin-start-end-time-with-redirects.html
        • cross-origin-status-codes.html
        • document-domain-no-impact-opener.html
        • entries-for-network-errors.sub.https.html
        • entry-attributes.html
        • event-source-timing.html
        • fetch-cross-origin-redirect.https.html
        • font-timestamps.html
        • frameset-timing.html
        • idlharness.any.js
        • iframe-failed-commit.html
        • iframe-non-html.html
        • iframe-redirect-without-location.html
        • iframe-sequence-of-events.html
        • iframe-with-download.html
        • image-sequence-of-events.html
        • initiator-type-for-script.html
        • initiator-type
          • audio.html
          • dynamic-insertion.html
          • embed.html
          • frameset.html
          • iframe.html
          • img-srcset.html
          • img.html
          • input.html
          • link.html
          • misc.html
          • picture.html
          • resources
            • initiator-type-test.js
          • script.html
          • style.html
          • svg.html
          • video.html
          • workers.html
        • input-sequence-of-events.html
        • link-sequence-of-events.html
        • load-from-mem-cache-transfer-size.html
        • nested-context-navigations-embed.html
        • nested-context-navigations-iframe.html
        • nested-context-navigations-object.html
        • nextHopProtocol-is-tao-protected.https.html
        • no-entries-for-cross-origin-css-fetched.sub.html
        • object-not-found-adds-entry.html
        • object-not-found-after-TAO-cross-origin-redirect.html
        • object-not-found-after-cross-origin-redirect.html
        • opaque-origin.html
        • ping-rt-entries.html
        • redirects.html
        • render-blocking-status-link.html
        • render-blocking-status-script.html
        • resource-ignore-data-url.html
        • resource-reload-TAO.html
        • resource-timing-level1.js
        • resource-timing-level1.sub.html
        • resource_connection_reuse_mixed_content.html
        • resource_connection_reuse_mixed_content_redirect.html
        • resource_dedicated_worker.html
        • resource_nested_dedicated_worker.worker.js
        • resource_reparenting.html
        • resource_subframe_self_navigation.html
        • resource_timing.worker.js
        • resource_timing_content_length.html
        • resources
          • 200.https.asis
          • 200_empty.asis
          • 204_empty.asis
          • 205_empty.asis
          • blank-with-tao.html.headers
          • blank-with-tao.html
          • blue-with-tao.png.headers
          • blue-with-tao.png
          • blue.png
          • buffer-full-utilities.js
          • close.html
          • connection-reuse-test.js
          • csp-default-none.html.headers
          • csp-default-none.html
          • document-domain-no-impact.html
          • document-navigated.html
          • document-refreshed.html
          • document-that-navigates.html
          • document-that-refreshes.html
          • download.asis
          • embed-navigate-back.html
          • embed-navigate.html
          • embed-refresh.html
          • empty.js
          • empty_script.js
          • empty_style.css
          • entry-invariants.js
          • fake_responses.html
          • fake_responses_https.sub.html
          • fake_responses_https_redirect.sub.html
          • frame-timing.js
          • frameset-timing-frame.html
          • green-frame.html
          • green.html.headers
          • green.html
          • iframe-TAO-crossorigin-port.sub.html
          • iframe-load-from-mem-cache-transfer-size.html
          • iframe-navigate-back.html
          • iframe-navigate.html
          • iframe-refresh.html
          • iframe-reload-TAO.html
          • iframe-setdomain.sub.html
          • iframe-with-delay.sub.html
          • iframe_TAO_match_origin.html
          • import.sub.css
          • importer.css
          • importer.js
          • importer_async.js
          • importer_dynamic.css
          • importer_print.css
          • inject_resource_test.html
          • invalid.jpg
          • manifest.json
          • navigate_back.html
          • nested-contexts.js
          • nested.css
          • notify_parent.html
          • object-navigate-back.html
          • object-navigate.html
          • object-refresh.html
          • observe-entry.js
          • resource-loaders.js
          • resource_timing_test0.css
          • resource_timing_test0.html
          • resource_timing_test0.js.headers
          • resource_timing_test0.js
          • resource_timing_test0.png
          • resource_timing_test0.xml
          • self_navigation.html
          • shared-worker.js
          • sizes-helper.js
          • sw-install.html
          • sw.js
          • tao-response.js
          • webperftestharness.js
          • webperftestharnessextension.js
          • worker_with_images.js
        • same-origin-from-cross-origin-redirect.html
        • script-rt-entries.html
        • secure-iframe-in-insecure-context.html
        • shared-worker-rt-entry.html
        • sizes-cache.any.js
        • sizes-redirect-img.html
        • sizes-redirect.any.js
        • status-codes-create-entry.html
        • supported_resource_type.any.js
        • test_resource_timing.html
        • test_resource_timing.https.html
        • test_resource_timing.js
        • tojson.html
        • workerStart-tao-protected.https.html
        • worklet-rt-entries.https.html
        • xhr-resource-timing.html
      • versions.json
    • parallel
      • test-perf-hooks-resourcetiming.js
      • test-perf-hooks-usertiming.js
    • sequential
      • test-worker-eventlooputil.js
    • wpt
      • status
        • hr-time.json
        • performance-timeline.json
        • resource-timing.json
        • user-timing.json
      • test-hr-time.js
      • test-performance-timeline.js
      • test-resource-timing.js
      • test-user-timing.js
  • tools/doc
    • type-parser.mjs

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/perf_hooks.md‎

Copy file name to clipboardExpand all lines: doc/api/perf_hooks.md
+271-45Lines changed: 271 additions & 45 deletions
  • Display the source diff
  • Display the rich diff
Large diffs are not rendered by default.
Collapse file

‎lib/internal/bootstrap/browser.js‎

Copy file name to clipboardExpand all lines: lib/internal/bootstrap/browser.js
+25-6Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ exposeInterface(globalThis, 'Blob', buffer.Blob);
7575
// https://www.w3.org/TR/hr-time-2/#the-performance-attribute
7676
const perf_hooks = require('perf_hooks');
7777
exposeInterface(globalThis, 'Performance', perf_hooks.Performance);
78-
defineReplacableAttribute(globalThis, 'performance',
79-
perf_hooks.performance);
78+
defineReplaceableAttribute(globalThis, 'performance',
79+
perf_hooks.performance);
8080

8181
function createGlobalConsole() {
8282
const consoleFromNode =
@@ -114,14 +114,33 @@ function exposeGetterAndSetter(target, name, getter, setter = undefined) {
114114
});
115115
}
116116

117-
// https://heycam.github.io/webidl/#Replaceable
118-
function defineReplacableAttribute(target, name, value) {
117+
// https://webidl.spec.whatwg.org/#Replaceable
118+
function defineReplaceableAttribute(target, name, value) {
119+
let slot = value;
120+
121+
// https://webidl.spec.whatwg.org/#dfn-attribute-getter
122+
function get() {
123+
return slot;
124+
}
125+
ObjectDefineProperty(get, 'name', {
126+
__proto__: null,
127+
value: `get ${name}`,
128+
});
129+
130+
function set(value) {
131+
slot = value;
132+
}
133+
ObjectDefineProperty(set, 'name', {
134+
__proto__: null,
135+
value: `set ${name}`,
136+
});
137+
119138
ObjectDefineProperty(target, name, {
120139
__proto__: null,
121-
writable: true,
122140
enumerable: true,
123141
configurable: true,
124-
value,
142+
get,
143+
set,
125144
});
126145
}
127146

Collapse file

‎lib/internal/perf/observe.js‎

Copy file name to clipboardExpand all lines: lib/internal/perf/observe.js
+59-16Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ const {
1616
ObjectDefineProperties,
1717
ObjectFreeze,
1818
ObjectKeys,
19+
ReflectConstruct,
1920
SafeMap,
2021
SafeSet,
2122
Symbol,
23+
SymbolToStringTag,
2224
} = primordials;
2325

2426
const {
@@ -36,12 +38,13 @@ const {
3638
} = internalBinding('performance');
3739

3840
const {
39-
InternalPerformanceEntry,
4041
isPerformanceEntry,
42+
createPerformanceNodeEntry,
4143
} = require('internal/perf/performance_entry');
4244

4345
const {
4446
codes: {
47+
ERR_ILLEGAL_CONSTRUCTOR,
4548
ERR_INVALID_ARG_VALUE,
4649
ERR_INVALID_ARG_TYPE,
4750
ERR_MISSING_ARGS,
@@ -51,13 +54,15 @@ const {
5154
const {
5255
validateFunction,
5356
validateObject,
57+
validateInternalField,
5458
} = require('internal/validators');
5559

5660
const {
5761
customInspectSymbol: kInspect,
5862
deprecate,
5963
lazyDOMException,
6064
kEmptyObject,
65+
kEnumerableProperty,
6166
} = require('internal/util');
6267

6368
const {
@@ -68,6 +73,7 @@ const { inspect } = require('util');
6873

6974
const { now } = require('internal/perf/utils');
7075

76+
const kBuffer = Symbol('kBuffer');
7177
const kDispatch = Symbol('kDispatch');
7278
const kMaybeBuffer = Symbol('kMaybeBuffer');
7379
const kDeprecatedFields = Symbol('kDeprecatedFields');
@@ -167,34 +173,39 @@ function maybeIncrementObserverCount(type) {
167173
}
168174

169175
class PerformanceObserverEntryList {
170-
#buffer = [];
171-
172-
constructor(entries) {
173-
this.#buffer = ArrayPrototypeSort(entries, (first, second) => {
174-
return first.startTime - second.startTime;
175-
});
176+
constructor() {
177+
throw new ERR_ILLEGAL_CONSTRUCTOR();
176178
}
177179

178180
getEntries() {
179-
return ArrayPrototypeSlice(this.#buffer);
181+
validateInternalField(this, kBuffer, 'PerformanceObserverEntryList');
182+
return ArrayPrototypeSlice(this[kBuffer]);
180183
}
181184

182185
getEntriesByType(type) {
186+
validateInternalField(this, kBuffer, 'PerformanceObserverEntryList');
187+
if (arguments.length === 0) {
188+
throw new ERR_MISSING_ARGS('type');
189+
}
183190
type = `${type}`;
184191
return ArrayPrototypeFilter(
185-
this.#buffer,
192+
this[kBuffer],
186193
(entry) => entry.entryType === type);
187194
}
188195

189-
getEntriesByName(name, type) {
196+
getEntriesByName(name, type = undefined) {
197+
validateInternalField(this, kBuffer, 'PerformanceObserverEntryList');
198+
if (arguments.length === 0) {
199+
throw new ERR_MISSING_ARGS('name');
200+
}
190201
name = `${name}`;
191202
if (type != null /** not nullish */) {
192203
return ArrayPrototypeFilter(
193-
this.#buffer,
204+
this[kBuffer],
194205
(entry) => entry.name === name && entry.entryType === type);
195206
}
196207
return ArrayPrototypeFilter(
197-
this.#buffer,
208+
this[kBuffer],
198209
(entry) => entry.name === name);
199210
}
200211

@@ -206,9 +217,29 @@ class PerformanceObserverEntryList {
206217
depth: options.depth == null ? null : options.depth - 1
207218
};
208219

209-
return `PerformanceObserverEntryList ${inspect(this.#buffer, opts)}`;
220+
return `PerformanceObserverEntryList ${inspect(this[kBuffer], opts)}`;
210221
}
211222
}
223+
ObjectDefineProperties(PerformanceObserverEntryList.prototype, {
224+
getEntries: kEnumerableProperty,
225+
getEntriesByType: kEnumerableProperty,
226+
getEntriesByName: kEnumerableProperty,
227+
[SymbolToStringTag]: {
228+
__proto__: null,
229+
writable: false,
230+
enumerable: false,
231+
configurable: true,
232+
value: 'PerformanceObserverEntryList',
233+
},
234+
});
235+
236+
function createPerformanceObserverEntryList(entries) {
237+
return ReflectConstruct(function PerformanceObserverEntryList() {
238+
this[kBuffer] = ArrayPrototypeSort(entries, (first, second) => {
239+
return first.startTime - second.startTime;
240+
});
241+
}, [], PerformanceObserverEntryList);
242+
}
212243

213244
class PerformanceObserver {
214245
#buffer = [];
@@ -319,7 +350,7 @@ class PerformanceObserver {
319350
}
320351

321352
[kDispatch]() {
322-
this.#callback(new PerformanceObserverEntryList(this.takeRecords()),
353+
this.#callback(createPerformanceObserverEntryList(this.takeRecords()),
323354
this);
324355
}
325356

@@ -339,6 +370,18 @@ class PerformanceObserver {
339370
}, opts)}`;
340371
}
341372
}
373+
ObjectDefineProperties(PerformanceObserver.prototype, {
374+
observe: kEnumerableProperty,
375+
disconnect: kEnumerableProperty,
376+
takeRecords: kEnumerableProperty,
377+
[SymbolToStringTag]: {
378+
__proto__: null,
379+
writable: false,
380+
enumerable: false,
381+
configurable: true,
382+
value: 'PerformanceObserver',
383+
},
384+
});
342385

343386
/**
344387
* https://www.w3.org/TR/performance-timeline/#dfn-queue-a-performanceentry
@@ -485,7 +528,7 @@ function filterBufferMapByNameAndType(name, type) {
485528

486529
function observerCallback(name, type, startTime, duration, details) {
487530
const entry =
488-
new InternalPerformanceEntry(
531+
createPerformanceNodeEntry(
489532
name,
490533
type,
491534
startTime,
@@ -542,7 +585,7 @@ function stopPerf(target, key, context = {}) {
542585
return;
543586
}
544587
const startTime = ctx.startTime;
545-
const entry = new InternalPerformanceEntry(
588+
const entry = createPerformanceNodeEntry(
546589
ctx.name,
547590
ctx.type,
548591
startTime,

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.