Changeset 139792 in webkit
- Timestamp:
- Jan 15, 2013 2:21:43 PM (11 years ago)
- Location:
- trunk/Tools
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r139786 r139792 1 2013-01-15 Jochen Eisinger <jochen@chromium.org> 2 3 [chromium] route more webkit_support and webviewhost callbacks through WebTestDelegate 4 https://bugs.webkit.org/show_bug.cgi?id=106904 5 6 Reviewed by Adam Barth. 7 8 * DumpRenderTree/chromium/DRTTestRunner.cpp: 9 (DRTTestRunner::DRTTestRunner): 10 (DRTTestRunner::notifyDone): 11 (DRTTestRunner::reset): 12 * DumpRenderTree/chromium/DRTTestRunner.h: 13 (DRTTestRunner): 14 * DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h: 15 (WebTestRunner::WebTestDelegate::setDeviceScaleFactor): 16 (WebTestRunner::WebTestDelegate::setFocus): 17 (WebTestRunner::WebTestDelegate::setAcceptAllCookies): 18 (WebTestRunner::WebTestDelegate::pathToLocalResource): 19 (WebTestRunner::WebTestDelegate::setLocale): 20 * DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp: 21 (WebTestRunner::TestRunner::TestRunner): 22 (WebTestRunner::TestRunner::reset): 23 (WebTestRunner::TestRunner::setAlwaysAcceptCookies): 24 (WebTestRunner): 25 (WebTestRunner::TestRunner::setWindowIsKey): 26 (WebTestRunner::TestRunner::pathToLocalResource): 27 (WebTestRunner::TestRunner::setBackingScaleFactor): 28 (WebTestRunner::TestRunner::setPOSIXLocale): 29 * DumpRenderTree/chromium/TestRunner/src/TestRunner.h: 30 (WebTestRunner::TestRunner::taskList): 31 (TestRunner): 32 * DumpRenderTree/chromium/WebViewHost.cpp: 33 (WebViewHost::setDeviceScaleFactor): 34 (WebViewHost::setFocus): 35 (WebViewHost::setAcceptAllCookies): 36 (WebViewHost::pathToLocalResource): 37 (WebViewHost::setLocale): 38 * DumpRenderTree/chromium/WebViewHost.h: 39 (WebViewHost): 40 1 41 2013-01-15 Zan Dobersek <zdobersek@igalia.com> 2 42 -
trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp
r139779 r139792 69 69 #include <algorithm> 70 70 #include <cctype> 71 #include <clocale>72 71 #include <cstdlib> 73 72 #include <limits> … … 117 116 bindMethod("notifyDone", &DRTTestRunner::notifyDone); 118 117 bindMethod("numberOfPendingGeolocationPermissionRequests", &DRTTestRunner:: numberOfPendingGeolocationPermissionRequests); 119 bindMethod("pathToLocalResource", &DRTTestRunner::pathToLocalResource);120 118 bindMethod("queueBackNavigation", &DRTTestRunner::queueBackNavigation); 121 119 bindMethod("queueForwardNavigation", &DRTTestRunner::queueForwardNavigation); … … 125 123 bindMethod("queueNonLoadingScript", &DRTTestRunner::queueNonLoadingScript); 126 124 bindMethod("queueReload", &DRTTestRunner::queueReload); 127 bindMethod("setAlwaysAcceptCookies", &DRTTestRunner::setAlwaysAcceptCookies);128 125 bindMethod("setCloseRemainingWindowsWhenComplete", &DRTTestRunner::setCloseRemainingWindowsWhenComplete); 129 126 bindMethod("setCustomPolicyDelegate", &DRTTestRunner::setCustomPolicyDelegate); … … 136 133 bindMethod("setPointerLockWillFailSynchronously", &DRTTestRunner::setPointerLockWillFailSynchronously); 137 134 #endif 138 bindMethod("setPOSIXLocale", &DRTTestRunner::setPOSIXLocale);139 bindMethod("setBackingScaleFactor", &DRTTestRunner::setBackingScaleFactor);140 135 bindMethod("setWillSendRequestClearHeader", &DRTTestRunner::setWillSendRequestClearHeader); 141 136 bindMethod("setWillSendRequestReturnsNull", &DRTTestRunner::setWillSendRequestReturnsNull); 142 137 bindMethod("setWillSendRequestReturnsNullOnRedirect", &DRTTestRunner::setWillSendRequestReturnsNullOnRedirect); 143 bindMethod("setWindowIsKey", &DRTTestRunner::setWindowIsKey);144 138 #if ENABLE(NOTIFICATIONS) 145 139 bindMethod("simulateLegacyWebNotificationClick", &DRTTestRunner::simulateLegacyWebNotificationClick); … … 219 213 { 220 214 // Test didn't timeout. Kill the timeout timer. 221 m_taskList.revokeAll();215 taskList()->revokeAll(); 222 216 223 217 completeNotifyDone(false); … … 390 384 { 391 385 TestRunner::reset(); 392 if (m_shell)393 m_shell->webViewHost()->setDeviceScaleFactor(1);394 386 m_waitUntilDone = false; 395 387 m_webHistoryItemCount.set(0); 396 388 m_interceptPostMessage.set(false); 397 398 webkit_support::SetAcceptAllCookies(false);399 400 setlocale(LC_ALL, "");401 389 402 390 if (m_closeRemainingWindows) … … 405 393 m_closeRemainingWindows = true; 406 394 m_workQueue.reset(); 407 m_taskList.revokeAll();408 395 } 409 396 … … 435 422 if (arguments.size() > 0 && arguments[0].isBool()) 436 423 m_closeRemainingWindows = arguments[0].value.boolValue; 437 result->setNull();438 }439 440 void DRTTestRunner::setAlwaysAcceptCookies(const CppArgumentList& arguments, CppVariant* result)441 {442 if (arguments.size() > 0)443 webkit_support::SetAcceptAllCookies(cppVariantToBool(arguments[0]));444 result->setNull();445 }446 447 void DRTTestRunner::setWindowIsKey(const CppArgumentList& arguments, CppVariant* result)448 {449 if (arguments.size() > 0 && arguments[0].isBool())450 m_shell->setFocus(m_shell->webView(), arguments[0].value.boolValue);451 424 result->setNull(); 452 425 } … … 495 468 } 496 469 497 void DRTTestRunner::pathToLocalResource(const CppArgumentList& arguments, CppVariant* result)498 {499 result->setNull();500 if (arguments.size() <= 0 || !arguments[0].isString())501 return;502 503 string url = arguments[0].toString();504 #if OS(WINDOWS)505 if (!url.find("/tmp/")) {506 // We want a temp file.507 const unsigned tempPrefixLength = 5;508 size_t bufferSize = MAX_PATH;509 OwnArrayPtr<WCHAR> tempPath = adoptArrayPtr(new WCHAR[bufferSize]);510 DWORD tempLength = ::GetTempPathW(bufferSize, tempPath.get());511 if (tempLength + url.length() - tempPrefixLength + 1 > bufferSize) {512 bufferSize = tempLength + url.length() - tempPrefixLength + 1;513 tempPath = adoptArrayPtr(new WCHAR[bufferSize]);514 tempLength = GetTempPathW(bufferSize, tempPath.get());515 ASSERT(tempLength < bufferSize);516 }517 string resultPath(WebString(tempPath.get(), tempLength).utf8());518 resultPath.append(url.substr(tempPrefixLength));519 result->set(resultPath);520 return;521 }522 #endif523 524 // Some layout tests use file://// which we resolve as a UNC path. Normalize525 // them to just file:///.526 string lowerUrl = url;527 transform(lowerUrl.begin(), lowerUrl.end(), lowerUrl.begin(), ::tolower);528 while (!lowerUrl.find("file:////")) {529 url = url.substr(0, 8) + url.substr(9);530 lowerUrl = lowerUrl.substr(0, 8) + lowerUrl.substr(9);531 }532 result->set(webkit_support::RewriteLayoutTestsURL(url).spec());533 }534 535 470 536 471 #if ENABLE(NOTIFICATIONS) … … 579 514 host->displayRepaintMask(); 580 515 result->setNull(); 581 }582 583 void DRTTestRunner::setPOSIXLocale(const CppArgumentList& arguments, CppVariant* result)584 {585 result->setNull();586 if (arguments.size() == 1 && arguments[0].isString())587 setlocale(LC_ALL, arguments[0].toString().c_str());588 516 } 589 517 … … 703 631 #endif 704 632 705 class InvokeCallbackTask : public WebMethodTask<DRTTestRunner> {706 public:707 InvokeCallbackTask(DRTTestRunner* object, PassOwnArrayPtr<CppVariant> callbackArguments, uint32_t numberOfArguments)708 : WebMethodTask<DRTTestRunner>(object)709 , m_callbackArguments(callbackArguments)710 , m_numberOfArguments(numberOfArguments)711 {712 }713 714 virtual void runIfValid()715 {716 CppVariant invokeResult;717 m_callbackArguments[0].invokeDefault(m_callbackArguments.get(), m_numberOfArguments, invokeResult);718 }719 720 private:721 OwnArrayPtr<CppVariant> m_callbackArguments;722 uint32_t m_numberOfArguments;723 };724 725 void DRTTestRunner::setBackingScaleFactor(const CppArgumentList& arguments, CppVariant* result)726 {727 if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isObject())728 return;729 730 float value = arguments[0].value.doubleValue;731 m_shell->webViewHost()->setDeviceScaleFactor(value);732 733 OwnArrayPtr<CppVariant> callbackArguments = adoptArrayPtr(new CppVariant[1]);734 callbackArguments[0].set(arguments[1]);735 result->setNull();736 postTask(new InvokeCallbackTask(this, callbackArguments.release(), 1));737 }738 739 633 #if ENABLE(POINTER_LOCK) 740 634 void DRTTestRunner::didAcquirePointerLock(const CppArgumentList&, CppVariant* result) -
trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.h
r139779 r139792 94 94 void queueLoadHTMLString(const CppArgumentList&, CppVariant*); 95 95 96 // Changes the cookie policy from the default to allow all cookies.97 void setAlwaysAcceptCookies(const CppArgumentList&, CppVariant*);98 99 // Gives focus to the window.100 void setWindowIsKey(const CppArgumentList&, CppVariant*);101 102 96 103 97 // Causes navigation actions just printout the intended navigation instead … … 117 111 // Causes WillSendRequest to return an empty request. 118 112 void setWillSendRequestReturnsNull(const CppArgumentList&, CppVariant*); 119 120 // Converts a URL starting with file:///tmp/ to the local mapping.121 void pathToLocalResource(const CppArgumentList&, CppVariant*);122 113 123 114 #if ENABLE(NOTIFICATIONS) … … 130 121 void display(const CppArgumentList&, CppVariant*); 131 122 void displayInvalidatedRegion(const CppArgumentList&, CppVariant*); 132 133 // Calls setlocale(LC_ALL, ...) for a specified locale.134 // Resets between tests.135 void setPOSIXLocale(const CppArgumentList&, CppVariant*);136 123 137 124 // Gets the number of geolocation permissions requests pending. … … 165 152 #endif 166 153 167 // Used to set the device scale factor.168 void setBackingScaleFactor(const CppArgumentList&, CppVariant*);169 170 154 public: 171 155 // The following methods are not exposed to JavaScript. … … 198 182 virtual bool run(TestShell*) = 0; 199 183 }; 200 201 WebTaskList* taskList() { return &m_taskList; }202 184 203 185 private: … … 242 224 }; 243 225 244 // Used for test timeouts.245 WebTaskList m_taskList;246 247 226 // Non-owning pointer. The DRTTestRunner is owned by the host. 248 227 TestShell* m_shell; -
trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h
r139776 r139792 88 88 virtual void clearAllDatabases() { } 89 89 virtual void setDatabaseQuota(int) { } 90 virtual void setDeviceScaleFactor(float) { } 91 virtual void setFocus(bool) { } 92 virtual void setAcceptAllCookies(bool) { } 93 virtual std::string pathToLocalResource(const std::string& resource) { return std::string(); } 94 virtual void setLocale(const std::string&) { } 90 95 }; 91 96 -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
r139779 r139792 48 48 #include "WebSettings.h" 49 49 #include "WebSurroundingText.h" 50 #include "WebTask.h" 50 51 #include "WebTestDelegate.h" 51 52 #include "WebView.h" … … 54 55 #include "platform/WebSerializedScriptValue.h" 55 56 #include "v8/include/v8.h" 57 #include <wtf/OwnArrayPtr.h> 56 58 #include <wtf/text/WTFString.h> 57 59 … … 75 77 virtual void postFailure(const WebSerializedScriptValue& data) const { } 76 78 virtual void destroy() { } 79 }; 80 81 class InvokeCallbackTask : public WebMethodTask<TestRunner> { 82 public: 83 InvokeCallbackTask(TestRunner* object, PassOwnArrayPtr<CppVariant> callbackArguments, uint32_t numberOfArguments) 84 : WebMethodTask<TestRunner>(object) 85 , m_callbackArguments(callbackArguments) 86 , m_numberOfArguments(numberOfArguments) 87 { 88 } 89 90 virtual void runIfValid() 91 { 92 CppVariant invokeResult; 93 m_callbackArguments[0].invokeDefault(m_callbackArguments.get(), m_numberOfArguments, invokeResult); 94 } 95 96 private: 97 OwnArrayPtr<CppVariant> m_callbackArguments; 98 uint32_t m_numberOfArguments; 77 99 }; 78 100 … … 181 203 bindMethod("clearAllDatabases", &TestRunner::clearAllDatabases); 182 204 bindMethod("setDatabaseQuota", &TestRunner::setDatabaseQuota); 205 bindMethod("setAlwaysAcceptCookies", &TestRunner::setAlwaysAcceptCookies); 206 bindMethod("setWindowIsKey", &TestRunner::setWindowIsKey); 207 bindMethod("pathToLocalResource", &TestRunner::pathToLocalResource); 208 bindMethod("setBackingScaleFactor", &TestRunner::setBackingScaleFactor); 209 bindMethod("setPOSIXLocale", &TestRunner::setPOSIXLocale); 183 210 184 211 // Properties. … … 250 277 // Reset the default quota for each origin to 5MB 251 278 m_delegate->setDatabaseQuota(5 * 1024 * 1024); 279 m_delegate->setDeviceScaleFactor(1); 280 m_delegate->setAcceptAllCookies(false); 281 m_delegate->setLocale(""); 252 282 253 283 m_dumpEditingCallbacks = false; … … 283 313 284 314 m_webPermissions->reset(); 315 316 m_taskList.revokeAll(); 285 317 } 286 318 … … 1321 1353 } 1322 1354 1355 void TestRunner::setAlwaysAcceptCookies(const CppArgumentList& arguments, CppVariant* result) 1356 { 1357 if (arguments.size() > 0) 1358 m_delegate->setAcceptAllCookies(cppVariantToBool(arguments[0])); 1359 result->setNull(); 1360 } 1361 1362 void TestRunner::setWindowIsKey(const CppArgumentList& arguments, CppVariant* result) 1363 { 1364 if (arguments.size() > 0 && arguments[0].isBool()) 1365 m_delegate->setFocus(arguments[0].value.boolValue); 1366 result->setNull(); 1367 } 1368 1369 void TestRunner::pathToLocalResource(const CppArgumentList& arguments, CppVariant* result) 1370 { 1371 result->setNull(); 1372 if (arguments.size() <= 0 || !arguments[0].isString()) 1373 return; 1374 1375 result->set(m_delegate->pathToLocalResource(arguments[0].toString())); 1376 } 1377 1378 void TestRunner::setBackingScaleFactor(const CppArgumentList& arguments, CppVariant* result) 1379 { 1380 if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isObject()) 1381 return; 1382 1383 float value = arguments[0].value.doubleValue; 1384 m_delegate->setDeviceScaleFactor(value); 1385 1386 OwnArrayPtr<CppVariant> callbackArguments = adoptArrayPtr(new CppVariant[1]); 1387 callbackArguments[0].set(arguments[1]); 1388 result->setNull(); 1389 m_delegate->postTask(new InvokeCallbackTask(this, callbackArguments.release(), 1)); 1390 } 1391 1392 void TestRunner::setPOSIXLocale(const CppArgumentList& arguments, CppVariant* result) 1393 { 1394 result->setNull(); 1395 if (arguments.size() == 1 && arguments[0].isString()) 1396 m_delegate->setLocale(arguments[0].toString()); 1397 } 1398 1323 1399 void TestRunner::dumpEditingCallbacks(const CppArgumentList&, CppVariant* result) 1324 1400 { -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h
r139779 r139792 35 35 #include "CppBoundClass.h" 36 36 #include "WebDeliveredIntentClient.h" 37 #include "WebTask.h" 37 38 #include "WebTestRunner.h" 38 39 #include "platform/WebArrayBufferView.h" … … 59 60 60 61 void reset(); 62 63 WebTaskList* taskList() { return &m_taskList; } 61 64 62 65 // WebTestRunner implementation. … … 338 341 void setDatabaseQuota(const CppArgumentList&, CppVariant*); 339 342 343 // Changes the cookie policy from the default to allow all cookies. 344 void setAlwaysAcceptCookies(const CppArgumentList&, CppVariant*); 345 346 // Gives focus to the window. 347 void setWindowIsKey(const CppArgumentList&, CppVariant*); 348 349 // Converts a URL starting with file:///tmp/ to the local mapping. 350 void pathToLocalResource(const CppArgumentList&, CppVariant*); 351 352 // Used to set the device scale factor. 353 void setBackingScaleFactor(const CppArgumentList&, CppVariant*); 354 355 // Calls setlocale(LC_ALL, ...) for a specified locale. 356 // Resets between tests. 357 void setPOSIXLocale(const CppArgumentList&, CppVariant*); 358 340 359 /////////////////////////////////////////////////////////////////////////// 341 360 // Properties 342 361 void workerThreadCount(CppVariant*); 343 362 344 ////////////////////////////////////////////////////////////////////////// /363 ////////////////////////////////////////////////////////////////////////// 345 364 // Fallback and stub methods 346 365 … … 467 486 WebKit::WebArrayBufferView m_audioData; 468 487 488 // Used for test timeouts. 489 WebTaskList m_taskList; 490 469 491 WebTestDelegate* m_delegate; 470 492 WebKit::WebView* m_webView; -
trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp
r139779 r139792 71 71 #include "webkit/support/test_media_stream_client.h" 72 72 #include "webkit/support/webkit_support.h" 73 #include <cctype> 74 #include <clocale> 73 75 #include <public/WebCString.h> 74 76 #include <public/WebCompositorOutputSurface.h> … … 1077 1079 { 1078 1080 webkit_support::SetDatabaseQuota(quota); 1081 } 1082 1083 void WebViewHost::setDeviceScaleFactor(float deviceScaleFactor) 1084 { 1085 webView()->setDeviceScaleFactor(deviceScaleFactor); 1086 discardBackingStore(); 1087 } 1088 1089 void WebViewHost::setFocus(bool focused) 1090 { 1091 m_shell->setFocus(m_shell->webView(), focused); 1092 } 1093 1094 void WebViewHost::setAcceptAllCookies(bool acceptCookies) 1095 { 1096 webkit_support::SetAcceptAllCookies(acceptCookies); 1097 } 1098 1099 string WebViewHost::pathToLocalResource(const string& url) 1100 { 1101 #if OS(WINDOWS) 1102 if (!url.find("/tmp/")) { 1103 // We want a temp file. 1104 const unsigned tempPrefixLength = 5; 1105 size_t bufferSize = MAX_PATH; 1106 OwnArrayPtr<WCHAR> tempPath = adoptArrayPtr(new WCHAR[bufferSize]); 1107 DWORD tempLength = ::GetTempPathW(bufferSize, tempPath.get()); 1108 if (tempLength + url.length() - tempPrefixLength + 1 > bufferSize) { 1109 bufferSize = tempLength + url.length() - tempPrefixLength + 1; 1110 tempPath = adoptArrayPtr(new WCHAR[bufferSize]); 1111 tempLength = GetTempPathW(bufferSize, tempPath.get()); 1112 ASSERT(tempLength < bufferSize); 1113 } 1114 string resultPath(WebString(tempPath.get(), tempLength).utf8()); 1115 resultPath.append(url.substr(tempPrefixLength)); 1116 return resultPath; 1117 } 1118 #endif 1119 1120 // Some layout tests use file://// which we resolve as a UNC path. Normalize 1121 // them to just file:///. 1122 string lowerUrl = url; 1123 string result = url; 1124 transform(lowerUrl.begin(), lowerUrl.end(), lowerUrl.begin(), ::tolower); 1125 while (!lowerUrl.find("file:////")) { 1126 result = result.substr(0, 8) + result.substr(9); 1127 lowerUrl = lowerUrl.substr(0, 8) + lowerUrl.substr(9); 1128 } 1129 return webkit_support::RewriteLayoutTestsURL(result).spec(); 1130 } 1131 1132 void WebViewHost::setLocale(const std::string& locale) 1133 { 1134 setlocale(LC_ALL, locale.c_str()); 1079 1135 } 1080 1136 … … 1402 1458 } 1403 1459 1404 void WebViewHost::setDeviceScaleFactor(float deviceScaleFactor)1405 {1406 webView()->setDeviceScaleFactor(deviceScaleFactor);1407 discardBackingStore();1408 }1409 1410 1460 void WebViewHost::setPageTitle(const WebString&) 1411 1461 { -
trunk/Tools/DumpRenderTree/chromium/WebViewHost.h
r139776 r139792 97 97 void setRequestReturnNull(bool returnNull) { m_requestReturnNull = returnNull; } 98 98 void setPendingExtraData(PassOwnPtr<TestShellExtraData>); 99 void setDeviceScaleFactor(float);100 99 101 100 void paintRect(const WebKit::WebRect&); … … 157 156 virtual void clearAllDatabases() OVERRIDE; 158 157 virtual void setDatabaseQuota(int) OVERRIDE; 158 virtual void setDeviceScaleFactor(float) OVERRIDE; 159 virtual void setFocus(bool) OVERRIDE; 160 virtual void setAcceptAllCookies(bool) OVERRIDE; 161 virtual std::string pathToLocalResource(const std::string& url) OVERRIDE; 162 virtual void setLocale(const std::string&) OVERRIDE; 159 163 160 164 // NavigationHost
Note: See TracChangeset
for help on using the changeset viewer.