From fce6172ec0a5b0359e29a5f6b38a08c143c3c2f8 Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Tue, 29 Jan 2013 11:02:56 -0500 Subject: [PATCH] Bug 831248 test fixup for the webconsole tests: a warning about mutation events being deprecated was being delivered into the console listener, confusing the test, r=rcampbell --- ...ebconsole_bug_595934_message_categories.js | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) 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 d3814aaa18f..d1a30d05ede 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 @@ -132,7 +132,8 @@ let TestObserver = { function consoleOpened(hud) { output = hud.outputNode; - output.addEventListener("DOMNodeInserted", onDOMNodeInserted, false); + + nodeInsertedListener.observe(output, {childList: true}); jsterm = hud.jsterm; Services.console.registerListener(TestObserver); @@ -150,6 +151,7 @@ function testNext() { pageError = false; pos++; + info("testNext: #" + pos); if (pos < TESTS.length) { waitForSuccess({ timeout: 10000, @@ -199,17 +201,26 @@ function testNext() { function testEnd() { Services.console.unregisterListener(TestObserver); - output.removeEventListener("DOMNodeInserted", onDOMNodeInserted, false); + nodeInsertedListener.disconnect(); TestObserver = output = jsterm = null; } -function onDOMNodeInserted(aEvent) { - let textContent = output.textContent; - foundText = textContent.indexOf(TESTS[pos].matchString) > -1; - if (foundText) { - ok(foundText, "test #" + pos + ": message found '" + TESTS[pos].matchString + "'"); +var nodeInsertedListener = new MutationObserver(function(mutations) { + if (testEnded) { + return; } -} + + for (var mutation of mutations) { + if (mutation.addedNodes) { + let textContent = output.textContent; + foundText = textContent.indexOf(TESTS[pos].matchString) > -1; + if (foundText) { + ok(foundText, "test #" + pos + ": message found '" + TESTS[pos].matchString + "'"); + } + return; + } + } +}); function test() { requestLongerTimeout(2);