1'use strict'; 2const common = require('../common'); 3common.skipIfInspectorDisabled(); 4 5// Test that if there is a side effect in a getter invoked through the vm 6// global proxy, Runtime.evaluate recognizes that. 7 8const assert = require('assert'); 9const inspector = require('inspector'); 10const vm = require('vm'); 11 12const session = new inspector.Session(); 13session.connect(); 14 15const context = vm.createContext({ 16 get a() { 17 global.foo = '1'; 18 return 100; 19 } 20}); 21 22session.post('Runtime.evaluate', { 23 expression: 'a', 24 throwOnSideEffect: true, 25 contextId: 2 // context's id 26}, (error, res) => { 27 assert.ifError(error); 28 const { exception } = res.exceptionDetails; 29 assert.strictEqual(exception.className, 'EvalError'); 30 assert(/Possible side-effect/.test(exception.description)); 31 32 assert(context); // Keep 'context' alive and make linter happy. 33}); 34