browser_scratchpad_close_toolbox.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. // Test that closing the toolbox after having opened a scratchpad leaves the
  4. // latter in a functioning state.
  5. var {Task} = require("devtools/shared/task");
  6. var {TargetFactory} = require("devtools/client/framework/target");
  7. function test() {
  8. const options = {
  9. tabContent: "test closing toolbox and then reusing scratchpad"
  10. };
  11. openTabAndScratchpad(options)
  12. .then(Task.async(runTests))
  13. .then(finish, console.error);
  14. }
  15. function* runTests([win, sp]) {
  16. // Use the scratchpad before opening the toolbox.
  17. const source = "window.foobar = 7;";
  18. sp.setText(source);
  19. let [,, result] = yield sp.display();
  20. is(result, 7, "Display produced the expected output.");
  21. // Now open the toolbox and close it again.
  22. let target = TargetFactory.forTab(gBrowser.selectedTab);
  23. let toolbox = yield gDevTools.showToolbox(target, "webconsole");
  24. ok(toolbox, "Toolbox was opened.");
  25. let closed = yield gDevTools.closeToolbox(target);
  26. is(closed, true, "Toolbox was closed.");
  27. // Now see if using the scratcphad works as expected.
  28. sp.setText(source);
  29. let [,, result2] = yield sp.display();
  30. is(result2, 7,
  31. "Display produced the expected output after the toolbox was gone.");
  32. }