toolkit/components/aboutmemory/tests/test_sqliteMultiReporter.xul

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
michael@0 3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
michael@0 4 <window title="about:memory"
michael@0 5 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 6 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
michael@0 7 <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 8
michael@0 9 <!-- test results are displayed in the html:body -->
michael@0 10 <body xmlns="http://www.w3.org/1999/xhtml"></body>
michael@0 11
michael@0 12 <!-- test code goes here -->
michael@0 13 <script type="application/javascript">
michael@0 14 <![CDATA[
michael@0 15
michael@0 16 // Test for bug 708248, where the SQLite memory multi-reporter was
michael@0 17 // crashing when a DB was closed.
michael@0 18
michael@0 19 // Nb: this test is all JS and so should be done with an xpcshell test,
michael@0 20 // but bug 671753 is preventing the memory-reporter-manager from being
michael@0 21 // accessed from xpcshell.
michael@0 22
michael@0 23 const Cc = Components.classes;
michael@0 24 const Ci = Components.interfaces;
michael@0 25 const Cu = Components.utils;
michael@0 26
michael@0 27 // Make a fake DB file.
michael@0 28 let file = Cc["@mozilla.org/file/directory_service;1"].
michael@0 29 getService(Ci.nsIProperties).
michael@0 30 get("ProfD", Ci.nsIFile);
michael@0 31 file.append("test_sqliteMultiReporter-fake-DB-tmp.sqlite");
michael@0 32
michael@0 33 // Open and close the DB.
michael@0 34 let storage = Cc["@mozilla.org/storage/service;1"].
michael@0 35 getService(Ci.mozIStorageService);
michael@0 36 let db = storage.openDatabase(file);
michael@0 37 db.close();
michael@0 38
michael@0 39 // Invoke all the reporters. The SQLite multi-reporter is among
michael@0 40 // them. It shouldn't crash.
michael@0 41 let mgr = Cc["@mozilla.org/memory-reporter-manager;1"].
michael@0 42 getService(Ci.nsIMemoryReporterManager);
michael@0 43 mgr.getReportsForThisProcess(function(){}, null);
michael@0 44
michael@0 45 // If we haven't crashed, we've passed, but the test harness requires that
michael@0 46 // we explicitly check something.
michael@0 47 ok(true, "didn't crash");
michael@0 48
michael@0 49 ]]>
michael@0 50 </script>
michael@0 51 </window>

mercurial