Title: [234601] trunk
Revision
234601
Author
wenson_hs...@apple.com
Date
2018-08-06 08:01:47 -0700 (Mon, 06 Aug 2018)

Log Message

[iOS] Tests that try to interact with the QuickType bar time out on iOS 11+
https://bugs.webkit.org/show_bug.cgi?id=188335
<rdar://problem/32542437> and <rdar://problem/32542433>

Reviewed by Tim Horton.

Tools:

Remove a UIScriptController helper method that attempted to wait for QuickType buttons to appear, and then send
touch events to the buttons. These were only used for the two tests which this patch refactors. See the
LayoutTests ChangeLog for more detail.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::selectTextCandidateAtIndex): Deleted.
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::selectTextCandidateAtIndex): Deleted.
(WTR::UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex): Deleted.
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* TestRunnerShared/spi/UIKitTestSPI.h:

Remove an internal class declaration that is now unnecessary.

* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::selectTextCandidateAtIndex): Deleted.
(WTR::UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex): Deleted.

LayoutTests:

Refactors a couple of tests that currently rely on the QuickType bar being shown when the hardware keyboard is
presented in the iOS simulator, so that it can insert text suggestions by tapping QuickType bar buttons; in the
first place, it was never guaranteed that this bar would show up, or even have more than 1 text suggestion.
Instead, we use the existing UIScriptController::applyAutocorrection method to trigger text replacement in the
same way tapping a button on the QuickType bar would replace the current word with the suggested word.

* fast/events/ios/before-input-events-prevent-candidate-insertion-expected.txt:
* fast/events/ios/before-input-events-prevent-candidate-insertion.html:
* fast/events/ios/input-events-insert-replacement-text-expected.txt:
* fast/events/ios/input-events-insert-replacement-text.html:
* platform/ios/TestExpectations:

Removes a [Timeout] expectation.

* resources/ui-helper.js:
(window.UIHelper.typeCharacter):

Add a new UIHelper method to type a character using the keyboard. Sends hardware keyboard events on the WebKit2
port of iOS, and uses EventSender elsewhere.

(window.UIHelper.applyAutocorrection):

Add a new UIHelper method that wraps UIScriptController::applyAutocorrection. Only supported in WebKit2
currently.

(window.UIHelper):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (234600 => 234601)


--- trunk/LayoutTests/ChangeLog	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/LayoutTests/ChangeLog	2018-08-06 15:01:47 UTC (rev 234601)
@@ -1,5 +1,40 @@
 2018-08-06  Wenson Hsieh  <wenson_hs...@apple.com>
 
+        [iOS] Tests that try to interact with the QuickType bar time out on iOS 11+
+        https://bugs.webkit.org/show_bug.cgi?id=188335
+        <rdar://problem/32542437> and <rdar://problem/32542433>
+
+        Reviewed by Tim Horton.
+
+        Refactors a couple of tests that currently rely on the QuickType bar being shown when the hardware keyboard is
+        presented in the iOS simulator, so that it can insert text suggestions by tapping QuickType bar buttons; in the
+        first place, it was never guaranteed that this bar would show up, or even have more than 1 text suggestion.
+        Instead, we use the existing UIScriptController::applyAutocorrection method to trigger text replacement in the
+        same way tapping a button on the QuickType bar would replace the current word with the suggested word.
+
+        * fast/events/ios/before-input-events-prevent-candidate-insertion-expected.txt:
+        * fast/events/ios/before-input-events-prevent-candidate-insertion.html:
+        * fast/events/ios/input-events-insert-replacement-text-expected.txt:
+        * fast/events/ios/input-events-insert-replacement-text.html:
+        * platform/ios/TestExpectations:
+
+        Removes a [Timeout] expectation.
+
+        * resources/ui-helper.js:
+        (window.UIHelper.typeCharacter):
+
+        Add a new UIHelper method to type a character using the keyboard. Sends hardware keyboard events on the WebKit2
+        port of iOS, and uses EventSender elsewhere.
+
+        (window.UIHelper.applyAutocorrection):
+
+        Add a new UIHelper method that wraps UIScriptController::applyAutocorrection. Only supported in WebKit2
+        currently.
+
+        (window.UIHelper):
+
+2018-08-06  Wenson Hsieh  <wenson_hs...@apple.com>
+
         [iOS] Caret disappears after resigning and becoming first responder if active focus state is retained
         https://bugs.webkit.org/show_bug.cgi?id=188322
         <rdar://problem/42455270>

