From 68f2df112dccb7a80cd139aeeeab88eccedf10e1 Mon Sep 17 00:00:00 2001 From: Mihai Sucan Date: Wed, 26 Jun 2013 15:03:23 +0300 Subject: [PATCH] Bug 886199 - Fix for intermittent browser_webconsole_bug_644419_log_limits.js | Timed out while waiting for: 10 console.log messages displayed and one pruned, and several more; r=me --- ...wser_webconsole_bug_618311_close_panels.js | 17 +- ...rowser_webconsole_bug_644419_log_limits.js | 205 ++++++++---------- ...le_messages_inserts_newlines_in_between.js | 22 +- ...console_live_filtering_of_message_types.js | 23 +- ...onsole_live_filtering_on_search_strings.js | 19 +- 5 files changed, 137 insertions(+), 149 deletions(-) diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_618311_close_panels.js b/browser/devtools/webconsole/test/browser_webconsole_bug_618311_close_panels.js index 69ff2ad1e190..b1bd90ffe005 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_bug_618311_close_panels.js +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_618311_close_panels.js @@ -13,15 +13,14 @@ function test() { openConsole(null, function(hud) { content.location.reload(); - waitForSuccess({ - name: "network message displayed", - validatorFn: function() - { - return hud.outputNode.querySelector(".webconsole-msg-network"); - }, - successFn: performTest, - failureFn: finishTest, - }); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "test-console.html", + category: CATEGORY_NETWORK, + severity: SEVERITY_LOG, + }], + }).then(performTest); }); }, true); } diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_644419_log_limits.js b/browser/devtools/webconsole/test/browser_webconsole_bug_644419_log_limits.js index cf3d2e3010e3..d72a6161177e 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_bug_644419_log_limits.js +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_644419_log_limits.js @@ -10,7 +10,7 @@ const TEST_URI = "http://example.com/browser/browser/devtools/" + "webconsole/test/test-bug-644419-log-limits.html"; -var gOldPref; +let hud, outputNode; function test() { addTab("data:text/html;charset=utf-8,Web Console test for bug 644419: Console should " + @@ -34,19 +34,17 @@ function onLoad(aEvent) { function testWebDevLimits(aEvent) { browser.removeEventListener(aEvent.type, testWebDevLimits, true); - gOldPref = Services.prefs.getIntPref("devtools.hud.loglimit.console"); Services.prefs.setIntPref("devtools.hud.loglimit.console", 10); // Find the sentinel entry. - waitForSuccess({ - name: "bar is not defined", - validatorFn: function() - { - return outputNode.textContent.indexOf("bar is not defined") > -1; - }, - successFn: testWebDevLimits2, - failureFn: testWebDevLimits2, - }); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "bar is not defined", + category: CATEGORY_JS, + severity: SEVERITY_ERROR, + }], + }).then(testWebDevLimits2); } function testWebDevLimits2() { @@ -55,44 +53,39 @@ function testWebDevLimits2() { content.console.log("test message " + i); } - waitForSuccess({ - name: "10 console.log messages displayed and one pruned", - validatorFn: function() - { - let message0 = outputNode.textContent.indexOf("test message 0"); - let message10 = outputNode.textContent.indexOf("test message 10"); - return message0 == -1 && message10 > -1; - }, - successFn: function() - { - findLogEntry("test message 1"); - // Check if the sentinel entry is still there. - findLogEntry("bar is not defined"); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "test message 10", + category: CATEGORY_WEBDEV, + severity: SEVERITY_LOG, + }], + }).then(() => { + testLogEntry(outputNode, "test message 0", "first message is pruned", false, true); + findLogEntry("test message 1"); + // Check if the sentinel entry is still there. + findLogEntry("bar is not defined"); - Services.prefs.setIntPref("devtools.hud.loglimit.console", gOldPref); - testJsLimits(); - }, - failureFn: testJsLimits, + Services.prefs.clearUserPref("devtools.hud.loglimit.console"); + testJsLimits(); }); } function testJsLimits() { - gOldPref = Services.prefs.getIntPref("devtools.hud.loglimit.exception"); Services.prefs.setIntPref("devtools.hud.loglimit.exception", 10); hud.jsterm.clearOutput(); content.console.log("testing JS limits"); // Find the sentinel entry. - waitForSuccess({ - name: "console.log 'testing JS limits'", - validatorFn: function() - { - return outputNode.textContent.indexOf("testing JS limits") > -1; - }, - successFn: testJsLimits2, - failureFn: testNetLimits, - }); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "testing JS limits", + category: CATEGORY_WEBDEV, + severity: SEVERITY_LOG, + }], + }).then(testJsLimits2); } function testJsLimits2() { @@ -105,49 +98,44 @@ function testJsLimits2() { head.insertBefore(script, head.firstChild); } - waitForSuccess({ - name: "10 JS errors shown", - validatorFn: function() - { - return outputNode.textContent.indexOf("fubar10 is not defined") > -1; - }, - successFn: function() - { - testLogEntry(outputNode, "fubar0 is not defined", "first message is pruned", false, true); - findLogEntry("fubar1 is not defined"); - // Check if the sentinel entry is still there. - findLogEntry("testing JS limits"); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "fubar10 is not defined", + category: CATEGORY_JS, + severity: SEVERITY_ERROR, + }], + }).then(() => { + testLogEntry(outputNode, "fubar0 is not defined", "first message is pruned", false, true); + findLogEntry("fubar1 is not defined"); + // Check if the sentinel entry is still there. + findLogEntry("testing JS limits"); - Services.prefs.setIntPref("devtools.hud.loglimit.exception", gOldPref); - testNetLimits(); - }, - failureFn: testNetLimits, + Services.prefs.clearUserPref("devtools.hud.loglimit.exception"); + testNetLimits(); }); } var gCounter, gImage; function testNetLimits() { - gOldPref = Services.prefs.getIntPref("devtools.hud.loglimit.network"); Services.prefs.setIntPref("devtools.hud.loglimit.network", 10); hud.jsterm.clearOutput(); content.console.log("testing Net limits"); // Find the sentinel entry. - waitForSuccess({ - name: "console.log 'testing Net limits'", - validatorFn: function() - { - return outputNode.textContent.indexOf("testing Net limits") > -1; - }, - successFn: function() - { - // Fill the log with network messages. - gCounter = 0; - loadImage(); - }, - failureFn: testCssLimits, + waitForMessages({ + webconsole: hud, + messages: [{ + text: "testing Net limits", + category: CATEGORY_WEBDEV, + severity: SEVERITY_LOG, + }], + }).then(() => { + // Fill the log with network messages. + gCounter = 0; + loadImage(); }); } @@ -165,44 +153,39 @@ function loadImage() { is(gCounter, 11, "loaded 11 files"); - waitForSuccess({ - name: "loaded 11 files, one message pruned", - validatorFn: function() - { - let message0 = outputNode.querySelector('*[value*="test-image.png?_fubar=0"]'); - let message10 = outputNode.querySelector('*[value*="test-image.png?_fubar=10"]'); - return !message0 && message10; - }, - successFn: function() - { - findLogEntry("test-image.png?_fubar=1"); - // Check if the sentinel entry is still there. - findLogEntry("testing Net limits"); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "test-image.png?_fubar=10", + category: CATEGORY_NETWORK, + severity: SEVERITY_LOG, + }], + }).then(() => { + testLogEntry(outputNode, "test-image.png?_fubar=0", "first message is pruned", false, true); + findLogEntry("test-image.png?_fubar=1"); + // Check if the sentinel entry is still there. + findLogEntry("testing Net limits"); - Services.prefs.setIntPref("devtools.hud.loglimit.network", gOldPref); - testCssLimits(); - }, - failureFn: testCssLimits, + Services.prefs.clearUserPref("devtools.hud.loglimit.network"); + testCssLimits(); }); } function testCssLimits() { - gOldPref = Services.prefs.getIntPref("devtools.hud.loglimit.cssparser"); Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", 10); hud.jsterm.clearOutput(); content.console.log("testing CSS limits"); // Find the sentinel entry. - waitForSuccess({ - name: "console.log 'testing CSS limits'", - validatorFn: function() - { - return outputNode.textContent.indexOf("testing CSS limits") > -1; - }, - successFn: testCssLimits2, - failureFn: finishTest, - }); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "testing CSS limits", + category: CATEGORY_WEBDEV, + severity: SEVERITY_LOG, + }], + }).then(testCssLimits2); } function testCssLimits2() { @@ -214,23 +197,21 @@ function testCssLimits2() { body.insertBefore(div, body.firstChild); } - waitForSuccess({ - name: "10 CSS errors shown", - validatorFn: function() - { - return outputNode.textContent.indexOf("-moz-foobar10") > -1; - }, - successFn: function() - { - testLogEntry(outputNode, "Unknown property '-moz-foobar0'", - "first message is pruned", false, true); - findLogEntry("Unknown property '-moz-foobar1'"); - // Check if the sentinel entry is still there. - findLogEntry("testing CSS limits"); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "-moz-foobar10", + category: CATEGORY_CSS, + severity: SEVERITY_WARNING, + }], + }).then(() => { + testLogEntry(outputNode, "Unknown property '-moz-foobar0'", + "first message is pruned", false, true); + findLogEntry("Unknown property '-moz-foobar1'"); + // Check if the sentinel entry is still there. + findLogEntry("testing CSS limits"); - Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", gOldPref); - finishTest(); - }, - failureFn: finishTest, + Services.prefs.clearUserPref("devtools.hud.loglimit.cssparser"); + finishTest(); }); } diff --git a/browser/devtools/webconsole/test/browser_webconsole_copying_multiple_messages_inserts_newlines_in_between.js b/browser/devtools/webconsole/test/browser_webconsole_copying_multiple_messages_inserts_newlines_in_between.js index 33ad67819a7a..85f2ce847609 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_copying_multiple_messages_inserts_newlines_in_between.js +++ b/browser/devtools/webconsole/test/browser_webconsole_copying_multiple_messages_inserts_newlines_in_between.js @@ -12,6 +12,8 @@ const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 586142"; +let hud; + function test() { addTab(TEST_URI); @@ -31,20 +33,22 @@ function testNewlines(aHud) { content.console.log("Hello world #" + i); } - waitForSuccess({ - name: "20 console.log messages displayed", - validatorFn: function() - { - return hud.outputNode.itemCount == 20; - }, - successFn: testClipboard, - failureFn: finishTest, - }); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "Hello world #19", + category: CATEGORY_WEBDEV, + severity: SEVERITY_LOG, + }], + }).then(testClipboard); } function testClipboard() { let outputNode = hud.outputNode; + info("messages in output: " + outputNode.itemCount); + ok(outputNode.itemCount >= 20, "expected number of messages"); + outputNode.selectAll(); outputNode.focus(); diff --git a/browser/devtools/webconsole/test/browser_webconsole_live_filtering_of_message_types.js b/browser/devtools/webconsole/test/browser_webconsole_live_filtering_of_message_types.js index 9e4351c7784d..eaba9f1e57c7 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_live_filtering_of_message_types.js +++ b/browser/devtools/webconsole/test/browser_webconsole_live_filtering_of_message_types.js @@ -7,6 +7,8 @@ const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; +let hud; + function test() { addTab(TEST_URI); browser.addEventListener("load", function onLoad() { @@ -22,21 +24,22 @@ function consoleOpened(aHud) { let console = content.console; for (let i = 0; i < 50; i++) { - console.log("http://www.example.com/" + i); + console.log("foobarz #" + i); } - waitForSuccess({ - name: "50 console.log messages displayed", - validatorFn: function() - { - return hud.outputNode.itemCount == 50; - }, - successFn: testLiveFilteringOfMessageTypes, - failureFn: finishTest, - }); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "foobarz #49", + category: CATEGORY_WEBDEV, + severity: SEVERITY_LOG, + }], + }).then(testLiveFilteringOfMessageTypes); } function testLiveFilteringOfMessageTypes() { + is(hud.outputNode.itemCount, 50, "number of messages"); + hud.setFilterState("log", false); is(countMessageNodes(), 0, "the log nodes are hidden when the " + "corresponding filter is switched off"); diff --git a/browser/devtools/webconsole/test/browser_webconsole_live_filtering_on_search_strings.js b/browser/devtools/webconsole/test/browser_webconsole_live_filtering_on_search_strings.js index b0ecf2a89183..e66e66fe3222 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_live_filtering_on_search_strings.js +++ b/browser/devtools/webconsole/test/browser_webconsole_live_filtering_on_search_strings.js @@ -26,18 +26,19 @@ function consoleOpened(aHud) { console.log("http://www.example.com/ " + i); } - waitForSuccess({ - name: "50 console.log messages displayed", - validatorFn: function() - { - return hud.outputNode.itemCount == 50; - }, - successFn: testLiveFilteringOnSearchStrings, - failureFn: finishTest, - }); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "http://www.example.com/ 49", + category: CATEGORY_WEBDEV, + severity: SEVERITY_LOG, + }], + }).then(testLiveFilteringOnSearchStrings); } function testLiveFilteringOnSearchStrings() { + is(hud.outputNode.itemCount, 50, "number of messages"); + setStringFilter("http"); isnot(countMessageNodes(), 0, "the log nodes are not hidden when the " + "search string is set to \"http\"");