[BlackBerry] http authenticate dialog popup only once no matter authentication pass...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 May 2012 03:49:32 +0000 (03:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 May 2012 03:49:32 +0000 (03:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80135

Patch by Jonathan Dong <jonathan.dong@torchmobile.com.cn> on 2012-05-28
Reviewed by Rob Buis.

Source/WebCore:

RIM PR: 145660
Fixed a regression introduced by r111810, we should cancel the new
request when user press cancel button in http authentication challenge
dialog, and we should also allow sending empty username and password
with the request.
Also removed redundant codes which checked the existence of the
FrameLoaderClient pointer, as we've already moved authenticationChallenge()
out of class FrameLoaderClient, it is not needed.

Manual test added. Testing http authentication dialog relies on user interaction.

Resubmit the patch reverted by r115104 after the digest infinite loop
issue for BlackBerry porting get identified and fixed.

Internally reviewed by Joe Mason <jmason@rim.com>

* platform/blackberry/PageClientBlackBerry.h:
* platform/network/blackberry/NetworkJob.cpp:
(WebCore::NetworkJob::sendRequestWithCredentials):

Source/WebKit/blackberry:

RIM PR: 145660
Fixed a regression introduced by r111810, which used the wrong
credential object.

Added the interface function didReceivedAuthenticaitonChallenge()
in interface class DumpRenderTreeClient;
Called m_dumpRenderTree->didReceiveAuthenticationChallenge() in
WebPagePrivate::authenticationChallenge() when DRT is enabled.

Test: reuse existing test cases:
http/tests/loading/basic-credentials-sent-automatically.html
http/tests/loading/basic-auth-resend-wrong-credentials.html

Resubmit the patch reverted by r115104 after the digest infinite loop
issue for BlackBerry porting get identified and fixed.

Internally reviewed by Joe Mason <jmason@rim.com>

* Api/DumpRenderTreeClient.h:
(WebCore):
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::authenticationChallenge):
* Api/WebPageClient.h:
* Api/WebPage_p.h:
(WebPagePrivate):

Tools:

Implemented interface function didReceiveAuthenticationChallenge in class
DumpRenderTree.

Resubmit the patch reverted by r115104 after the digest infinite loop
issue for BlackBerry porting get identified and fixed.

Internally reviewed by Joe Mason <jmason@rim.com>

* DumpRenderTree/blackberry/DumpRenderTree.cpp:
(drtCredentialDescription):
(BlackBerry::WebKit::DumpRenderTree::didReceiveAuthenticationChallenge):
(WebKit):
* DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h:
(WebCore):
(DumpRenderTree):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@118719 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/blackberry/PageClientBlackBerry.h
Source/WebCore/platform/network/blackberry/NetworkJob.cpp
Source/WebKit/blackberry/Api/DumpRenderTreeClient.h
Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/Api/WebPageClient.h
Source/WebKit/blackberry/Api/WebPage_p.h
Source/WebKit/blackberry/ChangeLog
Tools/ChangeLog
Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp
Tools/DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h

index c438616..457d780 100644 (file)
@@ -1,5 +1,32 @@
 2012-05-28  Jonathan Dong  <jonathan.dong@torchmobile.com.cn>
 
+        [BlackBerry] http authenticate dialog popup only once no matter authentication pass or fail
+        https://bugs.webkit.org/show_bug.cgi?id=80135
+
+        Reviewed by Rob Buis.
+
+        RIM PR: 145660
+        Fixed a regression introduced by r111810, we should cancel the new
+        request when user press cancel button in http authentication challenge
+        dialog, and we should also allow sending empty username and password
+        with the request.
+        Also removed redundant codes which checked the existence of the
+        FrameLoaderClient pointer, as we've already moved authenticationChallenge()
+        out of class FrameLoaderClient, it is not needed.
+
+        Manual test added. Testing http authentication dialog relies on user interaction.
+
+        Resubmit the patch reverted by r115104 after the digest infinite loop
+        issue for BlackBerry porting get identified and fixed.
+
+        Internally reviewed by Joe Mason <jmason@rim.com>
+
+        * platform/blackberry/PageClientBlackBerry.h:
+        * platform/network/blackberry/NetworkJob.cpp:
+        (WebCore::NetworkJob::sendRequestWithCredentials):
+
+2012-05-28  Jonathan Dong  <jonathan.dong@torchmobile.com.cn>
+
         [BlackBerry] http authentication challenge issue when loading favicon
         https://bugs.webkit.org/show_bug.cgi?id=87665
 
index 8f959dc..8a1f887 100644 (file)
@@ -70,7 +70,7 @@ public:
     virtual int showAlertDialog(BlackBerry::WebKit::WebPageClient::AlertType) = 0;
     virtual bool isActive() const = 0;
     virtual bool isVisible() const = 0;
-    virtual WebCore::Credential authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&) = 0;
+    virtual bool authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&, WebCore::Credential&) = 0;
     virtual SaveCredentialType notifyShouldSaveCredential(bool) = 0;
 };
 
