browser_webconsole_output_03.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. // Test the webconsole output for various types of objects.
  5. "use strict";
  6. const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
  7. "test/test-console-output-03.html";
  8. var inputTests = [
  9. // 0
  10. {
  11. input: "document",
  12. output: "HTMLDocument \u2192 " + TEST_URI,
  13. printOutput: "[object HTMLDocument]",
  14. inspectable: true,
  15. noClick: true,
  16. },
  17. // 1
  18. {
  19. input: "window",
  20. output: "Window \u2192 " + TEST_URI,
  21. printOutput: "[object Window",
  22. inspectable: true,
  23. noClick: true,
  24. },
  25. // 2
  26. {
  27. input: "document.body",
  28. output: "<body>",
  29. printOutput: "[object HTMLBodyElement]",
  30. inspectable: true,
  31. noClick: true,
  32. },
  33. // 3
  34. {
  35. input: "document.body.dataset",
  36. output: "DOMStringMap { }",
  37. printOutput: "[object DOMStringMap]",
  38. inspectable: true,
  39. variablesViewLabel: "DOMStringMap[0]",
  40. },
  41. // 4
  42. {
  43. input: "document.body.classList",
  44. output: "DOMTokenList [ ]",
  45. printOutput: '""',
  46. inspectable: true,
  47. variablesViewLabel: "DOMTokenList[0]",
  48. },
  49. // 5
  50. {
  51. input: "window.location.href",
  52. output: '"' + TEST_URI + '"',
  53. noClick: true,
  54. },
  55. // 6
  56. {
  57. input: "window.location",
  58. output: "Location \u2192 " + TEST_URI,
  59. printOutput: TEST_URI,
  60. inspectable: true,
  61. variablesViewLabel: "Location \u2192 test-console-output-03.html",
  62. },
  63. // 7
  64. {
  65. input: "document.body.attributes",
  66. output: "NamedNodeMap [ ]",
  67. printOutput: "[object NamedNodeMap]",
  68. inspectable: true,
  69. variablesViewLabel: "NamedNodeMap[0]",
  70. },
  71. // 8
  72. {
  73. input: "document.styleSheets",
  74. output: "StyleSheetList [ ]",
  75. printOutput: "[object StyleSheetList",
  76. inspectable: true,
  77. variablesViewLabel: "StyleSheetList[0]",
  78. },
  79. // 9
  80. {
  81. input: "testBodyClassName()",
  82. output: '<body class="test1 tezt2">',
  83. printOutput: "[object HTMLBodyElement]",
  84. inspectable: true,
  85. noClick: true,
  86. },
  87. // 10
  88. {
  89. input: "testBodyID()",
  90. output: '<body class="test1 tezt2" id="foobarid">',
  91. printOutput: "[object HTMLBodyElement]",
  92. inspectable: true,
  93. noClick: true,
  94. },
  95. // 11
  96. {
  97. input: "document.body.classList",
  98. output: 'DOMTokenList [ "test1", "tezt2" ]',
  99. printOutput: '"test1 tezt2"',
  100. inspectable: true,
  101. variablesViewLabel: "DOMTokenList[2]",
  102. },
  103. // 12
  104. {
  105. input: "testBodyDataset()",
  106. output: '<body class="test1 tezt2" id="foobarid"' +
  107. ' data-preview="zuzu&quot;&lt;a&gt;foo">',
  108. printOutput: "[object HTMLBodyElement]",
  109. inspectable: true,
  110. noClick: true,
  111. },
  112. // 13
  113. {
  114. input: "document.body.dataset",
  115. output: 'DOMStringMap { preview: "zuzu"<a>foo" }',
  116. printOutput: "[object DOMStringMap]",
  117. inspectable: true,
  118. variablesViewLabel: "DOMStringMap[1]",
  119. },
  120. // 14
  121. {
  122. input: "document.body.attributes",
  123. output: 'NamedNodeMap [ class="test1 tezt2", id="foobarid", ' +
  124. 'data-preview="zuzu&quot;&lt;a&gt;foo" ]',
  125. printOutput: "[object NamedNodeMap]",
  126. inspectable: true,
  127. variablesViewLabel: "NamedNodeMap[3]",
  128. },
  129. // 15
  130. {
  131. input: "document.body.attributes[0]",
  132. output: 'class="test1 tezt2"',
  133. printOutput: "[object Attr]",
  134. inspectable: true,
  135. variablesViewLabel: 'class="test1 tezt2"',
  136. },
  137. ];
  138. function test() {
  139. requestLongerTimeout(2);
  140. Task.spawn(function* () {
  141. const {tab} = yield loadTab(TEST_URI);
  142. const hud = yield openConsole(tab);
  143. yield checkOutputForInputs(hud, inputTests);
  144. inputTests = null;
  145. }).then(finishTest);
  146. }