Modified: trunk/LayoutTests/fast/events/ios/before-input-events-prevent-candidate-insertion-expected.txt (234600 => 234601)


--- trunk/LayoutTests/fast/events/ios/before-input-events-prevent-candidate-insertion-expected.txt	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/LayoutTests/fast/events/ios/before-input-events-prevent-candidate-insertion-expected.txt	2018-08-06 15:01:47 UTC (rev 234601)
@@ -1,5 +1,9 @@
 
-To manually test, type 't' into the contenteditable and try to select a candidate. The replacement text should not be inserted.
+This test verifies that beforeinput events of inputType "insertReplacementText" can be prevented.
 
-PASS: The replacement text was prevented.
+To manually test, type 'T' into the text field and try to select a candidate. The replacement text should not be inserted.
 
+Replacing "T" with "The"...
+Prevented "insertReplacementText" with data: "The"
+Does the input value contain replacement text? false
+

Modified: trunk/LayoutTests/fast/events/ios/before-input-events-prevent-candidate-insertion.html (234600 => 234601)


--- trunk/LayoutTests/fast/events/ios/before-input-events-prevent-candidate-insertion.html	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/LayoutTests/fast/events/ios/before-input-events-prevent-candidate-insertion.html	2018-08-06 15:01:47 UTC (rev 234601)
@@ -1,92 +1,63 @@
 <!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
 
 <html>
-
 <head>
-    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
-    <script id="ui-script" type="text/plain">
-        (function() {
-            uiController.didShowKeyboardCallback = function() {
-                uiController.typeCharacterUsingHardwareKeyboard("t", function() {
-                    uiController.selectTextCandidateAtIndex(1, function() {
-                        uiController.uiScriptComplete();
-                    });
-                });
-            }
-            uiController.singleTapAtPoint($x, $y, function() {});
-        })();
-    </script>
+<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
+<script src=""
+<style>
+#editable {
+    width: 320px;
+    height: 320px;
+    top: 0;
+    left: 0;
+    position: absolute;
+}
+</style>
+</head>
 
-    <script>
-        var progress = 0;
-        var replacementText = "";
-        let write = (message) => output.innerHTML += (message + "<br>");
-        function getUIScript() {
-            let rect = editable.getBoundingClientRect();
-            let script = document.getElementById("ui-script").text;
-            script = script.replace("$x", rect.left + rect.width / 2);
-            return script.replace("$y", rect.top + rect.height / 2);
-        }
+<body style="margin: 0;">
+<input contenteditable id="editable"></input>
+<p>This test verifies that <code>beforeinput</code> events of inputType "insertReplacementText" can be prevented.</p>
+<p>To manually test, type 'T' into the text field and try to select a candidate. The replacement text should not be inserted.</p>
+<pre id="output"></pre>
+<script>
+let write = (message) => output.innerHTML += (message + "<br>");
 
-        if (window.testRunner) {
-            testRunner.dumpAsText();
-            testRunner.waitUntilDone();
-            internals.settings.setInputEventsEnabled(true);
-        }
+function checkForCompletion() {
+    doneCount = window.doneCount ? doneCount : 0;
+    if (++doneCount == 2 && window.testRunner)
+        testRunner.notifyDone();
+}
 
-        function incrementProgress()
-        {
-            progress++;
-            if (!window.testRunner || progress !== 2)
-                return;
+function handleBeforeInput(event) {
+    if (event.inputType !== "insertReplacementText")
+        return;
 
-            setTimeout(function() {
-                if (editable.value.indexOf(replacementText) == -1)
-                    write(`PASS: The replacement text was prevented.`);
-                else
-                    write(`FAIL: The input value ${editable.value} should not contain replacement text ${replacementText}.`);
-                testRunner.notifyDone();
-            }, 0);
-        }
+    event.preventDefault();
 
-        function runTest()
-        {
-            editable.addEventListener("beforeinput", preventBeforeInput);
-            if (!window.testRunner || !testRunner.runUIScript)
-                return;
+    write(`Prevented "insertReplacementText" with data: "${event.data}"`);
+    setTimeout(() => {
+        write(`Does the input value contain replacement text? ${editable.value.includes("The")}`);
+        checkForCompletion();
+    }, 0);
+}
 
-            testRunner.runUIScript(getUIScript(), function(result) {
-                incrementProgress();
-            });
-        }
+function triggerAutocorrectionAfterFirstInput() {
+    editable.removeEventListener("input", triggerAutocorrectionAfterFirstInput);
+    write(`Replacing "T" with "The"...`);
+    editable.setSelectionRange(0, 1);
+    UIHelper.applyAutocorrection("The", "T").then(checkForCompletion);
+}
 
