diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_595934_message_categories.js b/browser/devtools/webconsole/test/browser_webconsole_bug_595934_message_categories.js index e8d62d319e7..4b5c073b1b1 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_bug_595934_message_categories.js +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_595934_message_categories.js @@ -40,68 +40,69 @@ const TESTS = [ }, }, { // #5 + file: "test-bug-595934-workers.html", + category: "Web Worker", + matchString: "fooBarWorker", + expectError: true, + }, + { // #6 file: "test-bug-595934-malformedxml.xhtml", category: "malformed-xml", matchString: "no element found", }, - { // #6 + { // #7 file: "test-bug-595934-svg.xhtml", category: "SVG", matchString: "fooBarSVG", }, - { // #7 + { // #8 file: "test-bug-595934-dom-html-external.html", category: "DOM:HTML", matchString: "document.all", }, - { // #8 + { // #9 file: "test-bug-595934-dom-events-external2.html", category: "DOM Events", matchString: "preventBubble()", }, - { // #9 + { // #10 file: "test-bug-595934-canvas.html", category: "Canvas", matchString: "strokeStyle", }, - { // #10 + { // #11 file: "test-bug-595934-css-parser.html", category: "CSS Parser", matchString: "foobarCssParser", }, - { // #11 + { // #12 file: "test-bug-595934-malformedxml-external.html", category: "malformed-xml", matchString: "", }, - { // #12 + { // #14 file: "test-bug-595934-empty-getelementbyid.html", category: "DOM", matchString: "getElementById", }, - { // #13 + { // #15 file: "test-bug-595934-canvas-css.html", category: "CSS Parser", matchString: "foobarCanvasCssParser", }, - { // #14 + { // #16 file: "test-bug-595934-image.html", category: "Image", matchString: "corrupt", }, - // TODO: disabled due to Bug 760837 - intermittent failures. - //{ // #15 - // file: "test-bug-595934-workers.html", - // category: "Web Worker", - // matchString: "fooBarWorker", - // expectError: true, - //}, ]; let pos = -1; let foundCategory = false; let foundText = false; +let pageLoaded = false; +let pageError = false; let output = null; let jsterm = null; let testEnded = false; @@ -120,15 +121,11 @@ let TestObserver = { if (aSubject.category == TESTS[pos].category) { foundCategory = true; - if (foundText) { - executeSoon(testNext); - } } else { ok(false, aSubject.sourceName + ':' + aSubject.lineNumber + '; ' + aSubject.errorMessage); testEnded = true; - executeSoon(finishTest); } } }; @@ -149,23 +146,47 @@ function testNext() { jsterm.clearOutput(); foundCategory = false; foundText = false; + pageLoaded = false; + pageError = false; pos++; if (pos < TESTS.length) { + waitForSuccess({ + name: "test #" + pos + " succesful finish", + validatorFn: function() + { + return foundCategory && foundText && pageLoaded && pageError; + }, + successFn: testNext, + failureFn: function() { + info("foundCategory " + foundCategory + " foundText " + foundText + + " pageLoaded " + pageLoaded + " pageError " + pageError); + finishTest(); + }, + }); + let test = TESTS[pos]; let testLocation = TESTS_PATH + test.file; - if (test.onload) { - browser.addEventListener("load", function onLoad(aEvent) { - if (content.location.href == testLocation) { - browser.removeEventListener(aEvent.type, onLoad, true); - test.onload(aEvent); - } - }, true); - } + browser.addEventListener("load", function onLoad(aEvent) { + if (content.location.href != testLocation) { + return; + } + browser.removeEventListener(aEvent.type, onLoad, true); - if (test.expectError) { - expectUncaughtException(); - } + pageLoaded = true; + test.onload && test.onload(aEvent); + + if (test.expectError) { + content.addEventListener("error", function _onError() { + content.removeEventListener("error", _onError); + pageError = true; + }); + expectUncaughtException(); + } + else { + pageError = true; + } + }, true); content.location = testLocation; } @@ -187,10 +208,6 @@ function onDOMNodeInserted(aEvent) { if (foundText) { ok(foundText, "test #" + pos + ": message found '" + TESTS[pos].matchString + "'"); } - - if (foundCategory) { - executeSoon(testNext); - } } function test() {