toolkit/components/aboutmemory/tests/test_aboutmemory6.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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>
     9   <!-- This file tests the saving of GC and CC logs in both concise and
    10        verbose formats. -->
    12   <!-- test results are displayed in the html:body -->
    13   <body xmlns="http://www.w3.org/1999/xhtml"></body>
    15   <iframe id="amFrame"  height="400" src="about:memory"></iframe>
    17   <script type="application/javascript">
    18   <![CDATA[
    19   "use strict";
    21   const Cc = Components.classes;
    22   const Ci = Components.interfaces;
    24   function onFocus() {
    25     let frame = document.getElementById("amFrame");
    26     frame.focus();
    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);
    35       let exists = localFile.exists();
    36       if (exists) {
    37         localFile.remove(/* recursive = */ false);
    38       }
    40       return exists;
    41     }
    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();
    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];
    57       // we expect 2 logs listed
    58       let numOfLogs = logNodes.childNodes.length;
    59       ok(numOfLogs == 2, "two log entries generated")
    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 ", "");
    67       // check that the files actually exist
    68       ok(checkForFileAndRemove(gcLogPath), "GC log file exists");
    69       ok(checkForFileAndRemove(ccLogPath), "CC log file exists");
    70     }
    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");
    78     saveLogs(saveConcise, "concise");
    79     saveLogs(saveVerbose, "verbose");
    81     SimpleTest.finish();
    82   }
    84   SimpleTest.waitForFocus(onFocus);
    85   SimpleTest.waitForExplicitFinish();
    86   ]]>
    87   </script>
    88 </window>

mercurial