Changeset 269157 in webkit
- Timestamp:
- Oct 29, 2020, 11:18:10 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
Source/WebKitLegacy/win/ChangeLog (modified) (1 diff)
-
Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl (modified) (1 diff)
-
Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h (modified) (1 diff)
-
Source/WebKitLegacy/win/WebPreferences.cpp (modified) (1 diff)
-
Source/WebKitLegacy/win/WebPreferences.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/DumpRenderTree/win/DumpRenderTree.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKitLegacy/win/ChangeLog
r269066 r269157 1 2020-10-29 Sam Weinig <weinig@apple.com> 2 3 [Testing] Remove requirement of adding new SPI for each preference that needs testing (WebKitLegacy Windows) 4 https://bugs.webkit.org/show_bug.cgi?id=218291 5 6 Reviewed by Brent Fulgham. 7 8 Expose a set of setters for DumpRenderTree to use when setting preferences 9 by string, matching WebKitLegacy for cocoa platforms and modern WebKit. 10 11 * Interfaces/IWebPreferencesPrivate.idl: 12 * WebPreferences.cpp: 13 (WebPreferences::setBoolPreferenceForTesting): 14 (WebPreferences::setUInt32PreferenceForTesting): 15 (WebPreferences::setDoublePreferenceForTesting): 16 (WebPreferences::setStringPreferenceForTesting): 17 * WebPreferences.h: 18 1 19 2020-10-27 Fujii Hironori <Hironori.Fujii@sony.com> 2 20 -
trunk/Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl
r267988 r269157 270 270 HRESULT contactPickerAPIEnabled([out, retval] BOOL* enabled); 271 271 HRESULT setContactPickerAPIEnabled([in] BOOL enabled); 272 } 272 HRESULT setBoolPreferenceForTesting([in] BSTR key, [in] BOOL value); 273 HRESULT setUInt32PreferenceForTesting([in] BSTR key, [in] unsigned value); 274 HRESULT setDoublePreferenceForTesting([in] BSTR key, [in] double value); 275 HRESULT setStringPreferenceForTesting([in] BSTR key, [in] BSTR value); 276 } -
trunk/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h
r267988 r269157 185 185 #define WebKitMenuItemElementEnabledPreferenceKey "WebKitMenuItemElementEnabled" 186 186 187 #define WebKitKeygenElementEnabledPreferenceKey "WebKitKeygenElementEnabled "187 #define WebKitKeygenElementEnabledPreferenceKey "WebKitKeygenElementEnabledPreferenceKey" 188 188 189 189 #define WebKitModernMediaControlsEnabledPreferenceKey "WebKitModernMediaControlsEnabled" -
trunk/Source/WebKitLegacy/win/WebPreferences.cpp
r268647 r269157 2329 2329 } 2330 2330 2331 HRESULT WebPreferences::setBoolPreferenceForTesting(_In_ BSTR key, _In_ BOOL value) 2332 { 2333 if (!SysStringLen(key)) 2334 return E_FAIL; 2335 2336 #if USE(CF) 2337 auto keyString = String(key).createCFString(); 2338 setValueForKey(keyString.get(), value ? kCFBooleanTrue : kCFBooleanFalse); 2339 #endif 2340 2341 postPreferencesChangesNotification(); 2342 2343 return S_OK; 2344 } 2345 2346 HRESULT WebPreferences::setUInt32PreferenceForTesting(_In_ BSTR key, _In_ unsigned value) 2347 { 2348 if (!SysStringLen(key)) 2349 return E_FAIL; 2350 2351 #if USE(CF) 2352 auto keyString = String(key).createCFString(); 2353 setValueForKey(keyString.get(), cfNumber(static_cast<int>(value)).get()); 2354 #endif 2355 2356 postPreferencesChangesNotification(); 2357 2358 return S_OK; 2359 } 2360 2361 HRESULT WebPreferences::setDoublePreferenceForTesting(_In_ BSTR key, _In_ double value) 2362 { 2363 if (!SysStringLen(key)) 2364 return E_FAIL; 2365 2366 #if USE(CF) 2367 auto keyString = String(key).createCFString(); 2368 setValueForKey(keyString.get(), cfNumber(static_cast<float>(value)).get()); 2369 #endif 2370 2371 postPreferencesChangesNotification(); 2372 2373 return S_OK; 2374 } 2375 2376 HRESULT WebPreferences::setStringPreferenceForTesting(_In_ BSTR key, _In_ BSTR value) 2377 { 2378 if (!SysStringLen(key) || !SysStringLen(value)) 2379 return E_FAIL; 2380 2381 #if USE(CF) 2382 auto keyString = String(key).createCFString(); 2383 auto valueString = String(value).createCFString(); 2384 setValueForKey(keyString.get(), valueString.get()); 2385 #endif 2386 2387 postPreferencesChangesNotification(); 2388 2389 return S_OK; 2390 } 2391 2331 2392 HRESULT WebPreferences::setApplicationId(BSTR applicationId) 2332 2393 { -
trunk/Source/WebKitLegacy/win/WebPreferences.h
r267988 r269157 308 308 virtual HRESULT STDMETHODCALLTYPE contactPickerAPIEnabled(_Out_ BOOL*); 309 309 virtual HRESULT STDMETHODCALLTYPE setContactPickerAPIEnabled(BOOL); 310 virtual HRESULT STDMETHODCALLTYPE setBoolPreferenceForTesting(_In_ BSTR key, _In_ BOOL); 311 virtual HRESULT STDMETHODCALLTYPE setUInt32PreferenceForTesting(_In_ BSTR key, _In_ unsigned); 312 virtual HRESULT STDMETHODCALLTYPE setDoublePreferenceForTesting(_In_ BSTR key, _In_ double); 313 virtual HRESULT STDMETHODCALLTYPE setStringPreferenceForTesting(_In_ BSTR key, _In_ BSTR); 310 314 311 315 // WebPreferences -
trunk/Tools/ChangeLog
r269132 r269157 1 2020-10-29 Sam Weinig <weinig@apple.com> 2 3 [Testing] Remove requirement of adding new SPI for each preference that needs testing (WebKitLegacy Windows) 4 https://bugs.webkit.org/show_bug.cgi?id=218291 5 6 Reviewed by Brent Fulgham. 7 8 Adopt set*PreferenceForTesting functions to match DumpRenderTree for cocoa platforms, and 9 make it so that only TestOptions.cpp needs to be touched to add support for new preference 10 in tests. 11 12 Also adds some helpers to convert between string types and use RetainPtr in a few more places. 13 14 * DumpRenderTree/win/DumpRenderTree.cpp: 15 (toUTF8): 16 (toBSTR): 17 (resetWebPreferencesToConsistentValues): 18 (boolWebPreferenceFeatureValue): 19 (setWebPreferencesForTestOptions): 20 (runTest): 21 1 22 2020-10-28 Aakash Jain <aakash_jain@apple.com> 2 23 -
trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp
r269111 r269157 233 233 #endif 234 234 235 st ring toUTF8(BSTR bstr)235 std::string toUTF8(BSTR bstr) 236 236 { 237 237 return toUTF8(bstr, SysStringLen(bstr)); 238 238 } 239 239 240 st ring toUTF8(const wstring& wideString)240 std::string toUTF8(const wstring& wideString) 241 241 { 242 242 return toUTF8(wideString.c_str(), wideString.length()); 243 } 244 245 static std::string toUTF8(CFStringRef input) 246 { 247 CFIndex maximumURLLengthAsUTF8 = CFStringGetMaximumSizeForEncoding(CFStringGetLength(input), kCFStringEncodingUTF8) + 1; 248 Vector<char> buffer(maximumURLLengthAsUTF8 + 1, 0); 249 CFStringGetCString(input, buffer.data(), maximumURLLengthAsUTF8, kCFStringEncodingUTF8); 250 251 return buffer.data(); 243 252 } 244 253 … … 249 258 250 259 return wstring(v.data(), v.size()); 260 } 261 262 static _bstr_t toBSTR(const std::string& input) 263 { 264 return input.c_str(); 265 } 266 267 static _bstr_t toBSTR(CFStringRef input) 268 { 269 size_t stringLength = CFStringGetLength(input); 270 Vector<UniChar> buffer(stringLength + 1, 0); 271 CFStringGetCharacters(input, CFRangeMake(0, stringLength), buffer.data()); 272 return reinterpret_cast<wchar_t*>(buffer.data()); 251 273 } 252 274 … … 885 907 prefsPrivate->setFrameFlatteningEnabled(FALSE); 886 908 if (persistentUserStyleSheetLocation) { 887 size_t stringLength = CFStringGetLength(persistentUserStyleSheetLocation.get()); 888 Vector<UniChar> urlCharacters(stringLength + 1, 0); 889 CFStringGetCharacters(persistentUserStyleSheetLocation.get(), CFRangeMake(0, stringLength), urlCharacters.data()); 890 _bstr_t url(reinterpret_cast<wchar_t*>(urlCharacters.data())); 891 preferences->setUserStyleSheetLocation(url); 909 preferences->setUserStyleSheetLocation(toBSTR(persistentUserStyleSheetLocation.get())); 892 910 preferences->setUserStyleSheetEnabled(TRUE); 893 911 } else … … 913 931 } 914 932 915 static bool boolWebPreferenceFeatureValue(std::string key, bool defaultValue,const WTR::TestOptions& options)933 static bool boolWebPreferenceFeatureValue(std::string key, const WTR::TestOptions& options) 916 934 { 917 935 auto it = options.boolWebPreferenceFeatures().find(key); 918 if (it != options.boolWebPreferenceFeatures().end()) 919 return it->second; 920 return defaultValue; 936 ASSERT(it != options.boolWebPreferenceFeatures().end()); 937 return it->second; 921 938 } 922 939 … … 927 944 preferences->setPrivateBrowsingEnabled(options.useEphemeralSession()); 928 945 929 preferences->setUsesPageCache(boolWebPreferenceFeatureValue("UsesBackForwardCache", false, options)); 930 prefsPrivate->setMenuItemElementEnabled(boolWebPreferenceFeatureValue("MenuItemElementEnabled", false, options)); 931 prefsPrivate->setKeygenElementEnabled(boolWebPreferenceFeatureValue("KeygenElementEnabled", false, options)); 932 prefsPrivate->setModernMediaControlsEnabled(boolWebPreferenceFeatureValue("ModernMediaControlsEnabled", true, options)); 933 prefsPrivate->setInspectorAdditionsEnabled(boolWebPreferenceFeatureValue("InspectorAdditionsEnabled", false, options)); 934 prefsPrivate->setRequestIdleCallbackEnabled(boolWebPreferenceFeatureValue("RequestIdleCallbackEnabled", false, options)); 935 prefsPrivate->setAsyncClipboardAPIEnabled(boolWebPreferenceFeatureValue("AsyncClipboardAPIEnabled", false, options)); 936 prefsPrivate->setContactPickerAPIEnabled(boolWebPreferenceFeatureValue("ContactPickerAPIEnabled", false, options)); 937 prefsPrivate->setAllowTopNavigationToDataURLs(boolWebPreferenceFeatureValue("AllowTopNavigationToDataURLs", true, options)); 938 prefsPrivate->setCSSOMViewSmoothScrollingEnabled(boolWebPreferenceFeatureValue("CSSOMViewSmoothScrollingEnabled", false, options)); 939 prefsPrivate->setSpatialNavigationEnabled(boolWebPreferenceFeatureValue("SpatialNavigationEnabled", false, options)); 940 preferences->setTabsToLinks(boolWebPreferenceFeatureValue("TabsToLinks", false, options)); 946 // FIXME: Remove this once there is a viable mechanism for reseting WebPreferences between tests, 947 // at which point, we will not need to manually reset every supported preference for each test. 948 for (const auto& key : options.supportedBoolWebPreferenceFeatures()) 949 prefsPrivate->setBoolPreferenceForTesting(toBSTR(WTR::TestOptions::toWebKitLegacyPreferenceKey(key)), boolWebPreferenceFeatureValue(key, options)); 941 950 } 942 951 … … 1196 1205 static _bstr_t methodBStr(TEXT("GET")); 1197 1206 1198 CFStringRef str = CFStringCreateWithCString(0, pathOrURL.c_str(), kCFStringEncodingWindowsLatin1);1207 auto str = adoptCF(CFStringCreateWithCString(0, pathOrURL.c_str(), kCFStringEncodingWindowsLatin1)); 1199 1208 if (!str) { 1200 1209 fprintf(stderr, "Failed to parse \"%s\" as UTF-8\n", pathOrURL.c_str()); … … 1202 1211 } 1203 1212 1204 CFURLRef url = CFURLCreateWithString(0, str, 0); 1205 1213 auto url = adoptCF(CFURLCreateWithString(0, str.get(), 0)); 1206 1214 if (!url) 1207 url = CFURLCreateWithFileSystemPath(0, str, kCFURLWindowsPathStyle, false); 1208 1209 CFRelease(str); 1215 url = adoptCF(CFURLCreateWithFileSystemPath(0, str.get(), kCFURLWindowsPathStyle, false)); 1210 1216 1211 1217 if (!url) { … … 1214 1220 } 1215 1221 1216 String hostName = String(adoptCF(CFURLCopyHostName(url)).get()); 1217 1222 String hostName = String(adoptCF(CFURLCopyHostName(url.get())).get()); 1218 1223 String fallbackPath = findFontFallback(pathOrURL.c_str()); 1219 1224 1220 str = CFURLGetString(url); 1221 1222 CFIndex length = CFStringGetLength(str); 1223 1224 Vector<UniChar> buffer(length + 1, 0); 1225 CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data()); 1226 1227 _bstr_t urlBStr(reinterpret_cast<wchar_t*>(buffer.data())); 1228 ASSERT(urlBStr.length() == length); 1229 1230 CFIndex maximumURLLengthAsUTF8 = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1; 1231 Vector<char> testURL(maximumURLLengthAsUTF8 + 1, 0); 1232 CFStringGetCString(str, testURL.data(), maximumURLLengthAsUTF8, kCFStringEncodingUTF8); 1233 1234 CFRelease(url); 1225 auto urlCFString = CFURLGetString(url.get()); 1226 1227 auto urlBStr = toBSTR(urlCFString); 1228 ASSERT(urlBStr.length() == CFStringGetLength(urlCFString)); 1235 1229 1236 1230 auto options = testOptionsForTest(command); … … 1238 1232 resetWebViewToConsistentStateBeforeTesting(options); 1239 1233 1240 ::gTestRunner = TestRunner::create(t estURL.data(), command.expectedPixelHash);1234 ::gTestRunner = TestRunner::create(toUTF8(urlCFString), command.expectedPixelHash); 1241 1235 ::gTestRunner->setCustomTimeout(command.timeout.milliseconds()); 1242 1236 ::gTestRunner->setDumpJSConsoleLogInStdErr(command.dumpJSConsoleLogInStdErr || options.dumpJSConsoleLogInStdErr());
Note:
See TracChangeset
for help on using the changeset viewer.