Changeset 154098 in webkit


Ignore:
Timestamp:
Aug 15, 2013 6:15:36 AM (11 years ago)
Author:
simon.pena@samsung.com
Message:

<https://webkit.org/b/119584> [Gtk] URL printing code in DumpRenderTree doesn't match WTR or Mac DRT

Reviewed by Gustavo Noronha Silva.

Following a similar approach as in r153977, return a path string
that is relative to main frame URL or just file name if the
resource is not in the same directory subtree, and replace empty
strings with "(null)".

Source/WebKit/gtk:

Update the AuthenticationCallback used in DumpRenderTree so that
it receives a WebKitWebResource, and update
dispatchDidReceiveAuthenticationChallenge so that it retrieves the
WebKitWebResource and passes it to the callback.

  • WebCoreSupport/DumpRenderTreeSupportGtk.h: Update the

AuthenticationCallback adding a WebKitWebResource parameter.

  • WebCoreSupport/FrameLoaderClientGtk.cpp:

(WebKit::toString): Define this function earlier so we can use it
to get the WebKitWebResource from the identifier in the
AuthenticationChallenge.
(WebKit::FrameLoaderClient::dispatchDidReceiveAuthenticationChallenge):
Use toString to retrieve a WebKitWebResource from the identifier
in the authentication challenge, and pass that WebKitWebResource
to the AuthenticationCallback.

Tools:

Update pathFromSoupURI so it behaves more closely to the other
ports, and remove the unused code after we no longer print
<unknown> in certain cases. Also move
soupURIToStringPreservingPassword to DumpRenderTreeGtk so it can
be used both in TestRunnerGtk and in DumpRenderTree.

  • DumpRenderTree/gtk/DumpRenderTree.cpp:

(soupURIToStringPreservingPassword): Moved from TestRunnerGtk so
we can print Soup URIs with the password, since soup_uri_to_string
doesn't preserve them.
(pathFromSoupURI): Updated following EFL implementation in
r153977, and return a WTFString instead of a CString.
(convertSoupMessageToURLPath): Return "(null)" instead of empty
strings, and handle the new return type of pathFromSoupURI.
(convertWebResourceToURLPath): Use a GOwnPtr to hold the Soup URI
reference, and handle the new return type of pathFromSoupURI.
(descriptionSuitableForTestResult): Remove unused code.
(didFinishLoading): Use convertResourceToURLPath.
(didFailLoadingWithError): Use convertResourceToURLPath.
(authenticationCallback): Display the URL of the authentication
challenge.

  • DumpRenderTree/gtk/DumpRenderTreeGtk.h: Declare

soupURIToStringPreservingPassword.

  • DumpRenderTree/gtk/TestRunnerGtk.cpp: Remove

