browser_cmd_commands.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Any copyright is dedicated to the Public Domain.
  2. * http://creativecommons.org/publicdomain/zero/1.0/ */
  3. // Test various GCLI commands
  4. const TEST_URI = "data:text/html;charset=utf-8,gcli-commands";
  5. const {HUDService} = require("devtools/client/webconsole/hudservice");
  6. // Use the old webconsole since pprint isn't working on new one (Bug 1304794)
  7. Services.prefs.setBoolPref("devtools.webconsole.new-frontend-enabled", false);
  8. registerCleanupFunction(function* () {
  9. Services.prefs.clearUserPref("devtools.webconsole.new-frontend-enabled");
  10. });
  11. function test() {
  12. return Task.spawn(spawnTest).then(finish, helpers.handleError);
  13. }
  14. function* spawnTest() {
  15. let options = yield helpers.openTab(TEST_URI);
  16. yield helpers.openToolbar(options);
  17. let subjectPromise = helpers.observeOnce("web-console-created");
  18. helpers.audit(options, [
  19. {
  20. setup: "console open",
  21. exec: { }
  22. }
  23. ]);
  24. let subject = yield subjectPromise;
  25. subject.QueryInterface(Ci.nsISupportsString);
  26. let hud = HUDService.getHudReferenceById(subject.data);
  27. ok(hud, "console open");
  28. let msg = yield hud.jsterm.execute("pprint(window)");
  29. ok(msg, "output for pprint(window)");
  30. yield helpers.audit(options, [
  31. {
  32. setup: "console clear",
  33. exec: { output: "" }
  34. }
  35. ]);
  36. let labels = hud.outputNode.querySelectorAll(".message");
  37. is(labels.length, 0, "no output in console");
  38. yield helpers.audit(options, [
  39. {
  40. setup: "console close",
  41. exec: { output: "" }
  42. }
  43. ]);
  44. ok(!HUDService.getHudReferenceById(hud.hudId), "console closed");
  45. yield helpers.closeToolbar(options);
  46. yield helpers.closeTab(options);
  47. }