11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// Test that if there is a side effect in a getter invoked through the vm 61cb0ef41Sopenharmony_ci// global proxy, Runtime.evaluate recognizes that. 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst assert = require('assert'); 91cb0ef41Sopenharmony_ciconst inspector = require('inspector'); 101cb0ef41Sopenharmony_ciconst vm = require('vm'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst session = new inspector.Session(); 131cb0ef41Sopenharmony_cisession.connect(); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst context = vm.createContext({ 161cb0ef41Sopenharmony_ci get a() { 171cb0ef41Sopenharmony_ci global.foo = '1'; 181cb0ef41Sopenharmony_ci return 100; 191cb0ef41Sopenharmony_ci } 201cb0ef41Sopenharmony_ci}); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_cisession.post('Runtime.evaluate', { 231cb0ef41Sopenharmony_ci expression: 'a', 241cb0ef41Sopenharmony_ci throwOnSideEffect: true, 251cb0ef41Sopenharmony_ci contextId: 2 // context's id 261cb0ef41Sopenharmony_ci}, (error, res) => { 271cb0ef41Sopenharmony_ci assert.ifError(error); 281cb0ef41Sopenharmony_ci const { exception } = res.exceptionDetails; 291cb0ef41Sopenharmony_ci assert.strictEqual(exception.className, 'EvalError'); 301cb0ef41Sopenharmony_ci assert.match(exception.description, /Possible side-effect/); 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci assert(context); // Keep 'context' alive and make linter happy. 331cb0ef41Sopenharmony_ci}); 34