mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 18:37:06 +00:00

Adds `--disable-proto` CLI option which can be set to `delete` or `throw`. Fixes #31951 PR-URL: https://github.com/nodejs/node/pull/32279 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
26 lines
672 B
JavaScript
26 lines
672 B
JavaScript
// Flags: --disable-proto=delete
|
|
|
|
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const vm = require('vm');
|
|
const { Worker, isMainThread } = require('worker_threads');
|
|
|
|
// eslint-disable-next-line no-proto
|
|
assert.strictEqual(Object.prototype.__proto__, undefined);
|
|
assert(!Object.prototype.hasOwnProperty('__proto__'));
|
|
|
|
const ctx = vm.createContext();
|
|
const ctxGlobal = vm.runInContext('this', ctx);
|
|
|
|
// eslint-disable-next-line no-proto
|
|
assert.strictEqual(ctxGlobal.Object.prototype.__proto__, undefined);
|
|
assert(!ctxGlobal.Object.prototype.hasOwnProperty('__proto__'));
|
|
|
|
if (isMainThread) {
|
|
new Worker(__filename);
|
|
} else {
|
|
process.exit();
|
|
}
|