Title: [202114] trunk/LayoutTests
Revision
202114
Author
simon.fra...@apple.com
Date
2016-06-15 16:07:42 -0700 (Wed, 15 Jun 2016)

Log Message

[iOS WK2] Add tests for zooming to text fields on focus
https://bugs.webkit.org/show_bug.cgi?id=158786

Reviewed by Enrica Casucci.

Add tests that focus form controls, and test the resulting scroll position and zoom level.

* TestExpectations:
* fast/forms/ios/focus-input-via-button-expected.txt: Added.
* fast/forms/ios/focus-input-via-button-no-scaling-expected.txt: Added.
* fast/forms/ios/focus-input-via-button-no-scaling.html: Added.
* fast/forms/ios/focus-input-via-button.html: Added.
* fast/forms/ios/resources/zooming-test-utils.js: Added.
(testZoomAfterTap):
(tableFromJSON):
* fast/forms/ios/zoom-after-input-tap-expected.txt: Added.
* fast/forms/ios/zoom-after-input-tap-wide-input-expected.txt: Added.
* fast/forms/ios/zoom-after-input-tap-wide-input.html: Added.
* fast/forms/ios/zoom-after-input-tap.html: Added.
* platform/ios-simulator-wk2/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202113 => 202114)


--- trunk/LayoutTests/ChangeLog	2016-06-15 22:37:03 UTC (rev 202113)
+++ trunk/LayoutTests/ChangeLog	2016-06-15 23:07:42 UTC (rev 202114)
@@ -1,3 +1,26 @@
+2016-06-15  Simon Fraser  <simon.fra...@apple.com>
+
+        [iOS WK2] Add tests for zooming to text fields on focus
+        https://bugs.webkit.org/show_bug.cgi?id=158786
+
+        Reviewed by Enrica Casucci.
+
+        Add tests that focus form controls, and test the resulting scroll position and zoom level.
+
+        * TestExpectations:
+        * fast/forms/ios/focus-input-via-button-expected.txt: Added.
+        * fast/forms/ios/focus-input-via-button-no-scaling-expected.txt: Added.
+        * fast/forms/ios/focus-input-via-button-no-scaling.html: Added.
+        * fast/forms/ios/focus-input-via-button.html: Added.
+        * fast/forms/ios/resources/zooming-test-utils.js: Added.
+        (testZoomAfterTap):
+        (tableFromJSON):
+        * fast/forms/ios/zoom-after-input-tap-expected.txt: Added.
+        * fast/forms/ios/zoom-after-input-tap-wide-input-expected.txt: Added.
+        * fast/forms/ios/zoom-after-input-tap-wide-input.html: Added.
+        * fast/forms/ios/zoom-after-input-tap.html: Added.
+        * platform/ios-simulator-wk2/TestExpectations:
+
 2016-06-15  Adam Bergkvist  <adam.bergkv...@ericsson.com>
 
         WebRTC: Add media setup test using the legacy callback APIs

Modified: trunk/LayoutTests/TestExpectations (202113 => 202114)


--- trunk/LayoutTests/TestExpectations	2016-06-15 22:37:03 UTC (rev 202113)
+++ trunk/LayoutTests/TestExpectations	2016-06-15 23:07:42 UTC (rev 202114)
@@ -17,6 +17,7 @@
 tiled-drawing [ Skip ]
 swipe [ Skip ]
 fast/zooming/ios [ Skip ]
+fast/forms/ios [ Skip ]
 fast/viewport/ios [ Skip ]
 fast/events/ios [ Skip ]
 fast/events/touch/ios [ Skip ]

Added: trunk/LayoutTests/fast/forms/ios/focus-input-via-button-expected.txt (0 => 202114)


--- trunk/LayoutTests/fast/forms/ios/focus-input-via-button-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/focus-input-via-button-expected.txt	2016-06-15 23:07:42 UTC (rev 202114)
@@ -0,0 +1,7 @@
+Tests zooming into a text input on tap.
+
+Click to focus input
+
+tap location	{ x: 20.000, y: 62.000 }
+scale	1.455
+visibleRect	{ left: 0.000, top: 791.923, width: 219.979, height: 329.968 }

Added: trunk/LayoutTests/fast/forms/ios/focus-input-via-button-no-scaling-expected.txt (0 => 202114)


--- trunk/LayoutTests/fast/forms/ios/focus-input-via-button-no-scaling-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/focus-input-via-button-no-scaling-expected.txt	2016-06-15 23:07:42 UTC (rev 202114)
@@ -0,0 +1,7 @@
+Tests zooming into a text input on tap.
+
+Click to focus input
+
+tap location	{ x: 20.000, y: 62.000 }
+scale	0.749
+visibleRect	{ left: 0.000, top: 703.883, width: 427.000, height: 640.500 }

Added: trunk/LayoutTests/fast/forms/ios/focus-input-via-button-no-scaling.html (0 => 202114)


