browser_dbg_variables-view-popup-07.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 the variable inspection popup behaves correctly when switching
  6. * between simple and complex objects.
  7. */
  8. const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.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 bubble = win.DebuggerView.VariableBubble;
  18. let tooltip = bubble._tooltip.panel;
  19. function verifySimpleContents(textContent, className) {
  20. is(tooltip.querySelectorAll(".variables-view-container").length, 0,
  21. "There should be no variables view container added to the tooltip.");
  22. is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 1,
  23. "There should be one simple text node added to the tooltip.");
  24. is(tooltip.querySelector(".devtools-tooltip-simple-text").textContent, textContent,
  25. "The inspected property's value is correct.");
  26. ok(tooltip.querySelector(".devtools-tooltip-simple-text").className.includes(className),
  27. "The inspected property's value is colorized correctly.");
  28. }
  29. function verifyComplexContents(propertyCount) {
  30. is(tooltip.querySelectorAll(".variables-view-container").length, 1,
  31. "There should be one variables view container added to the tooltip.");
  32. is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 0,
  33. "There should be no simple text node added to the tooltip.");
  34. is(tooltip.querySelectorAll(".variables-view-scope[untitled]").length, 1,
  35. "There should be one scope with no header displayed.");
  36. is(tooltip.querySelectorAll(".variables-view-variable[untitled]").length, 1,
  37. "There should be one variable with no header displayed.");
  38. ok(tooltip.querySelectorAll(".variables-view-property").length >= propertyCount,
  39. "There should be some properties displayed.");
  40. }
  41. let onCaretAndScopes = waitForCaretAndScopes(panel, 24);
  42. callInTab(tab, "start");
  43. yield onCaretAndScopes;
  44. // Inspect variables.
  45. yield openVarPopup(panel, { line: 15, ch: 12 });
  46. verifySimpleContents("1", "token-number");
  47. yield reopenVarPopup(panel, { line: 16, ch: 12 }, true);
  48. verifyComplexContents(2);
  49. yield reopenVarPopup(panel, { line: 19, ch: 10 });
  50. verifySimpleContents("42", "token-number");
  51. yield reopenVarPopup(panel, { line: 31, ch: 10 }, true);
  52. verifyComplexContents(100);
  53. yield resumeDebuggerThenCloseAndFinish(panel);
  54. });
  55. }