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
authorBenjamin Smedberg <benjamin@smedbergs.us>
Tue, 29 Jan 2013 11:02:56 -0500
changeset 130108 783ea16377776e5e538c8ad2492311a7a34d5bcb
parent 130107 507d85ab580785783b54d88fc6e2bb7a8c13dc28
child 130109 5c5b63581fc2d1006e6e5813dcaf8c027c5bfd55
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrcampbell
bugs831248
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
browser/devtools/webconsole/test/browser_webconsole_bug_595934_message_categories.js
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_595934_message_categories.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_595934_message_categories.js
@@ -127,17 +127,18 @@ let TestObserver = {
       info("unexpected message was: " + aSubject.sourceName + ':' + aSubject.lineNumber + '; ' +
                 aSubject.errorMessage);
     }
   }
 };
 
 function consoleOpened(hud) {
   output = hud.outputNode;
-  output.addEventListener("DOMNodeInserted", onDOMNodeInserted, false);
+
+  nodeInsertedListener.observe(output, {childList: true});
   jsterm = hud.jsterm;
 
   Services.console.registerListener(TestObserver);
 
   registerCleanupFunction(testEnd);
 
   executeSoon(testNext);
 }
@@ -145,16 +146,17 @@ function consoleOpened(hud) {
 function testNext() {
   jsterm.clearOutput();
   foundCategory = false;
   foundText = false;
   pageLoaded = false;
   pageError = false;
 
   pos++;
+  info("testNext: #" + pos);
   if (pos < TESTS.length) {
     waitForSuccess({
       timeout: 10000,
       name: "test #" + pos + " successful finish",
       validatorFn: function()
       {
         return foundCategory && foundText && pageLoaded && pageError;
       },
@@ -194,27 +196,36 @@ function testNext() {
   else {
     testEnded = true;
     executeSoon(finishTest);
   }
 }
 
 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);
 
   addTab("data:text/html;charset=utf-8,Web Console test for bug 595934 - message categories coverage.");
   browser.addEventListener("load", function onLoad() {
     browser.removeEventListener("load", onLoad, true);
     openConsole(null, consoleOpened);