Title: [241275] trunk
Revision
241275
Author
[email protected]
Date
2019-02-11 11:30:05 -0800 (Mon, 11 Feb 2019)

Log Message

fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html does not work on iPad
https://bugs.webkit.org/show_bug.cgi?id=194313

Reviewed by Tim Horton.

Source/WebKit:

Make `-dateTimePickerCalendarType` work on iPad by handling the case where the date picker control is a
WKDateTimePopover. This fixes UIScriptController::calendarType() returning null on iPad.

* UIProcess/ios/forms/WKFormInputControl.mm:
(-[WKFormInputControl dateTimePickerCalendarType]):
(-[WKDateTimePopover calendarType]):

Tools:

Add a helper to determine whether the web view is presenting modal UI.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::isPresentingModally const):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::isPresentingModally const):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/UIScriptControllerCocoa.mm:
(WTR::UIScriptController::calendarType const): Deleted.
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::isPresentingModally const):
(WTR::UIScriptController::calendarType const):
* WebKitTestRunner/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::calendarType const):

LayoutTests:

Adjusts an existing layout test to work on both iPhone and iPad simulators.

* fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry-expected.txt:
* fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html:

Make this test wait after blurring the currently focused element, such that tapping to focus the next form
control doesn't fail. Notably on iPad, not waiting for the popover to dismiss meant that subsequent taps would
be dispatched too soon, and hit-test to the popover view being dismissed rather than WKWebView.

* platform/ipad/TestExpectations:

Unskip the test on iPad.

* resources/ui-helper.js:

Add helpers to query whether or not the keyboard is shown, and whether or not a view controller is being modally
presented over the current root view controller (this is the case when interacting with date pickers on iPad).

(window.UIHelper.isShowingKeyboard):
(window.UIHelper.isPresentingModally):
(window.UIHelper.deactivateFormControl):

Add a new helper method to blur the given form control element and wait for web view chrome to finish dismissing
(on iOS, this is either the date picker input view in the keyboard on iPhone, or the date picker popover view
controller on iPad).

(window.UIHelper.isShowingDataListSuggestions):

Drive-by fix: remove an extraneous ternary conditional statement.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (241274 => 241275)


--- trunk/LayoutTests/ChangeLog	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/LayoutTests/ChangeLog	2019-02-11 19:30:05 UTC (rev 241275)
@@ -1,3 +1,40 @@
+2019-02-11  Wenson Hsieh  <[email protected]>
+
+        fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html does not work on iPad
+        https://bugs.webkit.org/show_bug.cgi?id=194313
+
+        Reviewed by Tim Horton.
+
+        Adjusts an existing layout test to work on both iPhone and iPad simulators.
+
+        * fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry-expected.txt:
+        * fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html:
+
+        Make this test wait after blurring the currently focused element, such that tapping to focus the next form
+        control doesn't fail. Notably on iPad, not waiting for the popover to dismiss meant that subsequent taps would
+        be dispatched too soon, and hit-test to the popover view being dismissed rather than WKWebView.
+
+        * platform/ipad/TestExpectations:
+
+        Unskip the test on iPad.
+
+        * resources/ui-helper.js:
+
+        Add helpers to query whether or not the keyboard is shown, and whether or not a view controller is being modally
+        presented over the current root view controller (this is the case when interacting with date pickers on iPad).
+
+        (window.UIHelper.isShowingKeyboard):
+        (window.UIHelper.isPresentingModally):
+        (window.UIHelper.deactivateFormControl):
+
+        Add a new helper method to blur the given form control element and wait for web view chrome to finish dismissing
+        (on iOS, this is either the date picker input view in the keyboard on iPhone, or the date picker popover view
+        controller on iPad).
+
+        (window.UIHelper.isShowingDataListSuggestions):
+
+        Drive-by fix: remove an extraneous ternary conditional statement.
+
 2019-02-11  Daniel Bates  <[email protected]>
 
         [iOS] Mouse/Touch/Pointer events are missing modifier keys

Modified: trunk/LayoutTests/fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry-expected.txt (241274 => 241275)


--- trunk/LayoutTests/fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry-expected.txt	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/LayoutTests/fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry-expected.txt	2019-02-11 19:30:05 UTC (rev 241275)
@@ -1,4 +1,5 @@
  
+
 Date input control marked as 'cc-exp' (default calendar set to japanese):
 { calendarType = gregorian }
 Date input control not marked as 'cc-exp' (default calendar set to japanese):

