[Extra zoom mode] REGRESSION(230860) Unable to change time input values using UI
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2018 02:45:32 +0000 (02:45 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2018 02:45:32 +0000 (02:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184901
<rdar://problem/39664797>

Reviewed by Tim Horton.

Source/WebKit:

Fixes the bug by falling back to setting the value of the focused input element in the case where the selection
is not editable. Also adds plumbing to make time pickers testable in extra zoom mode.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView setTimePickerValueToHour:minute:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setTimePickerValueToHour:minute:]):

Add plumbing to make it possible for WebKitTestRunner to simulate picking a time from the given hours and
minutes. This is currently only implemented for extra zoom mode, but may be implemented for UIKit's time picker
as well in the future by adjusting -[WKContentView setTimePickerValueToHour:minute:].

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setTextAsync):

Tools:

Introduce a new UIScriptController method to set the value of a currently focused input of type time, by
interacting with the UI. See WebKit ChangeLogs for more detail.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::setTimePickerValue):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::setTimePickerValue):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::setTimePickerValue):

LayoutTests:

Adds a basic test to verify that tapping on an input of type `time` and choosing a time actually changes the
value of the input. Also adds a new UIHelper function to set the value of the currently focused input of type
time to the given hours and minutes.

* fast/forms/extrazoom/time-picker-value-change-expected.txt: Added.
* fast/forms/extrazoom/time-picker-value-change.html: Added.
* resources/ui-helper.js:
(window.UIHelper.setTimePickerValue):
(window.UIHelper):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230941 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/extrazoom/time-picker-value-change-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/extrazoom/time-picker-value-change.html [new file with mode: 0644]
LayoutTests/resources/ui-helper.js
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

index aeea6cc..d3dc9b6 100644 (file)
@@ -1,3 +1,21 @@
+2018-04-23  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Extra zoom mode] REGRESSION(230860) Unable to change time input values using UI
+        https://bugs.webkit.org/show_bug.cgi?id=184901
+        <rdar://problem/39664797>
+
+        Reviewed by Tim Horton.
+
+        Adds a basic test to verify that tapping on an input of type `time` and choosing a time actually changes the
+        value of the input. Also adds a new UIHelper function to set the value of the currently focused input of type
+        time to the given hours and minutes.
+
+        * fast/forms/extrazoom/time-picker-value-change-expected.txt: Added.
+        * fast/forms/extrazoom/time-picker-value-change.html: Added.
+        * resources/ui-helper.js:
+        (window.UIHelper.setTimePickerValue):
+        (window.UIHelper):
+
 2018-04-23  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, fix a few tests that became flaky after r230919.
diff --git a/LayoutTests/fast/forms/extrazoom/time-picker-value-change-expected.txt b/LayoutTests/fast/forms/extrazoom/time-picker-value-change-expected.txt
new file mode 100644 (file)
index 0000000..abc14cd
--- /dev/null
@@ -0,0 +1,5 @@
+PASS time.value is '09:41'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/extrazoom/time-picker-value-change.html b/LayoutTests/fast/forms/extrazoom/time-picker-value-change.html
new file mode 100644 (file)
index 0000000..3ffe4e9
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<meta name="viewport" content="width=device-width">
+<head>
+<script src="../../../resources/js-test.js"></script>
+<script src="../../../resources/ui-helper.js"></script>
+<script>
+doneCount = 0;
+jsTestIsAsync = true;
+
+async function runTest() {
+    if (!window.testRunner) {
+        description(`This test requires WebKitTestRunner.`);
+        return;
+    }
+
+    time = document.querySelector("input");
+    time.addEventListener("change", checkDone);
+    time.addEventListener("blur", checkDone);
+
+    await UIHelper.activateAndWaitForInputSessionAt(75, 75);
+    UIHelper.waitForKeyboardToHide().then(checkDone)
+    UIHelper.setTimePickerValue(9, 41);
+}
+
+function checkDone() {
+    if (++doneCount < 3)
+        return;
+
+    shouldBe("time.value", "'09:41'");
+    finishJSTest();
+}
+</script>
+</head>
+<body onload="runTest()">
+<input type="time" value="04:01" style="width: 320px; height: 568px;"></input>
+</body>
+</html>
index fd700f6..3be7d72 100644 (file)
@@ -193,4 +193,10 @@ window.UIHelper = class UIHelper {
         const enterTextScript = `(() => uiController.enterText(\`${escapedText}\`))()`;
         return new Promise(resolve => testRunner.runUIScript(enterTextScript, resolve));
     }