-        function preventBeforeInput(event)
-        {
-            if (event.inputType === "insertReplacementText") {
-                replacementText = event.data;
-                if (!replacementText)
-                    write("FAIL: The replacement text input event lacks data.");
-                event.preventDefault();
-                incrementProgress();
-            }
-        }
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
 
-    </script>
-    <style>
-    #editable {
-        width: 200px;
-        height: 100px;
-        top: 0;
-        left: 0;
-        position: absolute;
-    }
-    </style>
-</head>
-
-<body style="margin: 0;" _onload_=runTest()>
-    <input contenteditable id="editable"></input>
-    <p>To manually test, type 't' into the contenteditable and try to select a candidate. The replacement text should not be inserted.</p>
-    <div id="output"></div>
+editable.addEventListener("beforeinput", handleBeforeInput);
+editable.addEventListener("input", triggerAutocorrectionAfterFirstInput);
+UIHelper.activateAndWaitForInputSessionAt(160, 160).then(() => UIHelper.typeCharacter("T"));
+</script>
 </body>
 
 </html>

Modified: trunk/LayoutTests/fast/events/ios/input-events-insert-replacement-text-expected.txt (234600 => 234601)


--- trunk/LayoutTests/fast/events/ios/input-events-insert-replacement-text-expected.txt	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/LayoutTests/fast/events/ios/input-events-insert-replacement-text-expected.txt	2018-08-06 15:01:47 UTC (rev 234601)
@@ -1,5 +1,9 @@
-To manually test, type 't' into the contenteditable and try to select a candidate. The output should indicate that the beforeinput and input events for the text replacement were handled, and that the range of the beforeinput event is from 0 to 1.
+The
+This test verifies that input events of type "insertReplacementText" target the right ranges.
 
-PASS: Handled text replacement before input event with range: [0, 1].
-PASS: Handled text replacement input event.
+To manually test, type 'T' into the input field and try to select a candidate. The output should indicate that the beforeinput and input events for the text replacement were handled, and that the range of the beforeinput event is from 0 to 1.
 
+Replacing "T" with "The"...
+Observed text replacement before input event with range: [0, 1] and data: "The"
+Observed text replacement input event with data: "The"
+

Modified: trunk/LayoutTests/fast/events/ios/input-events-insert-replacement-text.html (234600 => 234601)


--- trunk/LayoutTests/fast/events/ios/input-events-insert-replacement-text.html	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/LayoutTests/fast/events/ios/input-events-insert-replacement-text.html	2018-08-06 15:01:47 UTC (rev 234601)
@@ -1,90 +1,64 @@
 <!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
 
 <html>
-
 <head>
-    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
-    <script id="ui-script" type="text/plain">
-        (function() {
-            uiController.didShowKeyboardCallback = function() {
-                uiController.typeCharacterUsingHardwareKeyboard("t", function() {
-                    uiController.selectTextCandidateAtIndex(1, function() {
-                        uiController.uiScriptComplete();
-                    });
-                });
-            }
-            uiController.singleTapAtPoint($x, $y, function() {});
-        })();
-    </script>
+<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
+<script src=""
+<style>
+#editable {
+    width: 200px;
+    height: 200px;
+    top: 0;
+    left: 0;
+    position: absolute;
+}
+</style>
+</head>
 
