test_promise_state-01.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Test that the preview in a Promise's grip is correct when the Promise is
  5. * pending.
  6. */
  7. function run_test()
  8. {
  9. initTestDebuggerServer();
  10. const debuggee = addTestGlobal("test-promise-state");
  11. const client = new DebuggerClient(DebuggerServer.connectPipe());
  12. client.connect().then(function () {
  13. attachTestTabAndResume(client, "test-promise-state", function (response, tabClient, threadClient) {
  14. Task.spawn(function* () {
  15. const packet = yield executeOnNextTickAndWaitForPause(() => evalCode(debuggee), client);
  16. const grip = packet.frame.environment.bindings.variables.p;
  17. ok(grip.value.preview);
  18. equal(grip.value.class, "Promise");
  19. equal(grip.value.promiseState.state, "pending");
  20. finishClient(client);
  21. });
  22. });
  23. });
  24. do_test_pending();
  25. }
  26. function evalCode(debuggee) {
  27. Components.utils.evalInSandbox(
  28. "doTest();\n" +
  29. function doTest() {
  30. var p = new Promise(function () {});
  31. debugger;
  32. },
  33. debuggee
  34. );
  35. }