toolkit/profile/test/test_create_profile.xul
author Jeff Walden <jwalden@mit.edu>
Tue, 22 Nov 2011 17:42:57 -0800
changeset 83922 987a82806246dadc9c4562209d2a8a9f7b880f47
parent 75084 67f6f1908b0f4cb8c00d3de763787fdb8fe8eeeb
child 123195 964fe8cb452b24a04957c529de4c43c0adcdd529
permissions -rw-r--r--
Bug 704313 - Implement mozilla/StdInt.h. r=cjones

<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=543854
-->
<window title="Mozilla Bug 543854"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  <script type="application/javascript"
   src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   
    <!-- test results are displayed in the html:body -->
  <body xmlns="http://www.w3.org/1999/xhtml">
  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=543854"
     target="_blank">Mozilla Bug 543854</a>
  </body>

  <!-- test code goes here -->
  <script type="application/javascript">
  <![CDATA[

  /** Test for Bug 543854 **/

  SimpleTest.waitForExplicitFinish();

  const Cc = Components.classes;
  const Ci = Components.interfaces;

  const ASCIIName = "myprofile";
  const UnicodeName = "\u09A0\u09BE\u0995\u09C1\u09B0"; // A Bengali name

  var gProfileService;

  gProfileService = Cc["@mozilla.org/toolkit/profile-service;1"].
    getService(Ci.nsIToolkitProfileService);

  createProfile(ASCIIName);
  createProfile(UnicodeName);
  SimpleTest.finish();

function createProfile(profileName)
{
  var profile = gProfileService.createProfile(null, null, profileName);

  // check that the directory was created
  isnot(profile, null, "Profile " + profileName + " created");

  var profileDir = profile.rootDir;

  ok(profileDir.exists(), "Profile dir created");
  ok(profileDir.isDirectory(), "Profile dir is a directory");

  var profileDirPath = profileDir.path;

  is(profileDirPath.substr(profileDirPath.length - profileName.length),
     profileName, "Profile dir has expected name");

  // clean up the profile
  profile.remove(true);
}

  ]]>
  </script>
</window>