browser_webconsole_exception_stackframe.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. "use strict";
  5. // Test that the console receive exceptions include a stackframe.
  6. // See bug 1184172.
  7. // On e10s, the exception is triggered in child process
  8. // and is ignored by test harness
  9. if (!Services.appinfo.browserTabsRemoteAutostart) {
  10. SimpleTest.ignoreAllUncaughtExceptions();
  11. }
  12. function test() {
  13. let hud;
  14. const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
  15. "test/test-exception-stackframe.html";
  16. const TEST_FILE = TEST_URI.substr(TEST_URI.lastIndexOf("/"));
  17. Task.spawn(runner).then(finishTest);
  18. function* runner() {
  19. const {tab} = yield loadTab(TEST_URI);
  20. hud = yield openConsole(tab);
  21. const stack = [{
  22. file: TEST_FILE,
  23. fn: "thirdCall",
  24. line: 21,
  25. }, {
  26. file: TEST_FILE,
  27. fn: "secondCall",
  28. line: 17,
  29. }, {
  30. file: TEST_FILE,
  31. fn: "firstCall",
  32. line: 12,
  33. }];
  34. let results = yield waitForMessages({
  35. webconsole: hud,
  36. messages: [{
  37. text: "nonExistingMethodCall is not defined",
  38. category: CATEGORY_JS,
  39. severity: SEVERITY_ERROR,
  40. collapsible: true,
  41. stacktrace: stack,
  42. }, {
  43. text: "SyntaxError: 'buggy;selector' is not a valid selector",
  44. category: CATEGORY_JS,
  45. severity: SEVERITY_ERROR,
  46. collapsible: true,
  47. stacktrace: [{
  48. file: TEST_FILE,
  49. fn: "domAPI",
  50. line: 25,
  51. }, {
  52. file: TEST_FILE,
  53. fn: "onLoadDomAPI",
  54. line: 33,
  55. }
  56. ]
  57. }, {
  58. text: "DOMException",
  59. category: CATEGORY_JS,
  60. severity: SEVERITY_ERROR,
  61. collapsible: true,
  62. stacktrace: [{
  63. file: TEST_FILE,
  64. fn: "domException",
  65. line: 29,
  66. }, {
  67. file: TEST_FILE,
  68. fn: "onLoadDomException",
  69. line: 36,
  70. },
  71. ]
  72. }],
  73. });
  74. let elem = [...results[0].matched][0];
  75. ok(elem, "message element");
  76. let msg = elem._messageObject;
  77. ok(msg, "message object");
  78. ok(msg.collapsed, "message is collapsed");
  79. msg.toggleDetails();
  80. ok(!msg.collapsed, "message is not collapsed");
  81. msg.toggleDetails();
  82. ok(msg.collapsed, "message is collapsed");
  83. yield closeConsole(tab);
  84. }
  85. }