index 99f3f22..005352e 100644 (file)
@@ -772,9 +772,6 @@ bool NetworkJob::sendRequestWithCredentials(ProtectionSpaceServerType type, Prot
         String username;
         String password;
 
-        if (!m_frame || !m_frame->loader() || !m_frame->loader()->client())
-            return false;
-
         if (type == ProtectionSpaceProxyHTTP) {
             username = BlackBerry::Platform::Client::get()->getProxyUsername().c_str();
             password = BlackBerry::Platform::Client::get()->getProxyPassword().c_str();
@@ -791,15 +788,14 @@ bool NetworkJob::sendRequestWithCredentials(ProtectionSpaceServerType type, Prot
                 m_handle->getInternal()->m_user = "";
                 m_handle->getInternal()->m_pass = "";
             } else {
-                Credential inputCredential = m_frame->page()->chrome()->client()->platformPageClient()->authenticationChallenge(newURL, protectionSpace);
+                Credential inputCredential;
+                if (!m_frame->page()->chrome()->client()->platformPageClient()->authenticationChallenge(newURL, protectionSpace, inputCredential))
+                    return false;
                 username = inputCredential.user();
                 password = inputCredential.password();
             }
         }
 
-        if (username.isEmpty() && password.isEmpty())
-            return false;
-
         credential = Credential(username, password, CredentialPersistenceForSession);
 
         m_handle->getInternal()->m_currentWebChallenge = AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError());
index 03eb5bb..ce6dd27 100644 (file)
@@ -25,6 +25,7 @@
 #include <JavaScriptCore/JSObjectRef.h>
 
 namespace WebCore {
+class Credential;
 class Frame;
 class DOMWrapperWorld;
 class NavigationAction;
@@ -81,6 +82,7 @@ public:
     virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, int insertAction) = 0;
     virtual bool shouldInsertText(const WTF::String&, WebCore::Range*, int insertAction) = 0;
     virtual bool isSelectTrailingWhitespaceEnabled() const = 0;
+    virtual bool didReceiveAuthenticationChallenge(WebCore::Credential&) = 0;
 
 };
 }
index e3d6c14..7ba1a35 100644 (file)
@@ -2135,26 +2135,32 @@ bool WebPagePrivate::isActive() const
     return m_client->isActive();
 }
 
