blob: 3b79877e5edd5f9ccdf05cc344024715d5fb31e4 (
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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable max-nested-callbacks */
"use strict";
/**
* Test that the preview in a Promise's grip is correct when the Promise is
* rejected.
*/
add_task(
threadFrontTest(async ({ threadFront, debuggee }) => {
const packet = await executeOnNextTickAndWaitForPause(
() => evalCode(debuggee),
threadFront
);
const environment = await packet.frame.getEnvironment();
const grip = environment.bindings.variables.p.value;
ok(grip.preview);
equal(grip.class, "Promise");
equal(grip.preview.ownProperties["<state>"].value, "rejected");
equal(
grip.preview.ownProperties["<reason>"].value.actorID,
packet.frame.arguments[0].actorID,
"The promise's rejected state reason in the preview should be the same " +
"value passed to the then function"
);
const objClient = threadFront.pauseGrip(grip);
const { promiseState } = await objClient.getPromiseState();
equal(promiseState.state, "rejected");
equal(
promiseState.reason.getGrip().actorID,
packet.frame.arguments[0].actorID,
"The promise's rejected state value in getPromiseState() should be " +
"the same value passed to the then function"
);
})
);
function evalCode(debuggee) {
/* eslint-disable */
Cu.evalInSandbox(
"doTest();\n" +
function doTest() {
var resolved = Promise.reject(new Error("uh oh"));
resolved.catch(() => {
var p = resolved;
debugger;
});
},
debuggee
);
/* eslint-enable */
}
|