-    <script>
-        var progress = 0;
-        let write = (message) => output.innerHTML += (message + "<br>");
-        function getUIScript() {
-            let rect = editable.getBoundingClientRect();
-            let script = document.getElementById("ui-script").text;
-            script = script.replace("$x", rect.left + rect.width / 2);
-            return script.replace("$y", rect.top + rect.height / 2);
-        }
+<body style="margin: 0;">
+<div contenteditable id="editable"></div>
+<p>This test verifies that input events of type "insertReplacementText" target the right ranges.</p>
+<p>To manually test, type 'T' into the input field and try to select a candidate. The output should indicate that the beforeinput and input events for the text replacement were handled, and that the range of the beforeinput event is from 0 to 1.</p>
+<div id="output"></div>
+<script>
+let write = (message) => output.innerHTML += (message + "<br>");
 
-        if (window.testRunner) {
-            testRunner.dumpAsText();
-            testRunner.waitUntilDone();
-            internals.settings.setInputEventsEnabled(true);
-        }
+function checkForCompletion() {
+    doneCount = window.doneCount ? doneCount : 0;
+    if (++doneCount == 3 && window.testRunner)
+        testRunner.notifyDone();
+}
 
-        function incrementProgress()
-        {
-            progress++;
-            if (!window.testRunner || progress !== 3)
-                return;
+function logInputEvent(event)
+{
+    if (event.inputType !== "insertReplacementText")
+        return;
 
-            setTimeout(function() {
-                editable.textContent = "";
-                testRunner.notifyDone();
-            }, 0);
-        }
+    if (event.type === "beforeinput") {
+        let firstRange = event.getTargetRanges()[0];
+        write(`Observed text replacement before input event with range: [${firstRange.startOffset}, ${firstRange.endOffset}] and data: "${event.dataTransfer.getData("text/plain")}"`);
+    } else
+        write(`Observed text replacement input event with data: "${event.dataTransfer.getData("text/plain")}"`);
 
-        function runTest()
-        {
-            editable.addEventListener("input", logInputEvent);
-            editable.addEventListener("beforeinput", logInputEvent);
-            if (!window.testRunner || !testRunner.runUIScript)
-                return;
+    checkForCompletion();
+}
 
-            testRunner.runUIScript(getUIScript(), function(result) {
-                incrementProgress();
-            });
-        }
+function triggerAutocorrectionAfterFirstInput() {
+    editable.removeEventListener("input", triggerAutocorrectionAfterFirstInput);
+    write(`Replacing "T" with "The"...`);
+    getSelection().setBaseAndExtent(editable, 0, editable, 1);
+    UIHelper.applyAutocorrection("The", "T").then(checkForCompletion);
+}
 
-        function logInputEvent(event)
-        {
-            if (event.inputType !== "insertReplacementText")
-                return;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
 
-            if (event.type === "beforeinput") {
-                let firstRange = event.getTargetRanges()[0];
-                write(`PASS: Handled text replacement before input event with range: [${firstRange.startOffset}, ${firstRange.endOffset}].`);
-            } else
-                write(`PASS: Handled text replacement input event.`);
-            incrementProgress();
-        }
-    </script>
-    <style>
-    #editable {
-        width: 200px;
-        height: 200px;
-        top: 0;
-        left: 0;
-        position: absolute;
-    }
-    </style>
-</head>
-
-<body style="margin: 0;" _onload_=runTest()>
-    <div contenteditable id="editable"></div>
-    <p>To manually test, type 't' into the contenteditable and try to select a candidate. The output should indicate that the beforeinput and input events for the text replacement were handled, and that the range of the beforeinput event is from 0 to 1.</p>
-    <div id="output"></div>
+editable.addEventListener("beforeinput", logInputEvent);
+editable.addEventListener("input", logInputEvent);
+editable.addEventListener("input", triggerAutocorrectionAfterFirstInput);
+UIHelper.activateAndWaitForInputSessionAt(100, 100).then(() => UIHelper.typeCharacter("T"));
+</script>
 </body>
-
 </html>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (234600 => 234601)


--- trunk/LayoutTests/platform/ios/TestExpectations	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2018-08-06 15:01:47 UTC (rev 234601)
@@ -3078,9 +3078,6 @@
 
 webkit.org/b/172052 [ Release ] imported/w3c/web-platform-tests/html/webappapis/timers/type-long-setinterval.html [ Pass Failure ]
 
