mirror of
https://github.com/rn10950/RetroZilla.git
synced 2024-11-14 11:40:13 +01:00
187 lines
4.8 KiB
Plaintext
187 lines
4.8 KiB
Plaintext
<html>
|
|
<head>
|
|
<script TYPE="text/javascript" SRC="nsIWebNavTestLib.js"></script>
|
|
<script TYPE="text/javascript">
|
|
// This script tests out the methods and attributes in nsIWebNavigation.
|
|
// It uses the nsIWebNavTestLib.js test library.
|
|
var interfaceName = "nsIWebNavigation";
|
|
var testWin = window.open("about:blank");
|
|
// Calls the webNavInit() function to create nsIWebNav object
|
|
var webNav = webNavInit(testWin);
|
|
var goBack = 0;
|
|
var goForward = 0;
|
|
var index = 0;
|
|
var cnt = 0;
|
|
var indexCnt = 0;
|
|
var reloadCnt = 0;
|
|
|
|
var urlList = ["http://www.intel.com",
|
|
"http://www.yahoo.com",
|
|
"http://www.mozilla.org",
|
|
"ftp://ftp.mozilla.org",
|
|
"http://www.mozilla.org/newsbot",
|
|
"http://www.sun.com",
|
|
"http://www.cisco.com"
|
|
];
|
|
|
|
var loadFlagList = [webNav.LOAD_FLAGS_NONE,
|
|
webNav.LOAD_FLAGS_IS_REFRESH,
|
|
webNav.LOAD_FLAGS_IS_LINK,
|
|
webNav.LOAD_FLAGS_BYPASS_HISTORY,
|
|
webNav.LOAD_FLAGS_REPLACE_HISTORY,
|
|
webNav.LOAD_FLAGS_BYPASS_CACHE,
|
|
webNav.LOAD_FLAGS_BYPASS_PROXY,
|
|
webNav.LOAD_FLAGS_BYPASS_CACHE | webNav.LOAD_FLAGS_BYPASS_PROXY,
|
|
webNav.LOAD_FLAGS_CHARSET_CHANGE
|
|
];
|
|
|
|
var urlTotal = urlList.length;
|
|
var loadFlagTotal = loadFlagList.length;
|
|
|
|
function loadURITests()
|
|
{
|
|
var initTime = 10000;
|
|
|
|
if (!testWin) {
|
|
alert("didn't get test window");
|
|
return;
|
|
}
|
|
if (!webNav) {
|
|
alert("didn't get web navigation object");
|
|
return;
|
|
}
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
// Load pages sequentially in the child window
|
|
|
|
testLoadURI(webNav, urlList[cnt++], loadFlagList[0], null, null, null);
|
|
|
|
if (cnt == urlTotal)
|
|
setTimeout("nsIWebNavTests()", 10000);
|
|
else
|
|
setTimeout("loadURITests()", 10000);
|
|
}
|
|
|
|
function nsIWebNavTests()
|
|
{
|
|
// Test cases for nsIWebNavigation
|
|
|
|
dump("Testing nsIWebNavigation interface\n");
|
|
|
|
if (!webNav)
|
|
{
|
|
alert("Unable to get web navigation object");
|
|
return;
|
|
}
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
var getDoc = testDocument(webNav);
|
|
dump("getDoc object = " + getDoc + "\n");
|
|
|
|
var getCurrURI = testCurrentURI(webNav);
|
|
dump("getCurrURI object = " + getCurrURI + "\n");
|
|
dump("The current uri = " + getCurrURI.spec + "\n");
|
|
|
|
/* not implemented yet */
|
|
// var getRefURI = testReferringURI(webNav);
|
|
// dump("getRefURI object = " + getRefURI + "\n");
|
|
|
|
var getsHistory = testSessionHistory(webNav);
|
|
dump("getsHistory object = " + getsHistory + "\n");
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
doWebNavigation(webNav);
|
|
}
|
|
|
|
function doWebNavigation(webNav)
|
|
{
|
|
if (!webNav)
|
|
return;
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
setTimeout("doCanGoBack(webNav)", 10000); // canGoBack()
|
|
}
|
|
|
|
function doCanGoBack(webNav)
|
|
{
|
|
var goBack = testCanGoBack(webNav, 0);
|
|
dump("goBack = " + goBack + "\n");
|
|
setTimeout("doGoBack(webNav)", 10000);
|
|
}
|
|
|
|
function doGoBack(webNav)
|
|
{
|
|
testGoBack(webNav);
|
|
setTimeout("doCanGoForward(webNav)", 10000);
|
|
}
|
|
|
|
function doCanGoForward(webNav)
|
|
{
|
|
var goForward = testCanGoForward(webNav, 0);
|
|
dump("goForward = " + goForward + "\n");
|
|
setTimeout("doGoForward(webNav)", 10000);
|
|
}
|
|
|
|
function doGoForward(webNav)
|
|
{
|
|
testGoForward(webNav);
|
|
indexCnt = 0;
|
|
setTimeout("recurseIndex(webNav, indexCnt)", 10000);
|
|
}
|
|
|
|
function recurseIndex(webNav, indexCnt)
|
|
{
|
|
if (!webNav)
|
|
return;
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
dump("indexCnt = " + indexCnt + "\n");
|
|
if (indexCnt < urlTotal) {
|
|
testGotoIndex(webNav, indexCnt); // gotoIndex()
|
|
setTimeout("recurseIndex(webNav, ++indexCnt)", 10000);
|
|
}
|
|
else {
|
|
reloadCnt = 0;
|
|
setTimeout("recurseReload(webNav, reloadCnt)", 10000);
|
|
}
|
|
}
|
|
|
|
function recurseReload(webNav, reloadCnt)
|
|
{
|
|
if (!webNav)
|
|
return;
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
dump("reloadCnt = " + reloadCnt + "\n");
|
|
if (reloadCnt < loadFlagTotal) {
|
|
testReload(webNav, loadFlagList[reloadCnt]); // reload()
|
|
dump("loadFlag = " + loadFlagList[reloadCnt] + "\n");
|
|
setTimeout("recurseReload(webNav, ++reloadCnt)", 10000);
|
|
}
|
|
else {
|
|
webNav.loadURI("http://www.microsoft.com", loadFlagList[0], null, null, null);
|
|
testStop(webNav, loadFlagList[0]);
|
|
}
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<script TYPE="text/javascript">
|
|
loadURITests();
|
|
</script>
|
|
</body>
|
|
</html>
|