[iOS WK2] Make it possible to test the Next/Previous buttons in the keyboard accessor...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Jun 2016 23:44:57 +0000 (23:44 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Jun 2016 23:44:57 +0000 (23:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158714

Reviewed by Enrica Casucci.

Add UIScriptController.keyboardAccessoryBar{Next,Previous} and hook it up to the WKContentView
method that gets called from UIKit.

Add a test that exercises it.

Source/WebKit2:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView keyboardAssistantBarNext]):
(-[WKWebView keyboardAssistantBarPrevious]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

Tools:

* WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl:
* WebKitTestRunner/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::keyboardAccessoryBarNext):
(WTR::UIScriptController::keyboardAccessoryBarPrevious):
* WebKitTestRunner/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::keyboardAccessoryBarNext):
(WTR::UIScriptController::keyboardAccessoryBarPrevious):

LayoutTests:

* TestExpectations:
* fast/forms/ios/accessory-bar-navigation-expected.txt: Added.
* fast/forms/ios/accessory-bar-navigation.html: Added.
* fast/forms/ios/resources/zooming-test-utils.js: Added.
(testZoomAfterTap):
(tableFromJSON):
* platform/ios-simulator-wk2/TestExpectations:

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/ios/accessory-bar-navigation-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/ios/accessory-bar-navigation.html [new file with mode: 0644]
LayoutTests/fast/forms/ios/resources/zooming-test-utils.js
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Tools/ChangeLog
Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl
Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp
Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

index 4db52c0..6df351b 100644 (file)
@@ -1,3 +1,23 @@
+2016-06-13  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK2] Make it possible to test the Next/Previous buttons in the keyboard accessory bar
+        https://bugs.webkit.org/show_bug.cgi?id=158714
+
+        Reviewed by Enrica Casucci.
+
+        Add UIScriptController.keyboardAccessoryBar{Next,Previous} and hook it up to the WKContentView
+        method that gets called from UIKit.
+
+        Add a test that exercises it.
+
+        * TestExpectations:
+        * fast/forms/ios/accessory-bar-navigation-expected.txt: Added.
+        * fast/forms/ios/accessory-bar-navigation.html: Added.
+        * fast/forms/ios/resources/zooming-test-utils.js: Added.
+        (testZoomAfterTap):
+        (tableFromJSON):
+        * platform/ios-simulator-wk2/TestExpectations:
+
 2016-06-15  Dean Jackson  <dino@apple.com>
 
         [mac] LayoutTest transforms/undecomposable.html is a flaky timeout
