Bug 621056 - Prevent the timer to be eaten alive by the GC. r=bz a=tests
authorMounir Lamouri <mounir.lamouri@gmail.com>
Thu, 10 Mar 2011 17:03:39 +0100
changeset 63379 d5122581a0b49c374467451a96d9b32b6303fc24
parent 63378 db05de7b2d3d502bd1e2eaa31ab828eb78d83a1f
child 63380 fc05d053ed0354203f30df9910e4d8419b04d336
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, tests
bugs621056
milestone2.0b13pre
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 621056 - Prevent the timer to be eaten alive by the GC. r=bz a=tests
content/base/test/script-1_bug597345.sjs
--- a/content/base/test/script-1_bug597345.sjs
+++ b/content/base/test/script-1_bug597345.sjs
@@ -1,13 +1,16 @@
+// timer has to be alive so it can't be eaten by the GC.
+var timer;
+
 function handleRequest(request, response)
 {
   response.setHeader("Cache-Control", "no-cache", false);
   response.setHeader("Content-Type", "text/javascript", false);
   // The "stray" open comment at the end of the write is important!
   response.write("document.write(\"<script charset='utf-8' src='script-2_bug597345.js'></script><!--\")");
   response.processAsync();
-  var timer = Components.classes["@mozilla.org/timer;1"]
+  timer = Components.classes["@mozilla.org/timer;1"]
     .createInstance(Components.interfaces.nsITimer);
   timer.initWithCallback(function() {
       response.finish();
     }, 200, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
 }