browser_dbg_variables-view-popup-11.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 watch expression button is added in variable view popup.
  6. */
  7. const TAB_URL = EXAMPLE_URL + "doc_watch-expression-button.html";
  8. function test() {
  9. Task.spawn(function* () {
  10. let options = {
  11. source: TAB_URL,
  12. line: 1
  13. };
  14. let [tab,, panel] = yield initDebugger(TAB_URL, options);
  15. let win = panel.panelWin;
  16. let events = win.EVENTS;
  17. let watch = win.DebuggerView.WatchExpressions;
  18. let bubble = win.DebuggerView.VariableBubble;
  19. let tooltip = bubble._tooltip.panel;
  20. let label = win.L10N.getStr("addWatchExpressionButton");
  21. let className = "dbg-expression-button";
  22. function testExpressionButton(aLabel, aClassName, aExpression) {
  23. ok(tooltip.querySelector("button"),
  24. "There should be a button available in variable view popup.");
  25. is(tooltip.querySelector("button").label, aLabel,
  26. "The button available is labeled correctly.");
  27. is(tooltip.querySelector("button").className, aClassName,
  28. "The button available is styled correctly.");
  29. tooltip.querySelector("button").click();
  30. ok(!tooltip.querySelector("button"),
  31. "There should be no button available in variable view popup.");
  32. ok(watch.getItemAtIndex(0),
  33. "The expression at index 0 should be available.");
  34. is(watch.getItemAtIndex(0).attachment.initialExpression, aExpression,
  35. "The expression at index 0 is correct.");
  36. }
  37. let onCaretAndScopes = waitForCaretAndScopes(panel, 19);
  38. callInTab(tab, "start");
  39. yield onCaretAndScopes;
  40. // Inspect primitive value variable.
  41. yield openVarPopup(panel, { line: 15, ch: 12 });
  42. let popupHiding = once(tooltip, "popuphiding");
  43. let expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
  44. testExpressionButton(label, className, "a");
  45. yield promise.all([popupHiding, expressionsEvaluated]);
  46. ok(true, "The new watch expressions were re-evaluated and the panel got hidden (1).");
  47. // Inspect non primitive value variable.
  48. expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
  49. yield openVarPopup(panel, { line: 16, ch: 12 }, true);
  50. yield expressionsEvaluated;
  51. ok(true, "The watch expressions were re-evaluated when a new panel opened (1).");
  52. popupHiding = once(tooltip, "popuphiding");
  53. expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
  54. testExpressionButton(label, className, "b");
  55. yield promise.all([popupHiding, expressionsEvaluated]);
  56. ok(true, "The new watch expressions were re-evaluated and the panel got hidden (2).");
  57. // Inspect property of an object.
  58. expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
  59. yield openVarPopup(panel, { line: 17, ch: 10 });
  60. yield expressionsEvaluated;
  61. ok(true, "The watch expressions were re-evaluated when a new panel opened (2).");
  62. popupHiding = once(tooltip, "popuphiding");
  63. expressionsEvaluated = waitForDebuggerEvents(panel, events.FETCHED_WATCH_EXPRESSIONS);
  64. testExpressionButton(label, className, "b.a");
  65. yield promise.all([popupHiding, expressionsEvaluated]);
  66. ok(true, "The new watch expressions were re-evaluated and the panel got hidden (3).");
  67. yield resumeDebuggerThenCloseAndFinish(panel);
  68. });
  69. }