Changeset 190335 in webkit
- Timestamp:
- Sep 29, 2015 6:20:23 PM (9 years ago)
- Location:
- trunk/Tools
- Files:
-
- 12 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r190334 r190335 1 2015-09-29 Simon Fraser <simon.fraser@apple.com> 2 3 WebKitTestRunner fails to apply "useFlexibleViewport" when it's specified in a file comment 4 https://bugs.webkit.org/show_bug.cgi?id=149650 5 6 Reviewed by Tim Horton. 7 8 TestInvocation::invoke() consulted shouldMakeViewportFlexible(), but that only 9 looks at the file path, and not the custom options that come from file comments. 10 11 Fix by computing TestOptions before making the TestInvocation, and setting them 12 as const TestInvocation data. This meant changing various call sites to take 13 the std::string pathOrURL, rather than the TestInvocation itself. 14 15 Also initialize TestInvocation with a WKURLRef, rather than a std::string. 16 17 * WebKitTestRunner/CMakeLists.txt: 18 * WebKitTestRunner/TestController.cpp: 19 (WTR::TestController::ensureViewSupportsOptionsForTest): 20 (WTR::testPath): 21 (WTR::createTestURL): 22 (WTR::updateTestOptionsFromTestHeader): 23 (WTR::TestController::testOptionsForTest): 24 (WTR::TestController::updateWebViewSizeForTest): 25 (WTR::TestController::updateWindowScaleForTest): 26 (WTR::TestController::runTest): 27 * WebKitTestRunner/TestController.h: 28 * WebKitTestRunner/TestInvocation.cpp: 29 (WTR::TestInvocation::TestInvocation): 30 (WTR::TestInvocation::invoke): 31 (WTR::createWKURL): Deleted. 32 (WTR::TestInvocation::shouldMakeViewportFlexible): Deleted. 33 (WTR::TestInvocation::shouldUseFixedLayout): Deleted. 34 * WebKitTestRunner/TestInvocation.h: 35 (WTR::TestInvocation::options): 36 * WebKitTestRunner/TestOptions.cpp: Copied from Tools/WebKitTestRunner/TestOptions.h. 37 (WTR::pathContains): 38 (WTR::shouldMakeViewportFlexible): 39 (WTR::shouldUseFixedLayout): 40 (WTR::isSVGTestPath): 41 (WTR::isHiDPITestPath): 42 (WTR::TestOptions::TestOptions): 43 * WebKitTestRunner/TestOptions.h: 44 * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: 45 * WebKitTestRunner/efl/TestControllerEfl.cpp: 46 (WTR::pathContains): 47 (WTR::shouldUseFixedLayout): 48 (WTR::TestController::updatePlatformSpecificTestOptionsForTest): 49 * WebKitTestRunner/gtk/TestControllerGtk.cpp: 50 (WTR::TestController::updatePlatformSpecificTestOptionsForTest): 51 * WebKitTestRunner/ios/TestControllerIOS.mm: 52 (WTR::TestController::updatePlatformSpecificTestOptionsForTest): 53 * WebKitTestRunner/mac/TestControllerMac.mm: 54 (WTR::TestController::updatePlatformSpecificTestOptionsForTest): 55 1 56 2015-09-29 Aakash Jain <aakash_jain@apple.com> 2 57 -
trunk/Tools/WebKitTestRunner/CMakeLists.txt
r190065 r190335 13 13 ${WEBKIT_TESTRUNNER_DIR}/TestController.cpp 14 14 ${WEBKIT_TESTRUNNER_DIR}/TestInvocation.cpp 15 ${WEBKIT_TESTRUNNER_DIR}/TestOptions.cpp 15 16 ${WEBKIT_TESTRUNNER_DIR}/WebNotificationProvider.cpp 16 17 ${WEBKIT_TESTRUNNER_DIR}/WorkQueueManager.cpp -
trunk/Tools/WebKitTestRunner/TestController.cpp
r190262 r190335 59 59 #include <stdlib.h> 60 60 #include <string> 61 #include <unistd.h> 61 62 #include <wtf/MainThread.h> 62 63 #include <wtf/RunLoop.h> … … 586 587 void TestController::ensureViewSupportsOptionsForTest(const TestInvocation& test) 587 588 { 588 auto options = test OptionsForTest(test);589 auto options = test.options(); 589 590 590 591 if (m_mainWebView) { … … 808 809 } 809 810 810 static std::string testPath( constWKURLRef url)811 static std::string testPath(WKURLRef url) 811 812 { 812 813 auto scheme = adoptWK(WKURLCopyScheme(url)); … … 820 821 } 821 822 823 static WKURLRef createTestURL(const char* pathOrURL) 824 { 825 if (strstr(pathOrURL, "http://") || strstr(pathOrURL, "https://") || strstr(pathOrURL, "file://")) 826 return WKURLCreateWithUTF8CString(pathOrURL); 827 828 // Creating from filesytem path. 829 size_t length = strlen(pathOrURL); 830 if (!length) 831 return 0; 832 833 const char separator = '/'; 834 bool isAbsolutePath = pathOrURL[0] == separator; 835 const char* filePrefix = "file://"; 836 static const size_t prefixLength = strlen(filePrefix); 837 838 std::unique_ptr<char[]> buffer; 839 if (isAbsolutePath) { 840 buffer = std::make_unique<char[]>(prefixLength + length + 1); 841 strcpy(buffer.get(), filePrefix); 842 strcpy(buffer.get() + prefixLength, pathOrURL); 843 } else { 844 buffer = std::make_unique<char[]>(prefixLength + PATH_MAX + length + 2); // 1 for the separator 845 strcpy(buffer.get(), filePrefix); 846 if (!getcwd(buffer.get() + prefixLength, PATH_MAX)) 847 return 0; 848 size_t numCharacters = strlen(buffer.get()); 849 buffer[numCharacters] = separator; 850 strcpy(buffer.get() + numCharacters + 1, pathOrURL); 851 } 852 853 return WKURLCreateWithUTF8CString(buffer.get()); 854 } 855 822 856 static bool parseBooleanTestHeaderValue(const std::string& value) 823 857 { … … 831 865 } 832 866 833 static void updateTestOptionsFromTestHeader(TestOptions& testOptions, const TestInvocation& test) 834 { 835 std::string filename = testPath(test.url()); 867 static void updateTestOptionsFromTestHeader(TestOptions& testOptions, const std::string& pathOrURL) 868 { 869 // Gross. Need to reduce conversions between all the string types and URLs. 870 WKRetainPtr<WKURLRef> wkURL(AdoptWK, createTestURL(pathOrURL.c_str())); 871 std::string filename = testPath(wkURL.get()); 836 872 if (filename.empty()) 837 873 return; … … 875 911 } 876 912 877 TestOptions TestController::testOptionsForTest(const TestInvocation& test) const878 { 879 TestOptions options ;913 TestOptions TestController::testOptionsForTest(const std::string& pathOrURL) const 914 { 915 TestOptions options(pathOrURL); 880 916 881 917 options.useRemoteLayerTree = m_shouldUseRemoteLayerTree; 882 918 options.shouldShowWebView = m_shouldShowWebView; 883 options.useFixedLayout = test.shouldUseFixedLayout(); 884 options.useFlexibleViewport = test.shouldMakeViewportFlexible(); 885 886 updatePlatformSpecificTestOptionsForTest(options, test); 887 888 updateTestOptionsFromTestHeader(options, test); 919 920 updatePlatformSpecificTestOptionsForTest(options, pathOrURL); 921 updateTestOptionsFromTestHeader(options, pathOrURL); 889 922 890 923 return options; … … 893 926 void TestController::updateWebViewSizeForTest(const TestInvocation& test) 894 927 { 895 bool isSVGW3CTest = test.urlContains("svg/W3C-SVG-1.1") || test.urlContains("svg\\W3C-SVG-1.1");896 897 928 unsigned width = viewWidth; 898 929 unsigned height = viewHeight; 899 if ( isSVGW3CTest) {930 if (test.options().isSVGTest) { 900 931 width = w3cSVGViewWidth; 901 932 height = w3cSVGViewHeight; … … 907 938 void TestController::updateWindowScaleForTest(PlatformWebView* view, const TestInvocation& test) 908 939 { 909 bool needsHighDPIWindow = test.urlContains("/hidpi-"); 910 view->changeWindowScaleIfNeeded(needsHighDPIWindow ? 2 : 1); 940 view->changeWindowScaleIfNeeded(test.options().isHiDPITest ? 2 : 1); 911 941 } 912 942 … … 1010 1040 1011 1041 m_state = RunningTest; 1012 1013 m_currentInvocation = std::make_unique<TestInvocation>(command.pathOrURL); 1042 1043 TestOptions options = testOptionsForTest(command.pathOrURL); 1044 1045 WKRetainPtr<WKURLRef> wkURL(AdoptWK, createTestURL(command.pathOrURL.c_str())); 1046 m_currentInvocation = std::make_unique<TestInvocation>(wkURL.get(), options); 1047 1014 1048 if (command.shouldDumpPixels || m_shouldDumpPixelsForAllTests) 1015 1049 m_currentInvocation->setIsPixelTest(command.expectedPixelHash); -
trunk/Tools/WebKitTestRunner/TestController.h
r189668 r190335 159 159 160 160 void ensureViewSupportsOptionsForTest(const TestInvocation&); 161 TestOptions testOptionsForTest(const TestInvocation&) const;162 void updatePlatformSpecificTestOptionsForTest(TestOptions&, const TestInvocation&) const;161 TestOptions testOptionsForTest(const std::string& pathOrURL) const; 162 void updatePlatformSpecificTestOptionsForTest(TestOptions&, const std::string& pathOrURL) const; 163 163 164 164 void updateWebViewSizeForTest(const TestInvocation&); -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r190304 r190335 52 52 #endif 53 53 54 #include <unistd.h> // For getcwd.55 56 54 using namespace JSC; 57 55 using namespace WebKit; … … 60 58 namespace WTR { 61 59 62 static WKURLRef createWKURL(const char* pathOrURL) 63 { 64 if (strstr(pathOrURL, "http://") || strstr(pathOrURL, "https://") || strstr(pathOrURL, "file://")) 65 return WKURLCreateWithUTF8CString(pathOrURL); 66 67 // Creating from filesytem path. 68 size_t length = strlen(pathOrURL); 69 if (!length) 70 return 0; 71 72 const char separator = '/'; 73 bool isAbsolutePath = pathOrURL[0] == separator; 74 const char* filePrefix = "file://"; 75 static const size_t prefixLength = strlen(filePrefix); 76 77 std::unique_ptr<char[]> buffer; 78 if (isAbsolutePath) { 79 buffer = std::make_unique<char[]>(prefixLength + length + 1); 80 strcpy(buffer.get(), filePrefix); 81 strcpy(buffer.get() + prefixLength, pathOrURL); 82 } else { 83 buffer = std::make_unique<char[]>(prefixLength + PATH_MAX + length + 2); // 1 for the separator 84 strcpy(buffer.get(), filePrefix); 85 if (!getcwd(buffer.get() + prefixLength, PATH_MAX)) 86 return 0; 87 size_t numCharacters = strlen(buffer.get()); 88 buffer[numCharacters] = separator; 89 strcpy(buffer.get() + numCharacters + 1, pathOrURL); 90 } 91 92 return WKURLCreateWithUTF8CString(buffer.get()); 93 } 94 95 TestInvocation::TestInvocation(const std::string& pathOrURL) 96 : m_url(AdoptWK, createWKURL(pathOrURL.c_str())) 97 , m_dumpPixels(false) 98 , m_timeout(0) 99 , m_gotInitialResponse(false) 100 , m_gotFinalMessage(false) 101 , m_gotRepaint(false) 102 , m_error(false) 103 , m_webProcessIsUnresponsive(false) 60 TestInvocation::TestInvocation(WKURLRef url, const TestOptions& options) 61 : m_options(options) 62 , m_url(url) 104 63 { 105 64 WKRetainPtr<WKStringRef> urlString = adoptWK(WKURLCopyString(m_url.get())); … … 143 102 { 144 103 return urlContains("globalhistory/"); 145 }146 147 bool TestInvocation::shouldMakeViewportFlexible() const148 {149 return urlContains("viewport/");150 }151 152 bool TestInvocation::shouldUseFixedLayout() const153 {154 #if ENABLE(CSS_DEVICE_ADAPTATION)155 if (urlContains("device-adapt/") || urlContains("device-adapt\\"))156 return true;157 #endif158 159 return false;160 104 } 161 105 … … 182 126 183 127 WKRetainPtr<WKStringRef> useFlexibleViewportKey = adoptWK(WKStringCreateWithUTF8CString("UseFlexibleViewport")); 184 WKRetainPtr<WKBooleanRef> useFlexibleViewportValue = adoptWK(WKBooleanCreate( shouldMakeViewportFlexible()));128 WKRetainPtr<WKBooleanRef> useFlexibleViewportValue = adoptWK(WKBooleanCreate(options().useFlexibleViewport)); 185 129 WKDictionarySetItem(beginTestMessageBody.get(), useFlexibleViewportKey.get(), useFlexibleViewportValue.get()); 186 130 -
trunk/Tools/WebKitTestRunner/TestInvocation.h
r190304 r190335 28 28 29 29 #include "JSWrappable.h" 30 #include "TestOptions.h" 30 31 #include "UIScriptContext.h" 31 #include <JavaScriptCore/JSRetainPtr.h>32 32 #include <WebKit/WKRetainPtr.h> 33 33 #include <string> … … 40 40 WTF_MAKE_NONCOPYABLE(TestInvocation); 41 41 public: 42 explicit TestInvocation( const std::string& pathOrURL);42 explicit TestInvocation(WKURLRef, const TestOptions&); 43 43 ~TestInvocation(); 44 44 45 45 WKURLRef url() const; 46 46 bool urlContains(const char*) const; 47 48 const TestOptions& options() const { return m_options; } 47 49 48 50 void setIsPixelTest(const std::string& expectedPixelHash); … … 63 65 void didEndSwipe(); 64 66 void didRemoveSwipeSnapshot(); 65 66 bool shouldMakeViewportFlexible() const;67 bool shouldUseFixedLayout() const;68 67 69 68 private: … … 91 90 void uiScriptDidComplete(WKStringRef result, unsigned callbackID) override; 92 91 92 const TestOptions m_options; 93 93 94 WKRetainPtr<WKURLRef> m_url; 94 95 WTF::String m_urlString; 95 96 96 bool m_dumpPixels;97 bool m_pixelResultIsPending { false };98 97 std::string m_expectedPixelHash; 99 98 100 int m_timeout ;99 int m_timeout { 0 }; 101 100 102 101 // Invocation state 103 bool m_gotInitialResponse; 104 bool m_gotFinalMessage; 105 bool m_gotRepaint; 106 bool m_error; 102 bool m_gotInitialResponse { false }; 103 bool m_gotFinalMessage { false }; 104 bool m_gotRepaint { false }; 105 bool m_error { false }; 106 107 bool m_dumpPixels { false }; 108 bool m_pixelResultIsPending { false }; 109 bool m_webProcessIsUnresponsive { false }; 107 110 108 111 StringBuilder m_textOutput; … … 111 114 WKRetainPtr<WKArrayRef> m_repaintRects; 112 115 std::string m_errorMessage; 113 bool m_webProcessIsUnresponsive;114 116 115 117 std::unique_ptr<UIScriptContext> m_UIScriptContext; -
trunk/Tools/WebKitTestRunner/TestOptions.cpp
r190334 r190335 24 24 */ 25 25 26 #i fndef TestOptions_h27 # define TestOptions_h26 #include "config.h" 27 #include "TestOptions.h" 28 28 29 #include < wtf/Vector.h>29 #include <string> 30 30 #include <wtf/text/WTFString.h> 31 31 32 32 namespace WTR { 33 33 34 struct TestOptions { 35 bool useThreadedScrolling { false }; 36 bool useRemoteLayerTree { false }; 37 bool shouldShowWebView { false }; 38 bool useFlexibleViewport { false }; 39 bool useFixedLayout { false }; 40 Vector<String> overrideLanguages; 41 }; 34 static bool pathContains(const std::string& pathOrURL, const char* substring) 35 { 36 String path(pathOrURL.c_str()); 37 return path.contains(substring); // Case-insensitive. 38 } 39 40 static bool shouldMakeViewportFlexible(const std::string& pathOrURL) 41 { 42 return pathContains(pathOrURL, "viewport/"); 43 } 44 45 static bool shouldUseFixedLayout(const std::string& pathOrURL) 46 { 47 #if ENABLE(CSS_DEVICE_ADAPTATION) 48 if (pathContains(pathOrURL, "device-adapt/") || pathContains(pathOrURL, "device-adapt\\")) 49 return true; 50 #endif 51 return false; 52 } 53 54 static bool isSVGTestPath(const std::string& pathOrURL) 55 { 56 return pathContains(pathOrURL, "svg/W3C-SVG-1.1") || pathContains(pathOrURL, "svg\\W3C-SVG-1.1"); 57 } 58 59 static bool isHiDPITestPath(const std::string& pathOrURL) 60 { 61 return pathContains(pathOrURL, "/hidpi-"); 62 } 63 64 TestOptions::TestOptions(const std::string& pathOrURL) 65 : useFlexibleViewport(shouldMakeViewportFlexible(pathOrURL)) 66 , useFixedLayout(shouldUseFixedLayout(pathOrURL)) 67 , isSVGTest(isSVGTestPath(pathOrURL)) 68 , isHiDPITest(isHiDPITestPath(pathOrURL)) 69 { 70 } 42 71 43 72 } 44 45 #endif // TestOptions_h -
trunk/Tools/WebKitTestRunner/TestOptions.h
r190065 r190335 38 38 bool useFlexibleViewport { false }; 39 39 bool useFixedLayout { false }; 40 bool isSVGTest { false }; 41 bool isHiDPITest { false }; 42 40 43 Vector<String> overrideLanguages; 44 45 TestOptions(const std::string& pathOrURL); 41 46 }; 42 47 -
trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
r190065 r190335 35 35 /* Begin PBXBuildFile section */ 36 36 0F5169CC1445222D00E0A9D7 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F5169CA1445222D00E0A9D7 /* WebKit.framework */; }; 37 0F622CE91BBB3A1A00838AD3 /* TestOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F622CE81BBB3A1A00838AD3 /* TestOptions.cpp */; settings = {ASSET_TAGS = (); }; }; 37 38 0F73B5511BA78968004B3EF4 /* JSUIScriptController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F73B54F1BA78968004B3EF4 /* JSUIScriptController.cpp */; }; 38 39 0F73B5521BA78968004B3EF4 /* JSUIScriptController.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F73B5501BA78968004B3EF4 /* JSUIScriptController.h */; }; … … 171 172 0F2109C7189C650D00F879A3 /* BaseTarget.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = BaseTarget.xcconfig; sourceTree = "<group>"; }; 172 173 0F5169CA1445222D00E0A9D7 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 174 0F622CE81BBB3A1A00838AD3 /* TestOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestOptions.cpp; sourceTree = "<group>"; }; 173 175 0F73B54F1BA78968004B3EF4 /* JSUIScriptController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSUIScriptController.cpp; path = DerivedSources/WebKitTestRunner/JSUIScriptController.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; 174 176 0F73B5501BA78968004B3EF4 /* JSUIScriptController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSUIScriptController.h; path = DerivedSources/WebKitTestRunner/JSUIScriptController.h; sourceTree = BUILT_PRODUCTS_DIR; }; … … 407 409 BCD7D2F711921278006DB7EE /* TestInvocation.cpp */, 408 410 BCD7D2F611921278006DB7EE /* TestInvocation.h */, 411 0F622CE81BBB3A1A00838AD3 /* TestOptions.cpp */, 409 412 1A3326051B75396500F89F62 /* TestOptions.h */, 410 413 BC251A1711D16774002EBC01 /* WebKitTestRunnerPrefix.h */, … … 936 939 buildActionMask = 2147483647; 937 940 files = ( 941 0F622CE91BBB3A1A00838AD3 /* TestOptions.cpp in Sources */, 938 942 0F73B55A1BA792FF004B3EF4 /* JSWrapper.cpp in Sources */, 939 943 A18510441B9AE14A00744AEB /* WorkQueueManager.cpp in Sources */, -
trunk/Tools/WebKitTestRunner/efl/TestControllerEfl.cpp
r189668 r190335 135 135 } 136 136 137 static bool shouldUseFixedLayout(const TestInvocation& test)137 static bool pathContains(const std::string& pathOrURL, const char* substring) 138 138 { 139 #if ENABLE(CSS_DEVICE_ADAPTATION) 140 if (test.urlContains("device-adapt/") || test.urlContains("device-adapt\\")) 141 return true; 142 #endif 139 String path(pathOrURL.c_str()); 140 return path.contains(substring); // Case-insensitive. 141 } 143 142 143 static bool shouldUseFixedLayout(const std::string& pathOrURL) 144 { 144 145 #if USE(COORDINATED_GRAPHICS) 145 if ( test.urlContains("sticky/") || test.urlContains("sticky\\"))146 if (pathContains(pathOrURL, "sticky/") || pathContains(pathOrURL, "sticky\\")) 146 147 return true; 147 148 #endif … … 149 150 } 150 151 151 void TestController::updatePlatformSpecificTestOptionsForTest(TestOptions& testOptions, const TestInvocation& test) const152 void TestController::updatePlatformSpecificTestOptionsForTest(TestOptions& testOptions, const std::string& pathOrURL) const 152 153 { 153 testOptions.useFixedLayout = shouldUseFixedLayout( test);154 testOptions.useFixedLayout = shouldUseFixedLayout(pathOrURL); 154 155 } 155 156 -
trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp
r189668 r190335 129 129 } 130 130 131 void TestController::updatePlatformSpecificTestOptionsForTest(TestOptions&, const TestInvocation&) const131 void TestController::updatePlatformSpecificTestOptionsForTest(TestOptions&, const std::string&) const 132 132 { 133 133 } -
trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm
r189958 r190335 89 89 void TestController::platformConfigureViewForTest(const TestInvocation& test) 90 90 { 91 if (test. shouldMakeViewportFlexible()) {91 if (test.options().useFlexibleViewport) { 92 92 const unsigned phoneViewHeight = 480; 93 93 const unsigned phoneViewWidth = 320; … … 99 99 } 100 100 101 void TestController::updatePlatformSpecificTestOptionsForTest(TestOptions&, const TestInvocation&) const101 void TestController::updatePlatformSpecificTestOptionsForTest(TestOptions&, const std::string&) const 102 102 { 103 103 } -
trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm
r190065 r190335 92 92 } 93 93 94 void TestController::updatePlatformSpecificTestOptionsForTest(TestOptions& options, const TestInvocation& test) const94 void TestController::updatePlatformSpecificTestOptionsForTest(TestOptions& options, const std::string&) const 95 95 { 96 96 options.useThreadedScrolling = true;
Note: See TracChangeset
for help on using the changeset viewer.