Bug 932898 - Fix leaks in DOM tests; r=smaug CLOSED TREE
authorTim Taubert <ttaubert@mozilla.com>
Thu, 31 Oct 2013 02:30:00 +0000
changeset 152839 acd7840da834
parent 152838 494d0cca0cb0
child 152840 0057a1758c79
push id35632
push useremorley@mozilla.com
push dateThu, 31 Oct 2013 12:21:20 +0000
treeherdermozilla-inbound@acd7840da834 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs932898
milestone28.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 932898 - Fix leaks in DOM tests; r=smaug CLOSED TREE
dom/indexedDB/test/browser_bug839193.js
dom/tests/browser/browser_xhr_sandbox.js
--- a/dom/indexedDB/test/browser_bug839193.js
+++ b/dom/indexedDB/test/browser_bug839193.js
@@ -7,30 +7,30 @@ let gBugWindow = null;
 let gIterations = 5;
 
 function onLoad() {
   gBugWindow.close();
 }
 
 function onUnload() {
   if (!gIterations) {
+    gBugWindow = null;
+    Services.obs.removeObserver(onLoad, "bug839193-loaded");
+    Services.obs.removeObserver(onUnload, "bug839193-unloaded");
+
     window.focus();
     finish();
   } else {
     gBugWindow = window.openDialog(gTestRoot + "bug839193.xul");
     gIterations--;
   }
 }
 
 // This test is about leaks, which are handled by the test harness, so
 // there are no actual checks here. Whether or not this test passes or fails
 // will be apparent by the checks the harness performs.
 function test() {
   waitForExplicitFinish();
-  Components.classes["@mozilla.org/observer-service;1"]
-            .getService(Components.interfaces.nsIObserverService)
-            .addObserver(onLoad, "bug839193-loaded", false);
-  Components.classes["@mozilla.org/observer-service;1"]
-            .getService(Components.interfaces.nsIObserverService)
-            .addObserver(onUnload, "bug839193-unloaded", false);
+  Services.obs.addObserver(onLoad, "bug839193-loaded", false);
+  Services.obs.addObserver(onUnload, "bug839193-unloaded", false);
 
   gBugWindow = window.openDialog(gTestRoot + "bug839193.xul");
 }
--- a/dom/tests/browser/browser_xhr_sandbox.js
+++ b/dom/tests/browser/browser_xhr_sandbox.js
@@ -29,16 +29,17 @@ function test() {
   let frame = doc.createElement("iframe");
   frame.setAttribute("type", "content");
   frame.setAttribute("src", "http://mochi.test:8888/browser/dom/tests/browser/browser_xhr_sandbox.js");
 
   frame.addEventListener("load", function () {
     let workerWindow = frame.contentWindow;
     workerWindow.addEventListener("message", function(evt) {
       is(evt.data.result, "ok", "check the sandbox code was happy");
+      frame.remove();
       finish();
     }, true);
     let sandbox = new Cu.Sandbox(workerWindow);
     // inject some functions from the window into the sandbox.
     // postMessage so the async code in the sandbox can report a result.
     sandbox.importFunction(workerWindow.postMessage.bind(workerWindow), "postMessage");
     sandbox.importFunction(workerWindow.XMLHttpRequest, "XMLHttpRequest");
     Cu.evalInSandbox(sandboxCode, sandbox, "1.8");