diff --git a/embedding/qa/testembed/QaUtils.cpp b/embedding/qa/testembed/QaUtils.cpp index cb5f40a2fdf..3387740ec21 100644 --- a/embedding/qa/testembed/QaUtils.cpp +++ b/embedding/qa/testembed/QaUtils.cpp @@ -309,7 +309,7 @@ nsIDOMWindow * GetTheDOMWindow(nsIWebBrowser *webBrowser) return (theDOMWindow); } -void GetTheUri(nsIURI *theUri, int displayMethod) +nsCAutoString GetTheUri(nsIURI *theUri, int displayMethod) { nsresult rv; nsCAutoString uriString; @@ -317,6 +317,8 @@ void GetTheUri(nsIURI *theUri, int displayMethod) rv = theUri->GetSpec(uriString); RvTestResult(rv, "nsIURI::GetSpec() test", displayMethod); FormatAndPrintOutput("the uri = ", uriString, displayMethod); + + return uriString; } // used for web progress listener in BrowserImplWebPrgrsLstnr.cpp diff --git a/embedding/qa/testembed/QaUtils.h b/embedding/qa/testembed/QaUtils.h index fe918e16b38..e59894cc114 100644 --- a/embedding/qa/testembed/QaUtils.h +++ b/embedding/qa/testembed/QaUtils.h @@ -65,7 +65,7 @@ extern void FormatAndPrintOutput(const char *, PRUint32, int); extern void RequestName(nsIRequest *, nsCString &, int displayMethod=1); extern void WebProgDOMWindowTest(nsIWebProgress *, const char *,int displayMethod=1); extern nsIDOMWindow * GetTheDOMWindow(nsIWebBrowser *); -extern void GetTheUri(nsIURI *theUri, int displayMethod=1); +extern nsCAutoString GetTheUri(nsIURI *theUri, int displayMethod=1); extern void onStateChangeString(char *, char *, nsCString, PRUint32, int displayMethod=1); extern nsresult rv; diff --git a/embedding/qa/testembed/Tests.cpp b/embedding/qa/testembed/Tests.cpp index 5b482861f32..347ca81b222 100644 --- a/embedding/qa/testembed/Tests.cpp +++ b/embedding/qa/testembed/Tests.cpp @@ -531,8 +531,11 @@ void CTests::OnTestsAddUriContentListenerByOpenUri() if (myDialog.DoModal() == IDOK) { - NS_NewURI(getter_AddRefs(theURI), myDialog.m_urlfield); - NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull); + rv = NS_NewURI(getter_AddRefs(theURI), myDialog.m_urlfield); + RvTestResult(rv, "For OpenURI(): NS_NewURI() test", 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); diff --git a/embedding/qa/testembed/nsirequest.cpp b/embedding/qa/testembed/nsirequest.cpp index fa5de4bb4af..6c3366a01a5 100644 --- a/embedding/qa/testembed/nsirequest.cpp +++ b/embedding/qa/testembed/nsirequest.cpp @@ -81,24 +81,26 @@ CNsIRequest::~CNsIRequest() // setLoadGroup & getLoadGroup tests respectively. Element ReqTable[] = { - {"http://www.netscape.com", 1, 1, 0, 0, 0, 1, 1}, - {"http://www.yahoo.com", 0, 0, 1, 1, 0, 0, 0}, - {"http://www.cisco.com", 0, 0, 0, 0, 1, 0, 0}, - {"http://www.sun.com", 0, 0, 0, 0, 0, 1, 1}, - {"http://www.intel.com", 1, 1, 1, 0, 0, 0, 0}, - {"http://www.aol.com", 0, 1, 0, 0, 0, 1, 1}, - {"https://www.yahoo.com", 1, 1, 1, 1, 0, 1, 1}, - {"file://C|/Program Files", 1, 1, 1, 1, 0, 1, 1}, - {"ftp://ftp.netscape.com", 1, 1, 1, 1, 0, 1, 1}, - {"ftp://ftp.mozilla.org", 0, 0, 0, 0, 1, 0, 0}, + {"http://www.netscape.com/", 1, 1, 0, 0, 0, 1, 1}, + {"http://www.yahoo.com/", 0, 0, 1, 1, 0, 0, 0}, + {"http://www.cisco.com/", 0, 0, 0, 0, 1, 0, 0}, + {"http://www.sun.com/", 0, 0, 0, 0, 0, 1, 1}, + {"http://www.intel.com/", 1, 1, 1, 0, 0, 0, 0}, + {"http://www.aol.com/", 0, 1, 0, 0, 0, 1, 1}, + {"https://www.yahoo.com/", 1, 1, 1, 1, 0, 1, 1}, + {"data:text/plain;charset=iso-8859-7,%be%fg%be", + 1, 1, 1, 1, 0, 1, 1}, + {"file://C|/Program Files/", 1, 1, 1, 1, 0, 1, 1}, + {"ftp://ftp.netscape.com/", 1, 1, 1, 1, 0, 1, 1}, + {"ftp://ftp.mozilla.org/", 0, 0, 0, 0, 1, 0, 0}, }; void CNsIRequest::OnStartTests(UINT nMenuID) { if (nMenuID == ID_INTERFACES_NSIREQUEST_RUNALLTESTS) - RunAllTests(8); + RunAllTests(9); else - RunIndividualTests(nMenuID, 8); + RunIndividualTests(nMenuID, 9); } void CNsIRequest::RunIndividualTests(UINT nMenuID, int reqTotal) @@ -216,12 +218,12 @@ void CNsIRequest::RunAllTests(int reqTotal) nsIChannel * CNsIRequest::GetTheChannel(int i, nsILoadGroup *theLoadGroup) { - nsCAutoString theSpec; + nsCAutoString theSpec, retURI; nsCOMPtr theURI; nsCOMPtr theChannel; theSpec = ReqTable[i].theUrl; - FormatAndPrintOutput("the uri spec = ", theSpec, 2); + FormatAndPrintOutput("the input uri = ", theSpec, 2); rv = NS_NewURI(getter_AddRefs(theURI), theSpec); @@ -230,8 +232,15 @@ nsIChannel * CNsIRequest::GetTheChannel(int i, nsILoadGroup *theLoadGroup) QAOutput("We didn't get the URI. Test failed.", 1); return NULL; } - else + 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 URIs MATCH. Compare test passed.", 1); + else + QAOutput("The URIs didn't MATCH. Compare test failed.", 1); RvTestResult(rv, "NS_NewURI", 1); + } rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, theLoadGroup); if (!theChannel)