-# <rdar://problem/32542437> REGRESSION (iOS 11): LayoutTest fast/events/ios/before-input-events-prevent-candidate-insertion.html is timing out
-fast/events/ios/before-input-events-prevent-candidate-insertion.html [ Timeout ]
-
 # <rdar://problem/32542300> REGRESSION (iOS 11): LayoutTest fast/events/ios/contenteditable-autocapitalize.html is failing
 fast/events/ios/contenteditable-autocapitalize.html [ Failure ]
 

Modified: trunk/LayoutTests/resources/ui-helper.js (234600 => 234601)


--- trunk/LayoutTests/resources/ui-helper.js	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/LayoutTests/resources/ui-helper.js	2018-08-06 15:01:47 UTC (rev 234601)
@@ -278,4 +278,26 @@
             })()`, resolve);
         });
     }
+
+    static typeCharacter(characterString)
+    {
+        if (!this.isWebKit2() || !this.isIOS()) {
+            eventSender.keyDown(key);
+            return;
+        }
+
+        const escapedString = characterString.replace(/`/g, "\\`");
+        const uiScript = `uiController.typeCharacterUsingHardwareKeyboard(\`${escapedString}\`, () => uiController.uiScriptComplete())`;
+        return new Promise(resolve => testRunner.runUIScript(uiScript, resolve));
+    }
+
+    static applyAutocorrection(newText, oldText)
+    {
+        if (!this.isWebKit2())
+            return;
+
+        const [escapedNewText, escapedOldText] = [newText.replace(/`/g, "\\`"), oldText.replace(/`/g, "\\`")];
+        const uiScript = `uiController.applyAutocorrection(\`${escapedNewText}\`, \`${escapedOldText}\`, () => uiController.uiScriptComplete())`;
+        return new Promise(resolve => testRunner.runUIScript(uiScript, resolve));
+    }
 }

Modified: trunk/Tools/ChangeLog (234600 => 234601)


--- trunk/Tools/ChangeLog	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/Tools/ChangeLog	2018-08-06 15:01:47 UTC (rev 234601)
@@ -1,5 +1,32 @@
 2018-08-06  Wenson Hsieh  <wenson_hs...@apple.com>
 
+        [iOS] Tests that try to interact with the QuickType bar time out on iOS 11+
+        https://bugs.webkit.org/show_bug.cgi?id=188335
+        <rdar://problem/32542437> and <rdar://problem/32542433>
+
+        Reviewed by Tim Horton.
+
+        Remove a UIScriptController helper method that attempted to wait for QuickType buttons to appear, and then send
+        touch events to the buttons. These were only used for the two tests which this patch refactors. See the
+        LayoutTests ChangeLog for more detail.
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::selectTextCandidateAtIndex): Deleted.
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        (WTR::UIScriptController::selectTextCandidateAtIndex): Deleted.
+        (WTR::UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex): Deleted.
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        * TestRunnerShared/spi/UIKitTestSPI.h:
+
+        Remove an internal class declaration that is now unnecessary.
+
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::selectTextCandidateAtIndex): Deleted.
+        (WTR::UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex): Deleted.
+
+2018-08-06  Wenson Hsieh  <wenson_hs...@apple.com>
+
         [iOS] Caret disappears after resigning and becoming first responder if active focus state is retained
         https://bugs.webkit.org/show_bug.cgi?id=188322
         <rdar://problem/42455270>

Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (234600 => 234601)


--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2018-08-06 15:01:47 UTC (rev 234601)
@@ -143,10 +143,6 @@
 {
 }
 
-void UIScriptController::selectTextCandidateAtIndex(long, JSValueRef)
-{
-}
-
 void UIScriptController::keyDownUsingHardwareKeyboard(JSStringRef character, JSValueRef callback)
 {
 }

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (234600 => 234601)


--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2018-08-06 15:01:47 UTC (rev 234601)
@@ -63,8 +63,6 @@
     void keyDownUsingHardwareKeyboard(DOMString character, object callback);
     void keyUpUsingHardwareKeyboard(DOMString character, object callback);
 
-    void selectTextCandidateAtIndex(long index, object callback);
-
     // eventsJSON describes a series of user events in JSON form. For the keys, see HIDEventGenerator.mm.
     // For example, this JSON describes a touch down followed by a touch up (i.e. a single tap).
     //  {

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (234600 => 234601)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2018-08-06 15:01:47 UTC (rev 234601)
@@ -282,14 +282,6 @@
 {
 }
 
