2020-03-14 17:54:15 -07:00
|
|
|
// Flags: --disable-proto=throw
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const vm = require('vm');
|
|
|
|
const { Worker, isMainThread } = require('worker_threads');
|
|
|
|
|
2022-01-24 23:03:17 -08:00
|
|
|
assert(Object.hasOwn(Object.prototype, '__proto__'));
|
2020-03-14 17:54:15 -07:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2020-11-24 14:11:20 +01:00
|
|
|
// eslint-disable-next-line no-proto,no-unused-expressions
|
2020-03-14 17:54:15 -07:00
|
|
|
({}).__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();
|
|
|
|
}
|