browser_scratchpad_pprint.js 751 B

1234567891011121314151617181920212223242526272829
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. function test()
  4. {
  5. waitForExplicitFinish();
  6. gBrowser.selectedTab = gBrowser.addTab();
  7. gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
  8. gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
  9. openScratchpad(runTests);
  10. }, true);
  11. content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
  12. }
  13. function runTests(sw)
  14. {
  15. const sp = sw.Scratchpad;
  16. sp.setText("function main() { console.log(5); }");
  17. sp.prettyPrint().then(() => {
  18. const prettyText = sp.getText();
  19. ok(prettyText.includes("\n"));
  20. finish();
  21. }).then(null, error => {
  22. ok(false, error);
  23. });
  24. }