break-on-exception-compiler-errors.js 1.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

let {session, contextGroup, Protocol} = InspectorTest.start(
  'Break on exceptions from compiler errors.');

Protocol.Debugger.enable();
Protocol.Debugger.setPauseOnExceptions({state: 'all'});
Protocol.Debugger.onPaused(({params:{data}}) => {
  InspectorTest.log('paused on exception:');
  InspectorTest.logMessage(data);
  Protocol.Debugger.resume();
});

InspectorTest.runAsyncTestSuite([
  async function testUnexpectedEndOfInput() {
    InspectorTest.log(`Runs '+++'`);
    let {result:{exceptionDetails}} = await Protocol.Runtime.evaluate({
      expression: '+++'
    });
    InspectorTest.log('Runtime.evaluate exceptionDetails:');
    InspectorTest.logMessage(exceptionDetails);
  },

  async function testUnexpectedIdentifier() {
    InspectorTest.log(`Runs 'x x'`);
    let {result:{exceptionDetails}} = await Protocol.Runtime.evaluate({
      expression: 'x x'
    });
    InspectorTest.log('Runtime.evaluate exceptionDetails:');
    InspectorTest.logMessage(exceptionDetails);
  },

  async function testEvalUnexpectedEndOfInput() {
    InspectorTest.log(`Runs eval('+++')`);
    let {result:{exceptionDetails}} = await Protocol.Runtime.evaluate({
      expression: `eval('+++')`
    });
    InspectorTest.log('Runtime.evaluate exceptionDetails:');
    InspectorTest.logMessage(exceptionDetails);
  },

  async function testEvalUnexpectedIdentifier() {
    InspectorTest.log(`Runs eval('x x')`);
    let {result:{exceptionDetails}} = await Protocol.Runtime.evaluate({
      expression: `eval('x x')`
    });
    InspectorTest.log('Runtime.evaluate exceptionDetails:');
    InspectorTest.logMessage(exceptionDetails);
  }
]);