diff --git a/LayoutTests/fast/forms/ios/accessory-bar-navigation-expected.txt b/LayoutTests/fast/forms/ios/accessory-bar-navigation-expected.txt
new file mode 100644 (file)
index 0000000..f7c7999
--- /dev/null
@@ -0,0 +1,16 @@
+Tests zooming into a text input on tap.
+
+
+After focus first field
+
+tap location   { x: 38.000, y: 446.000 }
+scale  0.749
+visibleRect    { left: 0.000, top: 266.208, width: 427.000, height: 640.500 }
+After move to second field
+
+scale  0.749
+visibleRect    { left: 0.000, top: 687.203, width: 427.000, height: 640.500 }
+After move to first field
+
+scale  0.749
+visibleRect    { left: 0.000, top: 266.208, width: 427.000, height: 640.500 }
diff --git a/LayoutTests/fast/forms/ios/accessory-bar-navigation.html b/LayoutTests/fast/forms/ios/accessory-bar-navigation.html
new file mode 100644 (file)
index 0000000..d3ed676
--- /dev/null
@@ -0,0 +1,110 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=0.75, user-scalable=no">
+    <style>
+        input[type="text"] {
+            display: block;
+            margin: 400px 20px;
+        }
+        button {
+            display: block;
+        }
+    </style>
+    
+    <script src="resources/zooming-test-utils.js"></script>
+    <script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    function getMoveUIScript(nextOrPrevious)
+    {
+        return `
+            (function() {
+                uiController.didEndZoomingCallback = function() {
+                    var result = {
+                        'scale' : uiController.zoomScale,
+                        'visibleRect' : uiController.contentVisibleRect
+                    };
+
+                    var result = JSON.stringify(result, function(key, value) {
+                          if (typeof value === "number")
+                              return value.toFixed(3);
+                        return value;
+                    });
+
+                    uiController.uiScriptComplete(result);
+                };
+                uiController.keyboardAccessoryBar${nextOrPrevious}();
+            })();`
+    }
+    
+    function moveToNextField()
+    {
+        var uiScript = getMoveUIScript('Next');
+        testRunner.runUIScript(uiScript, function(result) {
+            var header = document.createElement('h1');
+            header.textContent = 'After move to second field';
+            document.body.appendChild(header);
+
+            var results = tableFromJSON(result);
+            document.body.appendChild(results);
+            
+            moveToPreviousField();
+        });
+    }
+
+    function moveToPreviousField()
+    {
+        var uiScript = getMoveUIScript('Previous');
+        testRunner.runUIScript(uiScript, function(result) {
+            var header = document.createElement('h1');
+            header.textContent = 'After move to first field';
+            document.body.appendChild(header);
+
+            var results = tableFromJSON(result);
+            document.body.appendChild(results);
+            testRunner.notifyDone();
+        });
+    }
+    
+    function tapOnElement(targetElement, xOffset, yOffset)
+    {
+        var point = getPointInsideElement(targetElement, xOffset, yOffset);
+
+        var uiScript = zoomAfterSingleTapUIScript(point.x, point.y);
+        testRunner.runUIScript(uiScript, function(result) {
+            var header = document.createElement('h1');
+            header.textContent = 'After focus first field';
+            document.body.appendChild(header);
+
+            var results = tableFromJSON(result);
+            document.body.appendChild(results);
+            
+            moveToNextField();
+        });
+    }
+    
+    function doTest()
+    {
+        if (!window.testRunner || !testRunner.runUIScript)
+            return;
+
+        tapOnElement(document.getElementById('input'), 10, 10);
+    }
+
+    window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<p>Tests zooming into a text input on tap.</p>
+
+<input id="input" type="text">
+<input id="input2" type="text">
+
+</body>
+</html>
index 583750f..0e3f4a5 100644 (file)
@@ -4,9 +4,8 @@ function testZoomAfterTap(targetElement, xOffset, yOffset)
     if (!window.testRunner || !testRunner.runUIScript)
         return;
 
-    // Tap near the right end of the text.
     var point = getPointInsideElement(targetElement, xOffset, yOffset);
-    
+
     var uiScript = zoomAfterSingleTapUIScript(point.x, point.y);
     testRunner.runUIScript(uiScript, function(result) {
         var results = tableFromJSON(result);
@@ -25,7 +24,7 @@ function zoomAfterSingleTapUIScript(x, y)
                     'scale' : uiController.zoomScale,
                     'visibleRect' : uiController.contentVisibleRect
                 };
-            
+
                 var result = JSON.stringify(result, function(key, value) {
                       if (typeof value === "number")
                           return value.toFixed(3);
index d55e755..1c4678b 100644 (file)
@@ -1,3 +1,20 @@
+2016-06-13  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK2] Make it possible to test the Next/Previous buttons in the keyboard accessory bar
+        https://bugs.webkit.org/show_bug.cgi?id=158714
+
+        Reviewed by Enrica Casucci.
+
+        Add UIScriptController.keyboardAccessoryBar{Next,Previous} and hook it up to the WKContentView
+        method that gets called from UIKit.
+
+        Add a test that exercises it.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView keyboardAssistantBarNext]):
+        (-[WKWebView keyboardAssistantBarPrevious]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
 2016-06-15  Dean Jackson  <dino@apple.com>
 
         RTL <select> forms are misplaced
index e1754f4..b8826dc 100644 (file)
@@ -4438,6 +4438,16 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
     return [self convertPoint:point toView:self._currentContentView];
 }
 
