test_interrupt.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. var gClient;
  4. var gDebuggee;
  5. function run_test()
  6. {
  7. initTestDebuggerServer();
  8. gDebuggee = testGlobal("test-1");
  9. DebuggerServer.addTestGlobal(gDebuggee);
  10. let transport = DebuggerServer.connectPipe();
  11. gClient = new DebuggerClient(transport);
  12. gClient.connect().then(function (aType, aTraits) {
  13. attachTestTab(gClient, "test-1", test_attach);
  14. });
  15. do_test_pending();
  16. }
  17. function test_attach(aResponse, aTabClient)
  18. {
  19. aTabClient.attachThread({}, function (aResponse, aThreadClient) {
  20. do_check_eq(aThreadClient.paused, true);
  21. aThreadClient.resume(function () {
  22. test_interrupt(aThreadClient);
  23. });
  24. });
  25. }
  26. function test_interrupt(aThreadClient)
  27. {
  28. do_check_eq(aThreadClient.paused, false);
  29. aThreadClient.interrupt(function (aResponse) {
  30. do_check_eq(aThreadClient.paused, true);
  31. aThreadClient.resume(function () {
  32. do_check_eq(aThreadClient.paused, false);
  33. cleanup();
  34. });
  35. });
  36. }
  37. function cleanup()
  38. {
  39. gClient.addListener("closed", function (aEvent) {
  40. do_test_finished();
  41. });
  42. gClient.close();
  43. }