soupURIToStringPreservingPassword.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/gtk/ChangeLog

    r154041 r154098  
     12013-08-15  Simon Pena  <simon.pena@samsung.com>
     2
     3        <https://webkit.org/b/119584> [Gtk] URL printing code in DumpRenderTree doesn't match WTR or Mac DRT
     4
     5        Reviewed by Gustavo Noronha Silva.
     6
     7        Following a similar approach as in r153977, return a path string
     8        that is relative to main frame URL or just file name if the
     9        resource is not in the same directory subtree, and replace empty
     10        strings with "(null)".
     11
     12        Update the AuthenticationCallback used in DumpRenderTree so that
     13        it receives a WebKitWebResource, and update
     14        dispatchDidReceiveAuthenticationChallenge so that it retrieves the
     15        WebKitWebResource and passes it to the callback.
     16
     17        * WebCoreSupport/DumpRenderTreeSupportGtk.h: Update the
     18        AuthenticationCallback adding a WebKitWebResource parameter.
     19        * WebCoreSupport/FrameLoaderClientGtk.cpp:
     20        (WebKit::toString): Define this function earlier so we can use it
     21        to get the WebKitWebResource from the identifier in the
     22        AuthenticationChallenge.
     23        (WebKit::FrameLoaderClient::dispatchDidReceiveAuthenticationChallenge):
     24        Use toString to retrieve a WebKitWebResource from the identifier
     25        in the authentication challenge, and pass that WebKitWebResource
     26        to the AuthenticationCallback.
     27
    1282013-08-13  Xabier Rodriguez Calvar  <calvaris@igalia.com>
    229
  • trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h

    r148088 r154098  
    137137    static FrameLoadEventCallback s_frameLoadEventCallback;
    138138
    139     typedef bool (*AuthenticationCallback) (CString& username, CString& password);
     139    typedef bool (*AuthenticationCallback) (CString& username, CString& password, WebKitWebResource* webResource);
    140140    static void setAuthenticationCallback(AuthenticationCallback);
    141141    static AuthenticationCallback s_authenticationCallback;
  • trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp

    r153927 r154098  
    191191}
    192192
     193// We convert this to string because it's easier to use strings as
     194// keys in a GHashTable.
     195static char* toString(unsigned long identifier)
     196{
     197    return g_strdup_printf("%ld", identifier);
     198}
     199
    193200void FrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long  identifier, const AuthenticationChallenge& challenge)
    194201{
     202    WebKitWebView* view = webkit_web_frame_get_web_view(m_frame);
     203
    195204    if (DumpRenderTreeSupportGtk::dumpRenderTreeModeEnabled()) {
    196205        CString username;
    197206        CString password;
    198         if (!DumpRenderTreeSupportGtk::s_authenticationCallback || !DumpRenderTreeSupportGtk::s_authenticationCallback(username, password)) {
     207        GOwnPtr<gchar> identifierString(toString(identifier));
     208        WebKitWebResource* webResource = webkit_web_view_get_resource(view, identifierString.get());
     209        if (!DumpRenderTreeSupportGtk::s_authenticationCallback || !DumpRenderTreeSupportGtk::s_authenticationCallback(username, password, webResource)) {
    199210            challenge.authenticationClient()->receivedRequestToContinueWithoutCredential(challenge);
    200211            return;
     
    205216    }
    206217
    207     WebKitWebView* view = webkit_web_frame_get_web_view(m_frame);
    208218
    209219    CredentialStorageMode credentialStorageMode;
     
    221231{
    222232    notImplemented();
    223 }
    224 
    225 // We convert this to string because it's easier to use strings as
    226 // keys in a GHashTable.
    227 static char* toString(unsigned long identifier)
    228 {
    229     return g_strdup_printf("%ld", identifier);
    230233}
    231234
  • trunk/Tools/ChangeLog

    r154084 r154098  
     12013-08-15  Simon Pena  <simon.pena@samsung.com>
     2
     3        <https://webkit.org/b/119584> [Gtk] URL printing code in DumpRenderTree doesn't match WTR or Mac DRT
     4
     5        Reviewed by Gustavo Noronha Silva.
     6
     7        Following a similar approach as in r153977, return a path string
     8        that is relative to main frame URL or just file name if the
     9        resource is not in the same directory subtree, and replace empty
     10        strings with "(null)".
     11
     12        Update pathFromSoupURI so it behaves more closely to the other
     13        ports, and remove the unused code after we no longer print
     14        <unknown> in certain cases. Also move
     15        soupURIToStringPreservingPassword to DumpRenderTreeGtk so it can
     16        be used both in TestRunnerGtk and in DumpRenderTree.
     17
     18        * DumpRenderTree/gtk/DumpRenderTree.cpp:
     19        (soupURIToStringPreservingPassword): Moved from TestRunnerGtk so
     20        we can print Soup URIs with the password, since soup_uri_to_string
     21        doesn't preserve them.
     22        (pathFromSoupURI): Updated following EFL implementation in
     23        r153977, and return a WTFString instead of a CString.
     24        (convertSoupMessageToURLPath): Return "(null)" instead of empty
     25        strings, and handle the new return type of pathFromSoupURI.
     26        (convertWebResourceToURLPath): Use a GOwnPtr to hold the Soup URI
     27        reference, and handle the new return type of pathFromSoupURI.
     28        (descriptionSuitableForTestResult): Remove unused code.
     29        (didFinishLoading): Use convertResourceToURLPath.
     30        (didFailLoadingWithError): Use convertResourceToURLPath.
     31        (authenticationCallback): Display the URL of the authentication
     32        challenge.
     33        * DumpRenderTree/gtk/DumpRenderTreeGtk.h: Declare
     34        soupURIToStringPreservingPassword.
     35        * DumpRenderTree/gtk/TestRunnerGtk.cpp: Remove
     36        soupURIToStringPreservingPassword.
     37
    1382013-08-14  Tim Horton  <timothy_horton@apple.com>
    239
  • trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp

    r153852 r154098  
    4646#include "WorkQueueItem.h"
    4747#include <JavaScriptCore/JavaScript.h>
     48#include <WebCore/platform/network/soup/GOwnPtrSoup.h>
    4849#include <cassert>
    4950#include <cstdlib>
     
    5657#include <wtf/gobject/GOwnPtr.h>
    5758#include <wtf/gobject/GlibUtilities.h>
     59#include <wtf/text/WTFString.h>
    5860
    5961#if PLATFORM(X11)
     
    423425{
    424426    return !waitToDumpWatchdog && useTimeoutWatchdog;
     427}
     428
     429CString soupURIToStringPreservingPassword(SoupURI* soupURI)
     430{
     431    if (!soupURI->password) {
     432        GOwnPtr<char> uriString(soup_uri_to_string(soupURI, FALSE));
     433        return uriString.get();
     434    }
     435
     436    // soup_uri_to_string does not insert the password into the string, so we need to create the
     437    // URI string and then reinsert any credentials that were present in the SoupURI. All tests that
     438    // use URL-embedded credentials use HTTP, so it's safe here.
     439    GOwnPtr<char> password(soupURI->password);
     440    GOwnPtr<char> user(soupURI->user);
     441    soupURI->password = 0;
     442    soupURI->user = 0;
     443
     444    GOwnPtr<char> uriString(soup_uri_to_string(soupURI, FALSE));
     445    String absoluteURIWithoutCredentialString = String::fromUTF8(uriString.get());
     446    String protocolAndCredential = String::format("http://%s:%s@", user ? user.get() : "", password.get());
     447    return absoluteURIWithoutCredentialString.replace("http://", protocolAndCredential).utf8();
    425448}
    426449
     
    11411164}
    11421165
    1143 // FIXME (119584): Make this match other platforms better.
    1144 static CString pathFromSoupURI(SoupURI* uri)
     1166static String pathFromSoupURI(SoupURI* uri)
    11451167{
    11461168    if (!uri)
    1147         return CString();
    1148 
    1149     if (g_str_equal(uri->scheme, "http") || g_str_equal(uri->scheme, "ftp")) {
    1150         GOwnPtr<char> uriString(soup_uri_to_string(uri, FALSE));
    1151         return CString(uriString.get());
    1152     }
    1153 
    1154     GOwnPtr<gchar> parentPath(g_path_get_dirname(uri->path));
    1155     GOwnPtr<gchar> pathDirname(g_path_get_basename(parentPath.get()));
    1156     GOwnPtr<gchar> pathBasename(g_path_get_basename(uri->path));
    1157     GOwnPtr<gchar> urlPath(g_strdup_printf("%s/%s", pathDirname.get(), pathBasename.get()));
    1158     return CString(urlPath.get());
     1169        return "(null)";
     1170
     1171    if (!g_str_equal(uri->scheme, "file"))
     1172        return soupURIToStringPreservingPassword(uri).data();
     1173
     1174    String pathString = uri->path;
     1175    GOwnPtr<gchar> pathBasename(g_path_get_basename(pathString.utf8().data()));
     1176
     1177    WebKitWebFrame* mainFrame = webkit_web_view_get_main_frame(webView);
     1178    GOwnPtr<SoupURI> mainFrameUri(soup_uri_new(webkit_web_frame_get_uri(mainFrame)));
     1179
     1180    String mainFrameUriPathString = mainFrameUri.get()->path;
     1181    String basePath = mainFrameUriPathString.substring(0, mainFrameUriPathString.reverseFind('/') + 1);
     1182
     1183    if (!basePath.isEmpty() && pathString.startsWith(basePath))
     1184        return pathString.substring(basePath.length());
     1185
     1186    return pathBasename.get();
    11591187}
    11601188
     
    11621190{
    11631191    if (!soupMessage)
    1164         return CString();
     1192        return CString("(null)");
    11651193    if (SoupURI* requestURI = soup_message_get_uri(soupMessage))
    1166         return pathFromSoupURI(requestURI);
    1167     return CString();
     1194        return pathFromSoupURI(requestURI).utf8();
     1195    return CString("(null)");
    11681196}
    11691197
     
    11751203static CString convertWebResourceToURLPath(WebKitWebResource* webResource)
    11761204{
    1177     SoupURI* uri = soup_uri_new(webkit_web_resource_get_uri(webResource));
    1178     CString urlPath(pathFromSoupURI(uri));
    1179     soup_uri_free(uri);
    1180     return urlPath;
     1205    GOwnPtr<SoupURI> uri(soup_uri_new(webkit_web_resource_get_uri(webResource)));
     1206    return pathFromSoupURI(uri.get()).utf8();
    11811207}
    11821208
     
    11931219{
    11941220    if (!uri)
    1195         return CString("");
     1221        return CString("(null)");
    11961222
    11971223    GOwnPtr<char> uriString(soup_uri_to_string(uri, false));
    11981224    return urlSuitableForTestResult(uriString.get());
    1199 }
    1200 
    1201 static CString descriptionSuitableForTestResult(WebKitWebView* webView, WebKitWebFrame* webFrame, WebKitWebResource* webResource)
    1202 {
    1203     SoupURI* uri = soup_uri_new(webkit_web_resource_get_uri(webResource));
    1204     CString description;
    1205     WebKitWebDataSource* dataSource = webkit_web_frame_get_data_source(webFrame);
    1206 
    1207     if (webResource == webkit_web_data_source_get_main_resource(dataSource)
    1208         && (!webkit_web_view_get_progress(webView) || g_str_equal(uri->scheme, "file")))
    1209         description = CString("<unknown>");
    1210     else
    1211         description = convertWebResourceToURLPath(webResource);
    1212 
    1213     if (uri)
    1214         soup_uri_free(uri);
    1215 
    1216     return description;
    12171225}
    12181226
     
    12391247
    12401248    if (!soupMessage)
    1241         return CString("");
    1242 
    1243     SoupURI* requestURI = soup_message_get_uri(soupMessage);
     1249        return CString("(null)");
     1250
    12441251    SoupURI* mainDocumentURI = soup_message_get_first_party(soupMessage);
    1245     CString requestURIString(descriptionSuitableForTestResult(requestURI));
    12461252    CString mainDocumentURIString(descriptionSuitableForTestResult(mainDocumentURI));
    12471253    CString path(convertNetworkRequestToURLPath(request));
     
    12651271        path = convertSoupMessageToURLPath(soupMessage);
    12661272    } else
    1267         path = CString("");
     1273        path = CString("(null)");
    12681274
    12691275    GOwnPtr<char> description(g_strdup_printf("<NSURLResponse %s, http status code %d>", path.data(), statusCode));
     
    13351341{
    13361342    if (!done && gTestRunner->dumpResourceLoadCallbacks())
    1337         printf("%s - didFinishLoading\n", descriptionSuitableForTestResult(webView, webFrame, webResource).data());
     1343        printf("%s - didFinishLoading\n", convertWebResourceToURLPath(webResource).data());
    13381344}
    13391345
     
    13421348    if (!done && gTestRunner->dumpResourceLoadCallbacks()) {
    13431349        CString webErrorString(descriptionSuitableForTestResult(webError, webResource));
    1344         printf("%s - didFailLoadingWithError: %s\n", descriptionSuitableForTestResult(webView, webFrame, webResource).data(),
     1350        printf("%s - didFailLoadingWithError: %s\n", convertWebResourceToURLPath(webResource).data(),
    13451351               webErrorString.data());
    13461352    }
     
    13881394}
    13891395
    1390 static bool authenticationCallback(CString& username, CString& password)
    1391 {
     1396static bool authenticationCallback(CString& username, CString& password, WebKitWebResource* webResource)
     1397{
     1398    CString description(convertWebResourceToURLPath(webResource));
     1399
    13921400    if (!gTestRunner->handlesAuthenticationChallenges()) {
    1393         printf("<unknown> - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet\n");
     1401        printf("%s - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet\n", description.data());
    13941402        return false;
    13951403    }
     
    13971405    username = gTestRunner->authenticationUsername().c_str();
    13981406    password = gTestRunner->authenticationPassword().c_str();
    1399     printf("<unknown> - didReceiveAuthenticationChallenge - Responding with %s:%s\n", username.data(), password.data());
     1407    printf("%s - didReceiveAuthenticationChallenge - Responding with %s:%s\n", description.data(), username.data(), password.data());
    14001408    return true;
    14011409}
  • trunk/Tools/DumpRenderTree/gtk/DumpRenderTreeGtk.h

    r106126 r154098  
    3030#define DumpRenderTreeGtk_h
    3131
    32 #include <webkit/webkitdefines.h>
    3332#include <JavaScriptCore/JSBase.h>
    3433#include <glib.h>
     34#include <libsoup/soup.h>
     35#include <webkit/webkitdefines.h>
    3536#include <wtf/text/CString.h>
    3637
     
    4546void setWaitToDumpWatchdog(guint timer);
    4647bool shouldSetWaitToDumpWatchdog();
     48CString soupURIToStringPreservingPassword(SoupURI* soupURI);
    4749
    4850#endif // DumpRenderTreeGtk_h
  • trunk/Tools/DumpRenderTree/gtk/TestRunnerGtk.cpp

    r148088 r154098  
    147147    GOwnPtr<char> testURI(g_filename_to_uri(testPath.get(), 0, 0));
    148148    return JSStringCreateWithUTF8CString(testURI.get());
    149 }
    150 
    151 static CString soupURIToStringPreservingPassword(SoupURI* soupURI)
    152 {
    153     if (!soupURI->password) {
    154         GOwnPtr<char> uriString(soup_uri_to_string(soupURI, FALSE));
    155         return uriString.get();
    156     }
    157 
    158     // soup_uri_to_string does not insert the password into the string, so we need to create the
    159     // URI string and then reinsert any credentials that were present in the SoupURI. All tests that
    160     // use URL-embedded credentials use HTTP, so it's safe here.
    161     GOwnPtr<char> password(soupURI->password);
    162     GOwnPtr<char> user(soupURI->user);
    163     soupURI->password = 0;
    164     soupURI->user = 0;
    165 
    166     GOwnPtr<char> uriString(soup_uri_to_string(soupURI, FALSE));
    167     String absoluteURIWithoutCredentialString = String::fromUTF8(uriString.get());
    168     String protocolAndCredential = String::format("http://%s:%s@", user ? user.get() : "", password.get());
    169     return absoluteURIWithoutCredentialString.replace("http://", protocolAndCredential).utf8();
    170149}
    171150
Note: See TracChangeset for help on using the changeset viewer.