Modified: trunk/LayoutTests/fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html (241274 => 241275)


--- trunk/LayoutTests/fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/LayoutTests/fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html	2019-02-11 19:30:05 UTC (rev 241275)
@@ -11,12 +11,14 @@
         }
 
         #target0, #target1 {
-            font-size: 150px;
+            font-size: 40px;
+            width: 100%;
         }
     </style>
 </head>
 <body>
     <input type='date' id='target0' autocomplete='cc-exp'>
+    <br>
     <input type='date' id='target1'>
     <pre id="output"></pre>
     <script>
@@ -32,13 +34,7 @@
             output.appendChild(paragraph);
         }
 
-        function toString(value)
-        {
-            return `{ calendarType = ${value} }`;
-        }
-
         (async () => {
-
             if (!window.testRunner || !testRunner.runUIScript) {
                 appendOutput(`This test checks if a gregorian calendar is presented when a date input control marked
                     as a credit card expiry date field (ie. through autocomplete='cc-exp') is tapped on Safari iOS. For
@@ -46,24 +42,17 @@
                 return;
             }
 
-            await UIHelper.setDefaultCalendarType("japanese");
-            await UIHelper.activateElement(target0);
-            appendOutput("Date input control marked as 'cc-exp' (default calendar set to japanese):");
-            appendOutput(toString(await UIHelper.calendarType()));
+            for (const calendarType of ["japanese", "gregorian"]) {
+                await UIHelper.setDefaultCalendarType(calendarType);
+                for (const element of [target0, target1]) {
+                    await UIHelper.activateFormControl(element);
+                    const isCreditCardField = element.getAttribute("autocomplete") === "cc-exp";
+                    appendOutput(`Date input control${isCreditCardField ? "" : " not"} marked as 'cc-exp' (default calendar set to ${calendarType}):`);
+                    appendOutput(`{ calendarType = ${await UIHelper.calendarType()} }`);
+                    await UIHelper.deactivateFormControl(element);
+                }
+            }
 
-            await UIHelper.activateElement(target1);
-            appendOutput("Date input control not marked as 'cc-exp' (default calendar set to japanese):");
-            appendOutput(toString(await UIHelper.calendarType()));
-
-            await UIHelper.setDefaultCalendarType("gregorian");
-            await UIHelper.activateElement(target0);
-            appendOutput("Date input control marked as 'cc-exp' (default calendar set to gregorian):");
-            appendOutput(toString(await UIHelper.calendarType()));
-
-            await UIHelper.activateElement(target1);
-            appendOutput("Date input control not marked as 'cc-exp' (default calendar set to gregorian):");
-            appendOutput(toString(await UIHelper.calendarType()));
-
             testRunner.notifyDone();
 
         })()

Modified: trunk/LayoutTests/platform/ipad/TestExpectations (241274 => 241275)


--- trunk/LayoutTests/platform/ipad/TestExpectations	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/LayoutTests/platform/ipad/TestExpectations	2019-02-11 19:30:05 UTC (rev 241275)
@@ -46,6 +46,4 @@
 webkit.org/b/194259 fast/events/ios/rotation/safari-like-rotation.html [ Skip ]
 webkit.org/b/194259 fast/events/ios/viewport-no-width-value-allows-double-tap.html [ Skip ]
 
-webkit.org/b/194313 fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html [ Skip ]
-
 webkit.org/b/194314 fast/forms/ios/scroll-to-reveal-focused-select.html

Modified: trunk/LayoutTests/resources/ui-helper.js (241274 => 241275)


--- trunk/LayoutTests/resources/ui-helper.js	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/LayoutTests/resources/ui-helper.js	2019-02-11 19:30:05 UTC (rev 241275)
@@ -220,6 +220,37 @@
         });
     }
 
+    static isShowingKeyboard()
+    {
+        return new Promise(resolve => {
+            testRunner.runUIScript("uiController.isShowingKeyboard", result => resolve(result === "true"));
+        });
+    }
+
+    static isPresentingModally()
+    {
+        return new Promise(resolve => {
+            testRunner.runUIScript("uiController.isPresentingModally", result => resolve(result === "true"));
+        });
+    }
+
+    static deactivateFormControl(element)
+    {
+        if (!this.isWebKit2() || !this.isIOS()) {
+            element.blur();
+            return Promise.resolve();
+        }
+
+        return new Promise(async resolve => {
+            element.blur();
+            while (await this.isPresentingModally())
+                continue;
+            while (await this.isShowingKeyboard())
+                continue;
+            resolve();
+        });
+    }
+
     static waitForKeyboardToHide()
     {
         if (!this.isWebKit2() || !this.isIOS())
@@ -419,7 +450,7 @@
         return new Promise(resolve => {
             testRunner.runUIScript(`(() => {
                 uiController.uiScriptComplete(uiController.isShowingDataListSuggestions);
-            })()`, result => resolve(result === "true" ? true : false));
+            })()`, result => resolve(result === "true"));
         });
     }
 

