11cb0ef41Sopenharmony_ci// Flags: --disable-proto=throw
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci'use strict';
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_cirequire('../common');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst vm = require('vm');
81cb0ef41Sopenharmony_ciconst { Worker, isMainThread } = require('worker_threads');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciassert(Object.hasOwn(Object.prototype, '__proto__'));
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciassert.throws(() => {
131cb0ef41Sopenharmony_ci  // eslint-disable-next-line no-proto,no-unused-expressions
141cb0ef41Sopenharmony_ci  ({}).__proto__;
151cb0ef41Sopenharmony_ci}, {
161cb0ef41Sopenharmony_ci  code: 'ERR_PROTO_ACCESS'
171cb0ef41Sopenharmony_ci});
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciassert.throws(() => {
201cb0ef41Sopenharmony_ci  // eslint-disable-next-line no-proto
211cb0ef41Sopenharmony_ci  ({}).__proto__ = {};
221cb0ef41Sopenharmony_ci}, {
231cb0ef41Sopenharmony_ci  code: 'ERR_PROTO_ACCESS',
241cb0ef41Sopenharmony_ci});
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ciconst ctx = vm.createContext();
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ciassert.throws(() => {
291cb0ef41Sopenharmony_ci  vm.runInContext('({}).__proto__;', ctx);
301cb0ef41Sopenharmony_ci}, {
311cb0ef41Sopenharmony_ci  code: 'ERR_PROTO_ACCESS'
321cb0ef41Sopenharmony_ci});
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ciassert.throws(() => {
351cb0ef41Sopenharmony_ci  vm.runInContext('({}).__proto__ = {};', ctx);
361cb0ef41Sopenharmony_ci}, {
371cb0ef41Sopenharmony_ci  code: 'ERR_PROTO_ACCESS',
381cb0ef41Sopenharmony_ci});
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ciif (isMainThread) {
411cb0ef41Sopenharmony_ci  new Worker(__filename);
421cb0ef41Sopenharmony_ci} else {
431cb0ef41Sopenharmony_ci  process.exit();
441cb0ef41Sopenharmony_ci}
45