-void UIScriptController::selectTextCandidateAtIndex(long, JSValueRef)
-{
-}
-
-void UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex(long, unsigned, float)
-{
-}
-
 void UIScriptController::keyDownUsingHardwareKeyboard(JSStringRef, JSValueRef)
 {
 }

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (234600 => 234601)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2018-08-06 15:01:47 UTC (rev 234601)
@@ -89,8 +89,6 @@
     void keyDownUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
     void keyUpUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
 
-    void selectTextCandidateAtIndex(long index, JSValueRef callback);
-
     void keyboardAccessoryBarNext();
     void keyboardAccessoryBarPrevious();
 
@@ -207,7 +205,6 @@
     JSClassRef wrapperClass() final;
 
     JSObjectRef objectFromRect(const WebCore::FloatRect&) const;
-    void waitForTextPredictionsViewAndSelectCandidateAtIndex(long index, unsigned callbackID, float interval);
 
     UIScriptContext* m_context;
 };

Modified: trunk/Tools/TestRunnerShared/spi/UIKitTestSPI.h (234600 => 234601)


--- trunk/Tools/TestRunnerShared/spi/UIKitTestSPI.h	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/Tools/TestRunnerShared/spi/UIKitTestSPI.h	2018-08-06 15:01:47 UTC (rev 234601)
@@ -41,11 +41,6 @@
 #import <UIKit/UIScreen_Private.h>
 #import <UIKit/_UIApplicationRotationFollowing.h>
 
-@interface UIKeyboardPredictionView : UIView
-+ (UIKeyboardPredictionView *)activeInstance;
-- (BOOL)hasPredictions;
-@end
-
 #else
 
 #import "IOKitSPI.h"

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (234600 => 234601)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2018-08-06 14:14:42 UTC (rev 234600)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2018-08-06 15:01:47 UTC (rev 234601)
@@ -374,51 +374,6 @@
     }];
 }
 
-void UIScriptController::selectTextCandidateAtIndex(long index, JSValueRef callback)
-{
-#if USE(APPLE_INTERNAL_SDK)
-    static const float textPredictionsPollingInterval = 0.1;
-    unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
-    waitForTextPredictionsViewAndSelectCandidateAtIndex(index, callbackID, textPredictionsPollingInterval);
-#else
-    // FIXME: This is a no-op on non-internal builds due to UIKeyboardPredictionView being unavailable. Ideally, there should be a better way to
-    // retrieve information and interact with the predictive text view that will be compatible with OpenSource.
-    UNUSED_PARAM(index);
-    UNUSED_PARAM(callback);
-#endif
-}
-
-void UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex(long index, unsigned callbackID, float interval)
-{
-    id UIKeyboardPredictionViewClass = NSClassFromString(@"UIKeyboardPredictionView");
-    if (!UIKeyboardPredictionViewClass)
-        return;
-
-#if USE(APPLE_INTERNAL_SDK)
-    UIKeyboardPredictionView *predictionView = (UIKeyboardPredictionView *)[UIKeyboardPredictionViewClass activeInstance];
-    if (![predictionView hasPredictions]) {
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, interval * NSEC_PER_SEC), dispatch_get_main_queue(), ^() {
-            waitForTextPredictionsViewAndSelectCandidateAtIndex(index, callbackID, interval);
-        });
-        return;
-    }
-
-    PlatformWKView webView = TestController::singleton().mainWebView()->platformView();
-    CGRect predictionViewFrame = [predictionView frame];
-    // This assumes there are 3 predicted text cells of equal width, which is the case on iOS.
-    float offsetX = (index * 2 + 1) * CGRectGetWidth(predictionViewFrame) / 6;
-    float offsetY = CGRectGetHeight(webView.window.frame) - CGRectGetHeight([[predictionView superview] frame]) + CGRectGetHeight(predictionViewFrame) / 2;
-    [[HIDEventGenerator sharedHIDEventGenerator] tap:CGPointMake(offsetX, offsetY) completionBlock:^{
-        if (m_context)
-            m_context->asyncTaskComplete(callbackID);
-    }];
-#else
-    UNUSED_PARAM(index);
-    UNUSED_PARAM(callbackID);
-    UNUSED_PARAM(interval);
-#endif
-}
-
 void UIScriptController::dismissFormAccessoryView()
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to