browser_console_iframe_messages.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. // Check that cached messages from nested iframes are displayed in the
  5. // Web/Browser Console.
  6. "use strict";
  7. const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
  8. "test/test-consoleiframes.html";
  9. const expectedMessages = [
  10. {
  11. text: "main file",
  12. category: CATEGORY_WEBDEV,
  13. severity: SEVERITY_LOG,
  14. },
  15. {
  16. text: "blah",
  17. category: CATEGORY_JS,
  18. severity: SEVERITY_ERROR
  19. },
  20. {
  21. text: "iframe 2",
  22. category: CATEGORY_WEBDEV,
  23. severity: SEVERITY_LOG
  24. },
  25. {
  26. text: "iframe 3",
  27. category: CATEGORY_WEBDEV,
  28. severity: SEVERITY_LOG
  29. }
  30. ];
  31. // "iframe 1" console messages can be coalesced into one if they follow each
  32. // other in the sequence of messages (depending on timing). If they do not, then
  33. // they will be displayed in the console output independently, as separate
  34. // messages. This is why we need to match any of the following two rules.
  35. const expectedMessagesAny = [
  36. {
  37. name: "iframe 1 (count: 2)",
  38. text: "iframe 1",
  39. category: CATEGORY_WEBDEV,
  40. severity: SEVERITY_LOG,
  41. count: 2
  42. },
  43. {
  44. name: "iframe 1 (repeats: 2)",
  45. text: "iframe 1",
  46. category: CATEGORY_WEBDEV,
  47. severity: SEVERITY_LOG,
  48. repeats: 2
  49. },
  50. ];
  51. add_task(function* () {
  52. // On e10s, the exception is triggered in child process
  53. // and is ignored by test harness
  54. if (!Services.appinfo.browserTabsRemoteAutostart) {
  55. expectUncaughtException();
  56. }
  57. yield loadTab(TEST_URI);
  58. let hud = yield openConsole();
  59. ok(hud, "web console opened");
  60. yield testWebConsole(hud);
  61. yield closeConsole();
  62. info("web console closed");
  63. hud = yield HUDService.toggleBrowserConsole();
  64. yield testBrowserConsole(hud);
  65. yield closeConsole();
  66. });
  67. function* testWebConsole(hud) {
  68. yield waitForMessages({
  69. webconsole: hud,
  70. messages: expectedMessages,
  71. });
  72. info("first messages matched");
  73. yield waitForMessages({
  74. webconsole: hud,
  75. messages: expectedMessagesAny,
  76. matchCondition: "any",
  77. });
  78. }
  79. function* testBrowserConsole(hud) {
  80. ok(hud, "browser console opened");
  81. // TODO: The browser console doesn't show page's console.log statements
  82. // in e10s windows. See Bug 1241289.
  83. if (Services.appinfo.browserTabsRemoteAutostart) {
  84. todo(false, "Bug 1241289");
  85. return;
  86. }
  87. yield waitForMessages({
  88. webconsole: hud,
  89. messages: expectedMessages,
  90. });
  91. info("first messages matched");
  92. yield waitForMessages({
  93. webconsole: hud,
  94. messages: expectedMessagesAny,
  95. matchCondition: "any",
  96. });
  97. }