browser_dbg_variables-view-popup-17.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Tests opening the variable inspection popup while stopped at a debugger statement,
  5. * clicking "step in" and verifying that the popup is gone.
  6. */
  7. const TAB_URL = EXAMPLE_URL + "doc_with-frame.html";
  8. let gTab, gPanel, gDebugger;
  9. let actions, gSources, gVariables;
  10. function test() {
  11. let options = {
  12. source: TAB_URL,
  13. line: 1
  14. };
  15. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  16. gTab = aTab;
  17. gPanel = aPanel;
  18. gDebugger = gPanel.panelWin;
  19. actions = bindActionCreators(gPanel);
  20. gSources = gDebugger.DebuggerView.Sources;
  21. gVariables = gDebugger.DebuggerView.Variables;
  22. let bubble = gDebugger.DebuggerView.VariableBubble;
  23. let tooltip = bubble._tooltip.panel;
  24. let testPopupHiding = Task.async(function* () {
  25. yield addBreakpoint();
  26. yield ensureThreadClientState(gPanel, "resumed");
  27. yield pauseDebuggee();
  28. yield openVarPopup(gPanel, { line: 20, ch: 17 });
  29. is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 1,
  30. "The popup should be open with a simple text entry");
  31. // Now we're stopped at a breakpoint with an open popup
  32. // we'll send a keypress and check if the popup closes
  33. executeSoon(() => EventUtils.synthesizeKey("VK_F11", {}));
  34. // The keypress should cause one resumed event and one paused event
  35. yield waitForThreadEvents(gPanel, "resumed");
  36. yield waitForThreadEvents(gPanel, "paused");
  37. // Here's the state we're actually interested in checking..
  38. checkVariablePopupClosed(bubble);
  39. yield resumeDebuggerThenCloseAndFinish(gPanel);
  40. });
  41. testPopupHiding();
  42. });
  43. }
  44. function addBreakpoint() {
  45. return actions.addBreakpoint({ actor: gSources.selectedValue, line: 21 });
  46. }
  47. function pauseDebuggee() {
  48. generateMouseClickInTab(gTab, "content.document.querySelector('button')");
  49. // The first 'with' scope should be expanded by default, but the
  50. // variables haven't been fetched yet. This is how 'with' scopes work.
  51. return promise.all([
  52. waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES),
  53. waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_VARIABLES)
  54. ]);
  55. }
  56. function checkVariablePopupClosed(bubble) {
  57. ok(!bubble.contentsShown(),
  58. "When stepping, popup should close and be hidden.");
  59. ok(bubble._tooltip.isEmpty(),
  60. "The variable inspection popup should now be empty.");
  61. ok(!bubble._markedText,
  62. "The marked text in the editor was removed.");
  63. }
  64. registerCleanupFunction(function () {
  65. gTab = null;
  66. gPanel = null;
  67. gDebugger = null;
  68. actions = null;
  69. gSources = null;
  70. gVariables = null;
  71. });