2001-09-26 02:58:40 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-19 02:01:16 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-06-20 22:28:48 +04:00
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* 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/
|
2001-06-20 22:28:48 +04:00
|
|
|
*
|
2001-09-26 02:58:40 +04: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-06-20 22:28:48 +04:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-26 02:58:40 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-06-20 22:28:48 +04:00
|
|
|
*
|
2001-09-26 02:58:40 +04:00
|
|
|
* Contributor(s):
|
2004-04-19 02:01:16 +04:00
|
|
|
* Chak Nanga <chak@netscape.com>
|
|
|
|
* David Epstein <depstein@netscape.com>
|
2001-09-26 02:58:40 +04: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
|
2004-04-19 02:01:16 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-26 02:58:40 +04:00
|
|
|
* 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
|
2004-04-19 02:01:16 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-26 02:58:40 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-06-20 22:28:48 +04:00
|
|
|
|
|
|
|
#ifdef _WINDOWS
|
|
|
|
#include "stdafx.h"
|
|
|
|
#endif
|
|
|
|
#include "BrowserImpl.h"
|
|
|
|
#include "IBrowserFrameGlue.h"
|
|
|
|
|
|
|
|
#include "TestEmbed.h"
|
|
|
|
#include "BrowserView.h"
|
|
|
|
#include "BrowserFrm.h"
|
|
|
|
|
|
|
|
#include "QaUtils.h"
|
2001-06-27 02:39:32 +04:00
|
|
|
#include "Tests.h"
|
2001-06-20 22:28:48 +04:00
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// CBrowserImpl::nsIWebProgressListener Implementation
|
|
|
|
//*****************************************************************************
|
|
|
|
//
|
|
|
|
// - Implements browser progress update functionality
|
|
|
|
// while loading a page into the embedded browser
|
|
|
|
//
|
|
|
|
// - Calls methods via the IBrowserFrameGlue interace
|
|
|
|
// (available thru' the m_pBrowserFrameGlue member var)
|
|
|
|
// to do the actual statusbar/progress bar updates.
|
|
|
|
//
|
|
|
|
|
|
|
|
class CBrowserView;
|
|
|
|
|
|
|
|
NS_IMETHODIMP CBrowserImpl::OnProgressChange(nsIWebProgress *progress, nsIRequest *request,
|
|
|
|
PRInt32 curSelfProgress, PRInt32 maxSelfProgress,
|
|
|
|
PRInt32 curTotalProgress, PRInt32 maxTotalProgress)
|
|
|
|
{
|
2002-08-09 06:43:04 +04:00
|
|
|
// nsCString
|
2001-06-20 22:28:48 +04:00
|
|
|
nsCString stringMsg;
|
|
|
|
|
|
|
|
if(! m_pBrowserFrameGlue)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("Entering nsIWebProgLstnr::OnProgressChange().");
|
2001-06-20 22:28:48 +04:00
|
|
|
|
|
|
|
PRInt32 nProgress = curTotalProgress;
|
|
|
|
PRInt32 nProgressMax = maxTotalProgress;
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
RequestName(request, stringMsg);
|
2001-06-20 22:28:48 +04:00
|
|
|
|
|
|
|
if (nProgressMax == 0)
|
|
|
|
nProgressMax = LONG_MAX;
|
|
|
|
|
2002-02-02 05:34:27 +03:00
|
|
|
FormatAndPrintOutput("OnProgressChange(): curSelfProgress value = ", curSelfProgress, 1);
|
|
|
|
FormatAndPrintOutput("OnProgressChange(): maxSelfProgress value = ", maxSelfProgress, 1);
|
|
|
|
FormatAndPrintOutput("OnProgressChange(): curTotalProgress value = ", nProgress, 1);
|
|
|
|
FormatAndPrintOutput("OnProgressChange(): maxTotalProgress value = ", nProgressMax, 1);
|
|
|
|
|
2002-07-15 22:25:47 +04:00
|
|
|
if (curSelfProgress == maxSelfProgress && maxSelfProgress != -1)
|
2001-06-27 02:39:32 +04:00
|
|
|
{
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("nsIWebProgLstnr::OnProgressChange(): Self progress complete!", 1);
|
2001-06-20 22:28:48 +04:00
|
|
|
|
2001-06-27 02:39:32 +04:00
|
|
|
// web progress DOMWindow test
|
2001-09-22 04:49:38 +04:00
|
|
|
WebProgDOMWindowTest(progress, "OnProgressChange()", 1);
|
2001-06-27 02:39:32 +04:00
|
|
|
}
|
|
|
|
|
2002-07-15 22:25:47 +04:00
|
|
|
if (nProgress > nProgressMax && nProgressMax != -1)
|
2001-06-20 22:28:48 +04:00
|
|
|
{
|
|
|
|
nProgress = nProgressMax; // Progress complete
|
2002-01-25 01:18:53 +03:00
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("nsIWebProgLstnr::OnProgressChange(): Progress Update complete!", 1);
|
2001-06-20 22:28:48 +04:00
|
|
|
}
|
2002-10-10 09:03:39 +04:00
|
|
|
WebProgIsDocLoadingTest(progress, "OnProgressChange()", 1);
|
2001-06-20 22:28:48 +04:00
|
|
|
m_pBrowserFrameGlue->UpdateProgress(nProgress, nProgressMax);
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("Exiting nsIWebProgLstnr::OnProgressChange().\r\n");
|
2001-06-20 22:28:48 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP CBrowserImpl::OnStateChange(nsIWebProgress *progress, nsIRequest *request,
|
2002-05-17 00:57:37 +04:00
|
|
|
PRUint32 progressStateFlags, nsresult status)
|
2001-06-20 22:28:48 +04:00
|
|
|
{
|
|
|
|
char theDocType[100];
|
|
|
|
char theStateType[100];
|
|
|
|
int displayMode = 1;
|
|
|
|
nsCString stringMsg;
|
|
|
|
|
|
|
|
if(! m_pBrowserFrameGlue)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("Entering nsIWebProgLstnr::OnStateChange().");
|
2001-06-20 22:28:48 +04:00
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
RequestName(request, stringMsg); // nsIRequest::GetName() test
|
2001-06-20 22:28:48 +04:00
|
|
|
|
|
|
|
if (progressStateFlags & STATE_IS_DOCUMENT) // DOCUMENT
|
|
|
|
{
|
2001-06-28 04:48:45 +04:00
|
|
|
displayMode = 1;
|
2001-06-20 22:28:48 +04:00
|
|
|
strcpy(theDocType, "DOCUMENT");
|
|
|
|
if (progressStateFlags & STATE_START)
|
|
|
|
{
|
|
|
|
// Navigation has begun
|
|
|
|
strcpy(theStateType, "STATE_START");
|
|
|
|
displayMode = 2;
|
|
|
|
|
|
|
|
if(m_pBrowserFrameGlue)
|
|
|
|
m_pBrowserFrameGlue->UpdateBusyState(PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_REDIRECTING)
|
|
|
|
strcpy(theStateType, "STATE_REDIRECTING");
|
|
|
|
|
2002-10-10 09:03:39 +04:00
|
|
|
else if (progressStateFlags & STATE_TRANSFERRING) {
|
|
|
|
strcpy(theStateType, "STATE_TRANSFERRING");
|
|
|
|
}
|
2001-06-20 22:28:48 +04:00
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_NEGOTIATING)
|
|
|
|
strcpy(theStateType, "STATE_NEGOTIATING");
|
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_STOP)
|
|
|
|
{
|
|
|
|
// We've completed the navigation
|
|
|
|
|
|
|
|
strcpy(theStateType, "STATE_STOP");
|
|
|
|
displayMode = 2;
|
|
|
|
|
|
|
|
m_pBrowserFrameGlue->UpdateBusyState(PR_FALSE);
|
|
|
|
m_pBrowserFrameGlue->UpdateProgress(0, 100); // Clear the prog bar
|
|
|
|
m_pBrowserFrameGlue->UpdateStatusBarText(nsnull); // Clear the status bar
|
2001-06-27 02:39:32 +04:00
|
|
|
|
|
|
|
// web progress DOMWindow test
|
2002-10-10 09:03:39 +04:00
|
|
|
WebProgDOMWindowTest(progress, "OnStateChange()", 1);
|
2001-06-20 22:28:48 +04:00
|
|
|
}
|
2002-02-02 05:34:27 +03:00
|
|
|
|
|
|
|
onStateChangeString(theStateType, theDocType, stringMsg, status, displayMode);
|
|
|
|
|
2001-06-20 22:28:48 +04:00
|
|
|
} // end STATE_IS_DOCUMENT
|
2002-02-02 05:34:27 +03:00
|
|
|
|
2001-06-20 22:28:48 +04:00
|
|
|
if (progressStateFlags & STATE_IS_REQUEST) // REQUEST
|
|
|
|
{
|
2001-06-28 04:48:45 +04:00
|
|
|
displayMode = 1;
|
2001-06-20 22:28:48 +04:00
|
|
|
strcpy(theDocType, "REQUEST");
|
|
|
|
if (progressStateFlags & STATE_START)
|
|
|
|
strcpy(theStateType, "STATE_START");
|
|
|
|
else if (progressStateFlags & STATE_REDIRECTING)
|
|
|
|
strcpy(theStateType, "STATE_REDIRECTING");
|
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_TRANSFERRING)
|
|
|
|
strcpy(theStateType, "STATE_TRANSFERRING");
|
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_NEGOTIATING)
|
|
|
|
strcpy(theStateType, "STATE_NEGOTIATING");
|
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_STOP)
|
|
|
|
strcpy(theStateType, "STATE_STOP");
|
2002-02-02 05:34:27 +03:00
|
|
|
|
|
|
|
onStateChangeString(theStateType, theDocType, stringMsg, status, displayMode);
|
2001-06-20 22:28:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (progressStateFlags & STATE_IS_NETWORK) // NETWORK
|
|
|
|
{
|
2001-06-28 04:48:45 +04:00
|
|
|
displayMode = 1;
|
2001-06-20 22:28:48 +04:00
|
|
|
strcpy(theDocType, "NETWORK");
|
|
|
|
if (progressStateFlags & STATE_START)
|
|
|
|
strcpy(theStateType, "STATE_START");
|
|
|
|
else if (progressStateFlags & STATE_REDIRECTING)
|
|
|
|
strcpy(theStateType, "STATE_REDIRECTING");
|
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_TRANSFERRING)
|
|
|
|
strcpy(theStateType, "STATE_TRANSFERRING");
|
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_NEGOTIATING)
|
|
|
|
strcpy(theStateType, "STATE_NEGOTIATING");
|
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_STOP)
|
|
|
|
strcpy(theStateType, "STATE_STOP");
|
2002-02-02 05:34:27 +03:00
|
|
|
|
|
|
|
onStateChangeString(theStateType, theDocType, stringMsg, status, displayMode);
|
|
|
|
|
2001-06-20 22:28:48 +04:00
|
|
|
}
|
|
|
|
if (progressStateFlags & STATE_IS_WINDOW) // WINDOW
|
|
|
|
{
|
2001-06-28 04:48:45 +04:00
|
|
|
displayMode = 1;
|
2001-06-20 22:28:48 +04:00
|
|
|
strcpy(theDocType, "WINDOW");
|
|
|
|
if (progressStateFlags & STATE_START)
|
|
|
|
strcpy(theStateType, "STATE_START");
|
|
|
|
else if (progressStateFlags & STATE_REDIRECTING)
|
|
|
|
strcpy(theStateType, "STATE_REDIRECTING");
|
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_TRANSFERRING)
|
|
|
|
strcpy(theStateType, "STATE_TRANSFERRING");
|
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_NEGOTIATING)
|
|
|
|
strcpy(theStateType, "STATE_NEGOTIATING");
|
|
|
|
|
|
|
|
else if (progressStateFlags & STATE_STOP)
|
|
|
|
strcpy(theStateType, "STATE_STOP");
|
2002-02-02 05:34:27 +03:00
|
|
|
|
|
|
|
onStateChangeString(theStateType, theDocType, stringMsg, status, displayMode);
|
2001-06-20 22:28:48 +04:00
|
|
|
|
2002-02-02 05:34:27 +03:00
|
|
|
}
|
2002-10-10 09:03:39 +04:00
|
|
|
// web progress isDocumentLoading test
|
|
|
|
WebProgIsDocLoadingTest(progress, "OnStateChange()", 1);
|
2001-06-20 22:28:48 +04:00
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("Exiting nsIWebProgLstnr::OnStateChange().\r\n");
|
2001-06-20 22:28:48 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP CBrowserImpl::OnLocationChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsIURI *location)
|
|
|
|
{
|
|
|
|
nsCString stringMsg;
|
|
|
|
|
|
|
|
if(! m_pBrowserFrameGlue)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("Entering nsIWebProgLstnr::OnLocationChange().");
|
2001-06-20 22:28:48 +04:00
|
|
|
|
2002-10-26 05:49:44 +04:00
|
|
|
// test nsIURI parameter
|
2004-05-20 06:15:10 +04:00
|
|
|
GetTheURI(location, 1);
|
2001-06-20 22:28:48 +04:00
|
|
|
|
2002-10-26 05:49:44 +04:00
|
|
|
RequestName(aRequest, stringMsg);
|
2001-06-20 22:28:48 +04:00
|
|
|
|
|
|
|
PRBool isSubFrameLoad = PR_FALSE; // Is this a subframe load
|
|
|
|
if (aWebProgress) {
|
|
|
|
nsCOMPtr<nsIDOMWindow> domWindow;
|
|
|
|
nsCOMPtr<nsIDOMWindow> topDomWindow;
|
|
|
|
aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
|
|
|
if (domWindow) { // Get root domWindow
|
|
|
|
domWindow->GetTop(getter_AddRefs(topDomWindow));
|
|
|
|
}
|
|
|
|
if (domWindow != topDomWindow)
|
|
|
|
isSubFrameLoad = PR_TRUE;
|
2002-10-10 09:03:39 +04:00
|
|
|
WebProgIsDocLoadingTest(aWebProgress, "OnLocationChange()", 1);
|
2001-06-20 22:28:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!isSubFrameLoad) // Update urlbar only if it is not a subframe load
|
|
|
|
m_pBrowserFrameGlue->UpdateCurrentURI(location);
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("Exiting nsIWebProgLstnr::OnLocationChange().\r\n");
|
2001-06-20 22:28:48 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CBrowserImpl::OnStatusChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsresult aStatus,
|
|
|
|
const PRUnichar* aMessage)
|
|
|
|
{
|
|
|
|
nsCString stringMsg;
|
|
|
|
|
|
|
|
if(! m_pBrowserFrameGlue)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("Entering nsIWebProgLstnr::OnStatusChange().");
|
2001-06-20 22:28:48 +04:00
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
RequestName(aRequest, stringMsg);
|
2001-06-20 22:28:48 +04:00
|
|
|
|
2002-01-25 01:18:53 +03:00
|
|
|
// status result test (id number)
|
|
|
|
FormatAndPrintOutput("OnStatusChange(): Status id = ", aStatus, 1);
|
2001-06-27 02:39:32 +04:00
|
|
|
|
2002-01-25 01:18:53 +03:00
|
|
|
// web progress DOMWindow test (typically the host name)
|
2001-09-22 04:49:38 +04:00
|
|
|
WebProgDOMWindowTest(aWebProgress, "OnStatusChange(): web prog DOM window test", 1);
|
2002-10-10 09:03:39 +04:00
|
|
|
// web progress isDocumentLoading test
|
|
|
|
WebProgIsDocLoadingTest(aWebProgress, "OnStatusChange()", 1);
|
2001-06-27 02:39:32 +04:00
|
|
|
|
2001-06-20 22:28:48 +04:00
|
|
|
m_pBrowserFrameGlue->UpdateStatusBarText(aMessage);
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("Exiting nsIWebProgLstnr::OnStatusChange().\r\n");
|
2001-06-20 22:28:48 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CBrowserImpl::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|
|
|
nsIRequest *aRequest,
|
2002-05-17 00:57:37 +04:00
|
|
|
PRUint32 state)
|
2001-06-20 22:28:48 +04:00
|
|
|
{
|
|
|
|
nsCString stringMsg;
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("Entering nsIWebProgLstnr::OnSecurityChange().");
|
2001-06-20 22:28:48 +04:00
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
RequestName(aRequest, stringMsg);
|
2001-06-20 22:28:48 +04:00
|
|
|
|
2002-01-25 01:18:53 +03:00
|
|
|
if (state & STATE_IS_SECURE)
|
2002-02-02 05:34:27 +03:00
|
|
|
{
|
2002-01-25 01:18:53 +03:00
|
|
|
QAOutput("OnSecurityChange():STATE_IS_SECURE. All docs & subdocs are https.");
|
2002-02-02 05:34:27 +03:00
|
|
|
if ((state & 0xFFFF0000) == STATE_SECURE_HIGH)
|
|
|
|
QAOutput("OnSecurityChange(): STATE_SECURE_HIGH state");
|
|
|
|
else if (state & STATE_SECURE_MED)
|
|
|
|
QAOutput("OnSecurityChange(): STATE_SECURE_MED state");
|
|
|
|
else if (state & STATE_SECURE_LOW)
|
|
|
|
QAOutput("OnSecurityChange(): STATE_SECURE_LOW state");
|
|
|
|
}
|
2002-01-25 01:18:53 +03:00
|
|
|
else if (state & STATE_IS_BROKEN)
|
|
|
|
QAOutput("OnSecurityChange():STATE_IS_BROKEN. Mixed: some docs are https.");
|
2002-02-02 05:34:27 +03:00
|
|
|
else if ((state & 0xFFFF) == STATE_IS_INSECURE)
|
2002-01-25 01:18:53 +03:00
|
|
|
QAOutput("OnSecurityChange():STATE_IS_INSECURE. Nothing is https.");
|
|
|
|
|
2001-06-27 02:39:32 +04:00
|
|
|
// web progress DOMWindow test
|
2001-09-22 04:49:38 +04:00
|
|
|
WebProgDOMWindowTest(aWebProgress, "OnSecurityChange()", 1);
|
2002-10-10 09:03:39 +04:00
|
|
|
// web progress isDocumentLoading test
|
|
|
|
WebProgIsDocLoadingTest(aWebProgress, "OnSecurityChange()", 1);
|
2001-06-27 02:39:32 +04:00
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("Exiting nsIWebProgLstnr::OnSecurityChange().\r\n");
|
2001-06-20 22:28:48 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|