Debug = debug.Debug

var listenerComplete = false;
var exception = false;

function listener(event, exec_state, event_data, data) {
  try {
    if (event == Debug.DebugEvent.Break) {
      // Get the debug command processor.
      var dcp = exec_state.debugCommandProcessor();

      var request = {
         seq: 0,
         type: 'request',
         command: 'evaluate',
         arguments: {
           expression: 'a',
           frame: 0
         }
      };
      request = JSON.stringify(request);

      var resp = dcp.processDebugJSONRequest(request);
      var response = JSON.parse(resp);
      assertTrue(response.success, 'Command failed: ' + resp);
      assertEquals('object', response.body.type);
      assertEquals('Object', response.body.className);

      // Indicate that all was processed.
      listenerComplete = true;
    }
  } catch (e) {
   exception = e
  };
};

// Add the debug event listener.
Debug.setListener(listener);

function callDebugger() {
  // Add set constructor field to a non-function value.
  var a = {constructor:true};
  debugger;
}

callDebugger();


// Make sure that the debug event listener vas invoked.
assertFalse(exception, "exception in listener")
assertTrue(listenerComplete, "listener did not run to completion");
