browser_dbg_variables-view-popup-12.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. * Tests that the clicking "Watch" button twice, for the same expression, only adds it
  6. * once.
  7. */
  8. const TAB_URL = EXAMPLE_URL + "doc_watch-expression-button.html";
  9. function test() {
  10. Task.spawn(function* () {
  11. let options = {
  12. source: TAB_URL,
  13. line: 1
  14. };
  15. let [tab,, panel] = yield initDebugger(TAB_URL, options);
  16. let win = panel.panelWin;
  17. let events = win.EVENTS;
  18. let watch = win.DebuggerView.WatchExpressions;
  19. let bubble = win.DebuggerView.VariableBubble;
  20. let tooltip = bubble._tooltip.panel;
  21. function verifyContent(aExpression, aItemCount) {
  22. ok(watch.getItemAtIndex(0),
  23. "The expression at index 0 should be available.");
  24. is(watch.getItemAtIndex(0).attachment.initialExpression, aExpression,
  25. "The expression at index 0 is correct.");
  26. is(watch.itemCount, aItemCount,
  27. "The expression count is correct.");
  28. }
  29. let onCaretAndScopes = waitForCaretAndScopes(panel, 19);
  30. callInTab(tab, "start");
  31. yield onCaretAndScopes;
  32. // Inspect primitive value variable.
  33. yield openVarPopup(panel, { line: 15, ch: 12 });
  34. let popupHiding = once(tooltip, "popuphiding");
  35. let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
  36. tooltip.querySelector("button").click();
  37. verifyContent("a", 1);
  38. yield promise.all([popupHiding, expressionsEvaluated]);
  39. ok(true, "The new watch expressions were re-evaluated and the panel got hidden (1).");
  40. // Inspect property of an object.
  41. expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
  42. yield openVarPopup(panel, { line: 17, ch: 10 });
  43. yield expressionsEvaluated;
  44. ok(true, "The watch expressions were re-evaluated when a new panel opened (1).");
  45. popupHiding = once(tooltip, "popuphiding");
  46. expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
  47. tooltip.querySelector("button").click();
  48. verifyContent("b.a", 2);
  49. yield promise.all([popupHiding, expressionsEvaluated]);
  50. ok(true, "The new watch expressions were re-evaluated and the panel got hidden (2).");
  51. // Re-inspect primitive value variable.
  52. expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
  53. yield openVarPopup(panel, { line: 15, ch: 12 });
  54. yield expressionsEvaluated;
  55. ok(true, "The watch expressions were re-evaluated when a new panel opened (2).");
  56. popupHiding = once(tooltip, "popuphiding");
  57. expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
  58. tooltip.querySelector("button").click();
  59. verifyContent("b.a", 2);
  60. yield promise.all([popupHiding, expressionsEvaluated]);
  61. ok(true, "The new watch expressions were re-evaluated and the panel got hidden (3).");
  62. yield resumeDebuggerThenCloseAndFinish(panel);
  63. });
  64. }