<HTML>
<HEAD>
<TITLE> Testing nsIURI Interface </TITLE>
<!--
Written by Dharma.
Tests last run on 05/22/01.

-->
<SCRIPT TYPE="text/javascript">

function getnsIURIObj()
{
  // get an implementation of nsIURI.
  try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

    // using standard url contractid. later on try with simple uri contractid.

    var nsUriObj = Components.classes["@mozilla.org/network/standard-url;1"].
             createInstance(Components.interfaces.nsIURI);

    //var nsUriObj = Components.classes["@mozilla.org/network/standard-url;1"].
    //         getService(Components.interfaces.nsIURI);
  }
  catch(e) {
    alert("Exception: " + e);
  }
  return nsUriObj;
}

</SCRIPT>

</HEAD>
<BODY>
<SCRIPT TYPE="text/javascript">
var uriObj = getnsIURIObj();
// newuriObj object is used for testing equals method.
var newuriObj = getnsIURIObj();

try {
  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

  // checking attribute spec.
  uriObj.spec = "http://username:password@www.mozilla.org:9090/quality/embed/index.html";
  newuriObj.spec = "http://username:password@www.mozilla.org:9090/quality/embed/index.html";

  /*
  alert(uriObj.spec);
  */

  // checking attribute prepath.
  /*
  alert(uriObj.prePath);
  // setting the prepath is not yet implemented.
  uriObj.prePath="http://username:password@www.yahoo.com";
  alert(uriObj.prePath);
  */

  // checking attribute scheme.
  /*
  alert(uriObj.scheme);
  uriObj.scheme="ftp";
  alert(uriObj.scheme);
  */

  // checking attribute preHost.
  /*
  alert(uriObj.preHost);
  uriObj.preHost = "giveusername:givepassword";
  alert(uriObj.preHost);
  */

  // checking attribute username.
  /*
  alert(uriObj.username);
  uriObj.username = "giveusername";
  alert(uriObj.username);
  */

  // checking attribute password.
  /*
  alert(uriObj.password);
  uriObj.password = "givepassword";
  alert(uriObj.password);
  */

  // checking attribute host.
  /*
  alert(uriObj.host);
  uriObj.host = "www.yahoo.com";
  alert(uriObj.host);
  */

  // checking attribute port.
  /*
  alert(uriObj.port);
  uriObj.port = -1;
  alert(uriObj.port);
  */

  // checking attribute path.

  alert(uriObj.path);
  uriObj.path = "projects/ui/";
  alert(uriObj.path);


  // checking the equals method.
  /*
  var boo = uriObj.equals(newuriObj);
  alert(boo);
  */

  // checking the schemeIs method.
  /*
  var boo = uriObj.schemeIs("ftp");
  alert(boo);
  */

  // checking the clone method.
  /*
  var cloneuriObj = uriObj.clone();
  alert(cloneuriObj.port);
  alert(cloneuriObj.path);
  */

  // checking the resolve method.
  /*
  var absuri = uriObj.resolve("projects/ui/accessibility/");
  alert(absuri);
  */
}
catch(e) {
  alert("Exception: " + e);
}
alert("END");
</SCRIPT>

</BODY>
</HTML>