test_promise_state-02.js (1742B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 /* eslint-disable max-nested-callbacks */ 4 5 "use strict"; 6 7 /** 8 * Test that the preview in a Promise's grip is correct when the Promise is 9 * fulfilled. 10 */ 11 12 add_task( 13 threadFrontTest(async ({ threadFront, debuggee }) => { 14 const packet = await executeOnNextTickAndWaitForPause( 15 () => evalCode(debuggee), 16 threadFront 17 ); 18 19 const environment = await packet.frame.getEnvironment(); 20 const grip = environment.bindings.variables.p.value; 21 22 ok(grip.preview); 23 equal(grip.class, "Promise"); 24 equal(grip.preview.ownProperties["<state>"].value, "fulfilled"); 25 equal( 26 grip.preview.ownProperties["<value>"].value.actorID, 27 packet.frame.arguments[0].actorID, 28 "The promise's fulfilled state value in the preview should be the same " + 29 "value passed to the then function" 30 ); 31 32 const objClient = threadFront.pauseGrip(grip); 33 const { promiseState } = await objClient.getPromiseState(); 34 equal(promiseState.state, "fulfilled"); 35 equal( 36 promiseState.value.getGrip().actorID, 37 packet.frame.arguments[0].actorID, 38 "The promise's fulfilled state value in getPromiseState() should be " + 39 "the same value passed to the then function" 40 ); 41 }) 42 ); 43 44 function evalCode(debuggee) { 45 /* eslint-disable mozilla/var-only-at-top-level, no-unused-vars */ 46 // prettier-ignore 47 Cu.evalInSandbox( 48 "doTest();\n" + 49 function doTest() { 50 var resolved = Promise.resolve({}); 51 resolved.then(() => { 52 var p = resolved; 53 debugger; 54 }); 55 }, 56 debuggee 57 ); 58 /* eslint-enable mozilla/var-only-at-top-level, no-unused-vars */ 59 }