browser_dbg_searchbox-help-popup-01.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 the searchbox popup is displayed when focusing the searchbox,
  6. * and hidden when the user starts typing.
  7. */
  8. const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
  9. var gTab, gPanel, gDebugger;
  10. var gSearchBox, gSearchBoxPanel;
  11. function test() {
  12. let options = {
  13. source: EXAMPLE_URL + "code_script-switching-01.js",
  14. line: 1
  15. };
  16. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  17. gTab = aTab;
  18. gPanel = aPanel;
  19. gDebugger = gPanel.panelWin;
  20. gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
  21. gSearchBoxPanel = gDebugger.DebuggerView.Filtering._searchboxHelpPanel;
  22. waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1)
  23. .then(showPopup)
  24. .then(hidePopup)
  25. .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
  26. .then(null, aError => {
  27. ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
  28. });
  29. callInTab(gTab, "firstCall");
  30. });
  31. }
  32. function showPopup() {
  33. is(gSearchBoxPanel.state, "closed",
  34. "The search box panel shouldn't be visible yet.");
  35. let finished = once(gSearchBoxPanel, "popupshown");
  36. EventUtils.sendMouseEvent({ type: "click" }, gSearchBox, gDebugger);
  37. return finished;
  38. }
  39. function hidePopup() {
  40. is(gSearchBoxPanel.state, "open",
  41. "The search box panel should be visible after searching started.");
  42. let finished = once(gSearchBoxPanel, "popuphidden");
  43. setText(gSearchBox, "#");
  44. return finished;
  45. }
  46. registerCleanupFunction(function () {
  47. gTab = null;
  48. gPanel = null;
  49. gDebugger = null;
  50. gSearchBox = null;
  51. gSearchBoxPanel = null;
  52. });