RetroZilla/embedding/qa/jstests/sHistory/NsISHistoryTestCase1.txt
2015-10-20 23:03:22 -04:00

148 lines
4.4 KiB
Plaintext

<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- 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 Corporation.
- Portions created by the Initial Developer are Copyright (C) 1999
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- depstein@netscape.com (original author)
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<html>
<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>