+- (void)keyboardAccessoryBarNext
+{
+    [_contentView accessoryTab:YES];
+}
+
+- (void)keyboardAccessoryBarPrevious
+{
+    [_contentView accessoryTab:NO];
+}
+
 #endif // PLATFORM(IOS)
 
 #if PLATFORM(MAC)
index d940a11..978348e 100644 (file)
@@ -250,6 +250,9 @@ typedef NS_ENUM(NSInteger, _WKImmediateActionType) {
 @property (nonatomic, readonly) CGRect _contentVisibleRect WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 - (CGPoint)_convertPointFromContentsToView:(CGPoint)point WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 - (CGPoint)_convertPointFromViewToContents:(CGPoint)point WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
+- (void)keyboardAccessoryBarNext;
+- (void)keyboardAccessoryBarPrevious;
 #endif
 
 #if !TARGET_OS_IPHONE
index 2987f13..602b1f2 100644 (file)
@@ -1,3 +1,24 @@
+2016-06-13  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK2] Make it possible to test the Next/Previous buttons in the keyboard accessory bar
+        https://bugs.webkit.org/show_bug.cgi?id=158714
+
+        Reviewed by Enrica Casucci.
+
+        Add UIScriptController.keyboardAccessoryBar{Next,Previous} and hook it up to the WKContentView
+        method that gets called from UIKit.
+
+        Add a test that exercises it.
+
+        * WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl:
+        * WebKitTestRunner/UIScriptContext/UIScriptController.cpp:
+        (WTR::UIScriptController::keyboardAccessoryBarNext):
+        (WTR::UIScriptController::keyboardAccessoryBarPrevious):
+        * WebKitTestRunner/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::keyboardAccessoryBarNext):
+        (WTR::UIScriptController::keyboardAccessoryBarPrevious):
+
 2016-06-15  Sam Weinig  <sam@webkit.org>
 
         Improve HashMap and HashSet support for Ref
index fab4641..3bc5a6b 100644 (file)
@@ -42,6 +42,9 @@ interface UIScriptController {
     void keyDownUsingHardwareKeyboard(DOMString character, object callback);
     void keyUpUsingHardwareKeyboard(DOMString character, object callback);
 
+    void keyboardAccessoryBarNext();
+    void keyboardAccessoryBarPrevious();
+
     attribute object didShowKeyboardCallback;
     attribute object didHideKeyboardCallback;
 
index 2a8f4cd..f327bf9 100644 (file)
@@ -150,6 +150,14 @@ void UIScriptController::keyDownUsingHardwareKeyboard(JSStringRef, JSValueRef)
 {
 }
 
+void UIScriptController::keyboardAccessoryBarNext()
+{
+}
+
+void UIScriptController::keyboardAccessoryBarPrevious()
+{
+}
+
 double UIScriptController::zoomScale() const
 {
     return 1;
index 514b5f0..b504786 100644 (file)
@@ -57,6 +57,9 @@ public:
     void keyDownUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
     void keyUpUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
 
+    void keyboardAccessoryBarNext();
+    void keyboardAccessoryBarPrevious();
+
     void setWillBeginZoomingCallback(JSValueRef);
     JSValueRef willBeginZoomingCallback() const;
 
index b5a4116..76d8e6f 100644 (file)
@@ -175,6 +175,18 @@ void UIScriptController::keyUpUsingHardwareKeyboard(JSStringRef character, JSVal
     }];
 }
 
+void UIScriptController::keyboardAccessoryBarNext()
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    [webView keyboardAccessoryBarNext];
+}
+
+void UIScriptController::keyboardAccessoryBarPrevious()
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    [webView keyboardAccessoryBarPrevious];
+}
+
 double UIScriptController::minimumZoomScale() const
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();