Skip to content

Commit 364c0e1

Browse files
committedOct 3, 2022
perf_hooks: fix webperf idlharness
1. Enforce receiver checks on IDL interfaces. 2. Avoid prototype manipulation on constructing IDL interfaces with `ReflectConstruct`. 3. `defineReplaceableAttribute` should create IDL getter/setter. 4. Corrected `PerformanceResourceTiming` to inherit the public interface `PerformanceEntry` instead of the internal interface `InternalPerformanceResourceTiming`. 5. `detail` is not a specified attribute on `PerfomanceEntry`. Node.js specific extensions are moved to a subclass of `PerformanceEntry` as `PerformanceNodeEntry`. PR-URL: #44483 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f529f73 commit 364c0e1

File tree

218 files changed

+8089
-529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+8089
-529
lines changed
 

‎doc/api/perf_hooks.md

+271-45
Large diffs are not rendered by default.

‎lib/internal/bootstrap/browser.js

+25-6
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

0 commit comments

Comments
 (0)
Please sign in to comment.