toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<!--
     1.6 +/* Any copyright is dedicated to the Public Domain.
     1.7 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.8 + */
     1.9 +
    1.10 +/**
    1.11 + * Removes files and preferences for previous application update tests in case
    1.12 + * any of them had a fatal error. The test name ensures that it will run after
    1.13 + * all other tests as long as the test naming uses the same format as the
    1.14 + * existing tests.
    1.15 + */
    1.16 +-->
    1.17 +
    1.18 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
    1.19 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
    1.20 +
    1.21 +<window title="Application Update test cleanup"
    1.22 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.23 +        onload="runTest();">
    1.24 +<script type="application/javascript"
    1.25 +        src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.26 +<script type="application/javascript"
    1.27 +        src="utils.js"/>
    1.28 +
    1.29 +<script type="application/javascript">
    1.30 +<![CDATA[
    1.31 +
    1.32 +/**
    1.33 + * If the application update tests left behind any of the files it uses it could
    1.34 + * be a very bad thing. The purpose of this test is to prevent that from
    1.35 + * happening.
    1.36 + */
    1.37 +function runTest() {
    1.38 +  debugDump("entering");
    1.39 +
    1.40 +  SimpleTest.waitForExplicitFinish();
    1.41 +
    1.42 +  closeUpdateWindow();
    1.43 +
    1.44 +  resetPrefs();
    1.45 +  resetFiles();
    1.46 +  removeUpdateDirsAndFiles();
    1.47 +  reloadUpdateManagerData();
    1.48 +
    1.49 +  let file = getUpdatesXMLFile(true);
    1.50 +  ok(!file.exists(), file.path + " should not exist");
    1.51 +
    1.52 +  file = getUpdatesXMLFile(false);
    1.53 +  ok(!file.exists(), file.path + " should not exist");
    1.54 +
    1.55 +  let dir = getUpdatesDir();
    1.56 +
    1.57 +  file = dir.clone();
    1.58 +  file.append(FILE_UPDATE_STATUS);
    1.59 +  ok(!file.exists(), file.path + " should not exist");
    1.60 +
    1.61 +  file = dir.clone();
    1.62 +  file.append(FILE_UPDATE_ARCHIVE);
    1.63 +  ok(!file.exists(), file.path + " should not exist");
    1.64 +
    1.65 +  let addonPrepDir = Services.dirsvc.get(NS_APP_USER_PROFILE_50_DIR,
    1.66 +                                         AUS_Ci.nsILocalFile);
    1.67 +  addonPrepDir.append(ADDON_PREP_DIR);
    1.68 +  // Not being able to remove the directory used to create the test add-ons
    1.69 +  // will not adversely affect subsequent tests so wrap it in a try lock and
    1.70 +  // don't test whether its removal was successful.
    1.71 +  try {
    1.72 +    removeDirRecursive(addonPrepDir);
    1.73 +  }
    1.74 +  catch (e) {
    1.75 +    dump("Unable to remove directory\n" +
    1.76 +         "path: " + addonPrepDir.path + "\n" +
    1.77 +         "Exception: " + e + "\n");
    1.78 +  }
    1.79 +
    1.80 +  resetAddons(SimpleTest.finish);
    1.81 +}
    1.82 +
    1.83 +]]>
    1.84 +</script>
    1.85 +
    1.86 +<body xmlns="http://www.w3.org/1999/xhtml">
    1.87 +  <p id="display"></p>
    1.88 +  <div id="content" style="display: none"></div>
    1.89 +  <pre id="test"></pre>
    1.90 +</body>
    1.91 +</window>

mercurial