Modified: trunk/Source/WebKit/ChangeLog (241274 => 241275)


--- trunk/Source/WebKit/ChangeLog	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/Source/WebKit/ChangeLog	2019-02-11 19:30:05 UTC (rev 241275)
@@ -1,3 +1,17 @@
+2019-02-11  Wenson Hsieh  <[email protected]>
+
+        fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html does not work on iPad
+        https://bugs.webkit.org/show_bug.cgi?id=194313
+
+        Reviewed by Tim Horton.
+
+        Make `-dateTimePickerCalendarType` work on iPad by handling the case where the date picker control is a
+        WKDateTimePopover. This fixes UIScriptController::calendarType() returning null on iPad.
+
+        * UIProcess/ios/forms/WKFormInputControl.mm:
+        (-[WKFormInputControl dateTimePickerCalendarType]):
+        (-[WKDateTimePopover calendarType]):
+
 2019-02-11  Daniel Bates  <[email protected]>
 
         [iOS] Mouse/Touch/Pointer events are missing modifier keys

Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm (241274 => 241275)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm	2019-02-11 19:30:05 UTC (rev 241275)
@@ -53,6 +53,7 @@
 }
 - (id)initWithView:(WKContentView *)view datePickerMode:(UIDatePickerMode)mode;
 - (WKDateTimePopoverViewController *)viewController;
+@property (nonatomic, readonly) NSString *calendarType;
 @end
 
 @interface WKDateTimePicker : NSObject<WKFormControl> {
@@ -239,7 +240,7 @@
 
 // WKFormInputControl
 @implementation WKFormInputControl {
-    RetainPtr<id<WKFormControl>> _control;
+    RetainPtr<NSObject <WKFormControl>> _control;
 }
 
 - (instancetype)initWithView:(WKContentView *)view
@@ -298,12 +299,18 @@
 @end
 
 @implementation WKFormInputControl (WKTesting)
+
 - (NSString *)dateTimePickerCalendarType
 {
-    if ([(NSObject *)_control.get() isKindOfClass:WKDateTimePicker.class])
+    if ([_control isKindOfClass:WKDateTimePicker.class])
         return [(WKDateTimePicker *)_control.get() calendarType];
+
+    if ([_control isKindOfClass:WKDateTimePopover.class])
+        return [(WKDateTimePopover *)_control.get() calendarType];
+
     return nil;
 }
+
 @end
 
 @implementation WKDateTimePopoverViewController
@@ -388,6 +395,12 @@
     return nil;
 }
 
+- (NSString *)calendarType
+{
+    WKDateTimePicker *dateTimePicker = (WKDateTimePicker *)self.viewController.innerControl;
+    return dateTimePicker.datePicker.calendar.calendarIdentifier;
+}
+
 @end
 
 #endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Tools/ChangeLog (241274 => 241275)


--- trunk/Tools/ChangeLog	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/Tools/ChangeLog	2019-02-11 19:30:05 UTC (rev 241275)
@@ -1,3 +1,26 @@
+2019-02-11  Wenson Hsieh  <[email protected]>
+
+        fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html does not work on iPad
+        https://bugs.webkit.org/show_bug.cgi?id=194313
+
+        Reviewed by Tim Horton.
+
+        Add a helper to determine whether the web view is presenting modal UI.
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::isPresentingModally const):
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        (WTR::UIScriptController::isPresentingModally const):
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/UIScriptControllerCocoa.mm:
+        (WTR::UIScriptController::calendarType const): Deleted.
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::isPresentingModally const):
+        (WTR::UIScriptController::calendarType const):
+        * WebKitTestRunner/mac/UIScriptControllerMac.mm:
+        (WTR::UIScriptController::calendarType const):
+
 2019-02-11  Joseph Pecoraro  <[email protected]>
 
         GCHeapInspector: Show the retained sizes in more places

Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (241274 => 241275)


