reject-caught-late.js 913 Bytes
Newer Older
1 2 3 4
// Copyright 2014 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.

5
// Flags: --expose-debug-as debug --allow-natives-syntax
6 7

// Test debug events when we only listen to uncaught exceptions, the Promise
8
// is rejected, and a catch handler is installed right before the rejection.
9 10 11 12 13 14 15 16 17 18 19 20 21
// We expect no debug event to be triggered.

Debug = debug.Debug;

var p = new Promise(function(resolve, reject) {
  resolve();
});

var q = p.chain(
  function() {
    q.catch(function(e) {
      assertEquals("caught", e.message);
    });
22
    return Promise.reject(Error("caught"));
23 24 25 26 27 28
  });

function listener(event, exec_state, event_data, data) {
  try {
    assertTrue(event != Debug.DebugEvent.Exception);
  } catch (e) {
29
    %AbortJS(e + "\n" + e.stack);
30 31 32 33 34
  }
}

Debug.setBreakOnUncaughtException();
Debug.setListener(listener);