/browser/devtools/debugger/test/browser_dbg_propertyview-05.js

https://github.com/Anachid/mozilla-central · JavaScript · 99 lines · 63 code · 31 blank · 5 comment · 0 complexity · 12869be50ef30df0d3e8a0621eb44cc3 MD5 · raw file

  1. /* vim:set ts=2 sw=2 sts=2 et: */
  2. /*
  3. * Any copyright is dedicated to the Public Domain.
  4. * http://creativecommons.org/publicdomain/zero/1.0/
  5. */
  6. var gPane = null;
  7. var gTab = null;
  8. var gDebuggee = null;
  9. var gDebugger = null;
  10. function test() {
  11. debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
  12. gTab = aTab;
  13. gDebuggee = aDebuggee;
  14. gPane = aPane;
  15. gDebugger = gPane.debuggerWindow;
  16. testSimpleCall();
  17. });
  18. }
  19. function testSimpleCall() {
  20. gPane.activeThread.addOneTimeListener("framesadded", function() {
  21. Services.tm.currentThread.dispatch({ run: function() {
  22. let testScope = gDebugger.DebuggerView.Properties._addScope("test");
  23. let testVar = testScope.addVar("something");
  24. testVar.setGrip(1.618);
  25. is(testVar.querySelector(".info").textContent, "1.618",
  26. "The grip information for the variable wasn't set correctly.");
  27. is(testVar.querySelector(".details").childNodes.length, 0,
  28. "Adding a value property shouldn't add any new tree nodes.");
  29. testVar.setGrip({ "type": "object", "class": "Window" });
  30. is(testVar.querySelector(".details").childNodes.length, 0,
  31. "Adding type and class properties shouldn't add any new tree nodes.");
  32. is(testVar.querySelector(".info").textContent, "[object Window]",
  33. "The information for the variable wasn't set correctly.");
  34. testVar.addProperties({ "helloWorld": { "value": "hello world" } });
  35. is(testVar.querySelector(".details").childNodes.length, 1,
  36. "A new detail node should have been added in the variable tree.");
  37. testVar.addProperties({ "helloWorld": { "value": "hello jupiter" } });
  38. is(testVar.querySelector(".details").childNodes.length, 1,
  39. "Shouldn't be able to duplicate nodes added in the variable tree.");
  40. testVar.addProperties({ "someProp0": { "value": "random string" },
  41. "someProp1": { "value": "another string" } });
  42. is(testVar.querySelector(".details").childNodes.length, 3,
  43. "Two new detail nodes should have been added in the variable tree.");
  44. testVar.addProperties({ "someProp2": { "value": { "type": "null" } },
  45. "someProp3": { "value": { "type": "undefined" } },
  46. "someProp4": { "value": { "type": "object", "class": "Object" } } });
  47. is(testVar.querySelector(".details").childNodes.length, 6,
  48. "Three new detail nodes should have been added in the variable tree.");
  49. testVar.empty();
  50. is(testVar.querySelector(".details").childNodes.length, 0,
  51. "The var should remove all it's details container tree children.");
  52. testVar.remove();
  53. is(testScope.querySelector(".details").childNodes.length, 0,
  54. "The var should have been removed from the parent container tree.");
  55. gDebugger.StackFrames.activeThread.resume(function() {
  56. closeDebuggerAndFinish(gTab);
  57. });
  58. }}, 0);
  59. });
  60. gDebuggee.simpleCall();
  61. }
  62. registerCleanupFunction(function() {
  63. removeTab(gTab);
  64. gPane = null;
  65. gTab = null;
  66. gDebuggee = null;
  67. gDebugger = null;
  68. });