Example #1
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);
		}
	}
}
Example #2
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);
}
Example #3
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;
}
Example #5
0
void CTests::OnVerifybugs170274()
{
	nsCOMPtr<nsIURILoader> myLoader(do_GetService(NS_URI_LOADER_CONTRACTID,&rv));
	nsCAutoString theStr;

	QAOutput("Verification for bug 170274!", 2);

	theStr = "data:text/plain;charset=iso-8859-7,%be%fg%be";
	rv = NS_NewURI(getter_AddRefs(theURI), theStr);
	RvTestResult(rv, "NS_NewURI() test for data url", 1);

	GetTheURI(theURI, 1);

	rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
	RvTestResult(rv, "NS_NewChannel() test for data url", 1);

	rv = myLoader->OpenURI(theChannel, PR_TRUE, qaBrowserImpl);
	RvTestResult(rv, "nsIUriLoader->OpenURI() test for data url", 2);
}
Example #6
0
void CTests::OnVerifybugs169617()
{
	nsCOMPtr<nsIURILoader> myLoader(do_GetService(NS_URI_LOADER_CONTRACTID,&rv));
	nsCAutoString theStr;

	QAOutput("Verification for bug 169617!", 2);

	theStr = "file://C|/Program Files";
	rv = NS_NewURI(getter_AddRefs(theURI), theStr);
	RvTestResult(rv, "NS_NewURI() test for file url", 1);

	GetTheURI(theURI, 1);

	rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
	RvTestResult(rv, "NS_NewChannel() test for file url", 1);

	rv = myLoader->OpenURI(theChannel, PR_TRUE, qaBrowserImpl);
	RvTestResult(rv, "nsIUriLoader->OpenURI() test for file url", 2);

}
Example #7
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);

		
	}
}