Changeset 139140 in webkit


Ignore:
Timestamp:
Jan 8, 2013 5:41:17 PM (11 years ago)
Author:
Martin Robinson
Message:

WebKitTestRunner needs support for setHandlesAuthenticationChallenges
https://bugs.webkit.org/show_bug.cgi?id=103653

Reviewed by Anders Carlsson.

Tools:

Implement setHandlesAuthenticationChallenges in the UIProcess by sending credentials
and the enabled boolean to the UIProcess and then implementing the didReceiveAuthenticationChallengeInFrame
client callback.

  • WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: Exposed the new TestRunner

methods to the JavaScript API.

  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setHandlesAuthenticationChallenges): Added this callback for the JavaScript API.
(WTR::TestRunner::setAuthenticationUsername): Ditto.
(WTR::TestRunner::setAuthenticationPassword): Ditto.

  • WebKitTestRunner/InjectedBundle/TestRunner.h:

(TestRunner): Added new declarations for the above.

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::createWebViewWithOptions): Hook up the new didReceiveSynchronousMessageFromInjectedBundle
callback.
(WTR::TestController::resetStateToConsistentValues): Reset the credentials and enabled boolean between tests.
(WTR::TestController::didReceiveAuthenticationChallengeInFrame): Handle the callback by using
the authentication information passed from the InjectedBundle.

  • WebKitTestRunner/TestController.h:

(WTR::TestController::setHandlesAuthenticationChallenges): Added setter to allow TestInvocation
to communicate with the TestController.
(WTR::TestController::setAuthenticationUsername): Ditto.
(WTR::TestController::setAuthenticationPassword): Ditto.
(TestController):

  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveMessageFromInjectedBundle): Handle the messages sending authentication
information from the InjectedBundle.
(WTR::TestInvocation::outputText): Added this method so that the TestController can output
text to the TestInvocation text output.

  • WebKitTestRunner/TestInvocation.h:

(TestInvocation): Added declaration for new method.

LayoutTests:

