browser_webconsole_output_01.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 = "data:text/html;charset=utf8,test for console output - 01";
  11. var {DebuggerServer} = require("devtools/server/main");
  12. var longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a");
  13. var initialString = longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
  14. var inputTests = [
  15. // 0
  16. {
  17. input: "'hello \\nfrom \\rthe \\\"string world!'",
  18. output: "\"hello \nfrom \rthe \"string world!\"",
  19. consoleOutput: "hello \nfrom \rthe \"string world!",
  20. },
  21. // 1
  22. {
  23. // unicode test
  24. input: "'\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165'",
  25. output: "\"\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165\"",
  26. consoleOutput: "\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165",
  27. },
  28. // 2
  29. {
  30. input: "'" + longString + "'",
  31. output: '"' + initialString + "\"[\u2026]",
  32. consoleOutput: initialString + "[\u2026]",
  33. printOutput: initialString,
  34. },
  35. // 3
  36. {
  37. input: "''",
  38. output: '""',
  39. consoleOutput: "",
  40. printOutput: '""',
  41. },
  42. // 4
  43. {
  44. input: "0",
  45. output: "0",
  46. },
  47. // 5
  48. {
  49. input: "'0'",
  50. output: '"0"',
  51. consoleOutput: "0",
  52. },
  53. // 6
  54. {
  55. input: "42",
  56. output: "42",
  57. },
  58. // 7
  59. {
  60. input: "'42'",
  61. output: '"42"',
  62. consoleOutput: "42",
  63. },
  64. // 8
  65. {
  66. input: "/foobar/",
  67. output: "/foobar/",
  68. inspectable: true,
  69. },
  70. // 9
  71. {
  72. input: "Symbol()",
  73. output: "Symbol()"
  74. },
  75. // 10
  76. {
  77. input: "Symbol('foo')",
  78. output: "Symbol(foo)"
  79. },
  80. // 11
  81. {
  82. input: "Symbol.iterator",
  83. output: "Symbol(Symbol.iterator)"
  84. },
  85. ];
  86. longString = initialString = null;
  87. function test() {
  88. requestLongerTimeout(2);
  89. Task.spawn(function* () {
  90. let {tab} = yield loadTab(TEST_URI);
  91. let hud = yield openConsole(tab);
  92. return checkOutputForInputs(hud, inputTests);
  93. }).then(finishUp);
  94. }
  95. function finishUp() {
  96. longString = initialString = inputTests = null;
  97. finishTest();
  98. }