browser/devtools/webconsole/test/browser_console_iframe_messages.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 4 */
michael@0 5
michael@0 6 // Check that cached messages from nested iframes are displayed in the
michael@0 7 // Web/Browser Console.
michael@0 8
michael@0 9 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-consoleiframes.html";
michael@0 10
michael@0 11 let expectedMessages = [
michael@0 12 {
michael@0 13 text: "main file",
michael@0 14 category: CATEGORY_WEBDEV,
michael@0 15 severity: SEVERITY_LOG,
michael@0 16 },
michael@0 17 {
michael@0 18 text: "blah",
michael@0 19 category: CATEGORY_JS,
michael@0 20 severity: SEVERITY_ERROR
michael@0 21 },
michael@0 22 {
michael@0 23 text: "iframe 2",
michael@0 24 category: CATEGORY_WEBDEV,
michael@0 25 severity: SEVERITY_LOG
michael@0 26 },
michael@0 27 {
michael@0 28 text: "iframe 3",
michael@0 29 category: CATEGORY_WEBDEV,
michael@0 30 severity: SEVERITY_LOG
michael@0 31 }
michael@0 32 ];
michael@0 33
michael@0 34 // "iframe 1" console messages can be coalesced into one if they follow each
michael@0 35 // other in the sequence of messages (depending on timing). If they do not, then
michael@0 36 // they will be displayed in the console output independently, as separate
michael@0 37 // messages. This is why we need to match any of the following two rules.
michael@0 38 let expectedMessagesAny = [
michael@0 39 {
michael@0 40 name: "iframe 1 (count: 2)",
michael@0 41 text: "iframe 1",
michael@0 42 category: CATEGORY_WEBDEV,
michael@0 43 severity: SEVERITY_LOG,
michael@0 44 count: 2
michael@0 45 },
michael@0 46 {
michael@0 47 name: "iframe 1 (repeats: 2)",
michael@0 48 text: "iframe 1",
michael@0 49 category: CATEGORY_WEBDEV,
michael@0 50 severity: SEVERITY_LOG,
michael@0 51 repeats: 2
michael@0 52 },
michael@0 53 ];
michael@0 54
michael@0 55 function test()
michael@0 56 {
michael@0 57 expectUncaughtException();
michael@0 58 addTab(TEST_URI);
michael@0 59 browser.addEventListener("load", function onLoad() {
michael@0 60 browser.removeEventListener("load", onLoad, true);
michael@0 61 info("open web console");
michael@0 62 openConsole(null, consoleOpened);
michael@0 63 }, true);
michael@0 64 }
michael@0 65
michael@0 66 function consoleOpened(hud)
michael@0 67 {
michael@0 68 ok(hud, "web console opened");
michael@0 69
michael@0 70 waitForMessages({
michael@0 71 webconsole: hud,
michael@0 72 messages: expectedMessages,
michael@0 73 }).then(() => {
michael@0 74 info("first messages matched");
michael@0 75 waitForMessages({
michael@0 76 webconsole: hud,
michael@0 77 messages: expectedMessagesAny,
michael@0 78 matchCondition: "any",
michael@0 79 }).then(() => {
michael@0 80 closeConsole(null, onWebConsoleClose);
michael@0 81 });
michael@0 82 });
michael@0 83 }
michael@0 84
michael@0 85 function onWebConsoleClose()
michael@0 86 {
michael@0 87 info("web console closed");
michael@0 88 HUDService.toggleBrowserConsole().then(onBrowserConsoleOpen);
michael@0 89 }
michael@0 90
michael@0 91 function onBrowserConsoleOpen(hud)
michael@0 92 {
michael@0 93 ok(hud, "browser console opened");
michael@0 94 waitForMessages({
michael@0 95 webconsole: hud,
michael@0 96 messages: expectedMessages,
michael@0 97 }).then(() => {
michael@0 98 info("first messages matched");
michael@0 99 waitForMessages({
michael@0 100 webconsole: hud,
michael@0 101 messages: expectedMessagesAny,
michael@0 102 matchCondition: "any",
michael@0 103 }).then(() => {
michael@0 104 closeConsole(null, finishTest);
michael@0 105 });
michael@0 106 });
michael@0 107 }

mercurial