Changeset 139234 in webkit
- Timestamp:
- Jan 9, 2013 1:44:18 PM (11 years ago)
- Location:
- trunk/Tools
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r139231 r139234 1 2013-01-09 Jochen Eisinger <jochen@chromium.org> 2 3 [chromium] move resource load callback dumping to TestRunner library 4 https://bugs.webkit.org/show_bug.cgi?id=106449 5 6 Reviewed by Adam Barth. 7 8 * DumpRenderTree/chromium/DRTTestRunner.cpp: 9 (DRTTestRunner::DRTTestRunner): 10 (DRTTestRunner::reset): 11 * DumpRenderTree/chromium/DRTTestRunner.h: 12 (DRTTestRunner): 13 * DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h: 14 (WebKit): 15 (WebTestRunner::WebTestDelegate::makeURLErrorDescription): 16 * DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h: 17 (WebKit): 18 (WebTestProxyBase): 19 (WebTestRunner::WebTestProxy::assignIdentifierToRequest): 20 (WebTestRunner::WebTestProxy::willRequestResource): 21 (WebTestRunner::WebTestProxy::willSendRequest): 22 (WebTestRunner::WebTestProxy::didReceiveResponse): 23 (WebTestRunner::WebTestProxy::didFinishResourceLoad): 24 (WebTestRunner::WebTestProxy::didFailResourceLoad): 25 * DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h: 26 (WebTestRunner::WebTestRunner::shouldDumpResourceLoadCallbacks): 27 (WebTestRunner::WebTestRunner::shouldDumpResourceRequestCallbacks): 28 (WebTestRunner::WebTestRunner::shouldDumpResourceResponseMIMETypes): 29 * DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp: 30 (WebTestRunner::TestRunner::TestRunner): 31 (WebTestRunner::TestRunner::reset): 32 (WebTestRunner::TestRunner::shouldDumpResourceLoadCallbacks): 33 (WebTestRunner::TestRunner::shouldDumpResourceRequestCallbacks): 34 (WebTestRunner::TestRunner::shouldDumpResourceResponseMIMETypes): 35 (WebTestRunner): 36 (WebTestRunner::TestRunner::dumpResourceLoadCallbacks): 37 (WebTestRunner::TestRunner::dumpResourceRequestCallbacks): 38 (WebTestRunner::TestRunner::dumpResourceResponseMIMETypes): 39 * DumpRenderTree/chromium/TestRunner/src/TestRunner.h: 40 (TestRunner): 41 * DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp: 42 (WebTestRunner::WebTestProxyBase::reset): 43 (WebTestRunner): 44 (WebTestRunner::WebTestProxyBase::assignIdentifierToRequest): 45 (WebTestRunner::WebTestProxyBase::willRequestResource): 46 (WebTestRunner::WebTestProxyBase::willSendRequest): 47 (WebTestRunner::WebTestProxyBase::didReceiveResponse): 48 (WebTestRunner::WebTestProxyBase::didFinishResourceLoad): 49 (WebTestRunner::WebTestProxyBase::didFailResourceLoad): 50 * DumpRenderTree/chromium/WebViewHost.cpp: 51 (WebViewHost::willSendRequest): 52 (WebViewHost::makeURLErrorDescription): 53 (WebViewHost::reset): 54 * DumpRenderTree/chromium/WebViewHost.h: 55 (WebViewHost): 56 1 57 2013-01-09 Dan Carney <dcarney@google.com> 2 58 -
trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp
r139231 r139234 120 120 bindMethod("dumpBackForwardList", &DRTTestRunner::dumpBackForwardList); 121 121 bindMethod("dumpProgressFinishedCallback", &DRTTestRunner::dumpProgressFinishedCallback); 122 bindMethod("dumpResourceLoadCallbacks", &DRTTestRunner::dumpResourceLoadCallbacks);123 bindMethod("dumpResourceRequestCallbacks", &DRTTestRunner::dumpResourceRequestCallbacks);124 bindMethod("dumpResourceResponseMIMETypes", &DRTTestRunner::dumpResourceResponseMIMETypes);125 122 bindMethod("dumpSelectionRect", &DRTTestRunner::dumpSelectionRect); 126 123 bindMethod("dumpStatusCallbacks", &DRTTestRunner::dumpWindowStatusChanges); … … 252 249 } 253 250 254 void DRTTestRunner::dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant* result)255 {256 m_dumpResourceLoadCallbacks = true;257 result->setNull();258 }259 260 void DRTTestRunner::dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant* result)261 {262 m_dumpResourceRequestCallbacks = true;263 result->setNull();264 }265 266 void DRTTestRunner::dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant* result)267 {268 m_dumpResourceResponseMIMETypes = true;269 result->setNull();270 }271 272 251 void DRTTestRunner::dumpWindowStatusChanges(const CppArgumentList&, CppVariant* result) 273 252 { … … 467 446 m_shell->webViewHost()->setDeviceScaleFactor(1); 468 447 m_dumpProgressFinishedCallback = false; 469 m_dumpResourceLoadCallbacks = false;470 m_dumpResourceRequestCallbacks = false;471 m_dumpResourceResponseMIMETypes = false;472 448 m_dumpBackForwardList = false; 473 449 m_dumpWindowStatusChanges = false; -
trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.h
r139231 r139234 85 85 void dumpBackForwardList(const CppArgumentList&, CppVariant*); 86 86 87 // This function sets a flag that tells the test_shell to dump a descriptive88 // line for each resource load callback. It takes no arguments, and ignores89 // any that may be present.90 void dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant*);91 92 // This function sets a flag that tells the test_shell to print a line of93 // descriptive text for each element that requested a resource. It takes no94 // arguments, and ignores any that may be present.95 void dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant*);96 97 // This function sets a flag that tells the test_shell to dump the MIME type98 // for each resource that was loaded. It takes no arguments, and ignores any99 // that may be present.100 void dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant*);101 102 87 // This function sets a flag that tells the test_shell to dump all calls 103 88 // to window.status(). … … 244 229 bool shouldDumpProgressFinishedCallback() { return m_dumpProgressFinishedCallback; } 245 230 void setShouldDumpProgressFinishedCallback(bool value) { m_dumpProgressFinishedCallback = value; } 246 bool shouldDumpResourceLoadCallbacks() {return m_dumpResourceLoadCallbacks; }247 void setShouldDumpResourceRequestCallbacks(bool value) { m_dumpResourceRequestCallbacks = value; }248 bool shouldDumpResourceRequestCallbacks() { return m_dumpResourceRequestCallbacks; }249 void setShouldDumpResourceResponseMIMETypes(bool value) { m_dumpResourceResponseMIMETypes = value; }250 bool shouldDumpResourceResponseMIMETypes() {return m_dumpResourceResponseMIMETypes; }251 231 bool shouldDumpStatusCallbacks() { return m_dumpWindowStatusChanges; } 252 232 bool shouldDumpSelectionRect() { return m_dumpSelectionRect; } … … 350 330 bool m_dumpProgressFinishedCallback; 351 331 352 // If true, the test_shell will output a descriptive line for each resource353 // load callback.354 bool m_dumpResourceLoadCallbacks;355 356 // If true, the test_shell will output a descriptive line for each resource357 // request callback.358 bool m_dumpResourceRequestCallbacks;359 360 // If true, the test_shell will output the MIME type for each resource that361 // was loaded.362 bool m_dumpResourceResponseMIMETypes;363 364 332 // If true, the test_shell will produce a dump of the back forward list as 365 333 // well. -
trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h
r137997 r139234 35 35 #include "Platform/chromium/public/WebURL.h" 36 36 #include "Platform/chromium/public/WebVector.h" 37 #include <string> 37 38 38 39 namespace WebKit { 39 struct WebContextMenuData;40 40 class WebGamepads; 41 41 class WebIntentRequest; 42 struct WebContextMenuData; 43 struct WebURLError; 42 44 } 43 45 … … 75 77 virtual void setCurrentWebIntentRequest(const WebKit::WebIntentRequest&) { }; 76 78 virtual WebKit::WebIntentRequest* currentWebIntentRequest() { return 0; } 79 virtual std::string makeURLErrorDescription(const WebKit::WebURLError&) { return std::string(); } 77 80 }; 78 81 -
trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h
r139231 r139234 39 39 #include "WebKit/chromium/public/WebTextAffinity.h" 40 40 #include "WebKit/chromium/public/WebTextDirection.h" 41 #include <map> 42 #include <string> 41 43 42 44 namespace WebKit { 43 45 class WebAccessibilityObject; 46 class WebCachedURLRequest; 44 47 class WebDragData; 45 48 class WebFrame; … … 54 57 class WebURL; 55 58 class WebURLRequest; 59 class WebURLResponse; 56 60 class WebView; 57 61 struct WebPoint; … … 71 75 void setInterfaces(WebTestInterfaces*); 72 76 void setDelegate(WebTestDelegate*); 77 78 void reset(); 73 79 74 80 void setPaintRect(const WebKit::WebRect&); … … 117 123 void didRunInsecureContent(WebKit::WebFrame*, const WebKit::WebSecurityOrigin&, const WebKit::WebURL& insecureURL); 118 124 void didDetectXSS(WebKit::WebFrame*, const WebKit::WebURL& insecureURL, bool didBlockEntirePage); 125 void assignIdentifierToRequest(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLRequest&); 126 void willRequestResource(WebKit::WebFrame*, const WebKit::WebCachedURLRequest&); 127 void willSendRequest(WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&, const WebKit::WebURLResponse& redirectResponse); 128 void didReceiveResponse(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLResponse&); 129 void didFinishResourceLoad(WebKit::WebFrame*, unsigned identifier); 130 void didFailResourceLoad(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLError&); 119 131 120 132 private: … … 123 135 124 136 WebKit::WebRect m_paintRect; 137 std::map<unsigned, std::string> m_resourceIdentifierMap; 125 138 }; 126 139 … … 330 343 Base::didDetectXSS(frame, insecureURL, didBlockEntirePage); 331 344 } 345 virtual void assignIdentifierToRequest(WebKit::WebFrame* frame, unsigned identifier, const WebKit::WebURLRequest& request) 346 { 347 WebTestProxyBase::assignIdentifierToRequest(frame, identifier, request); 348 Base::assignIdentifierToRequest(frame, identifier, request); 349 } 350 virtual void willRequestResource(WebKit::WebFrame* frame, const WebKit::WebCachedURLRequest& request) 351 { 352 WebTestProxyBase::willRequestResource(frame, request); 353 Base::willRequestResource(frame, request); 354 } 355 virtual void willSendRequest(WebKit::WebFrame* frame, unsigned identifier, WebKit::WebURLRequest& request, const WebKit::WebURLResponse& redirectResponse) 356 { 357 WebTestProxyBase::willSendRequest(frame, identifier, request, redirectResponse); 358 Base::willSendRequest(frame, identifier, request, redirectResponse); 359 } 360 virtual void didReceiveResponse(WebKit::WebFrame* frame, unsigned identifier, const WebKit::WebURLResponse& response) 361 { 362 WebTestProxyBase::didReceiveResponse(frame, identifier, response); 363 Base::didReceiveResponse(frame, identifier, response); 364 } 365 virtual void didFinishResourceLoad(WebKit::WebFrame* frame, unsigned identifier) 366 { 367 WebTestProxyBase::didFinishResourceLoad(frame, identifier); 368 Base::didFinishResourceLoad(frame, identifier); 369 } 370 virtual void didFailResourceLoad(WebKit::WebFrame* frame, unsigned identifier, const WebKit::WebURLError& error) 371 { 372 WebTestProxyBase::didFailResourceLoad(frame, identifier, error); 373 Base::didFailResourceLoad(frame, identifier, error); 374 } 332 375 }; 333 376 -
trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h
r139231 r139234 59 59 virtual bool shouldDumpCreateView() const { return false; } 60 60 virtual bool canOpenWindows() const { return false; } 61 virtual bool shouldDumpResourceLoadCallbacks() const { return false; } 62 virtual bool shouldDumpResourceRequestCallbacks() const { return false; } 63 virtual bool shouldDumpResourceResponseMIMETypes() const { return false; } 61 64 }; 62 65 -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
r139231 r139234 145 145 bindMethod("dumpCreateView", &TestRunner::dumpCreateView); 146 146 bindMethod("setCanOpenWindows", &TestRunner::setCanOpenWindows); 147 bindMethod("dumpResourceLoadCallbacks", &TestRunner::dumpResourceLoadCallbacks); 148 bindMethod("dumpResourceRequestCallbacks", &TestRunner::dumpResourceRequestCallbacks); 149 bindMethod("dumpResourceResponseMIMETypes", &TestRunner::dumpResourceResponseMIMETypes); 147 150 148 151 // The following methods interact with the WebTestProxy. … … 221 224 m_dumpCreateView = false; 222 225 m_canOpenWindows = false; 226 m_dumpResourceLoadCallbacks = false; 227 m_dumpResourceRequestCallbacks = false; 228 m_dumpResourceResponseMIMETypes = false; 223 229 224 230 m_globalFlag.set(false); … … 311 317 { 312 318 return m_canOpenWindows; 319 } 320 321 bool TestRunner::shouldDumpResourceLoadCallbacks() const 322 { 323 return m_testIsRunning && m_dumpResourceLoadCallbacks; 324 } 325 326 bool TestRunner::shouldDumpResourceRequestCallbacks() const 327 { 328 return m_testIsRunning && m_dumpResourceRequestCallbacks; 329 } 330 331 bool TestRunner::shouldDumpResourceResponseMIMETypes() const 332 { 333 return m_testIsRunning && m_dumpResourceResponseMIMETypes; 313 334 } 314 335 … … 1090 1111 } 1091 1112 1113 void TestRunner::dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant* result) 1114 { 1115 m_dumpResourceLoadCallbacks = true; 1116 result->setNull(); 1117 } 1118 1119 void TestRunner::dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant* result) 1120 { 1121 m_dumpResourceRequestCallbacks = true; 1122 result->setNull(); 1123 } 1124 1125 void TestRunner::dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant* result) 1126 { 1127 m_dumpResourceResponseMIMETypes = true; 1128 result->setNull(); 1129 } 1130 1092 1131 void TestRunner::workerThreadCount(CppVariant* result) 1093 1132 { -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h
r139231 r139234 77 77 virtual bool shouldDumpCreateView() const OVERRIDE; 78 78 virtual bool canOpenWindows() const OVERRIDE; 79 virtual bool shouldDumpResourceLoadCallbacks() const OVERRIDE; 80 virtual bool shouldDumpResourceRequestCallbacks() const OVERRIDE; 81 virtual bool shouldDumpResourceResponseMIMETypes() const OVERRIDE; 79 82 80 83 protected: … … 242 245 void setCanOpenWindows(const CppArgumentList&, CppVariant*); 243 246 247 // This function sets a flag that tells the test_shell to dump a descriptive 248 // line for each resource load callback. It takes no arguments, and ignores 249 // any that may be present. 250 void dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant*); 251 252 // This function sets a flag that tells the test_shell to print a line of 253 // descriptive text for each element that requested a resource. It takes no 254 // arguments, and ignores any that may be present. 255 void dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant*); 256 257 // This function sets a flag that tells the test_shell to dump the MIME type 258 // for each resource that was loaded. It takes no arguments, and ignores any 259 // that may be present. 260 void dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant*); 261 244 262 /////////////////////////////////////////////////////////////////////////// 245 263 // Methods interacting with the WebTestProxy … … 332 350 bool m_canOpenWindows; 333 351 352 // If true, the test_shell will output a descriptive line for each resource 353 // load callback. 354 bool m_dumpResourceLoadCallbacks; 355 356 // If true, the test_shell will output a descriptive line for each resource 357 // request callback. 358 bool m_dumpResourceRequestCallbacks; 359 360 // If true, the test_shell will output the MIME type for each resource that 361 // was loaded. 362 bool m_dumpResourceResponseMIMETypes; 363 334 364 // WAV audio data is stored here. 335 365 WebKit::WebArrayBufferView m_audioData; -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp
r139231 r139234 35 35 #include "WebAccessibilityNotification.h" 36 36 #include "WebAccessibilityObject.h" 37 #include "WebCachedURLRequest.h" 37 38 #include "WebElement.h" 38 39 #include "WebEventSender.h" … … 49 50 #include "platform/WebCString.h" 50 51 #include "platform/WebURLRequest.h" 52 #include "platform/WebURLResponse.h" 51 53 #include <wtf/StringExtras.h> 52 54 … … 142 144 } 143 145 146 // Used to write a platform neutral file:/// URL by taking the 147 // filename and its directory. (e.g., converts 148 // "file:///tmp/foo/bar.txt" to just "bar.txt"). 149 string descriptionSuitableForTestResult(const string& url) 150 { 151 if (url.empty() || string::npos == url.find("file://")) 152 return url; 153 154 size_t pos = url.rfind('/'); 155 if (pos == string::npos || !pos) 156 return "ERROR:" + url; 157 pos = url.rfind('/', pos - 1); 158 if (pos == string::npos) 159 return "ERROR:" + url; 160 161 return url.substr(pos + 1); 162 } 163 164 void printResponseDescription(WebTestDelegate* delegate, const WebURLResponse& response) 165 { 166 if (response.isNull()) { 167 delegate->printMessage("(null)"); 168 return; 169 } 170 string url = response.url().spec(); 171 char data[100]; 172 snprintf(data, sizeof(data), "%d", response. httpStatusCode()); 173 delegate->printMessage(string("<NSURLResponse ") + descriptionSuitableForTestResult(url) + ", http status code " + data + ">"); 174 } 175 144 176 string URLDescription(const GURL& url) 145 177 { … … 169 201 { 170 202 m_delegate = delegate; 203 } 204 205 void WebTestProxyBase::reset() 206 { 207 m_paintRect = WebRect(); 208 m_resourceIdentifierMap.clear(); 171 209 } 172 210 … … 610 648 } 611 649 612 } 650 void WebTestProxyBase::assignIdentifierToRequest(WebFrame*, unsigned identifier, const WebKit::WebURLRequest& request) 651 { 652 if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { 653 ASSERT(m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end()); 654 m_resourceIdentifierMap[identifier] = descriptionSuitableForTestResult(request.url().spec()); 655 } 656 } 657 658 void WebTestProxyBase::willRequestResource(WebFrame* frame, const WebKit::WebCachedURLRequest& request) 659 { 660 if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceRequestCallbacks()) { 661 printFrameDescription(m_delegate, frame); 662 WebElement element = request.initiatorElement(); 663 if (!element.isNull()) { 664 m_delegate->printMessage(" - element with "); 665 if (element.hasAttribute("id")) 666 m_delegate->printMessage(string("id '") + element.getAttribute("id").utf8().data() + "'"); 667 else 668 m_delegate->printMessage("no id"); 669 } else 670 m_delegate->printMessage(string(" - ") + request.initiatorName().utf8().data()); 671 m_delegate->printMessage(string(" requested '") + URLDescription(request.urlRequest().url()).c_str() + "'\n"); 672 } 673 } 674 675 void WebTestProxyBase::willSendRequest(WebFrame*, unsigned identifier, WebKit::WebURLRequest& request, const WebKit::WebURLResponse& redirectResponse) 676 { 677 // Need to use GURL for host() and SchemeIs() 678 GURL url = request.url(); 679 string requestURL = url.possibly_invalid_spec(); 680 681 GURL mainDocumentURL = request.firstPartyForCookies(); 682 683 if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { 684 if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end()) 685 m_delegate->printMessage("<unknown>"); 686 else 687 m_delegate->printMessage(m_resourceIdentifierMap[identifier]); 688 m_delegate->printMessage(" - willSendRequest <NSURLRequest URL "); 689 m_delegate->printMessage(descriptionSuitableForTestResult(requestURL).c_str()); 690 m_delegate->printMessage(", main document URL "); 691 m_delegate->printMessage(URLDescription(mainDocumentURL).c_str()); 692 m_delegate->printMessage(", http method "); 693 m_delegate->printMessage(request.httpMethod().utf8().data()); 694 m_delegate->printMessage("> redirectResponse "); 695 printResponseDescription(m_delegate, redirectResponse); 696 m_delegate->printMessage("\n"); 697 } 698 } 699 700 void WebTestProxyBase::didReceiveResponse(WebFrame*, unsigned identifier, const WebKit::WebURLResponse& response) 701 { 702 if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { 703 if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end()) 704 m_delegate->printMessage("<unknown>"); 705 else 706 m_delegate->printMessage(m_resourceIdentifierMap[identifier]); 707 m_delegate->printMessage(" - didReceiveResponse "); 708 printResponseDescription(m_delegate, response); 709 m_delegate->printMessage("\n"); 710 } 711 if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceResponseMIMETypes()) { 712 GURL url = response.url(); 713 WebString mimeType = response.mimeType(); 714 m_delegate->printMessage(url.ExtractFileName()); 715 m_delegate->printMessage(" has MIME type "); 716 // Simulate NSURLResponse's mapping of empty/unknown MIME types to application/octet-stream 717 m_delegate->printMessage(mimeType.isEmpty() ? "application/octet-stream" : mimeType.utf8().data()); 718 m_delegate->printMessage("\n"); 719 } 720 } 721 722 void WebTestProxyBase::didFinishResourceLoad(WebFrame*, unsigned identifier) 723 { 724 if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { 725 if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end()) 726 m_delegate->printMessage("<unknown>"); 727 else 728 m_delegate->printMessage(m_resourceIdentifierMap[identifier]); 729 m_delegate->printMessage(" - didFinishLoading\n"); 730 } 731 m_resourceIdentifierMap.erase(identifier); 732 } 733 734 void WebTestProxyBase::didFailResourceLoad(WebFrame*, unsigned identifier, const WebKit::WebURLError& error) 735 { 736 if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { 737 if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end()) 738 m_delegate->printMessage("<unknown>"); 739 else 740 m_delegate->printMessage(m_resourceIdentifierMap[identifier]); 741 m_delegate->printMessage(" - didFailLoadingWithError: "); 742 m_delegate->printMessage(m_delegate->makeURLErrorDescription(error)); 743 m_delegate->printMessage("\n"); 744 } 745 m_resourceIdentifierMap.erase(identifier); 746 } 747 748 } -
trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp
r139231 r139234 127 127 } 128 128 129 // Used to write a platform neutral file:/// URL by taking the130 // filename and its directory. (e.g., converts131 // "file:///tmp/foo/bar.txt" to just "bar.txt").132 static string descriptionSuitableForTestResult(const string& url)133 {134 if (url.empty() || string::npos == url.find("file://"))135 return url;136 137 size_t pos = url.rfind('/');138 if (pos == string::npos || !pos)139 return "ERROR:" + url;140 pos = url.rfind('/', pos - 1);141 if (pos == string::npos)142 return "ERROR:" + url;143 144 return url.substr(pos + 1);145 }146 147 129 // Get a debugging string from a WebNavigationType. 148 130 static const char* webNavigationTypeToString(WebNavigationType type) … … 170 152 return url.ExtractFileName(); 171 153 return url.possibly_invalid_spec(); 172 }173 174 static void printResponseDescription(const WebURLResponse& response)175 {176 if (response.isNull()) {177 fputs("(null)", stdout);178 return;179 }180 string url = response.url().spec();181 printf("<NSURLResponse %s, http status code %d>",182 descriptionSuitableForTestResult(url).c_str(),183 response.httpStatusCode());184 154 } 185 155 … … 915 885 } 916 886 917 void WebViewHost::assignIdentifierToRequest(WebFrame*, unsigned identifier, const WebURLRequest& request)918 {919 if (!m_shell->shouldDumpResourceLoadCallbacks())920 return;921 ASSERT(!m_resourceIdentifierMap.contains(identifier));922 m_resourceIdentifierMap.set(identifier, descriptionSuitableForTestResult(request.url().spec()));923 }924 925 void WebViewHost::removeIdentifierForRequest(unsigned identifier)926 {927 m_resourceIdentifierMap.remove(identifier);928 }929 930 887 static void blockRequest(WebURLRequest& request) 931 888 { … … 941 898 { 942 899 return host == "255.255.255.255"; 943 }944 945 void WebViewHost::willRequestResource(WebKit::WebFrame* frame, const WebKit::WebCachedURLRequest& request)946 {947 if (m_shell->shouldDumpResourceRequestCallbacks()) {948 printFrameDescription(frame);949 WebElement element = request.initiatorElement();950 if (!element.isNull()) {951 printf(" - element with ");952 if (element.hasAttribute("id"))953 printf("id '%s'", element.getAttribute("id").utf8().data());954 else955 printf("no id");956 } else957 printf(" - %s", request.initiatorName().utf8().data());958 printf(" requested '%s'\n", URLDescription(request.urlRequest().url()).c_str());959 }960 900 } 961 901 … … 967 907 968 908 GURL mainDocumentURL = request.firstPartyForCookies(); 969 if (testRunner()->shouldDumpResourceLoadCallbacks()) {970 printResourceDescription(identifier);971 printf(" - willSendRequest <NSURLRequest URL %s, main document URL %s,"972 " http method %s> redirectResponse ",973 descriptionSuitableForTestResult(requestURL).c_str(),974 URLDescription(mainDocumentURL).c_str(),975 request.httpMethod().utf8().data());976 printResponseDescription(redirectResponse);977 fputs("\n", stdout);978 }979 909 980 910 request.setExtraData(webkit_support::CreateWebURLRequestExtraData(frame->document().referrerPolicy())); … … 1010 940 } 1011 941 1012 void WebViewHost::didReceiveResponse(WebFrame*, unsigned identifier, const WebURLResponse& response)1013 {1014 if (m_shell->shouldDumpResourceLoadCallbacks()) {1015 printResourceDescription(identifier);1016 fputs(" - didReceiveResponse ", stdout);1017 printResponseDescription(response);1018 fputs("\n", stdout);1019 }1020 if (m_shell->shouldDumpResourceResponseMIMETypes()) {1021 GURL url = response.url();1022 WebString mimeType = response.mimeType();1023 printf("%s has MIME type %s\n",1024 url.ExtractFileName().c_str(),1025 // Simulate NSURLResponse's mapping of empty/unknown MIME types to application/octet-stream1026 mimeType.isEmpty() ? "application/octet-stream" : mimeType.utf8().data());1027 }1028 }1029 1030 void WebViewHost::didFinishResourceLoad(WebFrame*, unsigned identifier)1031 {1032 if (m_shell->shouldDumpResourceLoadCallbacks()) {1033 printResourceDescription(identifier);1034 fputs(" - didFinishLoading\n", stdout);1035 }1036 removeIdentifierForRequest(identifier);1037 }1038 1039 void WebViewHost::didFailResourceLoad(WebFrame*, unsigned identifier, const WebURLError& error)1040 {1041 if (m_shell->shouldDumpResourceLoadCallbacks()) {1042 printResourceDescription(identifier);1043 fputs(" - didFailLoadingWithError: ", stdout);1044 fputs(webkit_support::MakeURLErrorDescription(error).c_str(), stdout);1045 fputs("\n", stdout);1046 }1047 removeIdentifierForRequest(identifier);1048 }1049 1050 942 void WebViewHost::openFileSystem(WebFrame* frame, WebFileSystem::Type type, long long size, bool create, WebFileSystemCallbacks* callbacks) 1051 943 { … … 1160 1052 { 1161 1053 return &m_currentRequest; 1054 } 1055 1056 std::string WebViewHost::makeURLErrorDescription(const WebKit::WebURLError& error) 1057 { 1058 return webkit_support::MakeURLErrorDescription(error); 1162 1059 } 1163 1060 … … 1256 1153 1257 1154 m_pendingExtraData.clear(); 1258 m_resourceIdentifierMap.clear();1259 1155 m_clearHeaders.clear(); 1260 1156 m_editCommandName.clear(); … … 1273 1169 // m_proxy is not set when reset() is invoked from the constructor. 1274 1170 if (m_proxy) 1275 proxy()-> setPaintRect(WebRect());1171 proxy()->reset(); 1276 1172 1277 1173 if (m_webWidget) { … … 1474 1370 } 1475 1371 printf("frame \"%s\"", name8.c_str()); 1476 }1477 1478 void WebViewHost::printResourceDescription(unsigned identifier)1479 {1480 ResourceMap::iterator it = m_resourceIdentifierMap.find(identifier);1481 printf("%s", it != m_resourceIdentifierMap.end() ? it->value.c_str() : "<unknown>");1482 1372 } 1483 1373 -
trunk/Tools/DumpRenderTree/chromium/WebViewHost.h
r139090 r139234 149 149 virtual void setCurrentWebIntentRequest(const WebKit::WebIntentRequest&) OVERRIDE; 150 150 virtual WebKit::WebIntentRequest* currentWebIntentRequest() OVERRIDE; 151 virtual std::string makeURLErrorDescription(const WebKit::WebURLError&) OVERRIDE; 151 152 152 153 // NavigationHost … … 255 256 virtual void didFinishLoad(WebKit::WebFrame*); 256 257 virtual void didNavigateWithinPage(WebKit::WebFrame*, bool isNewNavigation); 257 virtual void assignIdentifierToRequest(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLRequest&);258 virtual void removeIdentifierForRequest(unsigned identifier);259 virtual void willRequestResource(WebKit::WebFrame*, const WebKit::WebCachedURLRequest&);260 258 virtual void willSendRequest(WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&, const WebKit::WebURLResponse&); 261 virtual void didReceiveResponse(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLResponse&);262 virtual void didFinishResourceLoad(WebKit::WebFrame*, unsigned identifier);263 virtual void didFailResourceLoad(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLError&);264 259 virtual void openFileSystem(WebKit::WebFrame*, WebKit::WebFileSystem::Type, long long size, bool create, WebKit::WebFileSystemCallbacks*); 265 260 virtual void deleteFileSystem(WebKit::WebFrame*, WebKit::WebFileSystem::Type, WebKit::WebFileSystemCallbacks*); … … 364 359 OwnPtr<TestShellExtraData> m_pendingExtraData; 365 360 366 // Maps resource identifiers to a descriptive string.367 typedef HashMap<unsigned, std::string> ResourceMap;368 ResourceMap m_resourceIdentifierMap;369 void printResourceDescription(unsigned identifier);370 371 361 WebKit::WebCursorInfo m_currentCursor; 372 362
Note: See TracChangeset
for help on using the changeset viewer.