+
+    static setTimePickerValue(hours, minutes)
+    {
+        const setValueScript = `(() => uiController.setTimePickerValue(${hours}, ${minutes}))()`;
+        return new Promise(resolve => testRunner.runUIScript(setValueScript, resolve));
+    }
 }
index f2e0523..a98d966 100644 (file)
@@ -1,3 +1,28 @@
+2018-04-23  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Extra zoom mode] REGRESSION(230860) Unable to change time input values using UI
+        https://bugs.webkit.org/show_bug.cgi?id=184901
+        <rdar://problem/39664797>
+
+        Reviewed by Tim Horton.
+
+        Fixes the bug by falling back to setting the value of the focused input element in the case where the selection
+        is not editable. Also adds plumbing to make time pickers testable in extra zoom mode.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView setTimePickerValueToHour:minute:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setTimePickerValueToHour:minute:]):
+
+        Add plumbing to make it possible for WebKitTestRunner to simulate picking a time from the given hours and
+        minutes. This is currently only implemented for extra zoom mode, but may be implemented for UIKit's time picker
+        as well in the future by adjusting -[WKContentView setTimePickerValueToHour:minute:].
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setTextAsync):
+
 2018-04-23  Saam Barati  <sbarati@apple.com>
 
         Keep around a pre-warmed process when doing process swap on navigation
index 6e8f072..de12e5a 100644 (file)
@@ -5899,6 +5899,11 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
     [_contentView accessoryDone];
 }
 
+- (void)setTimePickerValueToHour:(NSInteger)hour minute:(NSInteger)minute
+{
+    [_contentView setTimePickerValueToHour:hour minute:minute];
+}
+
 - (void)selectFormAccessoryPickerRow:(int)rowIndex
 {
     [_contentView selectFormAccessoryPickerRow:rowIndex];
index 38f4111..cf1fca8 100644 (file)
@@ -382,6 +382,7 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEdge) {
 - (void)dismissFormAccessoryView WK_API_AVAILABLE(ios(10.3));
 - (void)selectFormAccessoryPickerRow:(int)rowIndex WK_API_AVAILABLE(ios(10.3));
 @property (nonatomic, readonly) NSString *selectFormPopoverTitle WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)setTimePickerValueToHour:(NSInteger)hour minute:(NSInteger)minute WK_API_AVAILABLE(ios(WK_IOS_TBA));
 
 - (void)applyAutocorrection:(NSString *)newString toString:(NSString *)oldString withCompletionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(ios(11.0));
 
index 0291415..787f6b2 100644 (file)
@@ -361,6 +361,7 @@ FOR_EACH_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW)
 - (void)_simulateLongPressActionAtLocation:(CGPoint)location;
 - (void)_simulateTextEntered:(NSString *)text;
 - (void)selectFormAccessoryPickerRow:(NSInteger)rowIndex;
