blob: f5342db5294ed6e256aec679a253069992988eb4 (
plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// 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.
const {session, contextGroup, Protocol} =
InspectorTest.start('Test Debugger.paused reason for promise rejections');
(async function test() {
Protocol.Debugger.enable();
Protocol.Debugger.setPauseOnExceptions({state: 'all'});
InspectorTest.log('Check Promise.reject in script:');
contextGroup.addScript(`Promise.reject(new Error())`);
await logPausedReason();
await Protocol.Debugger.resume();
InspectorTest.log('Check Promise.reject in Runtime.evaluate:');
Protocol.Runtime.evaluate({expression: `Promise.reject(new Error())`});
await logPausedReason();
await Protocol.Debugger.resume();
InspectorTest.log('Check Promise.reject in async function:');
Protocol.Runtime.evaluate(
{expression: `(async function() { await Promise.reject(); })()`});
await logPausedReason();
await Protocol.Debugger.resume();
InspectorTest.log('Check throw in async function:');
Protocol.Runtime.evaluate({
expression: `(async function() { await Promise.resolve(); throw 42; })()`
});
await logPausedReason();
await Protocol.Debugger.resume();
InspectorTest.log('Check reject from constructor:');
Protocol.Runtime.evaluate({
expression: 'new Promise((_, reject) => reject(new Error())).catch(e => {})'
});
await logPausedReason();
await Protocol.Debugger.resume();
InspectorTest.log('Check reject from thenable job:');
Protocol.Runtime.evaluate({
expression:
`Promise.resolve().then(() => Promise.reject(new Error())).catch(e => 0)`
});
await logPausedReason();
await Protocol.Debugger.resume();
InspectorTest.log(
'Check caught exception in async function (should be exception):');
Protocol.Runtime.evaluate({
expression: `(async function() {
await Promise.resolve();
try {
throw 42;
} catch (e) {}
})()`
});
await logPausedReason();
await Protocol.Debugger.resume();
InspectorTest.completeTest();
})();
async function logPausedReason() {
const {params: {reason}} = await Protocol.Debugger.oncePaused();
InspectorTest.log(reason + '\n');
}
|