Changeset 140668 in webkit
- Timestamp:
- Jan 24, 2013 2:12:56 AM (11 years ago)
- Location:
- trunk/Tools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r140653 r140668 1 2013-01-24 Dan Carney <dcarney@google.com> 2 3 [chromium] move most WebViewHost printf calls to WebTestProxy 4 https://bugs.webkit.org/show_bug.cgi?id=107553 5 6 Reviewed by Jochen Eisinger. 7 8 * DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h: 9 (WebKit): 10 (WebTestProxyBase): 11 (WebTestRunner::WebTestProxy::unableToImplementPolicyWithError): 12 (WebTestRunner::WebTestProxy::didAddMessageToConsole): 13 (WebTestRunner::WebTestProxy::runModalAlertDialog): 14 (WebTestRunner::WebTestProxy::runModalConfirmDialog): 15 (WebTestRunner::WebTestProxy::runModalPromptDialog): 16 (WebTestRunner::WebTestProxy::runModalBeforeUnloadDialog): 17 * DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp: 18 (WebTestRunner::WebTestProxyBase::WebTestProxyBase): 19 (WebTestRunner::WebTestProxyBase::reset): 20 (WebTestRunner::WebTestProxyBase::setLogConsoleOutput): 21 (WebTestRunner): 22 (WebTestRunner::WebTestProxyBase::unableToImplementPolicyWithError): 23 (WebTestRunner::WebTestProxyBase::didAddMessageToConsole): 24 (WebTestRunner::WebTestProxyBase::runModalAlertDialog): 25 (WebTestRunner::WebTestProxyBase::runModalConfirmDialog): 26 (WebTestRunner::WebTestProxyBase::runModalPromptDialog): 27 (WebTestRunner::WebTestProxyBase::runModalBeforeUnloadDialog): 28 * DumpRenderTree/chromium/TestShell.cpp: 29 (TestShell::showDevTools): 30 * DumpRenderTree/chromium/WebViewHost.cpp: 31 (WebViewHost::didAddMessageToConsole): 32 (WebViewHost::runModalAlertDialog): 33 (WebViewHost::runModalConfirmDialog): 34 (WebViewHost::runModalPromptDialog): 35 (WebViewHost::runModalBeforeUnloadDialog): 36 (WebViewHost::unableToImplementPolicyWithError): 37 (WebViewHost::reset): 38 * DumpRenderTree/chromium/WebViewHost.h: 39 (WebViewHost): 40 1 41 2013-01-23 Mark Pilgrim <pilgrim@chromium.org> 2 42 -
trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h
r140396 r140668 42 42 #include <string> 43 43 44 #define TEST_RUNNER_MOVED_PRINTING 1 45 44 46 namespace WebKit { 45 47 class WebAccessibilityObject; … … 60 62 class WebURLResponse; 61 63 class WebView; 64 struct WebConsoleMessage; 62 65 struct WebPoint; 63 66 struct WebSize; … … 84 87 void setPaintRect(const WebKit::WebRect&); 85 88 WebKit::WebRect paintRect() const; 89 90 void setLogConsoleOutput(bool enabled); 86 91 87 92 protected: … … 136 141 void didFinishResourceLoad(WebKit::WebFrame*, unsigned identifier); 137 142 void didFailResourceLoad(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLError&); 143 void unableToImplementPolicyWithError(WebKit::WebFrame*, const WebKit::WebURLError&); 144 void didAddMessageToConsole(const WebKit::WebConsoleMessage&, const WebKit::WebString& sourceName, unsigned sourceLine); 145 void runModalAlertDialog(WebKit::WebFrame*, const WebKit::WebString&); 146 bool runModalConfirmDialog(WebKit::WebFrame*, const WebKit::WebString&); 147 bool runModalPromptDialog(WebKit::WebFrame*, const WebKit::WebString& message, const WebKit::WebString& defaultValue, WebKit::WebString* actualValue); 148 bool runModalBeforeUnloadDialog(WebKit::WebFrame*, const WebKit::WebString&); 138 149 139 150 private: … … 145 156 WebKit::WebRect m_paintRect; 146 157 std::map<unsigned, std::string> m_resourceIdentifierMap; 158 159 bool m_logConsoleOutput; 147 160 }; 148 161 … … 392 405 Base::didFailResourceLoad(frame, identifier, error); 393 406 } 407 virtual void unableToImplementPolicyWithError(WebKit::WebFrame* frame, const WebKit::WebURLError& error) 408 { 409 WebTestProxyBase::unableToImplementPolicyWithError(frame, error); 410 Base::unableToImplementPolicyWithError(frame, error); 411 } 412 virtual void didAddMessageToConsole(const WebKit::WebConsoleMessage& message, const WebKit::WebString& sourceName, unsigned sourceLine) 413 { 414 WebTestProxyBase::didAddMessageToConsole(message, sourceName, sourceLine); 415 Base::didAddMessageToConsole(message, sourceName, sourceLine); 416 } 417 virtual void runModalAlertDialog(WebKit::WebFrame* frame, const WebKit::WebString& message) 418 { 419 WebTestProxyBase::runModalAlertDialog(frame, message); 420 Base::runModalAlertDialog(frame, message); 421 } 422 virtual bool runModalConfirmDialog(WebKit::WebFrame* frame, const WebKit::WebString& message) 423 { 424 WebTestProxyBase::runModalConfirmDialog(frame, message); 425 return Base::runModalConfirmDialog(frame, message); 426 } 427 virtual bool runModalPromptDialog(WebKit::WebFrame* frame, const WebKit::WebString& message, const WebKit::WebString& defaultValue, WebKit::WebString* actualValue) 428 { 429 WebTestProxyBase::runModalPromptDialog(frame, message, defaultValue, actualValue); 430 return Base::runModalPromptDialog(frame, message, defaultValue, actualValue); 431 } 432 virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame, const WebKit::WebString& message) 433 { 434 WebTestProxyBase::runModalBeforeUnloadDialog(frame, message); 435 return Base::runModalBeforeUnloadDialog(frame, message); 436 } 394 437 }; 395 438 -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp
r140565 r140668 37 37 #include "WebAccessibilityObject.h" 38 38 #include "WebCachedURLRequest.h" 39 #include "WebConsoleMessage.h" 39 40 #include "WebElement.h" 40 41 #include "WebEventSender.h" … … 50 51 #include "WebView.h" 51 52 #include <public/WebCString.h> 53 #include <public/WebURLError.h> 52 54 #include <public/WebURLRequest.h> 53 55 #include <public/WebURLResponse.h> … … 187 189 } 188 190 191 // Used to write a platform neutral file:/// URL by only taking the filename 192 // (e.g., converts "file:///tmp/foo.txt" to just "foo.txt"). 193 string urlSuitableForTestResult(const string& url) 194 { 195 if (url.empty() || string::npos == url.find("file://")) 196 return url; 197 198 size_t pos = url.rfind('/'); 199 if (pos == string::npos) { 200 #if OS(WINDOWS) 201 pos = url.rfind('\\'); 202 if (pos == string::npos) 203 pos = 0; 204 #else 205 pos = 0; 206 #endif 207 } 208 string filename = url.substr(pos + 1); 209 if (filename.empty()) 210 return "file:"; // A WebKit test has this in its expected output. 211 return filename; 212 } 213 189 214 } 190 215 … … 194 219 , m_spellcheck(new SpellCheckClient) 195 220 { 221 reset(); 196 222 } 197 223 … … 216 242 m_paintRect = WebRect(); 217 243 m_resourceIdentifierMap.clear(); 244 m_logConsoleOutput = true; 218 245 } 219 246 … … 231 258 { 232 259 return m_paintRect; 260 } 261 262 void WebTestProxyBase::setLogConsoleOutput(bool enabled) 263 { 264 m_logConsoleOutput = enabled; 233 265 } 234 266 … … 792 824 } 793 825 794 } 826 void WebTestProxyBase::unableToImplementPolicyWithError(WebKit::WebFrame* frame, const WebKit::WebURLError& error) 827 { 828 char errorBuffer[40]; 829 snprintf(errorBuffer, sizeof(errorBuffer), "%d", error.reason); 830 m_delegate->printMessage(string("Policy delegate: unable to implement policy with error domain '") + error.domain.utf8().data() + 831 "', error code " + errorBuffer + 832 ", in frame '" + frame->uniqueName().utf8().data() + "'\n"); 833 } 834 835 void WebTestProxyBase::didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine) 836 { 837 // This matches win DumpRenderTree's UIDelegate.cpp. 838 if (!m_logConsoleOutput) 839 return; 840 m_delegate->printMessage(string("CONSOLE MESSAGE: ")); 841 if (sourceLine) { 842 char buffer[40]; 843 snprintf(buffer, sizeof(buffer), "line %d: ", sourceLine); 844 m_delegate->printMessage(buffer); 845 } 846 if (!message.text.isEmpty()) { 847 string newMessage; 848 newMessage = message.text.utf8(); 849 size_t fileProtocol = newMessage.find("file://"); 850 if (fileProtocol != string::npos) { 851 newMessage = newMessage.substr(0, fileProtocol) 852 + urlSuitableForTestResult(newMessage.substr(fileProtocol)); 853 } 854 m_delegate->printMessage(newMessage); 855 } 856 m_delegate->printMessage(string("\n")); 857 } 858 859 void WebTestProxyBase::runModalAlertDialog(WebFrame*, const WebString& message) 860 { 861 m_delegate->printMessage(string("ALERT: ") + message.utf8().data() + "\n"); 862 } 863 864 bool WebTestProxyBase::runModalConfirmDialog(WebFrame*, const WebString& message) 865 { 866 m_delegate->printMessage(string("CONFIRM: ") + message.utf8().data() + "\n"); 867 return true; 868 } 869 870 bool WebTestProxyBase::runModalPromptDialog(WebFrame* frame, const WebString& message, const WebString& defaultValue, WebString*) 871 { 872 m_delegate->printMessage(string("PROMPT: ") + message.utf8().data() + ", default text: " + defaultValue.utf8().data() + "\n"); 873 return true; 874 } 875 876 bool WebTestProxyBase::runModalBeforeUnloadDialog(WebFrame*, const WebString& message) 877 { 878 m_delegate->printMessage(string("CONFIRM NAVIGATION: ") + message.utf8().data() + "\n"); 879 return true; 880 } 881 882 } -
trunk/Tools/DumpRenderTree/chromium/TestShell.cpp
r140653 r140668 222 222 m_devTools = createNewWindow(url, 0, m_devToolsTestInterfaces.get()); 223 223 m_devTools->webView()->settings()->setMemoryInfoEnabled(true); 224 m_devTools-> setLogConsoleOutput(false);224 m_devTools->proxy()->setLogConsoleOutput(false); 225 225 m_devToolsTestInterfaces->setDelegate(m_devTools); 226 226 m_devToolsTestInterfaces->setWebView(m_devTools->webView()); -
trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp
r140565 r140668 105 105 static int nextPageID = 1; 106 106 107 // Used to write a platform neutral file:/// URL by only taking the filename108 // (e.g., converts "file:///tmp/foo.txt" to just "foo.txt").109 static string urlSuitableForTestResult(const string& url)110 {111 if (url.empty() || string::npos == url.find("file://"))112 return url;113 114 size_t pos = url.rfind('/');115 if (pos == string::npos) {116 #if OS(WINDOWS)117 pos = url.rfind('\\');118 if (pos == string::npos)119 pos = 0;120 #else121 pos = 0;122 #endif123 }124 string filename = url.substr(pos + 1);125 if (filename.empty())126 return "file:"; // A WebKit test has this in its expected output.127 return filename;128 }129 130 107 // Get a debugging string from a WebNavigationType. 131 108 static const char* webNavigationTypeToString(WebNavigationType type) … … 224 201 void WebViewHost::didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine) 225 202 { 226 // This matches win DumpRenderTree's UIDelegate.cpp.227 if (!m_logConsoleOutput)228 return;229 string newMessage;230 if (!message.text.isEmpty()) {231 newMessage = message.text.utf8();232 size_t fileProtocol = newMessage.find("file://");233 if (fileProtocol != string::npos) {234 newMessage = newMessage.substr(0, fileProtocol)235 + urlSuitableForTestResult(newMessage.substr(fileProtocol));236 }237 }238 printf("CONSOLE MESSAGE: ");239 if (sourceLine)240 printf("line %d: ", sourceLine);241 printf("%s\n", newMessage.data());242 203 } 243 204 … … 318 279 void WebViewHost::runModalAlertDialog(WebFrame*, const WebString& message) 319 280 { 320 printf("ALERT: %s\n", message.utf8().data());321 fflush(stdout);322 281 } 323 282 324 283 bool WebViewHost::runModalConfirmDialog(WebFrame*, const WebString& message) 325 284 { 326 printf("CONFIRM: %s\n", message.utf8().data());327 285 return true; 328 286 } … … 331 289 const WebString& defaultValue, WebString*) 332 290 { 333 printf("PROMPT: %s, default text: %s\n", message.utf8().data(), defaultValue.utf8().data());334 291 return true; 335 292 } … … 337 294 bool WebViewHost::runModalBeforeUnloadDialog(WebFrame*, const WebString& message) 338 295 { 339 printf("CONFIRM NAVIGATION: %s\n", message.utf8().data());340 296 return !testRunner()->shouldStayOnPageAfterHandlingBeforeUnload(); 341 297 } … … 724 680 void WebViewHost::unableToImplementPolicyWithError(WebFrame* frame, const WebURLError& error) 725 681 { 726 printf("Policy delegate: unable to implement policy with error domain '%s', "727 "error code %d, in frame '%s'\n",728 error.domain.utf8().data(), error.reason, frame->uniqueName().utf8().data());729 682 } 730 683 … … 1208 1161 m_inModalLoop = false; 1209 1162 m_smartInsertDeleteEnabled = true; 1210 m_logConsoleOutput = true;1211 1163 #if OS(WINDOWS) 1212 1164 m_selectTrailingWhitespaceEnabled = true; … … 1266 1218 { 1267 1219 setWindowRect(rect); 1268 }1269 1270 void WebViewHost::setLogConsoleOutput(bool enabled)1271 {1272 m_logConsoleOutput = enabled;1273 1220 } 1274 1221 -
trunk/Tools/DumpRenderTree/chromium/WebViewHost.h
r140561 r140668 87 87 void setProxy(WebTestRunner::WebTestProxyBase*); 88 88 void reset(); 89 void setLogConsoleOutput(bool);90 89 void waitForPolicyDelegate(); 91 90 void setCustomPolicyDelegate(bool, bool); … … 385 384 bool m_selectTrailingWhitespaceEnabled; 386 385 387 // true if whatever is sent to the console should be logged to stdout.388 bool m_logConsoleOutput;389 390 386 // Edit command associated to the current keyboard event. 391 387 std::string m_editCommandName;
Note: See TracChangeset
for help on using the changeset viewer.