+- (void)setTimePickerValueToHour:(NSInteger)hour minute:(NSInteger)minute;
 - (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem;
 
 @property (nonatomic, readonly) NSString *selectFormPopoverTitle;
index af7e3a8..1b83610 100644 (file)
@@ -5518,6 +5518,14 @@ static NSArray<UIItemProvider *> *extractItemProvidersFromDropSession(id <UIDrop
     return [(WKFormSelectControl *)_inputPeripheral selectFormPopoverTitle];
 }
 
+- (void)setTimePickerValueToHour:(NSInteger)hour minute:(NSInteger)minute
+{
+#if ENABLE(EXTRA_ZOOM_MODE)
+    if ([_presentedFullScreenInputViewController isKindOfClass:[WKTimePickerViewController class]])
+        [(WKTimePickerViewController *)_presentedFullScreenInputViewController.get() setHour:hour minute:minute];
+#endif
+}
+
 - (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem
 {
     if ([userInterfaceItem isEqualToString:@"actionSheet"])
index e4243c0..b4d31cf 100644 (file)
@@ -4608,12 +4608,19 @@ bool WebPage::shouldUseCustomContentProviderForResponse(const ResourceResponse&
 void WebPage::setTextAsync(const String& text)
 {
     auto frame = makeRef(m_page->focusController().focusedOrMainFrame());
-    if (!frame->selection().selection().isContentEditable())
+    if (frame->selection().selection().isContentEditable()) {
+        UserTypingGestureIndicator indicator(frame.get());
+        frame->selection().selectAll();
+        frame->editor().insertText(text, nullptr, TextEventInputKeyboard);
         return;
+    }
 
-    UserTypingGestureIndicator indicator(frame.get());
-    frame->selection().selectAll();
-    frame->editor().insertText(text, nullptr, TextEventInputKeyboard);
+    if (is<HTMLInputElement>(m_assistedNode.get())) {
+        downcast<HTMLInputElement>(*m_assistedNode).setValueForUser(text);
+        return;
+    }
+
+    ASSERT_NOT_REACHED();
 }
 
 void WebPage::insertTextAsync(const String& text, const EditingRange& replacementEditingRange, bool registerUndoGroup, uint32_t editingRangeIsRelativeTo, bool suppressSelectionUpdate)
index ad7e975..fbded94 100644 (file)
@@ -1,3 +1,23 @@
+2018-04-23  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Extra zoom mode] REGRESSION(230860) Unable to change time input values using UI
+        https://bugs.webkit.org/show_bug.cgi?id=184901
+        <rdar://problem/39664797>
+
+        Reviewed by Tim Horton.
+
+        Introduce a new UIScriptController method to set the value of a currently focused input of type time, by
+        interacting with the UI. See WebKit ChangeLogs for more detail.
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::setTimePickerValue):
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        (WTR::UIScriptController::setTimePickerValue):
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::setTimePickerValue):
+
 2018-04-23  Zalan Bujtas  <zalan@apple.com>
 
         [LayoutFormattingContext] Initial commit.
index 6a90c27..b5a3337 100644 (file)
@@ -159,6 +159,10 @@ void UIScriptController::dismissFormAccessoryView()
 {
 }
 
+void UIScriptController::setTimePickerValue(long, long)
+{
+}
+
 void UIScriptController::selectFormAccessoryPickerRow(long rowIndex)
 {
 }
index d73fd7b..37737a4 100644 (file)
@@ -190,6 +190,8 @@ interface UIScriptController {
     void selectFormAccessoryPickerRow(long rowIndex);
     readonly attribute DOMString selectFormPopoverTitle;
 
+    void setTimePickerValue(long hour, long minute);
+
     void keyboardAccessoryBarNext();
     void keyboardAccessoryBarPrevious();
 
index 83c2f59..2b4b493 100644 (file)
@@ -298,6 +298,10 @@ void UIScriptController::dismissFormAccessoryView()
 {
 }
 
+void UIScriptController::setTimePickerValue(long, long)
+{
+}
+
 void UIScriptController::selectFormAccessoryPickerRow(long)
 {
 }
index 54ff4d6..fd6ca93 100644 (file)
@@ -99,6 +99,7 @@ public:
     void dismissFormAccessoryView();
     void selectFormAccessoryPickerRow(long);
     JSRetainPtr<JSStringRef> selectFormPopoverTitle() const;
+    void setTimePickerValue(long hour, long minute);
     
     JSObjectRef contentsOfUserInterfaceItem(JSStringRef) const;
     void overridePreference(JSStringRef preference, JSStringRef value);
index a727e23..27f391f 100644 (file)
@@ -436,6 +436,12 @@ void UIScriptController::selectFormAccessoryPickerRow(long rowIndex)
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
     [webView selectFormAccessoryPickerRow:rowIndex];
 }
+
+void UIScriptController::setTimePickerValue(long hour, long minute)
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    [webView setTimePickerValueToHour:hour minute:minute];
+}
     
 JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const
 {