test_promise_state-01.js (1194B)
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 * pending. 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, "pending"); 25 26 const objClient = threadFront.pauseGrip(grip); 27 const { promiseState } = await objClient.getPromiseState(); 28 equal(promiseState.state, "pending"); 29 }) 30 ); 31 32 function evalCode(debuggee) { 33 /* eslint-disable mozilla/var-only-at-top-level, no-unused-vars */ 34 // prettier-ignore 35 Cu.evalInSandbox( 36 "doTest();\n" + 37 function doTest() { 38 var p = new Promise(function () {}); 39 debugger; 40 }, 41 debuggee 42 ); 43 /* eslint-enable mozilla/var-only-at-top-level, no-unused-vars */ 44 }