michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Check that cached messages from nested iframes are displayed in the michael@0: // Web/Browser Console. michael@0: michael@0: const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-consoleiframes.html"; michael@0: michael@0: let expectedMessages = [ michael@0: { michael@0: text: "main file", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: }, michael@0: { michael@0: text: "blah", michael@0: category: CATEGORY_JS, michael@0: severity: SEVERITY_ERROR michael@0: }, michael@0: { michael@0: text: "iframe 2", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG michael@0: }, michael@0: { michael@0: text: "iframe 3", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG michael@0: } michael@0: ]; michael@0: michael@0: // "iframe 1" console messages can be coalesced into one if they follow each michael@0: // other in the sequence of messages (depending on timing). If they do not, then michael@0: // they will be displayed in the console output independently, as separate michael@0: // messages. This is why we need to match any of the following two rules. michael@0: let expectedMessagesAny = [ michael@0: { michael@0: name: "iframe 1 (count: 2)", michael@0: text: "iframe 1", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: count: 2 michael@0: }, michael@0: { michael@0: name: "iframe 1 (repeats: 2)", michael@0: text: "iframe 1", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: repeats: 2 michael@0: }, michael@0: ]; michael@0: michael@0: function test() michael@0: { michael@0: expectUncaughtException(); michael@0: addTab(TEST_URI); michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: info("open web console"); michael@0: openConsole(null, consoleOpened); michael@0: }, true); michael@0: } michael@0: michael@0: function consoleOpened(hud) michael@0: { michael@0: ok(hud, "web console opened"); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: expectedMessages, michael@0: }).then(() => { michael@0: info("first messages matched"); michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: expectedMessagesAny, michael@0: matchCondition: "any", michael@0: }).then(() => { michael@0: closeConsole(null, onWebConsoleClose); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function onWebConsoleClose() michael@0: { michael@0: info("web console closed"); michael@0: HUDService.toggleBrowserConsole().then(onBrowserConsoleOpen); michael@0: } michael@0: michael@0: function onBrowserConsoleOpen(hud) michael@0: { michael@0: ok(hud, "browser console opened"); michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: expectedMessages, michael@0: }).then(() => { michael@0: info("first messages matched"); michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: expectedMessagesAny, michael@0: matchCondition: "any", michael@0: }).then(() => { michael@0: closeConsole(null, finishTest); michael@0: }); michael@0: }); michael@0: }