browser_webconsole_output_04.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. // Whitelisting this test.
  5. // As part of bug 1077403, the leaking uncaught rejection should be fixed.
  6. //
  7. "use strict";
  8. thisTestLeaksUncaughtRejectionsAndShouldBeFixed("null");
  9. // Test the webconsole output for various types of objects.
  10. const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
  11. "test/test-console-output-04.html";
  12. var inputTests = [
  13. // 0
  14. {
  15. input: "testTextNode()",
  16. output: '#text "hello world!"',
  17. printOutput: "[object Text]",
  18. inspectable: true,
  19. noClick: true,
  20. },
  21. // 1
  22. {
  23. input: "testCommentNode()",
  24. output: /<!--\s+- Any copyright /,
  25. printOutput: "[object Comment]",
  26. inspectable: true,
  27. noClick: true,
  28. },
  29. // 2
  30. {
  31. input: "testDocumentFragment()",
  32. output: "DocumentFragment [ <div#foo1.bar>, <div#foo3> ]",
  33. printOutput: "[object DocumentFragment]",
  34. inspectable: true,
  35. variablesViewLabel: "DocumentFragment[2]",
  36. },
  37. // 3
  38. {
  39. input: "testError()",
  40. output: "TypeError: window.foobar is not a function\n" +
  41. "Stack trace:\n" +
  42. "testError@" + TEST_URI + ":44",
  43. printOutput: '"TypeError: window.foobar is not a function"',
  44. inspectable: true,
  45. variablesViewLabel: "TypeError",
  46. },
  47. // 4
  48. {
  49. input: "testDOMException()",
  50. output: `DOMException [SyntaxError: "'foo;()bar!' is not a valid selector"`,
  51. printOutput: `"SyntaxError: 'foo;()bar!' is not a valid selector"`,
  52. inspectable: true,
  53. variablesViewLabel: "SyntaxError",
  54. },
  55. // 5
  56. {
  57. input: "testCSSStyleDeclaration()",
  58. output: 'CSS2Properties { color: "green", font-size: "2em" }',
  59. printOutput: "[object CSS2Properties]",
  60. inspectable: true,
  61. noClick: true,
  62. },
  63. // 6
  64. {
  65. input: "testStyleSheetList()",
  66. output: "StyleSheetList [ CSSStyleSheet ]",
  67. printOutput: "[object StyleSheetList",
  68. inspectable: true,
  69. variablesViewLabel: "StyleSheetList[1]",
  70. },
  71. // 7
  72. {
  73. input: "document.styleSheets[0]",
  74. output: "CSSStyleSheet",
  75. printOutput: "[object CSSStyleSheet]",
  76. inspectable: true,
  77. },
  78. // 8
  79. {
  80. input: "document.styleSheets[0].cssRules",
  81. output: "CSSRuleList [ CSSStyleRule, CSSMediaRule ]",
  82. printOutput: "[object CSSRuleList",
  83. inspectable: true,
  84. variablesViewLabel: "CSSRuleList[2]",
  85. },
  86. // 9
  87. {
  88. input: "document.styleSheets[0].cssRules[0]",
  89. output: 'CSSStyleRule "p, div"',
  90. printOutput: "[object CSSStyleRule",
  91. inspectable: true,
  92. variablesViewLabel: "CSSStyleRule",
  93. },
  94. // 10
  95. {
  96. input: "document.styleSheets[0].cssRules[1]",
  97. output: 'CSSMediaRule "print"',
  98. printOutput: "[object CSSMediaRule",
  99. inspectable: true,
  100. variablesViewLabel: "CSSMediaRule",
  101. },
  102. ];
  103. function test() {
  104. requestLongerTimeout(2);
  105. Task.spawn(function* () {
  106. const {tab} = yield loadTab(TEST_URI);
  107. const hud = yield openConsole(tab);
  108. yield checkOutputForInputs(hud, inputTests);
  109. inputTests = null;
  110. }).then(finishTest);
  111. }