browser_dbg_variables-view-hide-non-enums.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. * Test that non-enumerable variables and properties can be hidden
  6. * in the variables view.
  7. */
  8. const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
  9. var gTab, gPanel, gDebugger;
  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. waitForCaretAndScopes(gPanel, 14).then(performTest);
  20. callInTab(gTab, "simpleCall");
  21. });
  22. }
  23. function performTest() {
  24. let testScope = gDebugger.DebuggerView.Variables.addScope("test-scope");
  25. let testVar = testScope.addItem("foo");
  26. testVar.addItems({
  27. foo: {
  28. value: "bar",
  29. enumerable: true
  30. },
  31. bar: {
  32. value: "foo",
  33. enumerable: false
  34. }
  35. });
  36. // Expand the scope and variable.
  37. testScope.expand();
  38. testVar.expand();
  39. // Expanding the non-enumerable container is synchronously dispatched
  40. // on the main thread, so wait for the next tick.
  41. executeSoon(() => {
  42. let details = testVar._enum;
  43. let nonenum = testVar._nonenum;
  44. is(details.childNodes.length, 1,
  45. "There should be just one property in the .details container.");
  46. ok(details.hasAttribute("open"),
  47. ".details container should be visible.");
  48. ok(nonenum.hasAttribute("open"),
  49. ".nonenum container should be visible.");
  50. is(nonenum.childNodes.length, 1,
  51. "There should be just one property in the .nonenum container.");
  52. // Uncheck 'show hidden properties'.
  53. gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true");
  54. gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum();
  55. ok(details.hasAttribute("open"),
  56. ".details container should stay visible.");
  57. ok(!nonenum.hasAttribute("open"),
  58. ".nonenum container should become hidden.");
  59. // Check 'show hidden properties'.
  60. gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false");
  61. gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum();
  62. ok(details.hasAttribute("open"),
  63. ".details container should stay visible.");
  64. ok(nonenum.hasAttribute("open"),
  65. ".nonenum container should become visible.");
  66. // Collapse the variable. This is done on the current tick.
  67. testVar.collapse();
  68. ok(!details.hasAttribute("open"),
  69. ".details container should be hidden.");
  70. ok(!nonenum.hasAttribute("open"),
  71. ".nonenum container should be hidden.");
  72. // Uncheck 'show hidden properties'.
  73. gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true");
  74. gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum();
  75. ok(!details.hasAttribute("open"),
  76. ".details container should stay hidden.");
  77. ok(!nonenum.hasAttribute("open"),
  78. ".nonenum container should stay hidden.");
  79. // Check 'show hidden properties'.
  80. gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false");
  81. gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum();
  82. resumeDebuggerThenCloseAndFinish(gPanel);
  83. });
  84. }
  85. registerCleanupFunction(function () {
  86. gTab = null;
  87. gPanel = null;
  88. gDebugger = null;
  89. });