Changeset 237924 in webkit
- Timestamp:
- Nov 7, 2018 6:57:40 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r237919 r237924 1 2018-11-07 Zamiul Haque <zhaque@apple.com> 2 3 Created a layout test to ensure that date controls marked as credit card expiry 4 fields present a Gregorian calendar regardless of default system settings. 5 https://bugs.webkit.org/show_bug.cgi?id=191096 6 rdar://problem/42640256 7 8 Reviewed by Tim Horton. 9 10 Added two new methods to UIHelper, helping to facilitate this. calendarType 11 returns the calendar identifier of the NSCalendar instance used by the presented 12 date picker and setDefaultCalendarType accepts a calendar identifier as an 13 argument for changing the default system settings. 14 15 * fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html: 16 * platform/win/TestExpectations: 17 * resources/ui-helper.js: 18 (window.UIHelper.calendarType): 19 (window.UIHelper.setDefaultCalendarType): 20 1 21 2018-11-07 Tadeu Zagallo <tzagallo@apple.com> 2 22 -
trunk/LayoutTests/resources/ui-helper.js
r237743 r237924 347 347 } 348 348 349 static calendarType() 350 { 351 if (!this.isWebKit2()) 352 return Promise.resolve(); 353 354 return new Promise(resolve => { 355 testRunner.runUIScript(`(() => { 356 uiController.doAfterNextStablePresentationUpdate(() => { 357 uiController.uiScriptComplete(JSON.stringify(uiController.calendarType)); 358 }) 359 })()`, jsonString => { 360 resolve(JSON.parse(jsonString)); 361 }); 362 }); 363 } 364 365 static setDefaultCalendarType(calendarIdentifier) 366 { 367 if (!this.isWebKit2()) 368 return Promise.resolve(); 369 370 return new Promise(resolve => testRunner.runUIScript(`uiController.setDefaultCalendarType('${calendarIdentifier}')`, resolve)); 371 372 } 373 349 374 static setViewScale(scale) 350 375 { -
trunk/Source/WebKit/ChangeLog
r237923 r237924 1 2018-11-07 Zamiul Haque <zhaque@apple.com> 2 3 Force a gregorian calendar to show for credit card expiration date inputs 4 (autocomplete='cc-exp'*) regardless of default system settings. 5 https://bugs.webkit.org/show_bug.cgi?id=191096 6 rdar://problem/42640256 7 8 Reviewed by Tim Horton. 9 10 Added some plumbing code to expose the calendar identifier of the calendar used by a 11 presented date picker. Added shouldPresentGregorianCalendar:, to be used for 12 determining what property values a date input control must present a Gregorian 13 calendar for. 14 15 * UIProcess/ios/WKContentViewInteraction.mm: 16 (-[WKContentView formInputPeripheral]): 17 * UIProcess/ios/forms/WKFormInputControl.mm: 18 1 19 2018-11-07 Carlos Garcia Campos <cgarcia@igalia.com> 2 20 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r237820 r237924 93 93 @class WKActionSheetAssistant; 94 94 @class WKFocusedFormControlView; 95 @class WKFormInputControl; 95 96 @class WKFormInputSession; 96 97 @class WKInspectorNodeSearchGestureRecognizer; … … 423 424 @property (nonatomic, readonly) NSString *selectFormPopoverTitle; 424 425 @property (nonatomic, readonly) NSString *formInputLabel; 426 @property (nonatomic, readonly) WKFormInputControl *formInputControl; 425 427 426 428 @end -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r237820 r237924 5962 5962 @implementation WKContentView (WKTesting) 5963 5963 5964 - (WKFormInputControl *)formInputControl 5965 { 5966 if ([_inputPeripheral isKindOfClass:WKFormInputControl.class]) 5967 return (WKFormInputControl *)_inputPeripheral.get(); 5968 return nil; 5969 } 5970 5964 5971 - (void)_simulateTextEntered:(NSString *)text 5965 5972 { -
trunk/Source/WebKit/UIProcess/ios/forms/WKFormInputControl.h
r237266 r237924 34 34 @end 35 35 36 @interface WKFormInputControl (WKTesting) 37 @property (nonatomic, readonly) NSString *dateTimePickerCalendarType; 38 @end 39 36 40 #endif // PLATFORM(IOS_FAMILY) -
trunk/Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm
r237266 r237924 48 48 @end 49 49 50 @interface WKDateTimePopover : WKFormRotatingAccessoryPopover<WKFormControl> { 51 RetainPtr<WKDateTimePopoverViewController> _viewController; 52 WKContentView *_view; 53 } 54 - (id)initWithView:(WKContentView *)view datePickerMode:(UIDatePickerMode)mode; 55 - (WKDateTimePopoverViewController *)viewController; 56 @end 57 50 58 @interface WKDateTimePicker : NSObject<WKFormControl> { 51 59 RetainPtr<UIDatePicker> _datePicker; … … 57 65 - (id)initWithView:(WKContentView *)view datePickerMode:(UIDatePickerMode)mode; 58 66 - (UIDatePicker *)datePicker; 59 @end 60 61 @interface WKDateTimePopover : WKFormRotatingAccessoryPopover<WKFormControl> { 62 RetainPtr<WKDateTimePopoverViewController> _viewController; 63 WKContentView* _view; 64 } 65 - (id)initWithView:(WKContentView *)view datePickerMode:(UIDatePickerMode)mode; 66 - (WKDateTimePopoverViewController *) viewController; 67 67 68 @end 68 69 … … 110 111 _datePicker.get().datePickerMode = mode; 111 112 _datePicker.get().hidden = NO; 113 114 if ([self shouldPresentGregorianCalendar:view.assistedNodeInformation]) 115 _datePicker.get().calendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian]; 116 112 117 [_datePicker addTarget:self action:@selector(_dateChangeHandler:) forControlEvents:UIControlEventValueChanged]; 113 118 114 119 return self; 120 } 121 122 - (NSString *)calendarType 123 { 124 return _datePicker.get().calendar.calendarIdentifier; 115 125 } 116 126 … … 119 129 [_datePicker removeTarget:self action:NULL forControlEvents:UIControlEventValueChanged]; 120 130 [super dealloc]; 131 } 132 133 - (BOOL)shouldPresentGregorianCalendar:(const AssistedNodeInformation&)nodeInfo 134 { 135 return nodeInfo.autofillFieldName == WebCore::AutofillFieldName::CcExpMonth 136 || nodeInfo.autofillFieldName == WebCore::AutofillFieldName::CcExp 137 || nodeInfo.autofillFieldName == WebCore::AutofillFieldName::CcExpYear; 121 138 } 122 139 … … 281 298 @end 282 299 300 @implementation WKFormInputControl (WKTesting) 301 - (NSString *)dateTimePickerCalendarType 302 { 303 if ([(NSObject *)_control.get() isKindOfClass:WKDateTimePicker.class]) 304 return [(WKDateTimePicker *)_control.get() calendarType]; 305 return nil; 306 } 307 @end 283 308 284 309 @implementation WKDateTimePopoverViewController -
trunk/Tools/ChangeLog
r237914 r237924 1 2018-11-07 Zamiul Haque <zhaque@apple.com> 2 3 Force a gregorian calendar to show for credit card expiration date inputs 4 (autocomplete='cc-exp'*) regardless of default system settings. 5 https://bugs.webkit.org/show_bug.cgi?id=191096 6 rdar://problem/42640256 7 8 Reviewed by Tim Horton. 9 10 Implemented simulateForeignDefaultCalendar and calendarType to be used 11 for changing the default calendar returned by the system (ie. [NSCalendar 12 currentCalendar]) and getting the calendar type identifier of a presented date 13 picker. 14 15 * DumpRenderTree/ios/UIScriptControllerIOS.mm: 16 (WTR::UIScriptController::isShowingDataListSuggestions const): 17 (WTR::UIScriptController::calendarType const): 18 (WTR::UIScriptController::setDefaultCalendarType): 19 * DumpRenderTree/mac/UIScriptControllerMac.mm: 20 (WTR::UIScriptController::calendarType const): 21 (WTR::UIScriptController::setDefaultCalendarType): 22 * TestRunnerShared/UIScriptContext/UIScriptController.cpp: 23 (WTR::UIScriptController::selectionEndGrabberViewRect const): 24 (WTR::UIScriptController::calendarType const): Deleted. 25 * WebKitTestRunner/TestController.cpp: 26 * WebKitTestRunner/TestController.h: 27 * WebKitTestRunner/UIScriptControllerCocoa.mm: 28 (WTR::UIScriptController::calendarType const): 29 * WebKitTestRunner/cocoa/TestControllerCocoa.mm: 30 (WTR::swizzledCalendar): 31 (WTR::TestController::getOverriddenCalendarIdentifier const): 32 (WTR::TestController::setDefaultCalendarType): 33 (WTR::TestController::cocoaResetStateToConsistentValues): 34 * WebKitTestRunner/ios/UIScriptControllerIOS.mm: 35 (WTR::UIScriptController::selectionEndGrabberViewRect const): 36 (WTR::UIScriptController::calendarType const): Deleted. 37 1 38 2018-11-06 Jonathan Bedard <jbedard@apple.com> 2 39 -
trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
r237786 r237924 395 395 } 396 396 397 JSObjectRef UIScriptController::calendarType() const 398 { 399 return nullptr; 400 } 401 402 void UIScriptController::setDefaultCalendarType(JSStringRef calendarIdentifier) 403 { 404 } 405 397 406 void UIScriptController::overridePreference(JSStringRef, JSStringRef) 398 407 { -
trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm
r237305 r237924 197 197 { 198 198 } 199 199 200 JSObjectRef UIScriptController::calendarType() const 201 { 202 return nullptr; 203 } 204 205 void UIScriptController::setDefaultCalendarType(JSStringRef calendarIdentifier) 206 { 207 } 208 200 209 } 201 210 -
trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
r237305 r237924 23 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 26 enum DeviceOrientation { 27 27 "portrait", … … 243 243 readonly attribute object selectionStartGrabberViewRect; 244 244 readonly attribute object selectionEndGrabberViewRect; 245 245 readonly attribute object calendarType; 246 void setDefaultCalendarType(DOMString calendarIdentifier); 246 247 readonly attribute object inputViewBounds; 247 248 -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
r237786 r237924 227 227 return nullptr; 228 228 } 229 230 void UIScriptController::setDefaultCalendarType(JSStringRef calendarIdentifier) 231 { 232 } 233 234 JSObjectRef UIScriptController::calendarType() const 235 { 236 return nullptr; 237 } 238 229 239 #endif 230 240 -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
r237305 r237924 164 164 JSObjectRef selectionStartGrabberViewRect() const; 165 165 JSObjectRef selectionEndGrabberViewRect() const; 166 JSObjectRef calendarType() const; 167 void setDefaultCalendarType(JSStringRef calendarIdentifier); 166 168 JSObjectRef inputViewBounds() const; 167 169 -
trunk/Tools/WebKitTestRunner/TestController.h
r237893 r237924 34 34 #include <vector> 35 35 #include <wtf/HashMap.h> 36 #include <wtf/Noncopyable.h> 36 37 #include <wtf/Seconds.h> 37 38 #include <wtf/Vector.h> 38 39 #include <wtf/text/StringHash.h> 39 40 41 #if PLATFORM(COCOA) 42 43 #include <objc/runtime.h> 44 45 #endif 46 47 OBJC_CLASS NSString; 40 48 OBJC_CLASS WKWebViewConfiguration; 41 49 … … 48 56 struct TestCommand; 49 57 struct TestOptions; 58 59 #if PLATFORM(COCOA) 60 // FIXME: This should be shared with TestWebKitAPI. 61 class ClassMethodSwizzler { 62 WTF_MAKE_NONCOPYABLE(ClassMethodSwizzler); 63 public: 64 ClassMethodSwizzler(Class, SEL, IMP); 65 ~ClassMethodSwizzler(); 66 67 Method m_method; 68 IMP m_originalImplementation; 69 }; 70 #endif // PLATFORM(COCOA) 50 71 51 72 class AsyncTask { … … 263 284 void toggleCapsLock(); 264 285 286 #if PLATFORM(COCOA) 287 RetainPtr<NSString> getOverriddenCalendarIdentifier() const; 288 void setDefaultCalendarType(NSString *identifier); 289 #endif // PLATFORM(COCOA) 265 290 private: 266 291 WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(WKContextConfigurationRef); … … 414 439 415 440 std::unique_ptr<TestInvocation> m_currentInvocation; 416 441 #if PLATFORM(COCOA) 442 std::unique_ptr<ClassMethodSwizzler> m_calendarSwizzler; 443 RetainPtr<NSString> m_overriddenCalendarIdentifier; 444 #endif // PLATFORM(COCOA) 417 445 bool m_verbose { false }; 418 446 bool m_printSeparators { false }; -
trunk/Tools/WebKitTestRunner/UIScriptControllerCocoa.mm
r237786 r237924 165 165 } 166 166 167 void UIScriptController::setDefaultCalendarType(JSStringRef calendarIdentifier) 168 { 169 #if WK_API_ENABLED 170 TestController::singleton().setDefaultCalendarType((__bridge NSString *)adoptCF(JSStringCopyCFString(kCFAllocatorDefault, calendarIdentifier)).get()); 171 #endif 172 } 173 174 JSObjectRef UIScriptController::calendarType() const 175 { 176 #if WK_API_ENABLED 177 WKWebView *webView = TestController::singleton().mainWebView()->platformView(); 178 UIView *contentView = [webView valueForKeyPath:@"_currentContentView"]; 179 NSString *calendarTypeString = [contentView valueForKeyPath:@"formInputControl.dateTimePickerCalendarType"]; 180 auto jsContext = m_context->jsContext(); 181 return JSValueToObject(jsContext, [JSValue valueWithObject:calendarTypeString inContext:[JSContext contextWithJSGlobalContextRef:jsContext]].JSValueRef, nullptr); 182 #else 183 return nullptr; 184 #endif 185 } 186 167 187 } // namespace WTR -
trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
r237893 r237924 204 204 } 205 205 206 ClassMethodSwizzler::ClassMethodSwizzler(Class cls, SEL originalSelector, IMP implementation) 207 : m_method(class_getClassMethod(objc_getMetaClass(NSStringFromClass(cls).UTF8String), originalSelector)) 208 , m_originalImplementation(method_setImplementation(m_method, implementation)) 209 { 210 } 211 212 ClassMethodSwizzler::~ClassMethodSwizzler() 213 { 214 method_setImplementation(m_method, m_originalImplementation); 215 } 216 217 static NSCalendar *swizzledCalendar() 218 { 219 return [NSCalendar calendarWithIdentifier:TestController::singleton().getOverriddenCalendarIdentifier().get()]; 220 } 221 222 RetainPtr<NSString> TestController::getOverriddenCalendarIdentifier() const 223 { 224 return m_overriddenCalendarIdentifier; 225 } 226 227 void TestController::setDefaultCalendarType(NSString *identifier) 228 { 229 m_overriddenCalendarIdentifier = identifier; 230 if (!m_calendarSwizzler) 231 m_calendarSwizzler = std::make_unique<ClassMethodSwizzler>([NSCalendar class], @selector(currentCalendar), reinterpret_cast<IMP>(swizzledCalendar)); 232 } 233 206 234 void TestController::cocoaResetStateToConsistentValues(const TestOptions& options) 207 235 { … … 215 243 216 244 245 m_calendarSwizzler = nullptr; 246 m_overriddenCalendarIdentifier = nil; 247 217 248 if (auto* webView = mainWebView()) { 218 249 TestRunnerWKWebView *platformView = webView->platformView();
Note: See TracChangeset
for help on using the changeset viewer.