test_xpcshell_debugging.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. // Test the xpcshell-test debug support. Ideally we should have this test
  4. // next to the xpcshell support code, but that's tricky...
  5. function run_test() {
  6. let testFile = do_get_file("xpcshell_debugging_script.js");
  7. // _setupDebuggerServer is from xpcshell-test's head.js
  8. let testResumed = false;
  9. let DebuggerServer = _setupDebuggerServer([testFile.path], () => testResumed = true);
  10. let transport = DebuggerServer.connectPipe();
  11. let client = new DebuggerClient(transport);
  12. client.connect().then(() => {
  13. // Even though we have no tabs, listTabs gives us the chromeDebugger.
  14. client.getProcess().then(response => {
  15. let actor = response.form.actor;
  16. client.attachTab(actor, (response, tabClient) => {
  17. tabClient.attachThread(null, (response, threadClient) => {
  18. threadClient.addOneTimeListener("paused", (event, packet) => {
  19. equal(packet.why.type, "breakpoint",
  20. "yay - hit the breakpoint at the first line in our script");
  21. // Resume again - next stop should be our "debugger" statement.
  22. threadClient.addOneTimeListener("paused", (event, packet) => {
  23. equal(packet.why.type, "debuggerStatement",
  24. "yay - hit the 'debugger' statement in our script");
  25. threadClient.resume(() => {
  26. finishClient(client);
  27. });
  28. });
  29. threadClient.resume();
  30. });
  31. // tell the thread to do the initial resume. This would cause the
  32. // xpcshell test harness to resume and load the file under test.
  33. threadClient.resume(response => {
  34. // should have been told to resume the test itself.
  35. ok(testResumed);
  36. // Now load our test script.
  37. load(testFile.path);
  38. // and our "paused" listener above should get hit.
  39. });
  40. });
  41. });
  42. });
  43. });
  44. do_test_pending();
  45. }