Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html lang="en"> |
michael@0 | 3 | <head> |
michael@0 | 4 | <meta charset="utf8"> |
michael@0 | 5 | <title>Test for nsIConsoleMessages</title> |
michael@0 | 6 | <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 7 | <script type="text/javascript;version=1.8" src="common.js"></script> |
michael@0 | 8 | <!-- Any copyright is dedicated to the Public Domain. |
michael@0 | 9 | - http://creativecommons.org/publicdomain/zero/1.0/ --> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <p>Make sure that nsIConsoleMessages are logged. See bug 859756.</p> |
michael@0 | 13 | |
michael@0 | 14 | <script class="testbody" type="text/javascript;version=1.8"> |
michael@0 | 15 | "use strict"; |
michael@0 | 16 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 17 | |
michael@0 | 18 | let expectedMessages = []; |
michael@0 | 19 | |
michael@0 | 20 | function startTest() |
michael@0 | 21 | { |
michael@0 | 22 | removeEventListener("load", startTest); |
michael@0 | 23 | attachConsole(["PageError"], onAttach); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | function onAttach(aState, aResponse) |
michael@0 | 27 | { |
michael@0 | 28 | onLogMessage = onLogMessage.bind(null, aState); |
michael@0 | 29 | aState.dbgClient.addListener("logMessage", onLogMessage); |
michael@0 | 30 | |
michael@0 | 31 | expectedMessages = [{ |
michael@0 | 32 | message: "hello world! bug859756", |
michael@0 | 33 | timeStamp: /^\d+$/, |
michael@0 | 34 | }]; |
michael@0 | 35 | |
michael@0 | 36 | Services.console.logStringMessage("hello world! bug859756"); |
michael@0 | 37 | |
michael@0 | 38 | info("waiting for messages"); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | let receivedMessages = []; |
michael@0 | 42 | |
michael@0 | 43 | function onLogMessage(aState, aType, aPacket) |
michael@0 | 44 | { |
michael@0 | 45 | is(aPacket.from, aState.actor, "packet actor"); |
michael@0 | 46 | info("received message: " + aPacket.message); |
michael@0 | 47 | |
michael@0 | 48 | let found = false; |
michael@0 | 49 | for (let expected of expectedMessages) { |
michael@0 | 50 | if (expected.message == aPacket.message) { |
michael@0 | 51 | found = true; |
michael@0 | 52 | break; |
michael@0 | 53 | } |
michael@0 | 54 | } |
michael@0 | 55 | if (!found) { |
michael@0 | 56 | return; |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | receivedMessages.push(aPacket); |
michael@0 | 60 | if (receivedMessages.length != expectedMessages.length) { |
michael@0 | 61 | return; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | aState.dbgClient.removeListener("logMessage", onLogMessage); |
michael@0 | 65 | |
michael@0 | 66 | checkObject(receivedMessages, expectedMessages); |
michael@0 | 67 | |
michael@0 | 68 | closeDebugger(aState, () => SimpleTest.finish()); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | addEventListener("load", startTest); |
michael@0 | 72 | </script> |
michael@0 | 73 | </body> |
michael@0 | 74 | </html> |