Bug 1121558 - Remove message listener after test-success. r=smaug, a=test-only
authorKan-Ru Chen (陳侃如) <kanru@kanru.info>
Fri, 06 Feb 2015 16:12:04 +0800
changeset 243760 8b7f4835bd47
parent 243757 69a8d311ddd6
child 243761 6d2cd80ee4e9
push id4466
push userryanvm@gmail.com
push date2015-02-11 22:00 +0000
treeherdermozilla-beta@78815ed2e606 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, test-only
bugs1121558
milestone36.0
Bug 1121558 - Remove message listener after test-success. r=smaug, a=test-only
dom/browser-element/mochitest/browserElement_Alert.js
--- a/dom/browser-element/mochitest/browserElement_Alert.js
+++ b/dom/browser-element/mochitest/browserElement_Alert.js
@@ -104,17 +104,20 @@ function test3(e) {
       mm.loadFrameScript(script2, /* allowDelayedLoad = */ false);
     });
   }
 
   mm.addMessageListener('test-try-again', onTryAgain);
   numPendingChildTests++;
 
   onTryAgain();
-  waitForPendingTests(function() { test4(); });
+  waitForPendingTests(function() {
+    mm.removeMessageListener('test-try-again', onTryAgain);
+    test4();
+  });
 }
 
 function test4() {
   // Navigate the iframe while an alert is pending.  This shouldn't screw
   // things up.
 
   iframe.addEventListener("mozbrowsershowmodalprompt", test5);
 
@@ -235,17 +238,20 @@ function test6f() {
       mm.loadFrameScript(script2, /* allowDelayedLoad = */ false);
     });
   }
 
   mm.addMessageListener('test-try-again', onTryAgain);
   numPendingChildTests++;
 
   onTryAgain();
-  waitForPendingTests(test6g);
+  waitForPendingTests(function() {
+    mm.removeMessageListener('test-try-again', onTryAgain);
+    test6g();
+  });
 }
 
 function test6g() {
   var e = promptBlockers.pop();
   // Now unblock the iframe and check that the script completed.
   e.detail.unblock();
 
   var script2 = 'data:,\
@@ -264,17 +270,20 @@ function test6g() {
       mm.loadFrameScript(script2, /* allowDelayedLoad = */ false);
     });
   }
 
   mm.addMessageListener('test-try-again', onTryAgain);
   numPendingChildTests++;
 
   onTryAgain();
-  waitForPendingTests(test6h);
+  waitForPendingTests(function() {
+    mm.removeMessageListener('test-try-again', onTryAgain);
+    test6h();
+  });
 }
 
 function test6h() {
   SimpleTest.finish();
 }
 
 var prevNumPendingTests = null;
 function waitForPendingTests(next) {