browser/devtools/webconsole/test/browser_repeated_messages_accuracy.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 /* vim:set ts=2 sw=2 sts=2 et: */
michael@0 2 /*
michael@0 3 * Any copyright is dedicated to the Public Domain.
michael@0 4 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 5 */
michael@0 6
michael@0 7 // Test that makes sure messages are not considered repeated when coming from
michael@0 8 // different lines of code, or from different severities, etc.
michael@0 9 // See bugs 720180 and 800510.
michael@0 10
michael@0 11 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-repeated-messages.html";
michael@0 12
michael@0 13 function test() {
michael@0 14 const PREF = "devtools.webconsole.persistlog";
michael@0 15 Services.prefs.setBoolPref(PREF, true);
michael@0 16 registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
michael@0 17
michael@0 18 addTab(TEST_URI);
michael@0 19 browser.addEventListener("load", function onLoad() {
michael@0 20 browser.removeEventListener("load", onLoad, true);
michael@0 21 openConsole(null, consoleOpened);
michael@0 22 }, true);
michael@0 23 }
michael@0 24
michael@0 25 function consoleOpened(hud) {
michael@0 26 // Check that css warnings are not coalesced if they come from different lines.
michael@0 27 info("waiting for 2 css warnings");
michael@0 28
michael@0 29 waitForMessages({
michael@0 30 webconsole: hud,
michael@0 31 messages: [{
michael@0 32 name: "two css warnings",
michael@0 33 category: CATEGORY_CSS,
michael@0 34 count: 2,
michael@0 35 repeats: 1,
michael@0 36 }],
michael@0 37 }).then(testCSSRepeats.bind(null, hud));
michael@0 38 }
michael@0 39
michael@0 40 function testCSSRepeats(hud) {
michael@0 41 browser.addEventListener("load", function onLoad() {
michael@0 42 browser.removeEventListener("load", onLoad, true);
michael@0 43
michael@0 44 info("wait for repeats after page reload");
michael@0 45
michael@0 46 waitForMessages({
michael@0 47 webconsole: hud,
michael@0 48 messages: [{
michael@0 49 name: "two css warnings, repeated twice",
michael@0 50 category: CATEGORY_CSS,
michael@0 51 repeats: 2,
michael@0 52 count: 2,
michael@0 53 }],
michael@0 54 }).then(testCSSRepeatsAfterReload.bind(null, hud));
michael@0 55 }, true);
michael@0 56 content.location.reload();
michael@0 57 }
michael@0 58
michael@0 59 function testCSSRepeatsAfterReload(hud) {
michael@0 60 hud.jsterm.clearOutput(true);
michael@0 61 content.wrappedJSObject.testConsole();
michael@0 62
michael@0 63 info("wait for repeats with the console API");
michael@0 64
michael@0 65 waitForMessages({
michael@0 66 webconsole: hud,
michael@0 67 messages: [
michael@0 68 {
michael@0 69 name: "console.log 'foo repeat' repeated twice",
michael@0 70 category: CATEGORY_WEBDEV,
michael@0 71 severity: SEVERITY_LOG,
michael@0 72 repeats: 2,
michael@0 73 },
michael@0 74 {
michael@0 75 name: "console.log 'foo repeat' repeated once",
michael@0 76 category: CATEGORY_WEBDEV,
michael@0 77 severity: SEVERITY_LOG,
michael@0 78 repeats: 1,
michael@0 79 },
michael@0 80 {
michael@0 81 name: "console.error 'foo repeat' repeated once",
michael@0 82 category: CATEGORY_WEBDEV,
michael@0 83 severity: SEVERITY_ERROR,
michael@0 84 repeats: 1,
michael@0 85 },
michael@0 86 ],
michael@0 87 }).then(testConsoleRepeats.bind(null, hud));
michael@0 88 }
michael@0 89
michael@0 90 function testConsoleRepeats(hud) {
michael@0 91 hud.jsterm.clearOutput(true);
michael@0 92 hud.jsterm.execute("undefined");
michael@0 93 content.console.log("undefined");
michael@0 94
michael@0 95 info("make sure console API messages are not coalesced with jsterm output");
michael@0 96
michael@0 97 waitForMessages({
michael@0 98 webconsole: hud,
michael@0 99 messages: [
michael@0 100 {
michael@0 101 name: "'undefined' jsterm input message",
michael@0 102 text: "undefined",
michael@0 103 category: CATEGORY_INPUT,
michael@0 104 },
michael@0 105 {
michael@0 106 name: "'undefined' jsterm output message",
michael@0 107 text: "undefined",
michael@0 108 category: CATEGORY_OUTPUT,
michael@0 109 },
michael@0 110 {
michael@0 111 name: "'undefined' console.log message",
michael@0 112 text: "undefined",
michael@0 113 category: CATEGORY_WEBDEV,
michael@0 114 repeats: 1,
michael@0 115 },
michael@0 116 ],
michael@0 117 }).then(finishTest);
michael@0 118 }

mercurial