--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2019-02-11 19:30:05 UTC (rev 241275)
@@ -183,6 +183,11 @@
 {
 }
 
+bool UIScriptController::isPresentingModally() const
+{
+    return false;
+}
+
 JSRetainPtr<JSStringRef> UIScriptController::textContentType() const
 {
     return nullptr;

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (241274 => 241275)


--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2019-02-11 19:30:05 UTC (rev 241275)
@@ -232,6 +232,7 @@
     void setMinimumEffectiveWidth(double effectiveWidth);
 
     void resignFirstResponder();
+    readonly attribute boolean isPresentingModally;
 
     readonly attribute double contentOffsetX;
     readonly attribute double contentOffsetY;

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (241274 => 241275)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2019-02-11 19:30:05 UTC (rev 241275)
@@ -344,6 +344,11 @@
     return nullptr;
 }
 
+bool UIScriptController::isPresentingModally() const
+{
+    return false;
+}
+
 double UIScriptController::contentOffsetX() const
 {
     return 0;

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (241274 => 241275)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2019-02-11 19:30:05 UTC (rev 241275)
@@ -116,6 +116,8 @@
 
     JSObjectRef contentsOfUserInterfaceItem(JSStringRef) const;
     void overridePreference(JSStringRef preference, JSStringRef value);
+
+    bool isPresentingModally() const;
     
     double contentOffsetX() const;
     double contentOffsetY() const;

Modified: trunk/Tools/WebKitTestRunner/UIScriptControllerCocoa.mm (241274 => 241275)


--- trunk/Tools/WebKitTestRunner/UIScriptControllerCocoa.mm	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/Tools/WebKitTestRunner/UIScriptControllerCocoa.mm	2019-02-11 19:30:05 UTC (rev 241275)
@@ -180,19 +180,6 @@
 #endif
 }
 
-JSObjectRef UIScriptController::calendarType() const
-{
-#if WK_API_ENABLED
-    WKWebView *webView = TestController::singleton().mainWebView()->platformView();
-    UIView *contentView = [webView valueForKeyPath:@"_currentContentView"];
-    NSString *calendarTypeString = [contentView valueForKeyPath:@"formInputControl.dateTimePickerCalendarType"];
-    auto jsContext = m_context->jsContext();
-    return JSValueToObject(jsContext, [JSValue valueWithObject:calendarTypeString inContext:[JSContext contextWithJSGlobalContextRef:jsContext]].JSValueRef, nullptr);
-#else
-    return nullptr;
-#endif
-}
-
 JSRetainPtr<JSStringRef> UIScriptController::lastUndoLabel() const
 {
     return JSStringCreateWithCFString((__bridge CFStringRef)platformUndoManager().undoActionName);

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (241274 => 241275)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2019-02-11 19:30:05 UTC (rev 241275)
@@ -487,6 +487,12 @@
     [webView setTimePickerValueToHour:hour minute:minute];
 }
 
+bool UIScriptController::isPresentingModally() const
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    return !!webView.window.rootViewController.presentedViewController;
+}
+
 static CGPoint contentOffsetBoundedInValidRange(UIScrollView *scrollView, CGPoint contentOffset)
 {
     UIEdgeInsets contentInsets = scrollView.contentInset;
@@ -988,6 +994,15 @@
     return [(UIView *)[TestController::singleton().mainWebView()->platformView() valueForKeyPath:@"_currentContentView"] undoManager];
 }
 
+JSObjectRef UIScriptController::calendarType() const
+{
+    WKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    UIView *contentView = [webView valueForKeyPath:@"_currentContentView"];
+    NSString *calendarTypeString = [contentView valueForKeyPath:@"formInputControl.dateTimePickerCalendarType"];
+    auto jsContext = m_context->jsContext();
+    return JSValueToObject(jsContext, [JSValue valueWithObject:calendarTypeString inContext:[JSContext contextWithJSGlobalContextRef:jsContext]].JSValueRef, nullptr);
 }
 
+}
+
 #endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm (241274 => 241275)


--- trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm	2019-02-11 19:25:50 UTC (rev 241274)
+++ trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm	2019-02-11 19:30:05 UTC (rev 241275)
@@ -214,4 +214,9 @@
     return TestController::singleton().mainWebView()->platformView().undoManager;
 }
 
+JSObjectRef UIScriptController::calendarType() const
+{
+    return nullptr;
+}
+
 } // namespace WTR
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to