reject-caught-late.js 855 Bytes
Newer Older
1 2 3 4 5 6
// 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.


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

Debug = debug.Debug;

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

16
var q = p.then(
17 18 19 20
  function() {
    q.catch(function(e) {
      assertEquals("caught", e.message);
    });
21
    return Promise.reject(Error("caught"));
22 23 24 25 26 27
  });

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

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