Bug 759044 - Cleanup visibility message reciever on test completion. r=jlebar
authorDale Harvey <dale@arandomurl.com>
Mon, 28 May 2012 13:55:48 -0400
changeset 95124 795e5c9bec72890cbbc33e2cf09871b8d5222f54
parent 95123 b82ef4adc4d8b9b3e2a8a65ea21c76530dffb0bd
child 95125 58227b467522bae1e1a98a42234b9d6d0408264d
push id9955
push userjlebar@mozilla.com
push dateMon, 28 May 2012 17:56:08 +0000
treeherdermozilla-inbound@795e5c9bec72 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar
bugs759044
milestone15.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 759044 - Cleanup visibility message reciever on test completion. r=jlebar
dom/tests/mochitest/browser-frame/test_browserFrame10.html
--- a/dom/tests/mochitest/browser-frame/test_browserFrame10.html
+++ b/dom/tests/mochitest/browser-frame/test_browserFrame10.html
@@ -28,16 +28,17 @@ var iframeScript = function() {
   }, false);
 }
 
 function runTest() {
 
   browserFrameHelpers.setEnabledPref(true);
   browserFrameHelpers.addToWhitelist();
 
+  var mm;
   var numEvents = 0;
   var iframe1 = document.createElement('iframe');
   iframe1.mozbrowser = true;
   iframe1.src = 'data:text/html,1';
 
   document.body.appendChild(iframe1);
 
   function recvVisibilityChanged(msg) {
@@ -46,25 +47,26 @@ function runTest() {
       ok(true, 'iframe recieved visibility changed');
       ok(msg.json.hidden === true, 'mozHidden attribute correctly set');
       iframe1.setVisible(false);
       iframe1.setVisible(true);
     } else if (numEvents === 2) {
       ok(msg.json.hidden === false, 'mozHidden attribute correctly set');
       // Allow some time in case we generate too many events
       setTimeout(function() {
+        mm.removeMessageListener('test:visibilitychange', recvVisibilityChanged);
         SimpleTest.finish();
       }, 100);
     } else {
       ok(false, 'Too many mozhidden events');
     }
   }
 
   function iframeLoaded() {
-    var mm = SpecialPowers.getBrowserFrameMessageManager(iframe1);
+    mm = SpecialPowers.getBrowserFrameMessageManager(iframe1);
     mm.addMessageListener('test:visibilitychange', recvVisibilityChanged);
     mm.loadFrameScript('data:,(' + iframeScript.toString() + ')();', false);
     iframe1.setVisible(false);
   }
 
   iframe1.addEventListener('mozbrowserloadend', iframeLoaded);
 }