Changeset 154098 in webkit
- Timestamp:
- Aug 15, 2013 6:15:36 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/gtk/ChangeLog
r154041 r154098 1 2013-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 1 28 2013-08-13 Xabier Rodriguez Calvar <calvaris@igalia.com> 2 29 -
trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h
r148088 r154098 137 137 static FrameLoadEventCallback s_frameLoadEventCallback; 138 138 139 typedef bool (*AuthenticationCallback) (CString& username, CString& password );139 typedef bool (*AuthenticationCallback) (CString& username, CString& password, WebKitWebResource* webResource); 140 140 static void setAuthenticationCallback(AuthenticationCallback); 141 141 static AuthenticationCallback s_authenticationCallback; -
trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
r153927 r154098 191 191 } 192 192 193 // We convert this to string because it's easier to use strings as 194 // keys in a GHashTable. 195 static char* toString(unsigned long identifier) 196 { 197 return g_strdup_printf("%ld", identifier); 198 } 199 193 200 void FrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const AuthenticationChallenge& challenge) 194 201 { 202 WebKitWebView* view = webkit_web_frame_get_web_view(m_frame); 203 195 204 if (DumpRenderTreeSupportGtk::dumpRenderTreeModeEnabled()) { 196 205 CString username; 197 206 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)) { 199 210 challenge.authenticationClient()->receivedRequestToContinueWithoutCredential(challenge); 200 211 return; … … 205 216 } 206 217 207 WebKitWebView* view = webkit_web_frame_get_web_view(m_frame);208 218 209 219 CredentialStorageMode credentialStorageMode; … … 221 231 { 222 232 notImplemented(); 223 }224 225 // We convert this to string because it's easier to use strings as226 // keys in a GHashTable.227 static char* toString(unsigned long identifier)228 {229 return g_strdup_printf("%ld", identifier);230 233 } 231 234 -
trunk/Tools/ChangeLog
r154084 r154098 1 2013-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 1 38 2013-08-14 Tim Horton <timothy_horton@apple.com> 2 39 -
trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp
r153852 r154098 46 46 #include "WorkQueueItem.h" 47 47 #include <JavaScriptCore/JavaScript.h> 48 #include <WebCore/platform/network/soup/GOwnPtrSoup.h> 48 49 #include <cassert> 49 50 #include <cstdlib> … … 56 57 #include <wtf/gobject/GOwnPtr.h> 57 58 #include <wtf/gobject/GlibUtilities.h> 59 #include <wtf/text/WTFString.h> 58 60 59 61 #if PLATFORM(X11) … … 423 425 { 424 426 return !waitToDumpWatchdog && useTimeoutWatchdog; 427 } 428 429 CString 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(); 425 448 } 426 449 … … 1141 1164 } 1142 1165 1143 // FIXME (119584): Make this match other platforms better. 1144 static CString pathFromSoupURI(SoupURI* uri) 1166 static String pathFromSoupURI(SoupURI* uri) 1145 1167 { 1146 1168 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(); 1159 1187 } 1160 1188 … … 1162 1190 { 1163 1191 if (!soupMessage) 1164 return CString( );1192 return CString("(null)"); 1165 1193 if (SoupURI* requestURI = soup_message_get_uri(soupMessage)) 1166 return pathFromSoupURI(requestURI) ;1167 return CString( );1194 return pathFromSoupURI(requestURI).utf8(); 1195 return CString("(null)"); 1168 1196 } 1169 1197 … … 1175 1203 static CString convertWebResourceToURLPath(WebKitWebResource* webResource) 1176 1204 { 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(); 1181 1207 } 1182 1208 … … 1193 1219 { 1194 1220 if (!uri) 1195 return CString(" ");1221 return CString("(null)"); 1196 1222 1197 1223 GOwnPtr<char> uriString(soup_uri_to_string(uri, false)); 1198 1224 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 else1211 description = convertWebResourceToURLPath(webResource);1212 1213 if (uri)1214 soup_uri_free(uri);1215 1216 return description;1217 1225 } 1218 1226 … … 1239 1247 1240 1248 if (!soupMessage) 1241 return CString(""); 1242 1243 SoupURI* requestURI = soup_message_get_uri(soupMessage); 1249 return CString("(null)"); 1250 1244 1251 SoupURI* mainDocumentURI = soup_message_get_first_party(soupMessage); 1245 CString requestURIString(descriptionSuitableForTestResult(requestURI));1246 1252 CString mainDocumentURIString(descriptionSuitableForTestResult(mainDocumentURI)); 1247 1253 CString path(convertNetworkRequestToURLPath(request)); … … 1265 1271 path = convertSoupMessageToURLPath(soupMessage); 1266 1272 } else 1267 path = CString(" ");1273 path = CString("(null)"); 1268 1274 1269 1275 GOwnPtr<char> description(g_strdup_printf("<NSURLResponse %s, http status code %d>", path.data(), statusCode)); … … 1335 1341 { 1336 1342 if (!done && gTestRunner->dumpResourceLoadCallbacks()) 1337 printf("%s - didFinishLoading\n", descriptionSuitableForTestResult(webView, webFrame,webResource).data());1343 printf("%s - didFinishLoading\n", convertWebResourceToURLPath(webResource).data()); 1338 1344 } 1339 1345 … … 1342 1348 if (!done && gTestRunner->dumpResourceLoadCallbacks()) { 1343 1349 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(), 1345 1351 webErrorString.data()); 1346 1352 } … … 1388 1394 } 1389 1395 1390 static bool authenticationCallback(CString& username, CString& password) 1391 { 1396 static bool authenticationCallback(CString& username, CString& password, WebKitWebResource* webResource) 1397 { 1398 CString description(convertWebResourceToURLPath(webResource)); 1399 1392 1400 if (!gTestRunner->handlesAuthenticationChallenges()) { 1393 printf(" <unknown> - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet\n");1401 printf("%s - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet\n", description.data()); 1394 1402 return false; 1395 1403 } … … 1397 1405 username = gTestRunner->authenticationUsername().c_str(); 1398 1406 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()); 1400 1408 return true; 1401 1409 } -
trunk/Tools/DumpRenderTree/gtk/DumpRenderTreeGtk.h
r106126 r154098 30 30 #define DumpRenderTreeGtk_h 31 31 32 #include <webkit/webkitdefines.h>33 32 #include <JavaScriptCore/JSBase.h> 34 33 #include <glib.h> 34 #include <libsoup/soup.h> 35 #include <webkit/webkitdefines.h> 35 36 #include <wtf/text/CString.h> 36 37 … … 45 46 void setWaitToDumpWatchdog(guint timer); 46 47 bool shouldSetWaitToDumpWatchdog(); 48 CString soupURIToStringPreservingPassword(SoupURI* soupURI); 47 49 48 50 #endif // DumpRenderTreeGtk_h -
trunk/Tools/DumpRenderTree/gtk/TestRunnerGtk.cpp
r148088 r154098 147 147 GOwnPtr<char> testURI(g_filename_to_uri(testPath.get(), 0, 0)); 148 148 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 the159 // URI string and then reinsert any credentials that were present in the SoupURI. All tests that160 // 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();170 149 } 171 150
Note: See TracChangeset
for help on using the changeset viewer.