<html>
<!-- Descrpt: Test nsIAccessible Interface attributes and methods
     for HTML ANCHOR Node
     Author: depstein@netscape.com
     Last Updated:09.18.02.

   - The contents of this file are subject to the Mozilla Public
   - License Version 1.1 (the "License"); you may not use this file
   - except in compliance with the License. You may obtain a copy of
   - the License at http://www.mozilla.org/MPL/
   -
   - Software distributed under the License is distributed on an "AS
   - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
   - implied. See the License for the specific language governing
   - rights and limitations under the License.
   -
   - The Original Code is Mozilla Communicator Test Cases.
   -
   - The Initial Developer of the Original Code is Netscape Communications
   - Corp.  Portions created by Netscape Communications Corp. are
   - Copyright (C) 1999 Netscape Communications Corp.  All
   - Rights Reserved.
   -
   - Contributor(s):
  -->
<head>
<title> nsISHistory Interface Test Case </title>
<script TYPE="text/javascript" SRC="nsISHistoryTestLib.js"></script>
<script TYPE="text/javascript">

var urlList = ["http://www.intel.com",
               "http://www.yahoo.com",
               "http://www.mozilla.org"
                ];
var cnt = 0;
var testWin = null;
var sHistory = null;
var count = 0;
var index = 0;
var maxLength = 100;

testWin = window.open('about:blank', "testWin");
setTimeout("loadPages();", 2000);

function loadPages()
{

  var urlTotal = urlList.length;
  var initTime = 10000;

  callSHistInit(cnt);

  netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

  // Load pages sequentially in the child window

   testWin.location = urlList[cnt++];

   if (cnt == urlTotal)
      setTimeout("sHistoryTests()", 5000);
   else
      setTimeout("loadPages()", 6000);

}

function callSHistInit(cnt)
{
  // Calls the sHistoryInit() function to create sHistory object
  if (cnt == 0)
	 sHistory = sHistoryInit(testWin);
}

function sHistoryTests()
{
  netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");


  // begins testing session history interface;
  if (!sHistory)
  {
    alert("Unable to get session history");
    return;
  }

  alert("Testing nsISHistory interfaces\n");

  count = testHistoryCount(sHistory);	 // GetCount()
  alert("global count: " + count);

  index = testHistoryIndex(sHistory);	 // GetIndex()
  alert ("global index: " + index);

  maxLength = testMaxLength(sHistory);	 // GetMaxLength()
  alert ("global maxLength: " + maxLength);

  // Test GetEntryAtIndex()
	 for(cnt = 0; cnt < count; cnt++) {
	   entry = testGetEntryAtIndex(sHistory, cnt, false);
	   if (entry)
		 alert("GetEntryAtIndex() Valid, cnt =  " + cnt);
	   else
		 alert("GetEntryAtIndex() Invalid, cnt = " + cnt);
	 }   // for

	 // Test the enumerator
	 var simpleEnum = testSimpleEnum(sHistory);	// Get simple enumerator
	 alert("global simpleEnum: " + simpleEnum);
	 if (simpleEnum) {
		var enumCnt = 0;
		while (simpleEnum.hasMoreElements())
		{
			nextObj = simpleEnum.getNext();
			alert("global nextObj: " + nextObj);
			if (!nextObj)
			  continue;
			nextHE = nextObj.QueryInterface(Components.interfaces.nsIHistoryEntry);
			alert("global nextHE: " + nextHE);
			if (!nextHE)
			  continue;
		    testHistoryEntry(nextHE, enumCnt);
		    enumCnt++;
		}  // while
	 }   // if simplenum

}

</script>
</head>
<body>
<script TYPE="text/javascript">
</script>
</body>
</html>