mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 16:34:41 +00:00

Fixes: https://github.com/nodejs/node/issues/36246 PR-URL: https://github.com/nodejs/node/pull/36248 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@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.prototype.hasOwnProperty('__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();
|
|
}
|