-Credential WebPagePrivate::authenticationChallenge(const KURL& url, const ProtectionSpace& protectionSpace)
+bool WebPagePrivate::authenticationChallenge(const KURL& url, const ProtectionSpace& protectionSpace, Credential& inputCredential)
 {
     WebString username;
     WebString password;
 
+#if ENABLE_DRT
+    if (m_dumpRenderTree)
+        return m_dumpRenderTree->didReceiveAuthenticationChallenge(inputCredential);
+#endif
+
 #if ENABLE(BLACKBERRY_CREDENTIAL_PERSIST)
     if (!m_webSettings->isPrivateBrowsingEnabled())
         credentialManager().autofillAuthenticationChallenge(protectionSpace, username, password);
 #endif
 
-    m_client->authenticationChallenge(protectionSpace.realm().characters(), protectionSpace.realm().length(), username, password);
+    bool isConfirmed = m_client->authenticationChallenge(protectionSpace.realm().characters(), protectionSpace.realm().length(), username, password);
 
 #if ENABLE(BLACKBERRY_CREDENTIAL_PERSIST)
-    Credential inputCredential(username, password, CredentialPersistencePermanent);
-    if (!m_webSettings->isPrivateBrowsingEnabled())
-        credentialManager().saveCredentialIfConfirmed(this, CredentialTransformData(url, protectionSpace, inputCredential));
+    Credential credential(username, password, CredentialPersistencePermanent);
+    if (!m_webSettings->isPrivateBrowsingEnabled() && isConfirmed)
+        credentialManager().saveCredentialIfConfirmed(this, CredentialTransformData(url, protectionSpace, credential));
 #else
-    Credential inputCredential(username, password, CredentialPersistenceNone);
+    Credential credential(username, password, CredentialPersistenceNone);
 #endif
-    return inputCredential;
+    inputCredential = credential;
+    return isConfirmed;
 }
 
 PageClientBlackBerry::SaveCredentialType WebPagePrivate::notifyShouldSaveCredential(bool isNew)
index fee4a59..b89540f 100644 (file)
@@ -207,7 +207,7 @@ public:
     virtual void animateBlockZoom(const Platform::FloatPoint& finalPoint, double finalScale) = 0;
 
     virtual void setPreventsScreenIdleDimming(bool noDimming) = 0;
-    virtual void authenticationChallenge(const unsigned short* realm, unsigned int realmLength, WebString& username, WebString& password) = 0;
+    virtual bool authenticationChallenge(const unsigned short* realm, unsigned int realmLength, WebString& username, WebString& password) = 0;
     virtual SaveCredentialType notifyShouldSaveCredential(bool isNew) = 0;
     virtual void notifyPopupAutofillDialog(const std::vector<std::string>&, const Platform::IntRect&) = 0;
 
index 9fff201..3ebc0b8 100644 (file)
@@ -183,7 +183,7 @@ public:
     virtual int showAlertDialog(WebPageClient::AlertType atype);
     virtual bool isActive() const;
     virtual bool isVisible() const { return m_visible; }
-    virtual WebCore::Credential authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&);
+    virtual bool authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&, WebCore::Credential&);
     virtual SaveCredentialType notifyShouldSaveCredential(bool);
 
     // Called from within WebKit via ChromeClientBlackBerry.
index dcd272b..c849abb 100644 (file)
@@ -1,3 +1,36 @@
+2012-05-28  Jonathan Dong  <jonathan.dong@torchmobile.com.cn>
+
+        [BlackBerry] http authenticate dialog popup only once no matter authentication pass or fail
+        https://bugs.webkit.org/show_bug.cgi?id=80135
+
+        Reviewed by Rob Buis.
+
+        RIM PR: 145660
+        Fixed a regression introduced by r111810, which used the wrong
+        credential object.
+
+        Added the interface function didReceivedAuthenticaitonChallenge()
+        in interface class DumpRenderTreeClient;
+        Called m_dumpRenderTree->didReceiveAuthenticationChallenge() in
+        WebPagePrivate::authenticationChallenge() when DRT is enabled.
+
+        Test: reuse existing test cases:
+        http/tests/loading/basic-credentials-sent-automatically.html
+        http/tests/loading/basic-auth-resend-wrong-credentials.html
+
+        Resubmit the patch reverted by r115104 after the digest infinite loop
+        issue for BlackBerry porting get identified and fixed.
+
+        Internally reviewed by Joe Mason <jmason@rim.com>
+
+        * Api/DumpRenderTreeClient.h:
+        (WebCore):
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::authenticationChallenge):
+        * Api/WebPageClient.h:
+        * Api/WebPage_p.h:
+        (WebPagePrivate):
+
 2012-05-28  Arvid Nilsson  <anilsson@rim.com>
 
         [BlackBerry] Always create a compositor
