Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lib/internal/debugger/inspect_repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ const {
JSONStringify,
MathMax,
ObjectAssign,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectGetOwnPropertyDescriptors,
ObjectKeys,
ObjectSetPrototypeOf,
ObjectValues,
Promise,
PromisePrototypeThen,
PromiseResolve,
PromiseWithResolvers,
ReflectGetOwnPropertyDescriptor,
ReflectOwnKeys,
RegExpPrototypeExec,
SafeMap,
SafePromiseAllReturnArrayLike,
Expand Down Expand Up @@ -347,18 +349,20 @@ class ScopeSnapshot {
}

function copyOwnProperties(target, source) {
ArrayPrototypeForEach(
ReflectOwnKeys(source),
(prop) => {
const desc = ReflectGetOwnPropertyDescriptor(source, prop);
ObjectDefineProperty(target, prop, desc);
});
const descriptors = ObjectGetOwnPropertyDescriptors(source);

const descValues = ObjectValues(descriptors);
for (let i = 0; i < descValues.length; ++i) {
ObjectSetPrototypeOf(descValues[i], null);
}

ObjectDefineProperties(target, descriptors);
}

function aliasProperties(target, mapping) {
ArrayPrototypeForEach(ObjectKeys(mapping), (key) => {
const desc = ReflectGetOwnPropertyDescriptor(target, key);
ObjectDefineProperty(target, mapping[key], desc);
ObjectDefineProperty(target, mapping[key], { __proto__: null, ...desc });
});
}

Expand Down
1 change: 1 addition & 0 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3321,6 +3321,7 @@ function handleHeaderContinue(headers) {
}

const setTimeoutValue = {
__proto__: null,
configurable: true,
enumerable: true,
writable: true,
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/per_context/domexception.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ for (const { 0: name, 1: codeName, 2: value } of [
// There are some more error names, but since they don't have codes assigned,
// we don't need to care about them.
]) {
const desc = { enumerable: true, value };
const desc = { __proto__: null, enumerable: true, value };
ObjectDefineProperty(DOMException, codeName, desc);
ObjectDefineProperty(DOMExceptionPrototype, codeName, desc);
nameToCodeMap.set(name, value);
Expand Down
17 changes: 11 additions & 6 deletions lib/internal/test_runner/mock/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ const {
FunctionPrototypeBind,
FunctionPrototypeCall,
ObjectAssign,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectGetOwnPropertyDescriptor,
ObjectGetOwnPropertyDescriptors,
ObjectGetPrototypeOf,
ObjectKeys,
ObjectSetPrototypeOf,
ObjectValues,
Proxy,
ReflectApply,
ReflectConstruct,
Expand Down Expand Up @@ -146,7 +150,7 @@ class MockFunctionContext {

if (typeof methodName === 'string') {
// This is an object method spy.
ObjectDefineProperty(object, methodName, descriptor);
ObjectDefineProperty(object, methodName, { __proto__: null, ...descriptor });
} else {
// This is a bare function spy. There isn't much to do here but make
// the mock call the original function.
Expand Down Expand Up @@ -880,13 +884,14 @@ function normalizeModuleMockOptions(options) {


function copyOwnProperties(from, to) {
const keys = ObjectKeys(from);
const descriptors = ObjectGetOwnPropertyDescriptors(from);

for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
const descriptor = ObjectGetOwnPropertyDescriptor(from, key);
ObjectDefineProperty(to, key, descriptor);
const descValues = ObjectValues(descriptors);
for (let i = 0; i < descValues.length; ++i) {
ObjectSetPrototypeOf(descValues[i], null);
}

ObjectDefineProperties(to, descriptors);
}

function setupSharedModuleState() {
Expand Down
5 changes: 3 additions & 2 deletions lib/internal/test_runner/mock/mock_timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
ObjectDefineProperty,
ObjectGetOwnPropertyDescriptor,
ObjectGetOwnPropertyDescriptors,
ObjectSetPrototypeOf,
PromiseWithResolvers,
ReflectApply,
Symbol,
Expand Down Expand Up @@ -325,7 +326,7 @@ class MockTimers {
}

#restoreOriginalAbortSignalTimeout() {
ObjectDefineProperty(AbortSignal, 'timeout', this.#realAbortSignalTimeout);
ObjectDefineProperty(AbortSignal, 'timeout', ObjectSetPrototypeOf(this.#realAbortSignalTimeout, null));
}

#createTimer(isInterval, callback, delay, ...args) {
Expand Down Expand Up @@ -633,7 +634,7 @@ class MockTimers {
);
},
'Date': () => {
this.#nativeDateDescriptor = ObjectGetOwnPropertyDescriptor(globalThis, 'Date');
this.#nativeDateDescriptor = ObjectSetPrototypeOf(ObjectGetOwnPropertyDescriptor(globalThis, 'Date'), null);
globalThis.Date = this.#createDate();
},
'AbortSignal.timeout': () => {
Expand Down
Loading