Beispiel #1
0
NS_IMETHODIMP CBrowserImpl::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy)
{
    QAOutput("\n", 1);
	QAOutput("inside nsIEmbeddingSiteWindow::GetDimensions()", 1);

	FormatAndPrintOutput("GetDimensions() flags = ", aFlags, 1);
	FormatAndPrintOutput("GetDimensions() x1 coordinate = ", *x, 1);
	FormatAndPrintOutput("GetDimensions() y1 coordinate = ", *y, 1);
	FormatAndPrintOutput("GetDimensions() x2 coordinate = ", *cx, 1);
	FormatAndPrintOutput("GetDimensions() y2 coordinate = ", *cy, 1);

	if(! m_pBrowserFrameGlue)
		return NS_ERROR_FAILURE;
    
    if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
    {
    	m_pBrowserFrameGlue->GetBrowserFramePosition(x, y);
    }
    if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || 
        aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
    {
    	m_pBrowserFrameGlue->GetBrowserFrameSize(cx, cy);
    }

    return NS_OK;
}
Beispiel #2
0
NS_IMETHODIMP CBrowserImpl::OnDataAvailable(nsIRequest *request,
				nsISupports *ctxt, nsIInputStream *input,
				PRUint32 offset, PRUint32 count)
{
	nsCString stringMsg;
	PRUint32 readLen;
	QAOutput("\n");
	QAOutput("##### inside nsIStreamListener::OnDataAvailable(). #####");

	RequestName(request, stringMsg, 1);
	readLen = count;
		// from prmem.h: PR_Malloc()
	char *buf = (char *)PR_Malloc(count);
	if (!input)
		QAOutput("We didn't get the nsIInputStream object.", 1);
	else {
		// consumer of input stream
		rv = input->Read(buf, count, &readLen);
		RvTestResult(rv, "nsIInputStream->Read() consumer", 1);
	}

	FormatAndPrintOutput("OnDataAvailable() offset = ", offset, 1);
	FormatAndPrintOutput("OnDataAvailable() count = ", count, 1);

	if (!ctxt)
		QAOutput("OnDataAvailable():We didn't get the nsISupports object.", 1);
	else
		QAOutput("OnDataAvailable():We got the nsISupports object.", 1);

	return NS_OK;
}
Beispiel #3
0
void CTests::OnTestsGlobalHistory()
{
	// create instance of myHistory object. Call's XPCOM
	// service manager to pass the contract ID.

	PRBool theRetVal = PR_FALSE;

	nsCOMPtr<nsIGlobalHistory> myHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));

	if (!myHistory)
	{
		QAOutput("Couldn't find history object. No GH tests performed.", 2);
		return;
	}

	if (myDialog.DoModal() == IDOK)
	{
		QAOutput("Begin IsVisited() and AddPage() tests.", 2);
		FormatAndPrintOutput("The history url = ", myDialog.m_urlfield, 1);

		// see if url is already in the GH file (pre-AddPage() test)
		rv = myHistory->IsVisited(myDialog.m_urlfield, &theRetVal);
	    RvTestResult(rv, "rv IsVisited() test", 1);
		FormatAndPrintOutput("The IsVisited() boolean return value = ", theRetVal, 1);

		if (theRetVal)
			QAOutput("URL has been visited. Won't execute AddPage().", 2);
		else
		{
			QAOutput("URL hasn't been visited. Will execute AddPage().", 2);

			// adds a url to the global history file
			rv = myHistory->AddPage(myDialog.m_urlfield);

			// prints addPage() results to output file
			if (NS_FAILED(rv))
			{
				QAOutput("Invalid results for AddPage(). Url not added. Test failed.", 1);
				return;
			}
			else
				QAOutput("Valid results for AddPage(). Url added. Test passed.", 1);

			// checks if url was visited (post-AddPage() test)
 			myHistory->IsVisited(myDialog.m_urlfield, &theRetVal);

			if (theRetVal)
				QAOutput("URL is visited; post-AddPage() test. IsVisited() test passed.", 1);
			else
				QAOutput("URL isn't visited; post-AddPage() test. IsVisited() test failed.", 1);
		}
		QAOutput("End IsVisited() and AddPage() tests.", 2);
	}
	else
		QAOutput("IsVisited() and AddPage() tests not executed.", 1);
}
Beispiel #4
0
NS_IMETHODIMP CBrowserImpl::CanHandleContent(const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval)
{
	QAOutput("nsIURIContentListener->CanHandleContent()",1);

	FormatAndPrintOutput("CanHandleContent() content type = ", *aContentType, 1);
	FormatAndPrintOutput("CanHandleContent() preferred content type = ", aIsContentPreferred, 1);
	*aDesiredContentType = nsCRT::strdup("text/html");
	FormatAndPrintOutput("aDesiredContentType set to = ", *aDesiredContentType, 1);
	*_retval = PR_TRUE;
	FormatAndPrintOutput("_retval set to = ", *_retval, 1);
	return NS_OK;
}
Beispiel #5
0
//Gets called when you mouseover links etc. in a web page
//
NS_IMETHODIMP CBrowserImpl::SetStatus(PRUint32 aType, const PRUnichar* aStatus)
{
    QAOutput("\n", 1);
    QAOutput("inside nsIWebBrowserChrome::SetStatus().", 1);
	FormatAndPrintOutput("SetStatus() type = ", aType, 1);
	FormatAndPrintOutput("SetStatus() aStatus = ", *aStatus, 1);

	if(! m_pBrowserFrameGlue)
		return NS_ERROR_FAILURE;

	m_pBrowserFrameGlue->UpdateStatusBarText(aStatus);

	return NS_OK;
}
Beispiel #6
0
NS_IMETHODIMP CBrowserImpl::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
										  const PRUnichar *aTipText)
{
    if(! m_pBrowserFrameGlue)
        return NS_ERROR_FAILURE;

    m_pBrowserFrameGlue->ShowTooltip(aXCoords, aYCoords, aTipText);

	QAOutput("nsITooltipListener->OnShowTooltip()",1);
	FormatAndPrintOutput("OnShowTooltip() aXCoords = ", aXCoords, 1);
	FormatAndPrintOutput("OnShowTooltip() aYCoords = ", aYCoords, 1);
	FormatAndPrintOutput("OnShowTooltip() aTipText = ", *aTipText, 1);	
	return NS_OK;
}
Beispiel #7
0
NS_IMETHODIMP CBrowserImpl::IsPreferred(const char *aContentType, char **aDesiredContentType, PRBool *_retval)
{
	nsCAutoString contentStr;

	QAOutput("nsIURIContentListener->IsPreferred()",1);

	FormatAndPrintOutput("IsPreferred() content type = ", *aContentType, 1);
	*aDesiredContentType = nsCRT::strdup("text/html");
	FormatAndPrintOutput("aDesiredContentType set to = ", *aDesiredContentType, 1);
	*_retval = PR_TRUE;
	FormatAndPrintOutput("_retval set to = ", *_retval, 1);

	return NS_OK;
}
Beispiel #8
0
// Gets called in response to set the size of a window
// Ex: In response to a JavaScript Window.Open() call of
// the form 
//
//		window.open("http://www.mozilla.org", "theWin", "width=200, height=400");
//
// First the CreateBrowserWindow() call will be made followed by a 
// call to this method to resize the window
//
NS_IMETHODIMP CBrowserImpl::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
{
    QAOutput("\n", 1);
	QAOutput("inside nsIWebBrowserChrome::SizeBrowserTo(): Browser sized.", 1);

	if(! m_pBrowserFrameGlue)
		return NS_ERROR_FAILURE;

	FormatAndPrintOutput("SizeBrowserTo() x coordinate = ", aCX, 1);
	FormatAndPrintOutput("SizeBrowserTo() y coordinate = ", aCY, 1);

	m_pBrowserFrameGlue->SetBrowserFrameSize(aCX, aCY);

	return NS_OK;
}
Beispiel #9
0
void CTests::OnTestsIOServiceNewURI()
{
	nsCOMPtr<nsIIOService> ioService(do_GetIOService(&rv));
	if (!ioService) {
		QAOutput("We didn't get the IOService object.", 2);
		return;
	}

	if (myDialog.DoModal() == IDOK)
	{
		nsCAutoString theStr, retURI;

		theStr = myDialog.m_urlfield;

		rv = ioService->NewURI(theStr, nsnull, nsnull, getter_AddRefs(theURI));
		RvTestResult(rv, "ioService->NewURI() test", 2);

		if (!theURI)
			QAOutput("We didn't get the nsIURI object for IOService test.", 2);
		else {
			retURI = GetTheURI(theURI, 1);
			FormatAndPrintOutput("The ioService->NewURI() output uri = ", retURI, 2);
		}
	}
}
Beispiel #10
0
void CTests::OnTestsAddUriContentListenerByOpenUri()
{
	nsCOMPtr<nsIURILoader> myLoader(do_GetService(NS_URI_LOADER_CONTRACTID,&rv));
	RvTestResult(rv, "nsIURILoader() object test", 1);

	if (!myLoader) {
		QAOutput("Didn't get urILoader object. test failed", 2);
		return;
	}

	if (myDialog.DoModal() == IDOK)
	{
		nsCAutoString theStr;

		theStr = myDialog.m_urlfield;
		rv = NS_NewURI(getter_AddRefs(theURI), theStr);
		RvTestResult(rv, "For OpenURI(): NS_NewURI() test", 1);
		FormatAndPrintOutput("theStr = ", theStr, 1);
		GetTheURI(theURI, 1);
		rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
		RvTestResult(rv, "For OpenURI(): NS_NewChannel() test", 1);
	}
	else {
		QAOutput("Didn't get a url. test failed", 2);
		return;
	}

	rv = myLoader->OpenURI(theChannel, PR_TRUE, qaBrowserImpl);
	RvTestResult(rv, "nsIUriLoader->OpenURI() test", 2);
}
Beispiel #11
0
NS_IMETHODIMP CBrowserImpl::DoContent(const char *aContentType, PRBool aIsContentPreferred, nsIRequest *aRequest, nsIStreamListener **aContentHandler, PRBool *_retval)
{
	nsCString stringMsg;

	QAOutput("nsIURIContentListener->DoContent()",1);

	FormatAndPrintOutput("DoContent() content type = ", *aContentType, 1);
	FormatAndPrintOutput("DoContent() aIsContentPreferred = ", aIsContentPreferred, 1);
	RequestName(aRequest, stringMsg);	// nsIRequest::GetName() test
//	*aContentHandler = nsnull;
	QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);

	*_retval = PR_FALSE;
	FormatAndPrintOutput("_retval set to = ", *_retval, 1);

	return NS_OK;
}
Beispiel #12
0
NS_IMETHODIMP CBrowserImpl::GetChromeFlags(PRUint32* aChromeMask)
{
    QAOutput("inside nsIWebBrowserChrome::GetChromeFlags().", 1);

	*aChromeMask = nsIWebBrowserChrome::CHROME_ALL;
	FormatAndPrintOutput("GetChromeFlags() chromeMask = ", *aChromeMask, 1);

	return NS_OK;
}
Beispiel #13
0
NS_IMETHODIMP CBrowserImpl::SetChromeFlags(PRUint32 aChromeMask)
{
    QAOutput("nsIWebBrowserChrome::SetChromeFlags().", 1);

	FormatAndPrintOutput("SetChromeFlags() chromeMask = ", aChromeMask, 1);

	mChromeMask = aChromeMask;

	return NS_OK;
}
Beispiel #14
0
NS_IMETHODIMP CBrowserImpl::OnStartURIOpen(nsIURI *aURI, PRBool *_retval)
{
	QAOutput("nsIURIContentListener->OnStartURIOpen()",1);

	GetTheURI(aURI, 1);
	// set return boolean to false so uriOpen doesn't abort
	*_retval = PR_FALSE;
	FormatAndPrintOutput("_retval set to = ", *_retval, 1);

	return NS_OK;
}
nsIChannel * CNsIRequest::GetTheChannel(int i, nsILoadGroup *theLoadGroup)
{
	nsCAutoString theSpec, retURI;
	nsCOMPtr<nsIURI> theURI;
	nsCOMPtr<nsIChannel> theChannel;

	theSpec = ReqTable[i].theUrl;
	FormatAndPrintOutput("the input uri = ", theSpec, 1);

	rv = NS_NewURI(getter_AddRefs(theURI), theSpec);

	if (!theURI)
	{
	   QAOutput("We didn't get the URI. Test failed.", 1);
	   return nsnull;
	}
	else {
	   retURI = GetTheURI(theURI, 1);
	   // simple string compare to see if input & output URLs match
	   if (strcmp(ReqTable[i].theUrl, retURI.get()) == 0)
		  QAOutput("The in/out URIs MATCH.", 1);
	   else
		  QAOutput("The in/out URIs don't MATCH.", 1);
	   RvTestResult(rv, "NS_NewURI", 1);
	   RvTestResultDlg(rv, "NS_NewURI", true);
	}

	rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, theLoadGroup);
	if (!theChannel)
	{
	   QAOutput("We didn't get the Channel. Test failed.", 1);
	   return nsnull;
	}
	else {
	   RvTestResult(rv, "NS_NewChannel", 1);
	   RvTestResultDlg(rv, "NS_NewChannel");
	}

	nsCOMPtr<nsIStreamListener> listener(static_cast<nsIStreamListener*>(qaBrowserImpl));
	nsCOMPtr<nsIWeakReference> thisListener(do_GetWeakReference(listener));
	qaWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsIStreamListener));

	if (!listener) {
	   QAOutput("We didn't get the listener for AsyncOpen(). Test failed.", 1);
	   return nsnull;
	}
	// this calls nsIStreamListener::OnDataAvailable()
	rv = theChannel->AsyncOpen(listener, nsnull);
	RvTestResult(rv, "AsyncOpen()", 1);
	RvTestResultDlg(rv, "AsyncOpen()");

	return theChannel;
}
Beispiel #16
0
NS_IMETHODIMP CBrowserImpl::SetVisibility(PRBool aVisibility)
{
    QAOutput("inside nsIEmbeddingSiteWindow::SetVisibility()", 1);
	FormatAndPrintOutput("SetVisibility() boolean = ", aVisibility, 1);

    if(! m_pBrowserFrameGlue)
        return NS_ERROR_FAILURE;

    m_pBrowserFrameGlue->ShowBrowserFrame(aVisibility);

    return NS_OK;
}
Beispiel #17
0
NS_IMETHODIMP CBrowserImpl::SetTitle(const PRUnichar* aTitle)
{
    QAOutput("inside nsIEmbeddingSiteWindow::SetTitle()", 1);
	FormatAndPrintOutput("SetTitle() title = ", *aTitle, 1);

	if(! m_pBrowserFrameGlue)
		return NS_ERROR_FAILURE;

	m_pBrowserFrameGlue->SetBrowserFrameTitle(aTitle);
	
	return NS_OK;
}
Beispiel #18
0
void CTests::OnTestsChangeUrl()
{
	if (!qaWebNav)
	{
		QAOutput("Web navigation object not found. Change URL test not performed.", 2);
		return;
	}

	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);
		FormatAndPrintOutput("The url = ", myDialog.m_urlfield, 2);
		FormatAndPrintOutput("The flag = ", myDialog.m_flagvalue, 1);
		QAOutput("End Change URL test.", 1);
	}
	else
		QAOutput("Change URL test not executed.", 1);
}
Beispiel #19
0
void CnsIEditSession::WinIsEditTest(PRBool outIsEditable, PRInt16 displayMode)
{
	editingSession = GetEditSessionObject();
	domWindow = GetTheDOMWindow(qaWebBrowser);
	if (editingSession) {
		rv = editingSession->WindowIsEditable(domWindow, &outIsEditable);
		RvTestResult(rv, "WindowIsEditable() test", displayMode);
		if (displayMode == 1)
			RvTestResultDlg(rv, "WindowIsEditable() test");
		if (!domWindow)
			QAOutput("Didn't get domWindow object for WindowIsEditable() test. Test failed.", displayMode);
		FormatAndPrintOutput("the outIsEditable boolean = ", outIsEditable, displayMode);
	}
	else
		QAOutput("Didn't get object(s) for WinIsEditTest() test. Test failed.", 1);
}
Beispiel #20
0
void CnsIObserServ::RemoveObserversTest(int displayType)
{
	int i;

	nsCOMPtr<nsIObserverService>observerService(do_GetService("@mozilla.org/observer-service;1",&rv));

	QAOutput("\n nsIObserverService::RemoveObserversTest().");
	if (!observerService) 
	{
		QAOutput("Can't get nsIObserverService object. Tests fail.");
		return;
	}

	for (i=0; i<10; i++)
	{
		rv = observerService->RemoveObserver(this, ObserverTable[i].theTopic);
		FormatAndPrintOutput("The observer to be removed = ", ObserverTable[i].theTopic, 1);	
		RvTestResult(rv, "RemoveObservers() test", displayType);
		RvTestResultDlg(rv, "RemoveObservers() test");
	}
}
Beispiel #21
0
void CnsIObserServ::NotifyObserversTest(int displayType)
{
	PRInt32 i;
	nsCOMPtr<nsIObserverService>observerService(do_GetService("@mozilla.org/observer-service;1",&rv));

	QAOutput("\n nsIObserverService::NotifyObserversTest().");

	if (!observerService) 
	{
		QAOutput("Can't get nsIObserverService object. Tests fail.");
		return;
	}

	for (i=0; i<10; i++)
	{
		FormatAndPrintOutput("The notified observer = ", ObserverTable[i].theTopic, 1);
		rv = observerService->NotifyObservers(nsnull, ObserverTable[i].theTopic, 0);
		RvTestResult(rv, "NotifyObservers() test", displayType);
		RvTestResultDlg(rv, "NotifyObservers() test");
	}
}
Beispiel #22
0
void CTests::OnTestsProtocolHandlerNewURI()
{
	nsCOMPtr<nsIIOService> ioService(do_GetIOService(&rv));

	if (!ioService) {
		QAOutput("We didn't get the IOService object.", 2);
		return;
	}

	if (myDialog.DoModal() == IDOK)
	{
		nsCAutoString theStr, retStr;
		nsCOMPtr<nsIURI> theOriginalURI;
		nsIURI *theReturnURI = nsnull;
		nsIChannel *theReturnChannel = nsnull;
		const char *theProtocol;

		nsCOMPtr<nsIProtocolHandler> protocolHandler;

		theStr = myDialog.m_urlfield;
		theProtocol = myDialog.m_protocolvalue;
		FormatAndPrintOutput("The protocol scheme = ", theProtocol, 1);
		rv = ioService->GetProtocolHandler(theProtocol, getter_AddRefs(protocolHandler));
		RvTestResult(rv, "ioService->GetProtocolHandler() test", 2);
		rv = qaWebNav->GetCurrentURI(getter_AddRefs(theOriginalURI));
		if (!protocolHandler) {
			QAOutput("We didn't get the protocolHandler object.", 2);
			return;
		}
		rv = protocolHandler->NewURI(theStr, nsnull, theOriginalURI, &theReturnURI);
		if (!theOriginalURI)
			QAOutput("We didn't get the original nsIURI object.", 2);
		else if (!theReturnURI)
			QAOutput("We didn't get the output nsIURI object.", 2);

		RvTestResult(rv, "protocolHandler->NewURI() test", 2);

	    retStr = GetTheURI(theReturnURI, 1);

	   // simple string compare to see if input & output URLs match
	    if (strcmp(myDialog.m_urlfield, retStr.get()) == 0)
		   QAOutput("The in/out URIs MATCH.", 1);
	    else
		   QAOutput("The in/out URIs don't MATCH.", 1);

		// other protocol handler tests:

		// GetScheme() test
		nsCAutoString theScheme;
		rv = protocolHandler->GetScheme(theScheme);
		RvTestResult(rv, "protocolHandler->GetScheme() test", 1);
		FormatAndPrintOutput("GetScheme() = ", theScheme, 1);

		// GetDefaultPort() test
		PRInt32 theDefaultPort;
		rv = protocolHandler->GetDefaultPort(&theDefaultPort);
		RvTestResult(rv, "protocolHandler->GetDefaultPort() test", 1);
		FormatAndPrintOutput("GetDefaultPort() = ", theDefaultPort, 1);

		// GetProtocolFlags() test
		PRUint32 theProtocolFlags;
		rv = protocolHandler->GetProtocolFlags(&theProtocolFlags);
		RvTestResult(rv, "protocolHandler->GetDefaultPort() test", 1);
		FormatAndPrintOutput("GetProtocolFlags() = ", theProtocolFlags, 1);

		// NewChannel() test
		rv = protocolHandler->NewChannel(theReturnURI, &theReturnChannel);
		RvTestResult(rv, "protocolHandler->NewChannel() test", 1);
		if (!theReturnChannel)
			QAOutput("We didn't get the returned nsIChannel object.", 1);


		// AllowPort() test
		PRBool retPort;
		rv = protocolHandler->AllowPort(theDefaultPort, "http", &retPort);
		RvTestResult(rv, "protocolHandler->AllowPort() test", 1);
		FormatAndPrintOutput("AllowPort() boolean = ", retPort, 1);

		
	}
}