browser_keybindings_03.js 1.7 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. "use strict";
  5. // Test that the toolbox 'switch to previous host' feature works.
  6. // Pressing ctrl/cmd+shift+d should switch to the last used host.
  7. const URL = "data:text/html;charset=utf8,test page for toolbox switching";
  8. var {Toolbox} = require("devtools/client/framework/toolbox");
  9. const {LocalizationHelper} = require("devtools/shared/l10n");
  10. const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
  11. add_task(function* () {
  12. info("Create a test tab and open the toolbox");
  13. let tab = yield addTab(URL);
  14. let target = TargetFactory.forTab(tab);
  15. let toolbox = yield gDevTools.showToolbox(target, "webconsole");
  16. let shortcut = L10N.getStr("toolbox.toggleHost.key");
  17. let {SIDE, BOTTOM, WINDOW} = Toolbox.HostType;
  18. checkHostType(toolbox, BOTTOM, SIDE);
  19. info("Switching from bottom to side");
  20. let onHostChanged = toolbox.once("host-changed");
  21. synthesizeKeyShortcut(shortcut, toolbox.win);
  22. yield onHostChanged;
  23. checkHostType(toolbox, SIDE, BOTTOM);
  24. info("Switching from side to bottom");
  25. onHostChanged = toolbox.once("host-changed");
  26. synthesizeKeyShortcut(shortcut, toolbox.win);
  27. yield onHostChanged;
  28. checkHostType(toolbox, BOTTOM, SIDE);
  29. info("Switching to window");
  30. yield toolbox.switchHost(WINDOW);
  31. checkHostType(toolbox, WINDOW, BOTTOM);
  32. info("Switching from window to bottom");
  33. onHostChanged = toolbox.once("host-changed");
  34. synthesizeKeyShortcut(shortcut, toolbox.win);
  35. yield onHostChanged;
  36. checkHostType(toolbox, BOTTOM, WINDOW);
  37. yield toolbox.destroy();
  38. gBrowser.removeCurrentTab();
  39. });