1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/aboutmemory/tests/test_sqliteMultiReporter.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?> 1.6 +<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> 1.7 +<window title="about:memory" 1.8 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.9 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.10 + <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.11 + 1.12 + <!-- test results are displayed in the html:body --> 1.13 + <body xmlns="http://www.w3.org/1999/xhtml"></body> 1.14 + 1.15 + <!-- test code goes here --> 1.16 + <script type="application/javascript"> 1.17 + <![CDATA[ 1.18 + 1.19 + // Test for bug 708248, where the SQLite memory multi-reporter was 1.20 + // crashing when a DB was closed. 1.21 + 1.22 + // Nb: this test is all JS and so should be done with an xpcshell test, 1.23 + // but bug 671753 is preventing the memory-reporter-manager from being 1.24 + // accessed from xpcshell. 1.25 + 1.26 + const Cc = Components.classes; 1.27 + const Ci = Components.interfaces; 1.28 + const Cu = Components.utils; 1.29 + 1.30 + // Make a fake DB file. 1.31 + let file = Cc["@mozilla.org/file/directory_service;1"]. 1.32 + getService(Ci.nsIProperties). 1.33 + get("ProfD", Ci.nsIFile); 1.34 + file.append("test_sqliteMultiReporter-fake-DB-tmp.sqlite"); 1.35 + 1.36 + // Open and close the DB. 1.37 + let storage = Cc["@mozilla.org/storage/service;1"]. 1.38 + getService(Ci.mozIStorageService); 1.39 + let db = storage.openDatabase(file); 1.40 + db.close(); 1.41 + 1.42 + // Invoke all the reporters. The SQLite multi-reporter is among 1.43 + // them. It shouldn't crash. 1.44 + let mgr = Cc["@mozilla.org/memory-reporter-manager;1"]. 1.45 + getService(Ci.nsIMemoryReporterManager); 1.46 + mgr.getReportsForThisProcess(function(){}, null); 1.47 + 1.48 + // If we haven't crashed, we've passed, but the test harness requires that 1.49 + // we explicitly check something. 1.50 + ok(true, "didn't crash"); 1.51 + 1.52 + ]]> 1.53 + </script> 1.54 +</window>