Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Unified Diff: webkit/tools/test_shell/test_webview_delegate.cc

Issue 255024: Make dumpResourceLoadCallbacks() show relative paths which match the results ... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/tools/layout_tests/test_expectations.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/tools/test_shell/test_webview_delegate.cc
===================================================================
--- webkit/tools/test_shell/test_webview_delegate.cc (revision 27609)
+++ webkit/tools/test_shell/test_webview_delegate.cc (working copy)
@@ -122,6 +122,23 @@
return filename;
}
+// Used to write a platform neutral file:/// URL by taking the
+// filename and its directory. (e.g., converts
+// "file:///tmp/foo/bar.txt" to just "bar.txt").
+std::string DescriptionSuitableForTestResult(const std::string& url) {
+ if (url.empty() || std::string::npos == url.find("file://"))
+ return url;
+
+ size_t pos = url.rfind('/');
+ if (pos == std::string::npos || pos == 0)
+ return "ERROR:" + url;
+ pos = url.rfind('/', pos - 1);
+ if (pos == std::string::npos)
+ return "ERROR:" + url;
+
+ return url.substr(pos + 1);
+}
+
// Adds a file called "DRTFakeFile" to |data_object| (CF_HDROP). Use to fake
// dragging a file.
void AddDRTFakeFileToDataObject(WebDragData* drag_data) {
@@ -158,9 +175,10 @@
if (response.isNull())
return "(null)";
+ const std::string url = GURL(response.url()).possibly_invalid_spec();
return StringPrintf("<NSURLResponse %s, http status code %d>",
- GURL(response.url()).possibly_invalid_spec().c_str(),
- response.httpStatusCode());
+ DescriptionSuitableForTestResult(url).c_str(),
+ response.httpStatusCode());
}
std::string GetErrorDescription(const WebURLError& error) {
@@ -801,8 +819,10 @@
void TestWebViewDelegate::assignIdentifierToRequest(
WebFrame* frame, unsigned identifier, const WebURLRequest& request) {
- if (shell_->ShouldDumpResourceLoadCallbacks())
- resource_identifier_map_[identifier] = request.url().spec();
+ if (shell_->ShouldDumpResourceLoadCallbacks()) {
+ resource_identifier_map_[identifier] =
+ DescriptionSuitableForTestResult(request.url().spec());
+ }
}
void TestWebViewDelegate::willSendRequest(
@@ -816,7 +836,7 @@
printf("%s - willSendRequest <NSURLRequest URL %s, main document URL %s,"
" http method %s> redirectResponse %s\n",
GetResourceDescription(identifier).c_str(),
- request_url.c_str(),
+ DescriptionSuitableForTestResult(request_url).c_str(),
GetURLDescription(main_document_url).c_str(),
request.httpMethod().utf8().data(),
GetResponseDescription(redirect_response).c_str());
« no previous file with comments | « webkit/tools/layout_tests/test_expectations.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698