mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 23:56:58 +00:00

Replace Object.prototpye.hasOwnProperty() with Object.hasOwn() where applicable. PR-URL: https://github.com/nodejs/node/pull/41664 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tierney Cyren <hello@bnb.im> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
45 lines
824 B
JavaScript
45 lines
824 B
JavaScript
// Flags: --disable-proto=throw
|
|
|
|
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const vm = require('vm');
|
|
const { Worker, isMainThread } = require('worker_threads');
|
|
|
|
assert(Object.hasOwn(Object.prototype, '__proto__'));
|
|
|
|
assert.throws(() => {
|
|
// eslint-disable-next-line no-proto,no-unused-expressions
|
|
({}).__proto__;
|
|
}, {
|
|
code: 'ERR_PROTO_ACCESS'
|
|
});
|
|
|
|
assert.throws(() => {
|
|
// eslint-disable-next-line no-proto
|
|
({}).__proto__ = {};
|
|
}, {
|
|
code: 'ERR_PROTO_ACCESS',
|
|
});
|
|
|
|
const ctx = vm.createContext();
|
|
|
|
assert.throws(() => {
|
|
vm.runInContext('({}).__proto__;', ctx);
|
|
}, {
|
|
code: 'ERR_PROTO_ACCESS'
|
|
});
|
|
|
|
assert.throws(() => {
|
|
vm.runInContext('({}).__proto__ = {};', ctx);
|
|
}, {
|
|
code: 'ERR_PROTO_ACCESS',
|
|
});
|
|
|
|
if (isMainThread) {
|
|
new Worker(__filename);
|
|
} else {
|
|
process.exit();
|
|
}
|