--- trunk/LayoutTests/fast/forms/ios/focus-input-via-button-no-scaling.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/focus-input-via-button-no-scaling.html	2016-06-15 23:07:42 UTC (rev 202114)
@@ -0,0 +1,43 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=0.75, user-scalable=no">
+    <style>
+        input[type="text"] {
+            margin: 800px 20px;
+        }
+        button {
+            display: block;
+        }
+    </style>
+    
+    <script src=""
+    <script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+    
+    function buttonClicked()
+    {
+        document.getElementById('input').focus();
+    }
+
+    function doTest()
+    {
+        testZoomAfterTap(document.getElementById('target'), 10, 10);
+    }
+
+    window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<p>Tests zooming into a text input on tap.</p>
+<button id="target" _onclick_="buttonClicked()">Click to focus input</button>
+
+<input id="input" type="text">
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/focus-input-via-button.html (0 => 202114)


--- trunk/LayoutTests/fast/forms/ios/focus-input-via-button.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/focus-input-via-button.html	2016-06-15 23:07:42 UTC (rev 202114)
@@ -0,0 +1,43 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=0.5">
+    <style>
+        input[type="text"] {
+            margin: 800px 20px;
+        }
+        button {
+            display: block;
+        }
+    </style>
+    
+    <script src=""
+    <script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+    
+    function buttonClicked()
+    {
+        document.getElementById('input').focus();
+    }
+
+    function doTest()
+    {
+        testZoomAfterTap(document.getElementById('target'), 10, 10);
+    }
+
+    window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<p>Tests zooming into a text input on tap.</p>
+<button id="target" _onclick_="buttonClicked()">Click to focus input</button>
+
+<input id="input" type="text">
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/resources/zooming-test-utils.js (0 => 202114)


--- trunk/LayoutTests/fast/forms/ios/resources/zooming-test-utils.js	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/resources/zooming-test-utils.js	2016-06-15 23:07:42 UTC (rev 202114)
@@ -0,0 +1,77 @@
+
+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);
+        document.body.appendChild(results);
+        testRunner.notifyDone();
+    });
+}
+
+function zoomAfterSingleTapUIScript(x, y)
+{
+    return `
+        (function() {
+            uiController.didEndZoomingCallback = function() {
+                var result = {
+                    'tap location' : { 'x' : ${x}, 'y' : ${y}},
+                    '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.singleTapAtPoint(${x}, ${y}, function() {});
+        })();`
+}
+
+function getPointInsideElement(element, xOffset, yOffset)
+{
+    var clientRect = element.getBoundingClientRect();
+
+    var scrollLeft = document.scrollingElement.scrollLeft;
+    var scrollTop = document.scrollingElement.scrollTop;
+    
+    // Returns point in document coordinates.
+    return { 'x' : clientRect.left + scrollLeft + xOffset, 'y' : clientRect.top + scrollTop + yOffset };
+}
+
+function tableFromJSON(value)
+{
+    var result = JSON.parse(value);
+    
+    var table = document.createElement('table');
+    for (var property in result) {
+        var row = document.createElement('tr');
+        
+        var th = document.createElement('th');
+        th.textContent = property;
+        
+        var td = document.createElement('td');
+        var value = result[property];
+        if (typeof value === "object")
+            value = JSON.stringify(value, "", 2).replace(/"/g, '');
+        
+        td.textContent = value;
+    
+        row.appendChild(th);
+        row.appendChild(td);
+        table.appendChild(row);
+    }
+    
+    return table;
+}

Added: trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap-expected.txt (0 => 202114)


--- trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap-expected.txt	2016-06-15 23:07:42 UTC (rev 202114)
@@ -0,0 +1,6 @@
+Tests zooming into a text input on tap.
+
+
+tap location	{ x: 38.000, y: 862.000 }
+scale	1.455
+visibleRect	{ left: 0.000, top: 769.925, width: 219.979, height: 329.968 }

Added: trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap-wide-input-expected.txt (0 => 202114)


--- trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap-wide-input-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap-wide-input-expected.txt	2016-06-15 23:07:42 UTC (rev 202114)
@@ -0,0 +1,6 @@
+Tests zooming to an offset in a wide text input on tap.
+
+
+tap location	{ x: 328.000, y: 862.000 }
+scale	1.455
+visibleRect	{ left: 122.707, top: 769.928, width: 219.980, height: 329.969 }

Added: trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap-wide-input.html (0 => 202114)


--- trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap-wide-input.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap-wide-input.html	2016-06-15 23:07:42 UTC (rev 202114)
@@ -0,0 +1,33 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=0.5">
+    <style>
+        input[type="text"] {
+            margin: 800px 20px;
+        }
+    </style>
+    
+    <script src=""
+    <script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    function doTest()
+    {
+        testZoomAfterTap(document.getElementById('input'), 300, 10);
+    }
+
+    window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<p>Tests zooming to an offset in a wide text input on tap.</p>
+<input id="input" type="text" size="100" value="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz">
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap.html (0 => 202114)


--- trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/zoom-after-input-tap.html	2016-06-15 23:07:42 UTC (rev 202114)
@@ -0,0 +1,33 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=0.5">
+    <style>
+        input[type="text"] {
+            margin: 800px 20px;
+        }
+    </style>
+    
+    <script src=""
+    <script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    function doTest()
+    {
+        testZoomAfterTap(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">
+
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to