test_pause_exceptions-02.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Test that setting pauseOnExceptions to true when the debugger isn't in a
  5. * paused state will cause the debuggee to pause when an exceptions is thrown.
  6. */
  7. var gDebuggee;
  8. var gClient;
  9. var gThreadClient;
  10. function run_test()
  11. {
  12. initTestDebuggerServer();
  13. gDebuggee = addTestGlobal("test-stack");
  14. gClient = new DebuggerClient(DebuggerServer.connectPipe());
  15. gClient.connect().then(function () {
  16. attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
  17. gThreadClient = aThreadClient;
  18. test_pause_frame();
  19. });
  20. });
  21. do_test_pending();
  22. }
  23. function test_pause_frame()
  24. {
  25. gThreadClient.pauseOnExceptions(true, false, function () {
  26. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
  27. do_check_eq(aPacket.why.type, "exception");
  28. do_check_eq(aPacket.why.exception, 42);
  29. gThreadClient.resume(function () {
  30. finishClient(gClient);
  31. });
  32. });
  33. gDebuggee.eval("(" + function () {
  34. function stopMe() {
  35. throw 42;
  36. }
  37. try {
  38. stopMe();
  39. } catch (e) {}
  40. } + ")()");
  41. });
  42. }