|
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 <window title="about:memory" |
|
5 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
6 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
|
7 <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
8 |
|
9 <!-- This file tests the saving of GC and CC logs in both concise and |
|
10 verbose formats. --> |
|
11 |
|
12 <!-- test results are displayed in the html:body --> |
|
13 <body xmlns="http://www.w3.org/1999/xhtml"></body> |
|
14 |
|
15 <iframe id="amFrame" height="400" src="about:memory"></iframe> |
|
16 |
|
17 <script type="application/javascript"> |
|
18 <![CDATA[ |
|
19 "use strict"; |
|
20 |
|
21 const Cc = Components.classes; |
|
22 const Ci = Components.interfaces; |
|
23 |
|
24 function onFocus() { |
|
25 let frame = document.getElementById("amFrame"); |
|
26 frame.focus(); |
|
27 |
|
28 // Checks that a file exists on the local file system and removes it if it |
|
29 // is present. |
|
30 function checkForFileAndRemove(aFilename) { |
|
31 let localFile = Cc["@mozilla.org/file/local;1"] |
|
32 .createInstance(Ci.nsILocalFile); |
|
33 localFile.initWithPath(aFilename); |
|
34 |
|
35 let exists = localFile.exists(); |
|
36 if (exists) { |
|
37 localFile.remove(/* recursive = */ false); |
|
38 } |
|
39 |
|
40 return exists; |
|
41 } |
|
42 |
|
43 // Given a save log button, triggers the action and checks if both CC & GC |
|
44 // logs were written to disk. |
|
45 function saveLogs(aLogButton, aCCLogType) |
|
46 { |
|
47 // trigger the log saving |
|
48 aLogButton.click(); |
|
49 |
|
50 // mainDiv |
|
51 // |-> section |
|
52 // | -> div gc log path |
|
53 // | -> div cc log path |
|
54 let mainDiv = frame.contentWindow.document.getElementById("mainDiv"); |
|
55 let logNodes = mainDiv.childNodes[0]; |
|
56 |
|
57 // we expect 2 logs listed |
|
58 let numOfLogs = logNodes.childNodes.length; |
|
59 ok(numOfLogs == 2, "two log entries generated") |
|
60 |
|
61 // grab the path portion of the text |
|
62 let gcLogPath = logNodes.childNodes[0].textContent |
|
63 .replace("Saved GC log to ", ""); |
|
64 let ccLogPath = logNodes.childNodes[1].textContent |
|
65 .replace("Saved " + aCCLogType + " CC log to ", ""); |
|
66 |
|
67 // check that the files actually exist |
|
68 ok(checkForFileAndRemove(gcLogPath), "GC log file exists"); |
|
69 ok(checkForFileAndRemove(ccLogPath), "CC log file exists"); |
|
70 } |
|
71 |
|
72 // get the log buttons to test |
|
73 let saveConcise = frame.contentWindow.document |
|
74 .getElementById("saveLogsConcise"); |
|
75 let saveVerbose = frame.contentWindow.document |
|
76 .getElementById("saveLogsVerbose"); |
|
77 |
|
78 saveLogs(saveConcise, "concise"); |
|
79 saveLogs(saveVerbose, "verbose"); |
|
80 |
|
81 SimpleTest.finish(); |
|
82 } |
|
83 |
|
84 SimpleTest.waitForFocus(onFocus); |
|
85 SimpleTest.waitForExplicitFinish(); |
|
86 ]]> |
|
87 </script> |
|
88 </window> |