Diff
Modified: trunk/LayoutTests/ChangeLog (204524 => 204525)
--- trunk/LayoutTests/ChangeLog 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/LayoutTests/ChangeLog 2016-08-16 22:15:47 UTC (rev 204525)
@@ -1,3 +1,20 @@
+2016-08-16 Simon Fraser <[email protected]>
+
+ Make it possible to test iOS select elements, and add iPhone and iPad tests for them
+ https://bugs.webkit.org/show_bug.cgi?id=160909
+
+ Reviewed by Enrica Casucci.
+
+ Add iPhone and iPad tests for the <select> pickers. The iPhone test has to
+ use a didShowKeyboardCallback to know when to select the appropriate row,
+ and to dismiss the picker. The iPad test can just select the row, which also
+ dismisses the popover.
+
+ * fast/forms/ios/choose-select-option-expected.txt: Added.
+ * fast/forms/ios/choose-select-option.html: Added.
+ * fast/forms/ios/ipad/choose-select-option-expected.txt: Added.
+ * fast/forms/ios/ipad/choose-select-option.html: Added.
+
2016-08-15 Simon Fraser <[email protected]>
[iOS] Add iPad viewport and form tests, and revert the iPad-testing part of r202132
Added: trunk/LayoutTests/fast/forms/ios/choose-select-option-expected.txt (0 => 204525)
--- trunk/LayoutTests/fast/forms/ios/choose-select-option-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/choose-select-option-expected.txt 2016-08-16 22:15:47 UTC (rev 204525)
@@ -0,0 +1,4 @@
+Tests that a basic select element works
+
+
+Successfully handled oninput, value is now "april"
Added: trunk/LayoutTests/fast/forms/ios/choose-select-option.html (0 => 204525)
--- trunk/LayoutTests/fast/forms/ios/choose-select-option.html (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/choose-select-option.html 2016-08-16 22:15:47 UTC (rev 204525)
@@ -0,0 +1,84 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+ <meta name="viewport" content="width=device-width">
+ <style>
+ </style>
+
+ <script src=""
+ <script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ var uiScriptHasCompleted = false;
+ var _oninputHasBeenHandled_ = false;
+
+ function getUIScript(x, y)
+ {
+ return `
+ (function() {
+ uiController.didShowKeyboardCallback = function() {
+ uiController.selectFormAccessoryPickerRow(3);
+ uiController.dismissFormAccessoryView();
+ uiController.uiScriptComplete();
+ }
+ uiController.singleTapAtPoint(${x}, ${y}, function() {});
+ })();`
+ }
+
+ function checkDone()
+ {
+ if (oninputHasBeenHandled && uiScriptHasCompleted)
+ testRunner.notifyDone();
+ }
+
+ function handleValueChanged(value)
+ {
+ document.getElementById("console").textContent = "Successfully handled oninput, value is now \"" + value.toLowerCase() + "\"";
+ _oninputHasBeenHandled_ = true;
+ checkDone();
+ }
+
+ function doTest()
+ {
+ if (!window.testRunner || !testRunner.runUIScript)
+ return;
+
+ var targetElement = document.getElementsByTagName('select')[0];
+ var point = getPointInsideElement(targetElement, 10, 10);
+
+ testRunner.runUIScript(getUIScript(point.x, point.y), function() {
+ uiScriptHasCompleted = true;
+ checkDone();
+ });
+ }
+
+ window.addEventListener('load', doTest, false);
+ </script>
+</head>
+<body>
+
+<p>Tests that a basic select element works</p>
+
+<select _oninput_="handleValueChanged(this.value)">
+ <option>January</option>
+ <option>February</option>
+ <option>March</option>
+ <option>April</option>
+ <option>May</option>
+ <option>June</option>
+ <option>July</option>
+ <option>August</option>
+ <option>September</option>
+ <option>October</option>
+ <option>November</option>
+ <option>December</option>
+</select>
+
+<div id="console">Failed to handle oninput<div>
+
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/ios/ipad/choose-select-option-expected.txt (0 => 204525)
--- trunk/LayoutTests/fast/forms/ios/ipad/choose-select-option-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/ipad/choose-select-option-expected.txt 2016-08-16 22:15:47 UTC (rev 204525)
@@ -0,0 +1,4 @@
+Tests that a basic select element works
+
+
+Successfully handled oninput, value is now "april"
Added: trunk/LayoutTests/fast/forms/ios/ipad/choose-select-option.html (0 => 204525)
--- trunk/LayoutTests/fast/forms/ios/ipad/choose-select-option.html (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/ipad/choose-select-option.html 2016-08-16 22:15:47 UTC (rev 204525)
@@ -0,0 +1,91 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+ <meta name="viewport" content="width=device-width">
+ <style>
+ </style>
+
+ <script src=""
+ <script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ var uiScriptHasCompleted = false;
+ var _oninputHasBeenHandled_ = false;
+
+ function getTapOnSelectUIScript(x, y)
+ {
+ return `
+ (function() {
+ uiController.singleTapAtPoint(${x}, ${y}, function() {
+ uiController.uiScriptComplete('');
+ });
+ })();`
+ }
+
+ function getUIScriptForSelectRow()
+ {
+ return `
+ (function() {
+ uiController.selectFormAccessoryPickerRow(3);
+ })();`
+ }
+
+ function checkDone()
+ {
+ if (oninputHasBeenHandled && uiScriptHasCompleted)
+ testRunner.notifyDone();
+ }
+
+ function handleValueChanged(value)
+ {
+ document.getElementById("console").textContent = "Successfully handled oninput, value is now \"" + value.toLowerCase() + "\"";
+ _oninputHasBeenHandled_ = true;
+ checkDone();
+ }
+
+ function doTest()
+ {
+ if (!window.testRunner || !testRunner.runUIScript)
+ return;
+
+ var targetElement = document.getElementsByTagName('select')[0];
+ var point = getPointInsideElement(targetElement, 10, 10);
+
+ testRunner.runUIScript(getTapOnSelectUIScript(point.x, point.y), function() {
+ testRunner.runUIScript(getUIScriptForSelectRow(), function() {
+ uiScriptHasCompleted = true;
+ checkDone();
+ });
+ });
+ }
+
+ window.addEventListener('load', doTest, false);
+ </script>
+</head>
+<body>
+
+<p>Tests that a basic select element works</p>
+
+<select _oninput_="handleValueChanged(this.value)">
+ <option>January</option>
+ <option>February</option>
+ <option>March</option>
+ <option>April</option>
+ <option>May</option>
+ <option>June</option>
+ <option>July</option>
+ <option>August</option>
+ <option>September</option>
+ <option>October</option>
+ <option>November</option>
+ <option>December</option>
+</select>
+
+<div id="console">Failed to handle oninput<div>
+
+</body>
+</html>
Modified: trunk/Source/WebKit2/ChangeLog (204524 => 204525)
--- trunk/Source/WebKit2/ChangeLog 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Source/WebKit2/ChangeLog 2016-08-16 22:15:47 UTC (rev 204525)
@@ -1,3 +1,29 @@
+2016-08-16 Simon Fraser <[email protected]>
+
+ Make it possible to test iOS select elements, and add iPhone and iPad tests for them
+ https://bugs.webkit.org/show_bug.cgi?id=160909
+
+ Reviewed by Enrica Casucci.
+
+ Hook up form-related UIScriptController functions, and plumb through the various
+ <select> pickers the ability to select a row.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView dismissFormAccessoryView]):
+ (-[WKWebView selectFormAccessoryPickerRow:]):
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView selectFormAccessoryPickerRow:]):
+ * UIProcess/ios/forms/WKFormSelectControl.h:
+ * UIProcess/ios/forms/WKFormSelectControl.mm:
+ (-[WKFormSelectControl selectRow:inComponent:extendingSelection:]):
+ * UIProcess/ios/forms/WKFormSelectPicker.mm:
+ (-[WKMultipleSelectPicker selectRow:inComponent:extendingSelection:]):
+ (-[WKSelectSinglePicker selectRow:inComponent:extendingSelection:]):
+ * UIProcess/ios/forms/WKFormSelectPopover.mm:
+ (-[WKSelectPopover selectRow:inComponent:extendingSelection:]):
+
2016-08-16 Brady Eidson <[email protected]>
Cleanup WK2 platform gamepad handling.
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (204524 => 204525)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2016-08-16 22:15:47 UTC (rev 204525)
@@ -4517,6 +4517,16 @@
[_contentView accessoryTab:NO];
}
+- (void)dismissFormAccessoryView
+{
+ [_contentView accessoryDone];
+}
+
+- (void)selectFormAccessoryPickerRow:(int)rowIndex
+{
+ [_contentView selectFormAccessoryPickerRow:rowIndex];
+}
+
#endif // PLATFORM(IOS)
#if PLATFORM(MAC)
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (204524 => 204525)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2016-08-16 22:15:47 UTC (rev 204525)
@@ -254,6 +254,7 @@
@interface WKWebView (WKTesting)
#if TARGET_OS_IPHONE
+
@property (nonatomic, readonly) CGRect _contentVisibleRect WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
- (CGPoint)_convertPointFromContentsToView:(CGPoint)point WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
- (CGPoint)_convertPointFromViewToContents:(CGPoint)point WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
@@ -260,6 +261,9 @@
- (void)keyboardAccessoryBarNext WK_API_AVAILABLE(ios(WK_IOS_TBA));
- (void)keyboardAccessoryBarPrevious WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)dismissFormAccessoryView WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)selectFormAccessoryPickerRow:(int)rowIndex WK_API_AVAILABLE(ios(WK_IOS_TBA));
+
#endif
#if !TARGET_OS_IPHONE
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (204524 => 204525)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h 2016-08-16 22:15:47 UTC (rev 204525)
@@ -223,6 +223,12 @@
- (NSArray *)_dataDetectionResults;
@end
+@interface WKContentView (WKTesting)
+
+- (void)selectFormAccessoryPickerRow:(NSInteger)rowIndex;
+
+@end
+
#if HAVE(LINK_PREVIEW)
@interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate>
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (204524 => 204525)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2016-08-16 22:15:47 UTC (rev 204525)
@@ -3797,6 +3797,16 @@
@end
+@implementation WKContentView (WKTesting)
+
+- (void)selectFormAccessoryPickerRow:(NSInteger)rowIndex
+{
+ if ([_inputPeripheral isKindOfClass:[WKFormSelectControl self]])
+ [(WKFormSelectControl *)_inputPeripheral selectRow:rowIndex inComponent:0 extendingSelection:NO];
+}
+
+@end
+
#if HAVE(LINK_PREVIEW)
@implementation WKContentView (WKInteractionPreview)
@@ -4108,7 +4118,7 @@
@end
-#endif
+#endif // HAVE(LINK_PREVIEW)
// UITextRange, UITextPosition and UITextSelectionRect implementations for WK2
Modified: trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectControl.h (204524 => 204525)
--- trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectControl.h 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectControl.h 2016-08-16 22:15:47 UTC (rev 204525)
@@ -39,6 +39,10 @@
- (instancetype)initWithView:(WKContentView *)view;
@end
+@interface WKFormSelectControl(WKTesting)
+- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection;
+@end
+
@interface WKSelectPopover : WKFormRotatingAccessoryPopover<WKFormControl>
- (instancetype)initWithView:(WKContentView *)view hasGroups:(BOOL)hasGroups;
- (void)_userActionDismissedPopover:(id)sender;
@@ -52,5 +56,10 @@
- (instancetype)initWithView:(WKContentView *)view;
@end
+@protocol WKSelectTesting
+@optional
+- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection;
+@end
+
#endif // PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectControl.mm (204524 => 204525)
--- trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectControl.mm 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectControl.mm 2016-08-16 22:15:47 UTC (rev 204525)
@@ -58,7 +58,7 @@
}
@implementation WKFormSelectControl {
- RetainPtr<id<WKFormControl>> _control;
+ RetainPtr<NSObject<WKFormControl>> _control;
}
- (instancetype)initWithView:(WKContentView *)view
@@ -101,4 +101,14 @@
@end
+@implementation WKFormSelectControl(WKTesting)
+
+- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection
+{
+ if ([_control respondsToSelector:@selector(selectRow:inComponent:extendingSelection:)])
+ [id<WKSelectTesting>(_control.get()) selectRow:rowIndex inComponent:componentIndex extendingSelection:extendingSelection];
+}
+
+@end
+
#endif // PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectPicker.mm (204524 => 204525)
--- trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectPicker.mm 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectPicker.mm 2016-08-16 22:15:47 UTC (rev 204525)
@@ -303,6 +303,15 @@
}
}
+// WKSelectTesting
+- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection
+{
+ // FIXME: handle extendingSelection.
+ [self selectRow:rowIndex inComponent:0 animated:NO];
+ // Progammatic selection changes don't call the delegate, so do that manually.
+ [self.delegate pickerView:self didSelectRow:rowIndex inComponent:0];
+}
+
@end
@implementation WKSelectSinglePicker {
@@ -430,6 +439,15 @@
_selectedIndex = row;
}
+// WKSelectTesting
+- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection
+{
+ // FIXME: handle extendingSelection.
+ [self selectRow:rowIndex inComponent:0 animated:NO];
+ // Progammatic selection changes don't call the delegate, so do that manually.
+ [self.delegate pickerView:self didSelectRow:rowIndex inComponent:0];
+}
+
@end
#endif // PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectPopover.mm (204524 => 204525)
--- trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectPopover.mm 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectPopover.mm 2016-08-16 22:15:47 UTC (rev 204525)
@@ -448,4 +448,16 @@
@end
+@implementation WKSelectPopover(WKTesting)
+
+- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection
+{
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowIndex inSection:componentIndex];
+ [[_tableViewController tableView] selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
+ // Inform the delegate, since -selectRowAtIndexPath:... doesn't do that.
+ [_tableViewController tableView:[_tableViewController tableView] didSelectRowAtIndexPath:indexPath];
+}
+
+@end
+
#endif // PLATFORM(IOS)
Modified: trunk/Tools/ChangeLog (204524 => 204525)
--- trunk/Tools/ChangeLog 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Tools/ChangeLog 2016-08-16 22:15:47 UTC (rev 204525)
@@ -1,3 +1,22 @@
+2016-08-16 Simon Fraser <[email protected]>
+
+ Make it possible to test iOS select elements, and add iPhone and iPad tests for them
+ https://bugs.webkit.org/show_bug.cgi?id=160909
+
+ Reviewed by Enrica Casucci.
+
+ Add functions to UIScriptController to dismiss the form accessory view for iOS,
+ and to programmatically pick a row from a <select> picker.
+
+ * WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl:
+ * WebKitTestRunner/UIScriptContext/UIScriptController.cpp:
+ (WTR::UIScriptController::dismissFormAccessoryView):
+ (WTR::UIScriptController::selectFormAccessoryPickerRow):
+ * WebKitTestRunner/UIScriptContext/UIScriptController.h:
+ * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+ (WTR::UIScriptController::dismissFormAccessoryView):
+ (WTR::UIScriptController::selectFormAccessoryPickerRow):
+
2016-08-15 Simon Fraser <[email protected]>
[iOS] Add iPad viewport and form tests, and revert the iPad-testing part of r202132
Modified: trunk/Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl (204524 => 204525)
--- trunk/Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl 2016-08-16 22:15:47 UTC (rev 204525)
@@ -42,9 +42,16 @@
void keyDownUsingHardwareKeyboard(DOMString character, object callback);
void keyUpUsingHardwareKeyboard(DOMString character, object callback);
+ // Equivalent of pressing the Done button in the form accessory bar.
+ void dismissFormAccessoryView();
+
+ // <select> picker
+ void selectFormAccessoryPickerRow(long rowIndex);
+
void keyboardAccessoryBarNext();
void keyboardAccessoryBarPrevious();
+ // These callbacks also work for the form accessory views.
attribute object didShowKeyboardCallback;
attribute object didHideKeyboardCallback;
Modified: trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp (204524 => 204525)
--- trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp 2016-08-16 22:15:47 UTC (rev 204525)
@@ -150,6 +150,14 @@
{
}
+void UIScriptController::dismissFormAccessoryView()
+{
+}
+
+void UIScriptController::selectFormAccessoryPickerRow(long)
+{
+}
+
void UIScriptController::keyboardAccessoryBarNext()
{
}
Modified: trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h (204524 => 204525)
--- trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h 2016-08-16 22:15:47 UTC (rev 204525)
@@ -59,6 +59,9 @@
void keyboardAccessoryBarNext();
void keyboardAccessoryBarPrevious();
+
+ void dismissFormAccessoryView();
+ void selectFormAccessoryPickerRow(long);
void setWillBeginZoomingCallback(JSValueRef);
JSValueRef willBeginZoomingCallback() const;
Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (204524 => 204525)
--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm 2016-08-16 21:44:25 UTC (rev 204524)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm 2016-08-16 22:15:47 UTC (rev 204525)
@@ -175,6 +175,18 @@
}];
}
+void UIScriptController::dismissFormAccessoryView()
+{
+ TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+ [webView dismissFormAccessoryView];
+}
+
+void UIScriptController::selectFormAccessoryPickerRow(long rowIndex)
+{
+ TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+ [webView selectFormAccessoryPickerRow:rowIndex];
+}
+
void UIScriptController::keyboardAccessoryBarNext()
{
TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();