Unskip authentication tests which are now passing.

  • platform/wk2/TestExpectations:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r139137 r139140  
     12013-01-08  Martin Robinson  <mrobinson@igalia.com>
     2
     3        WebKitTestRunner needs support for setHandlesAuthenticationChallenges
     4        https://bugs.webkit.org/show_bug.cgi?id=103653
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Unskip authentication tests which are now passing.
     9
     10        * platform/wk2/TestExpectations:
     11
    1122013-01-08  Justin Novosad  <junov@google.com>
    213
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r139118 r139140  
    388388# WebKitTestRunner should dump text/plain content as text
    389389http/tests/incremental/slow-utf8-text.pl
    390 
    391 # WebKitTestRunner needs layoutTestController.setHandlesAuthenticationChallenges
    392 http/tests/misc/authentication-redirect-1/authentication-sent-to-redirect-cross-origin.html
    393 http/tests/misc/authentication-redirect-2/authentication-sent-to-redirect-same-origin.html
    394 http/tests/misc/authentication-redirect-3/authentication-sent-to-redirect-same-origin-with-location-credentials.html
    395 http/tests/misc/authentication-redirect-4/authentication-sent-to-redirect-same-origin-url.html
    396 http/tests/loading/authentication-after-redirect-stores-wrong-credentials/authentication-after-redirect-stores-wrong-credentials.html
    397 http/tests/loading/basic-auth-resend-wrong-credentials.html
    398 http/tests/loading/basic-credentials-sent-automatically.html
    399 http/tests/security/401-logout/401-logout.php
    400 http/tests/xmlhttprequest/basic-auth-nopassword.html
    401 http/tests/xmlhttprequest/basic-auth-nouser.html
    402 http/tests/xmlhttprequest/remember-bad-password.html
    403 http/tests/xmlhttprequest/failed-auth.html
    404 http/tests/misc/401-alternative-content.php
    405390
    406391# WebKitTestRunner needs layoutTestController.setSmartInsertDeleteEnabled
  • trunk/Tools/ChangeLog

    r139129 r139140  
     12013-01-08  Martin Robinson  <mrobinson@igalia.com>
     2
     3        WebKitTestRunner needs support for setHandlesAuthenticationChallenges
     4        https://bugs.webkit.org/show_bug.cgi?id=103653
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Implement setHandlesAuthenticationChallenges in the UIProcess by sending credentials
     9        and the enabled boolean to the UIProcess and then implementing the didReceiveAuthenticationChallengeInFrame
     10        client callback.
     11
     12        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: Exposed the new TestRunner
     13        methods to the JavaScript API.
     14        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     15        (WTR::TestRunner::setHandlesAuthenticationChallenges): Added this callback for the JavaScript API.
     16        (WTR::TestRunner::setAuthenticationUsername): Ditto.
     17        (WTR::TestRunner::setAuthenticationPassword): Ditto.
     18        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     19        (TestRunner): Added new declarations for the above.
     20        * WebKitTestRunner/TestController.cpp:
     21        (WTR::TestController::createWebViewWithOptions): Hook up the new didReceiveSynchronousMessageFromInjectedBundle
     22        callback.
     23        (WTR::TestController::resetStateToConsistentValues): Reset the credentials and enabled boolean between tests.
     24        (WTR::TestController::didReceiveAuthenticationChallengeInFrame): Handle the callback by using
     25        the authentication information passed from the InjectedBundle.
     26        * WebKitTestRunner/TestController.h:
     27        (WTR::TestController::setHandlesAuthenticationChallenges): Added setter to allow TestInvocation
     28        to communicate with the TestController.
     29        (WTR::TestController::setAuthenticationUsername): Ditto.
     30        (WTR::TestController::setAuthenticationPassword): Ditto.
     31        (TestController):
     32        * WebKitTestRunner/TestInvocation.cpp:
     33        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): Handle the messages sending authentication
     34        information from the InjectedBundle.
     35        (WTR::TestInvocation::outputText): Added this method so that the TestController can output
     36        text to the TestInvocation text output.
     37        * WebKitTestRunner/TestInvocation.h:
     38        (TestInvocation): Added declaration for new method.
     39
    1402013-01-08  Benjamin Poulain  <benjamin@webkit.org>
    241
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r138232 r139140  
    196196    void queueLoadingScript(in DOMString script);
    197197    void queueNonLoadingScript(in DOMString script);
     198
     199    // Authentication
     200    void setHandlesAuthenticationChallenges(in boolean value);
     201    void setAuthenticationUsername(in DOMString username);
     202    void setAuthenticationPassword(in DOMString password);
    198203};
    199204
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r138232 r139140  
    3434#include "TestController.h"
    3535#include <WebCore/PageVisibilityState.h>
     36#include <WebKit2/WKBundle.h>
    3637#include <WebKit2/WKBundleBackForwardList.h>
    3738#include <WebKit2/WKBundleFrame.h>
     
    897898}
    898899
     900void TestRunner::setHandlesAuthenticationChallenges(bool handlesAuthenticationChallenges)
     901{
     902    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetHandlesAuthenticationChallenge"));
     903    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(handlesAuthenticationChallenges));
     904    WKBundlePostMessage(InjectedBundle::shared().bundle(), messageName.get(), messageBody.get());
     905}
     906
     907void TestRunner::setAuthenticationUsername(JSStringRef username)
     908{
     909    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetAuthenticationUsername"));
     910    WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(username));
     911    WKBundlePostMessage(InjectedBundle::shared().bundle(), messageName.get(), messageBody.get());
     912}
     913
     914void TestRunner::setAuthenticationPassword(JSStringRef password)
     915{
     916    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetAuthenticationPassword"));
     917    WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(password));
     918    WKBundlePostMessage(InjectedBundle::shared().bundle(), messageName.get(), messageBody.get());
     919}
     920
    899921} // namespace WTR
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r138326 r139140  
    163163    bool isPageBoxVisible(int pageIndex);
    164164
     165    // Authentication
     166    void setHandlesAuthenticationChallenges(bool);
     167    void setAuthenticationUsername(JSStringRef);
     168    void setAuthenticationPassword(JSStringRef);
     169
    165170    void setValueForUser(JSContextRef, JSValueRef element, JSStringRef value);
    166171
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r138608 r139140  
    3030#include "StringFunctions.h"
    3131#include "TestInvocation.h"
     32#include <WebKit2/WKAuthenticationChallenge.h>
     33#include <WebKit2/WKAuthenticationDecisionListener.h>
    3234#include <WebKit2/WKContextPrivate.h>
     35#include <WebKit2/WKCredential.h>
    3336#include <WebKit2/WKNotification.h>
    3437#include <WebKit2/WKNotificationManager.h>
     
    4548#include <string>
    4649#include <wtf/PassOwnPtr.h>
     50#include <wtf/text/CString.h>
    4751
    4852#if PLATFORM(MAC)
     
    437441        0, // didDisplayInsecureContentForFrame
    438442        0, // canAuthenticateAgainstProtectionSpaceInFrame
    439         0, // didReceiveAuthenticationChallengeInFrame
     443        didReceiveAuthenticationChallengeInFrame, // didReceiveAuthenticationChallengeInFrame
    440444        0, // didStartProgress
    441445        0, // didChangeProgress
     
    585589    m_workQueueManager.clearWorkQueue();
    586590
     591    m_handlesAuthenticationChallenges = false;
     592    m_authenticationUsername = String();
     593    m_authenticationPassword = String();
     594
    587595    // Reset main page back to about:blank
    588596    m_doneResetting = false;
     
    10031011}
    10041012
     1013void TestController::didReceiveAuthenticationChallengeInFrame(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo)
     1014{
     1015    static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveAuthenticationChallengeInFrame(page, frame, authenticationChallenge);
     1016}
     1017
    10051018void TestController::processDidCrash(WKPageRef page, const void* clientInfo)
    10061019{
     
    10301043    m_doneResetting = true;
    10311044    shared().notifyDone();
     1045}
     1046
     1047void TestController::didReceiveAuthenticationChallengeInFrame(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge)
     1048{
     1049    String message;
     1050    if (!m_handlesAuthenticationChallenges)
     1051        message = "<unknown> - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet\n";
     1052    else
     1053        message = String::format("<unknown> - didReceiveAuthenticationChallenge - Responding with %s:%s\n", m_authenticationUsername.utf8().data(), m_authenticationPassword.utf8().data());
     1054    m_currentInvocation->outputText(message);
     1055
     1056    WKAuthenticationDecisionListenerRef decisionListener = WKAuthenticationChallengeGetDecisionListener(authenticationChallenge);
     1057    if (!m_handlesAuthenticationChallenges) {
     1058        WKAuthenticationDecisionListenerUseCredential(decisionListener, 0);
     1059        return;
     1060    }
     1061    WKRetainPtr<WKStringRef> username(AdoptWK, WKStringCreateWithUTF8CString(m_authenticationUsername.utf8().data()));
     1062    WKRetainPtr<WKStringRef> password(AdoptWK, WKStringCreateWithUTF8CString(m_authenticationPassword.utf8().data()));
     1063    WKRetainPtr<WKCredentialRef> credential(AdoptWK, WKCredentialCreate(username.get(), password.get(), kWKCredentialPersistenceForSession));
     1064    WKAuthenticationDecisionListenerUseCredential(decisionListener, credential.get());
    10321065}
    10331066
  • trunk/Tools/WebKitTestRunner/TestController.h

    r138608 r139140  
    8484    WorkQueueManager& workQueueManager() { return m_workQueueManager; }
    8585
     86    void setHandlesAuthenticationChallenges(bool value) { m_handlesAuthenticationChallenges = value; }
     87    void setAuthenticationUsername(String username) { m_authenticationUsername = username; }
     88    void setAuthenticationPassword(String password) { m_authenticationPassword = password; }
     89
    8690private:
    8791    void initialize(int argc, const char* argv[]);
     
    122126
    123127    static void unavailablePluginButtonClicked(WKPageRef, WKPluginUnavailabilityReason, WKStringRef, WKStringRef, WKStringRef, const void*);
     128
     129    static void didReceiveAuthenticationChallengeInFrame(WKPageRef, WKFrameRef, WKAuthenticationChallengeRef, const void *clientInfo);
     130    void didReceiveAuthenticationChallengeInFrame(WKPageRef, WKFrameRef, WKAuthenticationChallengeRef);
    124131
    125132    // WKPagePolicyClient
     
    182189    bool m_policyDelegatePermissive;
    183190
     191    bool m_handlesAuthenticationChallenges;
     192    String m_authenticationUsername;
     193    String m_authenticationPassword;
     194
    184195#if PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
    185196    OwnPtr<EventSenderProxy> m_eventSenderProxy;
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r138368 r139140  
    591591    }
    592592
     593    if (WKStringIsEqualToUTF8CString(messageName, "SetHandlesAuthenticationChallenge")) {
     594        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
     595        WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
     596        TestController::shared().setHandlesAuthenticationChallenges(WKBooleanGetValue(value));
     597        return;
     598    }
     599
     600    if (WKStringIsEqualToUTF8CString(messageName, "SetAuthenticationUsername")) {
     601        ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
     602        WKStringRef username = static_cast<WKStringRef>(messageBody);
     603        TestController::shared().setAuthenticationUsername(toWTFString(username));
     604        return;
     605    }
     606
     607    if (WKStringIsEqualToUTF8CString(messageName, "SetAuthenticationPassword")) {
     608        ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
     609        WKStringRef password = static_cast<WKStringRef>(messageBody);
     610        TestController::shared().setAuthenticationPassword(toWTFString(password));
     611        return;
     612    }
     613
    593614    ASSERT_NOT_REACHED();
    594615}
     
    613634}
    614635
     636void TestInvocation::outputText(const WTF::String& text)
     637{
     638    m_textOutput.append(text);
     639}
     640
    615641} // namespace WTR
  • trunk/Tools/WebKitTestRunner/TestInvocation.h

    r138232 r139140  
    4848
    4949    void dumpWebProcessUnresponsiveness();
     50    void outputText(const WTF::String&);
    5051private:
    5152    void dumpResults();
Note: See TracChangeset for help on using the changeset viewer.