index 6362c74..368a4a2 100644 (file)
@@ -1,3 +1,26 @@
+2012-05-28  Jonathan Dong  <jonathan.dong@torchmobile.com.cn>
+
+        [BlackBerry] http authenticate dialog popup only once no matter authentication pass or fail
+        https://bugs.webkit.org/show_bug.cgi?id=80135
+
+        Reviewed by Rob Buis.
+
+        Implemented interface function didReceiveAuthenticationChallenge in class
+        DumpRenderTree.
+
+        Resubmit the patch reverted by r115104 after the digest infinite loop
+        issue for BlackBerry porting get identified and fixed.
+
+        Internally reviewed by Joe Mason <jmason@rim.com>
+
+        * DumpRenderTree/blackberry/DumpRenderTree.cpp:
+        (drtCredentialDescription):
+        (BlackBerry::WebKit::DumpRenderTree::didReceiveAuthenticationChallenge):
+        (WebKit):
+        * DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h:
+        (WebCore):
+        (DumpRenderTree):
+
 2012-05-25  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
 
         WebKitTestRunner needs to support layoutTestController.setJavaScriptProfilingEnabled
index 620e6ac..a19742c 100644 (file)
@@ -24,6 +24,7 @@
 #include "BackForwardController.h"
 #include "BackForwardListImpl.h"
 #include "CString.h"
+#include "Credential.h"
 #include "DatabaseTracker.h"
 #include "DocumentLoader.h"
 #include "DumpRenderTree/GCController.h"
@@ -124,6 +125,12 @@ static String drtFrameDescription(WebCore::Frame* frame)
     return "frame (anonymous)";
 }
 
+static WTF::String drtCredentialDescription(WebCore::Credential&)
+{
+    // TODO: Implementation needed.
+    return "<unknown>";
+}
+
 static bool shouldLogFrameLoadDelegates(const String& url)
 {
     return url.contains("loading/");
@@ -857,6 +864,20 @@ void DumpRenderTree::didReceiveResponseForFrame(WebCore::Frame* frame, const Web
         printf("%s has MIME type %s\n", response.url().lastPathComponent().utf8().data(), response.mimeType().utf8().data());
 }
 
+bool DumpRenderTree::didReceiveAuthenticationChallenge(WebCore::Credential& credential)
+{
+    if (!gLayoutTestController->handlesAuthenticationChallenges()) {
+        credential = WebCore::Credential();
+        printf("%s - didReceiveAuthenticationChallenge - Simulating cancelled authentication\n", drtCredentialDescription(credential).utf8().data());
+        return false;
+    }
+    const char* user = gLayoutTestController->authenticationUsername().c_str();
+    const char* password = gLayoutTestController->authenticationPassword().c_str();
+    credential = WebCore::Credential(user, password, WebCore::CredentialPersistenceForSession);
+    printf("%s - didReceiveAuthenticationChallenge - Responding with %s:%s\n", drtCredentialDescription(credential).utf8().data(), user, password);
+    return true;
+}
+
 }
 }
 
index 2ff6916..c6eba9d 100644 (file)
@@ -28,8 +28,9 @@
 #include <wtf/Vector.h>
 
 namespace WebCore {
-class Frame;
+class Credential;
 class DOMWrapperWorld;
+class Frame;
 class Range;
 }
 
@@ -101,6 +102,7 @@ public:
 
     bool isSelectTrailingWhitespaceEnabled() const { return s_selectTrailingWhitespaceEnabled; }
     void setSelectTrailingWhitespaceEnabled(bool enabled) { s_selectTrailingWhitespaceEnabled = enabled; }
+    bool didReceiveAuthenticationChallenge(WebCore::Credential&);
 
 private:
     void runTest(const String& url);