browser_dbg_pretty-print-on-paused.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4. /**
  5. * Test that pretty printing when the debugger is paused does not switch away
  6. * from the selected source.
  7. */
  8. const TAB_URL = EXAMPLE_URL + "doc_pretty-print-on-paused.html";
  9. var gTab, gPanel, gDebugger, gThreadClient, gSources;
  10. const SECOND_SOURCE_VALUE = EXAMPLE_URL + "code_ugly-2.js";
  11. function test() {
  12. // Wait for debugger panel to be fully set and break on debugger statement
  13. let options = {
  14. source: EXAMPLE_URL + "code_script-switching-02.js",
  15. line: 1
  16. };
  17. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  18. gTab = aTab;
  19. gPanel = aPanel;
  20. gDebugger = gPanel.panelWin;
  21. gThreadClient = gDebugger.gThreadClient;
  22. gSources = gDebugger.DebuggerView.Sources;
  23. Task.spawn(function* () {
  24. try {
  25. yield doInterrupt(gPanel);
  26. let source = gThreadClient.source(getSourceForm(gSources, SECOND_SOURCE_VALUE));
  27. yield source.setBreakpoint({
  28. line: 6
  29. });
  30. yield doResume(gPanel);
  31. const bpHit = waitForCaretAndScopes(gPanel, 6);
  32. callInTab(gTab, "secondCall");
  33. yield bpHit;
  34. info("Switch to the second source.");
  35. const sourceShown = waitForSourceShown(gPanel, SECOND_SOURCE_VALUE);
  36. gSources.selectedValue = getSourceActor(gSources, SECOND_SOURCE_VALUE);
  37. yield sourceShown;
  38. info("Pretty print the source.");
  39. const prettyPrinted = waitForSourceShown(gPanel, SECOND_SOURCE_VALUE);
  40. gDebugger.document.getElementById("pretty-print").click();
  41. yield prettyPrinted;
  42. yield resumeDebuggerThenCloseAndFinish(gPanel);
  43. } catch (e) {
  44. DevToolsUtils.reportException("browser_dbg_pretty-print-on-paused.js", e);
  45. ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
  46. }
  47. });
  48. });
  49. }
  50. registerCleanupFunction(function () {
  51. gTab = null;
  52. gPanel = null;
  53. gDebugger = null;
  54. gThreadClient = null;
  55. gSources = null;
  56. });