<?xml version="1.0"?>
<!--
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

/**
 * Removes files and preferences for previous application update tests in case
 * any of them had a fatal error. The test name ensures that it will run after
 * all other tests as long as the test naming uses the same format as the
 * existing tests.
 */
-->

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>

<window title="Application Update test cleanup"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        onload="runTest();">
<script type="application/javascript" 
        src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
        src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
        src="utils.js"/>

<script type="application/javascript">
<![CDATA[

/**
 * If the application update tests left behind any of the files it uses it could
 * be a very bad thing. The purpose of this test is to prevent that from
 * happening.
 */
function runTest() {
  debugDump("entering");

  closeUpdateWindow();

  resetPrefs();
  removeUpdateDirsAndFiles();
  reloadUpdateManagerData();

  let dir = getCurrentProcessDir();
  let file = dir.clone();
  file.append(FILE_UPDATE_ACTIVE);
  ok(!file.exists(), file.path + " should not exist");

  file = dir.clone();
  file.append(FILE_UPDATES_DB);
  ok(!file.exists(), file.path + " should not exist");

  dir.append("updates");
  dir.append("0");

  file = dir.clone();
  file.append(FILE_UPDATE_STATUS);
  ok(!file.exists(), file.path + " should not exist");

  file = dir.clone();
  file.append(FILE_UPDATE_ARCHIVE);
  ok(!file.exists(), file.path + " should not exist");
}

]]>
</script>

<body xmlns="http://www.w3.org/1999/xhtml">
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test"></pre>
</body>
</window>
