browser_dbg_pretty-print-13.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. * Make sure that clicking the pretty print button prettifies the source, even
  6. * when the source URL does not end in ".js", but the content type is
  7. * JavaScript.
  8. */
  9. const TAB_URL = EXAMPLE_URL + "doc_pretty-print-3.html";
  10. function test() {
  11. // Wait for debugger panel to be fully set and break on debugger statement
  12. let options = {
  13. source: EXAMPLE_URL + "code_ugly-8",
  14. line: 2
  15. };
  16. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  17. const gTab = aTab;
  18. const gPanel = aPanel;
  19. const gDebugger = gPanel.panelWin;
  20. const gEditor = gDebugger.DebuggerView.editor;
  21. const gSources = gDebugger.DebuggerView.Sources;
  22. const queries = gDebugger.require("./content/queries");
  23. const constants = gDebugger.require("./content/constants");
  24. const actions = bindActionCreators(gPanel);
  25. const getState = gDebugger.DebuggerController.getState;
  26. Task.spawn(function* () {
  27. ok(!gEditor.getText().includes("\n "),
  28. "The source shouldn't be pretty printed yet.");
  29. const finished = waitForSourceShown(gPanel, "code_ugly-8");
  30. gDebugger.document.getElementById("pretty-print").click();
  31. const deck = gDebugger.document.getElementById("editor-deck");
  32. is(deck.selectedIndex, 2, "The progress bar should be shown");
  33. yield finished;
  34. ok(gEditor.getText().includes("\n "),
  35. "The source should be pretty printed.");
  36. is(deck.selectedIndex, 0, "The editor should be shown");
  37. const source = queries.getSelectedSource(getState());
  38. const { text } = queries.getSourceText(getState(), source.actor);
  39. ok(text.includes("\n "),
  40. "Subsequent calls to getText return the pretty printed source.");
  41. resumeDebuggerThenCloseAndFinish(gPanel);
  42. })
  43. });
  44. }