pjs/embedding/qa/jstests/webNav/nsIWebNavTestCase1.html

253 строки
7.4 KiB
HTML

<html>
<title> nsIAccessible Interface Test Case </title>
<!-- Descrpt: Test nsIAccessible Interface attributes and methods
for HTML ANCHOR Node
Author: depstein@netscape.com
Last Updated:09.18.02.
- ***** 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 Corp.
- Portions created by the Initial Developer are Copyright (C) 1999
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- 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 GPL or the LGPL. 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 ***** -->
<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 = null;
var webNav = null;
var goBack = 0;
var goForward = 0;
var index = 0;
var cnt = 0;
var indexCnt = 0;
var reloadCnt = 0;
var urlList;
var loadFlagList;
var urlTotal;
var loadFlagTotal;
var urlElement;
var flagElement;
var referrer;
var postData;
var headers;
testWin = window.open('about:blank');
setTimeout("loadURITests();", 2000);
function loadURITests()
{
var initTime = 10000;
callNavInit(cnt);
urlList = ["http://www.intel.com",
"http://www.yahoo.com",
"http://www.mozilla.org",
"ftp://ftp.mozilla.org",
"http://www.mozilla.org/newsbot",
"https://www.sun.com",
"http://www.oracle.com"
];
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
];
urlTotal = urlList.length;
loadFlagTotal = loadFlagList.length;
referrer = null;
postData = null;
headers = null;
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], referrer, postData, headers);
if (cnt == urlTotal)
setTimeout("nsIWebNavTests(webNav, urlTotal, loadFlagTotal)", 10000);
else
setTimeout("loadURITests(webNav)", 10000);
}
function callNavInit(cnt)
{
// Calls the webNavInit() function to create nsIWebNav object
if (cnt == 0)
webNav = webNavInit(testWin);
}
function nsIWebNavTests(webNav, urlTotal, loadFlagTotal)
{
// 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, urlTotal, loadFlagTotal);
}
function doWebNavigation(webNav, urlTotal, loadFlagTotal)
{
if (!webNav)
return;
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
setTimeout("doCanGoBack(webNav, urlTotal, loadFlagTotal)", 10000); // canGoBack()
}
function doCanGoBack(webNav, urlTotal, loadFlagTotal)
{
var goBack = testCanGoBack(webNav, 0);
dump("goBack = " + goBack + "\n");
setTimeout("doGoBack(webNav, urlTotal, loadFlagTotal)", 10000);
}
function doGoBack(webNav, urlTotal, loadFlagTotal)
{
testGoBack(webNav);
setTimeout("doCanGoForward(webNav, urlTotal, loadFlagTotal)", 10000);
}
function doCanGoForward(webNav, urlTotal, loadFlagTotal)
{
var goForward = testCanGoForward(webNav, 0);
dump("goForward = " + goForward + "\n");
setTimeout("doGoForward(webNav, urlTotal, loadFlagTotal)", 10000);
}
function doGoForward(webNav, urlTotal, loadFlagTotal)
{
testGoForward(webNav);
indexCnt = 0;
setTimeout("recurseIndex(webNav, indexCnt, urlTotal, loadFlagTotal)", 10000);
}
function recurseIndex(webNav, indexCnt, urlTotal, loadFlagTotal)
{
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, urlTotal, loadFlagTotal)", 10000);
}
else {
reloadCnt = 0;
setTimeout("recurseReload(webNav, reloadCnt, loadFlagTotal)", 10000);
}
}
function recurseReload(webNav, reloadCnt, loadFlagTotal)
{
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, urlTotal, loadFlagTotal)", 10000);
}
else {
webNav.loadURI("http://www.microsoft.com", loadFlagList[0], null, null, null);
testStop(webNav, webNav.STOP_CONTENT);
}
}
</script>
</head>
<body>
</body>
</html>