diff --git a/mozilla/content/base/src/nsXMLHttpRequest.cpp b/mozilla/content/base/src/nsXMLHttpRequest.cpp index 719e3ca56a0..2e6b2ec52b1 100644 --- a/mozilla/content/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/content/base/src/nsXMLHttpRequest.cpp @@ -68,8 +68,6 @@ #include "nsVariant.h" #include "nsIParser.h" #include "nsLoadListenerProxy.h" -#include "nsIWindowWatcher.h" -#include "nsIAuthPrompt.h" #include "nsStringStream.h" #include "nsIStreamConverterService.h" #include "nsICachingChannel.h" @@ -2737,8 +2735,7 @@ nsXMLHttpRequest::GetInterface(const nsIID & aIID, void **aResult) } // Now give mNotificationCallbacks (if non-null) a chance to return the - // desired interface. Note that this means that it can override our - // nsIAuthPrompt impl, but that's fine, if it has a better auth prompt idea. + // desired interface. if (mNotificationCallbacks) { nsresult rv = mNotificationCallbacks->GetInterface(aIID, aResult); if (NS_SUCCEEDED(rv)) { @@ -2746,25 +2743,6 @@ nsXMLHttpRequest::GetInterface(const nsIID & aIID, void **aResult) return rv; } } - - if (aIID.Equals(NS_GET_IID(nsIAuthPrompt))) { - *aResult = nsnull; - - nsresult rv; - nsCOMPtr ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv)); - if (NS_FAILED(rv)) - return rv; - - nsCOMPtr prompt; - rv = ww->GetNewAuthPrompter(nsnull, getter_AddRefs(prompt)); - if (NS_FAILED(rv)) - return rv; - - nsIAuthPrompt *p = prompt.get(); - NS_ADDREF(p); - *aResult = p; - return NS_OK; - } return QueryInterface(aIID, aResult); } diff --git a/mozilla/content/xml/document/src/Makefile.in b/mozilla/content/xml/document/src/Makefile.in index b3a66975ccc..533119c0ad3 100644 --- a/mozilla/content/xml/document/src/Makefile.in +++ b/mozilla/content/xml/document/src/Makefile.in @@ -66,7 +66,6 @@ REQUIRES = xpcom \ exthandler \ mimetype \ unicharutil \ - windowwatcher \ locale \ util \ $(NULL) diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index 41e3e174fea..f319357e2e6 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -83,7 +83,6 @@ #include "nsThreadUtils.h" #include "nsJSUtils.h" #include "nsCRT.h" -#include "nsIWindowWatcher.h" #include "nsIAuthPrompt.h" #include "nsIScriptGlobalObjectOwner.h" #include "nsIJSContextStack.h" @@ -242,27 +241,6 @@ nsXMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup, NS_IMETHODIMP nsXMLDocument::GetInterface(const nsIID& aIID, void** aSink) { - if (aIID.Equals(NS_GET_IID(nsIAuthPrompt))) { - NS_ENSURE_ARG_POINTER(aSink); - *aSink = nsnull; - - nsresult rv; - nsCOMPtr ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv)); - if (NS_FAILED(rv)) - return rv; - - nsCOMPtr prompt; - rv = ww->GetNewAuthPrompter(nsnull, getter_AddRefs(prompt)); - if (NS_FAILED(rv)) - return rv; - - nsIAuthPrompt *p = prompt.get(); - NS_ADDREF(p); - *aSink = p; - return NS_OK; - } - - return QueryInterface(aIID, aSink); } diff --git a/mozilla/toolkit/components/passwordmgr/test/Makefile.in b/mozilla/toolkit/components/passwordmgr/test/Makefile.in index 118dd90de50..016a6a96be3 100644 --- a/mozilla/toolkit/components/passwordmgr/test/Makefile.in +++ b/mozilla/toolkit/components/passwordmgr/test/Makefile.in @@ -63,11 +63,14 @@ MOCHI_TESTS = \ test_bug_360493_2.html \ test_bug_391514.html \ test_prompt.html \ + test_xhr.html \ + test_xml_load.html \ test_zzz_finish.html \ $(NULL) MOCHI_CONTENT = \ pwmgr_common.js \ + prompt_common.js \ authenticate.sjs \ $(NULL) diff --git a/mozilla/toolkit/components/passwordmgr/test/authenticate.sjs b/mozilla/toolkit/components/passwordmgr/test/authenticate.sjs index c01804a1552..534bb987275 100644 --- a/mozilla/toolkit/components/passwordmgr/test/authenticate.sjs +++ b/mozilla/toolkit/components/passwordmgr/test/authenticate.sjs @@ -70,11 +70,13 @@ function reallyHandleRequest(request, response) { response.setStatusLine("1.0", 200, "OK"); } - response.setHeader("Content-Type", "text/html", false); - response.write("Login: " + (requestAuth ? "FAIL" : "PASS") + "
\n"); - response.write("Auth: " + authHeader + "
\n"); - response.write("User: " + actual_user + "
\n"); - response.write("Pass: " + actual_pass + "
\n"); + response.setHeader("Content-Type", "application/xhtml+xml", false); + response.write(""); + response.write("

