2001-09-25 22:58:40 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2001-09-22 00:49:38 +00:00
|
|
|
*
|
2001-09-25 22:58:40 +00:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
2001-09-22 00:49:38 +00:00
|
|
|
*
|
2001-09-25 22:58:40 +00:00
|
|
|
* 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.
|
2001-09-22 00:49:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-25 22:58:40 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-09-22 00:49:38 +00:00
|
|
|
*
|
2001-09-25 22:58:40 +00:00
|
|
|
* Contributor(s):
|
2001-09-22 00:49:38 +00:00
|
|
|
* David Epstein <depstein@netscape.com>
|
|
|
|
* Ashish Bhatt <ashishbhatt@netscape.com>
|
2001-09-25 22:58:40 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-09-22 00:49:38 +00:00
|
|
|
|
|
|
|
// File Overview....
|
|
|
|
//
|
|
|
|
// Test cases for the nsiWebNavigation Interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "testembed.h"
|
|
|
|
#include "qautils.h"
|
2001-11-26 21:47:06 +00:00
|
|
|
#include "nsiwebnav.h"
|
2002-09-28 01:41:25 +00:00
|
|
|
#include "UrlDialog.h"
|
2001-09-22 00:49:38 +00:00
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
#define new DEBUG_NEW
|
|
|
|
#undef THIS_FILE
|
|
|
|
static char THIS_FILE[] = __FILE__;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CNsIWebNav
|
|
|
|
|
2001-11-26 21:47:06 +00:00
|
|
|
CNsIWebNav::CNsIWebNav(nsIWebNavigation *mWebNav)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
2001-11-26 21:47:06 +00:00
|
|
|
qaWebNav = mWebNav ;
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CNsIWebNav::~CNsIWebNav()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CNsIWebNav message handlers
|
|
|
|
// ***********************************************************************
|
|
|
|
// nsIWebNavigation iface
|
|
|
|
// ***********************************************************************
|
|
|
|
|
|
|
|
// Url table for web navigation
|
|
|
|
NavElement UrlTable[] = {
|
2002-04-20 02:24:27 +00:00
|
|
|
{"http://www.intel.com/", nsIWebNavigation::LOAD_FLAGS_NONE},
|
2002-05-29 03:13:37 +00:00
|
|
|
{"http://www.yahoo.com/", nsIWebNavigation::LOAD_FLAGS_MASK},
|
2002-04-06 02:58:50 +00:00
|
|
|
{"http://www.oracle.com/", nsIWebNavigation::LOAD_FLAGS_IS_LINK},
|
2001-09-22 00:49:38 +00:00
|
|
|
{"http://www.sun.com/", nsIWebNavigation::LOAD_FLAGS_IS_REFRESH},
|
2002-05-29 03:13:37 +00:00
|
|
|
{"ftp://ftp.netscape.com", nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY},
|
2002-04-20 02:24:27 +00:00
|
|
|
{"ftp://ftp.mozilla.org/", nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY},
|
2002-07-04 01:37:04 +00:00
|
|
|
{"https://www.motorola.com/", nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE},
|
2002-06-22 03:25:39 +00:00
|
|
|
{"https://www.amazon.com", nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY},
|
2002-05-29 03:13:37 +00:00
|
|
|
{"about:plugins", nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE},
|
2002-07-04 01:37:04 +00:00
|
|
|
{"javascript: document.write('Test!')", nsIWebNavigation::LOAD_FLAGS_NONE},
|
2002-05-29 03:13:37 +00:00
|
|
|
{"file://C|/Program Files", nsIWebNavigation::LOAD_FLAGS_NONE}
|
2001-09-22 00:49:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-11-26 21:47:06 +00:00
|
|
|
void CNsIWebNav::OnStartTests(UINT nMenuID)
|
|
|
|
{
|
|
|
|
switch(nMenuID)
|
|
|
|
{
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_RUNALLTESTS :
|
|
|
|
RunAllTests();
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_GETCANGOBACK :
|
2002-10-10 05:03:39 +00:00
|
|
|
CanGoBackTest(2);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_GETCANGOFORWARD :
|
2002-10-10 05:03:39 +00:00
|
|
|
CanGoForwardTest(2);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_GOBACK :
|
2002-10-10 05:03:39 +00:00
|
|
|
GoBackTest(2);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_GOFORWARD :
|
2002-10-10 05:03:39 +00:00
|
|
|
GoForwardTest(2);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_GOTOINDEX :
|
2002-10-10 05:03:39 +00:00
|
|
|
GoToIndexTest(2);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_LOADURI :
|
2002-10-10 05:03:39 +00:00
|
|
|
LoadUriTest(nsnull, nsnull, 2, PR_FALSE);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_RELOAD :
|
2002-10-10 05:03:39 +00:00
|
|
|
ReloadTest(nsIWebNavigation::LOAD_FLAGS_NONE, 2);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_STOP :
|
2002-05-29 03:13:37 +00:00
|
|
|
StopUriTest("file://C|/Program Files",
|
2002-10-10 05:03:39 +00:00
|
|
|
nsIWebNavigation::STOP_CONTENT, 2);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_GETDOCUMENT :
|
2002-10-10 05:03:39 +00:00
|
|
|
GetDocumentTest(2);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_GETCURRENTURI :
|
2002-10-10 05:03:39 +00:00
|
|
|
GetCurrentURITest(2);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
2003-02-04 20:01:55 +00:00
|
|
|
case ID_INTERFACES_NSIWEBNAV_GETREFERINGURI:
|
|
|
|
GetReferingURITest(2);
|
|
|
|
break;
|
2001-11-26 21:47:06 +00:00
|
|
|
case ID_INTERFACES_NSIWEBNAV_GETSESSIONHISTORY :
|
2002-10-10 05:03:39 +00:00
|
|
|
GetSHTest(2);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSIWEBNAV_SETSESSIONHISTORY :
|
2002-10-10 05:03:39 +00:00
|
|
|
SetSHTest(2);
|
2001-11-26 21:47:06 +00:00
|
|
|
break ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNsIWebNav::RunAllTests()
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
|
|
|
int i=0;
|
|
|
|
|
2002-05-29 03:13:37 +00:00
|
|
|
if (qaWebNav)
|
2002-10-10 05:03:39 +00:00
|
|
|
QAOutput("We have the web nav object.", 1);
|
2001-09-22 00:49:38 +00:00
|
|
|
else {
|
|
|
|
QAOutput("We don't have the web nav object. No tests performed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-21 02:31:36 +00:00
|
|
|
// load a couple of URLs to get things going
|
2002-10-10 05:03:39 +00:00
|
|
|
LoadUriTest("http://www.cisco.com", nsIWebNavigation::LOAD_FLAGS_NONE, 2, PR_TRUE);
|
|
|
|
LoadUriTest("www.google.com", nsIWebNavigation::LOAD_FLAGS_NONE, 2, PR_TRUE);
|
2002-06-21 02:31:36 +00:00
|
|
|
|
2001-09-22 00:49:38 +00:00
|
|
|
// canGoBack attribute test
|
2002-10-10 05:03:39 +00:00
|
|
|
CanGoBackTest(1);
|
2001-09-22 00:49:38 +00:00
|
|
|
|
|
|
|
// GoBack test
|
2002-10-10 05:03:39 +00:00
|
|
|
GoBackTest(2);
|
2001-09-22 00:49:38 +00:00
|
|
|
|
|
|
|
// canGoForward attribute test
|
2002-10-10 05:03:39 +00:00
|
|
|
CanGoForwardTest(1);
|
2001-09-22 00:49:38 +00:00
|
|
|
|
|
|
|
// GoForward test
|
2002-10-10 05:03:39 +00:00
|
|
|
GoForwardTest(2);
|
2001-09-22 00:49:38 +00:00
|
|
|
|
|
|
|
// GotoIndex test
|
2002-10-10 05:03:39 +00:00
|
|
|
GoToIndexTest(2);
|
2001-09-22 00:49:38 +00:00
|
|
|
|
|
|
|
// LoadURI() & reload tests
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
QAOutput("Run a few LoadURI() tests.", 1);
|
2001-09-22 00:49:38 +00:00
|
|
|
|
|
|
|
|
2002-05-30 21:54:32 +00:00
|
|
|
LoadUriandReload(11);
|
2002-05-29 03:13:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Stop() tests
|
2002-10-10 05:03:39 +00:00
|
|
|
StopUriTest("http://www.microsoft.com", nsIWebNavigation::STOP_ALL, 1);
|
|
|
|
StopUriTest("https://www.microsoft.com/", nsIWebNavigation::STOP_NETWORK, 1);
|
|
|
|
StopUriTest("ftp://ftp.microsoft.com/", nsIWebNavigation::STOP_CONTENT, 1);
|
2002-05-29 03:13:37 +00:00
|
|
|
|
|
|
|
// document test
|
2002-10-10 05:03:39 +00:00
|
|
|
GetDocumentTest(1);
|
2002-05-29 03:13:37 +00:00
|
|
|
|
|
|
|
// uri test
|
2002-10-10 05:03:39 +00:00
|
|
|
GetCurrentURITest(1);
|
2003-02-04 20:01:55 +00:00
|
|
|
GetReferingURITest(1);
|
2002-05-29 03:13:37 +00:00
|
|
|
|
|
|
|
// session history test
|
2002-10-10 05:03:39 +00:00
|
|
|
SetSHTest(1);
|
|
|
|
GetSHTest(1);
|
2002-05-29 03:13:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CNsIWebNav::LoadUriandReload(int URItotal)
|
|
|
|
{
|
2002-05-30 01:11:53 +00:00
|
|
|
int i=0, j=0;
|
2002-05-29 03:13:37 +00:00
|
|
|
// LoadURI() & reload tests
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
QAOutput("Run a few LoadURI() and Reload() tests.", 1);
|
2002-05-30 01:11:53 +00:00
|
|
|
|
|
|
|
for (j=0; j < 9; j++)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
2002-05-30 01:11:53 +00:00
|
|
|
for (i=0; i < URItotal; i++)
|
|
|
|
{
|
2002-10-10 05:03:39 +00:00
|
|
|
LoadUriTest(UrlTable[i].theUri, UrlTable[j].theFlag, 2, PR_TRUE);
|
2002-05-30 01:11:53 +00:00
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 0:
|
2002-10-10 05:03:39 +00:00
|
|
|
ReloadTest(nsIWebNavigation::LOAD_FLAGS_NONE, 1);
|
2002-05-30 01:11:53 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2002-10-10 05:03:39 +00:00
|
|
|
ReloadTest(nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE, 1);
|
2002-05-30 01:11:53 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2002-10-10 05:03:39 +00:00
|
|
|
ReloadTest(nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY, 1);
|
2002-05-30 01:11:53 +00:00
|
|
|
break;
|
|
|
|
// simulate shift-reload
|
|
|
|
case 3:
|
|
|
|
ReloadTest(nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE |
|
2002-10-10 05:03:39 +00:00
|
|
|
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY, 1);
|
2002-05-30 01:11:53 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2002-10-10 05:03:39 +00:00
|
|
|
ReloadTest(nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE, 1);
|
2002-05-30 01:11:53 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2002-10-10 05:03:39 +00:00
|
|
|
ReloadTest(nsIWebNavigation::LOAD_FLAGS_NONE, 1);
|
2002-05-30 01:11:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***********************************************************************
|
|
|
|
// Individual nsIWebNavigation tests
|
|
|
|
|
2002-05-29 03:13:37 +00:00
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
void CNsIWebNav::CanGoBackTest(PRInt16 displayMode)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
|
|
|
PRBool canGoBack = PR_FALSE;
|
2001-11-26 21:47:06 +00:00
|
|
|
rv = qaWebNav->GetCanGoBack(&canGoBack);
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, "GetCanGoBack() attribute test", displayMode);
|
|
|
|
FormatAndPrintOutput("canGoBack value = ", canGoBack, displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
void CNsIWebNav::GoBackTest(PRInt16 displayMode)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
2001-11-26 21:47:06 +00:00
|
|
|
rv = qaWebNav->GoBack();
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, "GoBack() test", displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
void CNsIWebNav::CanGoForwardTest(PRInt16 displayMode)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
|
|
|
PRBool canGoForward = PR_FALSE;
|
2001-11-26 21:47:06 +00:00
|
|
|
rv = qaWebNav->GetCanGoForward(&canGoForward);
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, "GetCanGoForward() attribute test", displayMode);
|
|
|
|
FormatAndPrintOutput("canGoForward value = ", canGoForward, displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
void CNsIWebNav::GoForwardTest(PRInt16 displayMode)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
2001-11-26 21:47:06 +00:00
|
|
|
rv = qaWebNav->GoForward();
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, "GoForward() test", displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
void CNsIWebNav::GoToIndexTest(PRInt16 displayMode)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
|
|
|
PRInt32 theIndex = 0;
|
|
|
|
|
2001-11-26 21:47:06 +00:00
|
|
|
rv = qaWebNav->GotoIndex(theIndex);
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, "GotoIndex() test", displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
|
2002-09-28 01:41:25 +00:00
|
|
|
void CNsIWebNav::LoadUriTest(char *theUrl, PRUint32 theFlag,
|
2002-10-10 05:03:39 +00:00
|
|
|
PRInt16 displayMode, PRBool runAllTests)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
|
|
|
char theTotalString[500];
|
2001-11-26 21:47:06 +00:00
|
|
|
char theFlagName[200];
|
2001-09-22 00:49:38 +00:00
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
if (runAllTests == PR_FALSE) // load just one url from Url dialog
|
2002-09-28 01:41:25 +00:00
|
|
|
{
|
|
|
|
CUrlDialog myDialog;
|
|
|
|
if (myDialog.DoModal() == IDOK)
|
|
|
|
{
|
|
|
|
QAOutput("Begin Change URL test.", 1);
|
|
|
|
rv = qaWebNav->LoadURI(NS_ConvertASCIItoUCS2(myDialog.m_urlfield).get(),
|
|
|
|
myDialog.m_flagvalue, nsnull,nsnull, nsnull);
|
|
|
|
|
|
|
|
RvTestResult(rv, "rv LoadURI() test", 1);
|
2002-10-10 05:03:39 +00:00
|
|
|
FormatAndPrintOutput("The url = ", myDialog.m_urlfield, displayMode);
|
|
|
|
FormatAndPrintOutput("The flag = ", myDialog.m_flagvalue, displayMode);
|
2002-09-28 01:41:25 +00:00
|
|
|
QAOutput("End Change URL test.", 1);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-09-22 00:49:38 +00:00
|
|
|
switch(theFlag)
|
|
|
|
{
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_NONE:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_NONE");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_MASK:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_MASK");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_IS_REFRESH:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_IS_REFRESH");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_IS_LINK:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_IS_LINK");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_BYPASS_HISTORY");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_REPLACE_HISTORY");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_BYPASS_CACHE");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_BYPASS_PROXY");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_CHARSET_CHANGE");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-11-30 22:35:33 +00:00
|
|
|
rv = qaWebNav->LoadURI(NS_ConvertASCIItoUCS2(theUrl).get(),
|
|
|
|
theFlag,
|
|
|
|
nsnull,
|
|
|
|
nsnull,
|
|
|
|
nsnull);
|
2001-09-22 00:49:38 +00:00
|
|
|
sprintf(theTotalString, "%s%s%s%s%s", "LoadURI(): ", theUrl, " w/ ", theFlagName, " test");
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, theTotalString, displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
void CNsIWebNav::ReloadTest(PRUint32 theFlag, PRInt16 displayMode)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
|
|
|
char theTotalString[500];
|
2001-11-26 21:47:06 +00:00
|
|
|
char theFlagName[200];
|
2001-09-22 00:49:38 +00:00
|
|
|
|
2002-05-30 01:11:53 +00:00
|
|
|
switch(theFlag)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_NONE:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_NONE");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_MASK:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_MASK");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_IS_REFRESH:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_IS_REFRESH");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_IS_LINK:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_IS_LINK");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_BYPASS_HISTORY");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_REPLACE_HISTORY");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_BYPASS_CACHE");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_BYPASS_PROXY");
|
|
|
|
break;
|
|
|
|
case nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE:
|
|
|
|
strcpy(theFlagName, "LOAD_FLAGS_CHARSET_CHANGE");
|
|
|
|
break;
|
2002-04-20 03:39:31 +00:00
|
|
|
case nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY:
|
|
|
|
strcpy(theFlagName, "cache & proxy");
|
2001-09-22 00:49:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-11-26 21:47:06 +00:00
|
|
|
rv = qaWebNav->Reload(theFlag);
|
2001-09-22 00:49:38 +00:00
|
|
|
sprintf(theTotalString, "%s%s%s%s", "Reload(): ", " w/ ", theFlagName, " test");
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, theTotalString, displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
void CNsIWebNav::StopUriTest(char *theUrl, PRUint32 theFlag,
|
|
|
|
PRInt16 displayMode)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
|
|
|
char theTotalString[200];
|
2002-05-29 03:13:37 +00:00
|
|
|
char flagString[100];
|
|
|
|
|
|
|
|
if (theFlag == nsIWebNavigation::STOP_ALL)
|
|
|
|
strcpy(flagString, "STOP_ALL");
|
|
|
|
else if (theFlag == nsIWebNavigation::STOP_NETWORK)
|
|
|
|
strcpy(flagString, "STOP_NETWORK");
|
|
|
|
else
|
|
|
|
strcpy(flagString, "STOP_CONTENT");
|
2001-09-22 00:49:38 +00:00
|
|
|
|
2001-11-30 22:35:33 +00:00
|
|
|
qaWebNav->LoadURI(NS_ConvertASCIItoUCS2(theUrl).get(),
|
|
|
|
nsIWebNavigation::LOAD_FLAGS_NONE,
|
|
|
|
nsnull,
|
|
|
|
nsnull,
|
|
|
|
nsnull);
|
2002-05-29 03:13:37 +00:00
|
|
|
|
|
|
|
rv = qaWebNav->Stop(theFlag);
|
|
|
|
sprintf(theTotalString, "%s%s%s%s", "Stop(): ", theUrl, " test: ", flagString);
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, theTotalString, displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
void CNsIWebNav::GetDocumentTest(PRInt16 displayMode)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMDocument> theDocument;
|
|
|
|
nsCOMPtr<nsIDOMDocumentType> theDocType;
|
|
|
|
|
2001-11-26 21:47:06 +00:00
|
|
|
rv = qaWebNav->GetDocument(getter_AddRefs(theDocument));
|
2001-09-22 00:49:38 +00:00
|
|
|
if (!theDocument) {
|
|
|
|
QAOutput("We didn't get the document. Test failed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, "GetDocument() test", displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
|
|
|
|
rv = theDocument->GetDoctype(getter_AddRefs(theDocType));
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, "nsIDOMDocument::GetDoctype() for nsIWebNav test", displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
void CNsIWebNav::GetCurrentURITest(PRInt16 displayMode)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
2003-02-04 20:01:55 +00:00
|
|
|
nsCOMPtr<nsIURI> theURI;
|
2001-09-22 00:49:38 +00:00
|
|
|
|
2003-02-04 20:01:55 +00:00
|
|
|
rv = qaWebNav->GetCurrentURI(getter_AddRefs(theURI));
|
|
|
|
if (!theURI) {
|
2001-09-22 00:49:38 +00:00
|
|
|
QAOutput("We didn't get the URI. Test failed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, "GetCurrentURI() test", displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
|
2002-03-16 02:31:53 +00:00
|
|
|
nsCAutoString uriString;
|
2003-02-04 20:01:55 +00:00
|
|
|
rv = theURI->GetSpec(uriString);
|
|
|
|
RvTestResult(rv, "nsIURI::GetSpec() for nsIWebNav test", 1);
|
|
|
|
|
|
|
|
FormatAndPrintOutput("the nsIWebNav uri = ", uriString, displayMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNsIWebNav::GetReferingURITest(PRInt16 displayMode)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURI> theURI;
|
|
|
|
nsCAutoString uriString;
|
|
|
|
CUrlDialog myDialog;
|
|
|
|
if (myDialog.DoModal() == IDOK)
|
|
|
|
{
|
|
|
|
uriString = myDialog.m_urlfield;
|
|
|
|
rv = NS_NewURI(getter_AddRefs(theURI), uriString);
|
|
|
|
if (theURI)
|
|
|
|
QAOutput("We GOT the URI.", 1);
|
|
|
|
else
|
|
|
|
QAOutput("We DIDN'T GET the URI.", 1);
|
2003-02-12 23:50:14 +00:00
|
|
|
rv = qaWebNav->GetReferringURI(getter_AddRefs(theURI));
|
2003-02-04 20:01:55 +00:00
|
|
|
RvTestResult(rv, "GetReferingURI() test", displayMode);
|
|
|
|
// rv = qaWebNav->LoadURI(NS_ConvertASCIItoUCS2(myDialog.m_urlfield).get(),
|
|
|
|
// myDialog.m_flagvalue, theURI, nsnull, nsnull);
|
|
|
|
}
|
|
|
|
if (!theURI) {
|
|
|
|
QAOutput("We didn't get the URI. Test failed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = theURI->GetSpec(uriString);
|
2001-09-22 00:49:38 +00:00
|
|
|
RvTestResult(rv, "nsIURI::GetSpec() for nsIWebNav test", 1);
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
FormatAndPrintOutput("the nsIWebNav uri = ", uriString, displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
void CNsIWebNav::GetSHTest(PRInt16 displayMode)
|
2001-09-22 00:49:38 +00:00
|
|
|
{
|
|
|
|
PRInt32 numOfElements;
|
|
|
|
|
|
|
|
nsCOMPtr<nsISHistory> theSessionHistory;
|
2001-11-26 21:47:06 +00:00
|
|
|
rv = qaWebNav->GetSessionHistory(getter_AddRefs(theSessionHistory));
|
2001-09-22 00:49:38 +00:00
|
|
|
if (!theSessionHistory) {
|
|
|
|
QAOutput("We didn't get the session history. Test failed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, "GetSessionHistory() test", displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
|
|
|
|
rv = theSessionHistory->GetCount(&numOfElements);
|
|
|
|
RvTestResult(rv, "nsISHistory::GetCount() for nsIWebNav test", 1);
|
|
|
|
|
2002-10-10 05:03:39 +00:00
|
|
|
FormatAndPrintOutput("the sHist entry count = ", numOfElements, displayMode);
|
2001-09-22 00:49:38 +00:00
|
|
|
}
|
2002-10-10 05:03:39 +00:00
|
|
|
|
|
|
|
void CNsIWebNav::SetSHTest(PRInt16 displayMode)
|
|
|
|
{
|
2002-10-12 01:51:18 +00:00
|
|
|
nsCOMPtr<nsISHistory> theSessionHistory, tempSHObject;
|
|
|
|
// we want to save the existing session history
|
|
|
|
rv = qaWebNav->GetSessionHistory(getter_AddRefs(theSessionHistory));
|
|
|
|
// this will create the test session history object
|
|
|
|
tempSHObject = do_CreateInstance(NS_SHISTORY_CONTRACTID);
|
|
|
|
rv = qaWebNav->SetSessionHistory(tempSHObject);
|
2002-10-10 05:03:39 +00:00
|
|
|
RvTestResult(rv, "SetSessionHistory() test", displayMode);
|
2002-10-12 01:51:18 +00:00
|
|
|
if (!tempSHObject)
|
|
|
|
QAOutput("We didn't get the session history test object. Test failed.", 2);
|
|
|
|
// we now reset the previous session history
|
|
|
|
rv = qaWebNav->SetSessionHistory(theSessionHistory);
|
2002-10-10 05:03:39 +00:00
|
|
|
}
|