test_cyclecollector.xhtml (1777B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?> 3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> 4 <!-- 5 https://bugzilla.mozilla.org/show_bug.cgi?id= 6 --> 7 <window title="Mozilla Bug " 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 10 11 <!-- test results are displayed in the html:body --> 12 <body xmlns="http://www.w3.org/1999/xhtml"> 13 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=" 14 target="_blank">Mozilla Bug </a> 15 </body> 16 17 <!-- test code goes here --> 18 <script type="application/javascript"> 19 <![CDATA[ 20 /** Test for Bug */ 21 var obs = Cc["@mozilla.org/observer-service;1"] 22 .getService(Ci.nsIObserverService); 23 var didCall = false; 24 var observer = { 25 QueryInterface: function QueryInterface(aIID) { 26 if (aIID.equals(Ci.nsIObserver) || 27 aIID.equals(Ci.nsISupports)) 28 return this; 29 throw Components.Exception("", Cr.NS_NOINTERFACE); 30 }, 31 observe(subject, topic, data) { 32 obs.removeObserver(observer, "cycle-collector-begin"); 33 observer = null; 34 didCall = true; 35 } 36 }; 37 38 // Start an incremental GC, to make sure that calling ccSlice 39 // when an IGC is running finishes the GC. 40 SpecialPowers.Cu.getJSTestingFunctions().gcslice(1); 41 42 // Make sure that we call the observer even if we're in the middle 43 // of an ICC when we add the observer. See bug 981033. 44 SpecialPowers.finishCC(); 45 SpecialPowers.ccSlice(1); 46 47 obs.addObserver(observer, "cycle-collector-begin"); 48 49 SpecialPowers.DOMWindowUtils.cycleCollect(); 50 51 ok(didCall, "Observer should have been called!"); 52 ]]> 53 </script> 54 </window>