Login: " + (requestAuth ? "FAIL" : "PASS") + "

\n"); + response.write("

Auth: " + authHeader + "

\n"); + response.write("

User: " + actual_user + "

\n"); + response.write("

Pass: " + actual_pass + "

\n"); + response.write(""); } diff --git a/mozilla/toolkit/components/passwordmgr/test/prompt_common.js b/mozilla/toolkit/components/passwordmgr/test/prompt_common.js new file mode 100644 index 00000000000..c93d3b131f3 --- /dev/null +++ b/mozilla/toolkit/components/passwordmgr/test/prompt_common.js @@ -0,0 +1,77 @@ +netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + +const Ci = Components.interfaces; +ok(Ci != null, "Access Ci"); +const Cc = Components.classes; +ok(Cc != null, "Access Cc"); + +var didDialog; + +var timer; // keep in outer scope so it's not GC'd before firing +function startCallbackTimer() { + didDialog = false; + + // Delay before the callback twiddles the prompt. + const dialogDelay = 10; + + // Use a timer to invoke a callback to twiddle the authentication dialog + timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); + timer.init(observer, dialogDelay, Ci.nsITimer.TYPE_ONE_SHOT); +} + + +var observer = { + QueryInterface : function (iid) { + const interfaces = [Ci.nsIObserver, + Ci.nsISupports, Ci.nsISupportsWeakReference]; + + if (!interfaces.some( function(v) { return iid.equals(v) } )) + throw Components.results.NS_ERROR_NO_INTERFACE; + return this; + }, + + observe : function (subject, topic, data) { + netscape.security.PrivilegeManager + .enablePrivilege('UniversalXPConnect'); + + var doc = getDialogDoc(); + if (doc) + handleDialog(doc, testNum); + else + startCallbackTimer(); // try again in a bit + } +}; + +function getDialogDoc() { + // Find the which contains notifyWindow, by looking + // through all the open windows and all the in each. + var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. + getService(Ci.nsIWindowMediator); + //var enumerator = wm.getEnumerator("navigator:browser"); + var enumerator = wm.getXULWindowEnumerator(null); + + while (enumerator.hasMoreElements()) { + var win = enumerator.getNext(); + var windowDocShell = win.QueryInterface(Ci.nsIXULWindow).docShell; + + var containedDocShells = windowDocShell.getDocShellEnumerator( + Ci.nsIDocShellTreeItem.typeChrome, + Ci.nsIDocShell.ENUMERATE_FORWARDS); + while (containedDocShells.hasMoreElements()) { + // Get the corresponding document for this docshell + var childDocShell = containedDocShells.getNext(); + // We don't want it if it's not done loading. + if (childDocShell.busyFlags != Ci.nsIDocShell.BUSY_FLAGS_NONE) + continue; + var childDoc = childDocShell.QueryInterface(Ci.nsIDocShell) + .contentViewer + .DOMDocument; + + //ok(true, "Got window: " + childDoc.location.href); + if (childDoc.location.href == "chrome://global/content/commonDialog.xul") + return childDoc; + } + } + + return null; +} diff --git a/mozilla/toolkit/components/passwordmgr/test/test_prompt.html b/mozilla/toolkit/components/passwordmgr/test/test_prompt.html index 0184b5d376c..41b3cfdf502 100644 --- a/mozilla/toolkit/components/passwordmgr/test/test_prompt.html +++ b/mozilla/toolkit/components/passwordmgr/test/test_prompt.html @@ -5,6 +5,7 @@ + @@ -19,6 +20,7 @@ Login Manager test: username/password prompts diff --git a/mozilla/toolkit/components/passwordmgr/test/test_xhr.html b/mozilla/toolkit/components/passwordmgr/test/test_xhr.html new file mode 100644 index 00000000000..5402b6ea8bc --- /dev/null +++ b/mozilla/toolkit/components/passwordmgr/test/test_xhr.html @@ -0,0 +1,184 @@ + + + + Test for Login Manager + + + + + + + +Login Manager test: XHR prompt +

+ + + +
+
+
+ + diff --git a/mozilla/toolkit/components/passwordmgr/test/test_xml_load.html b/mozilla/toolkit/components/passwordmgr/test/test_xml_load.html new file mode 100644 index 00000000000..cc854999c72 --- /dev/null +++ b/mozilla/toolkit/components/passwordmgr/test/test_xml_load.html @@ -0,0 +1,183 @@ + + + + Test for Login Manager + + + + + + + +Login Manager test: XML prompt +

+ + + +
+
+
+ +