Title: [261783] trunk/LayoutTests
Revision
261783
Author
[email protected]
Date
2020-05-16 09:24:59 -0700 (Sat, 16 May 2020)

Log Message

Make editing/spelling/editing-word-with-marker-2.html test what it claims and make it work on iOS
https://bugs.webkit.org/show_bug.cgi?id=211802

Reviewed by Darin Adler.

Went back and looked at the originally written version of this test that was added in r70826
and brought back the missing "insert whitespace after misspelling" sub-test. While I am here,
I also simplified the test and made the test work on iOS by using UIHelper. I also fixed some
idiosyncrasies that were introduced in r169687 and did other modernizations.

The fix for iOS was simple: just enable internals.setContinuousSpellCheckingEnabled() + use UIHelper
to activate the textarea + blur the textarea on reset (for maximal code reuse). I didn't enable this
via the WKTR option spellCheckingDots because this test should be capable of running in DumpRenderTree
though we don't actually run DumpRenderTree for iOS on any bots. So, I did this largely for just for me.

I removed the use of editing commands to clear the textarea in favor of just setting the element's
value attribute because it's simpler and exercises less code in the engine, which I hope will reduce
future flakiness + the purpose of the test is to test how a spelling marker is updated not an exercise
on how to clear a textarea using editing commands. That kind of exercise is expected to be covered
by dedicated editing tests, though I haven't checked that they exist, but would be suprised if they
didn't.

* editing/spelling/editing-word-with-marker-2-expected.txt:
* editing/spelling/editing-word-with-marker-2.html:
* platform/ios-wk1/TestExpectations: Unskip.
* platform/ios-wk2/TestExpectations: Ditto.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (261782 => 261783)


--- trunk/LayoutTests/ChangeLog	2020-05-16 15:27:52 UTC (rev 261782)
+++ trunk/LayoutTests/ChangeLog	2020-05-16 16:24:59 UTC (rev 261783)
@@ -1,3 +1,32 @@
+2020-05-16  Daniel Bates  <[email protected]>
+
+        Make editing/spelling/editing-word-with-marker-2.html test what it claims and make it work on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=211802
+
+        Reviewed by Darin Adler.
+
+        Went back and looked at the originally written version of this test that was added in r70826
+        and brought back the missing "insert whitespace after misspelling" sub-test. While I am here,
+        I also simplified the test and made the test work on iOS by using UIHelper. I also fixed some
+        idiosyncrasies that were introduced in r169687 and did other modernizations.
+
+        The fix for iOS was simple: just enable internals.setContinuousSpellCheckingEnabled() + use UIHelper
+        to activate the textarea + blur the textarea on reset (for maximal code reuse). I didn't enable this
+        via the WKTR option spellCheckingDots because this test should be capable of running in DumpRenderTree
+        though we don't actually run DumpRenderTree for iOS on any bots. So, I did this largely for just for me.
+
+        I removed the use of editing commands to clear the textarea in favor of just setting the element's
+        value attribute because it's simpler and exercises less code in the engine, which I hope will reduce
+        future flakiness + the purpose of the test is to test how a spelling marker is updated not an exercise
+        on how to clear a textarea using editing commands. That kind of exercise is expected to be covered
+        by dedicated editing tests, though I haven't checked that they exist, but would be suprised if they
+        didn't.
+
+        * editing/spelling/editing-word-with-marker-2-expected.txt:
+        * editing/spelling/editing-word-with-marker-2.html:
+        * platform/ios-wk1/TestExpectations: Unskip.
+        * platform/ios-wk2/TestExpectations: Ditto.
+
 2020-05-16  Zalan Bujtas  <[email protected]>
 
         [LFC][TFC] Take vertical spacing into account when setting the height of a cell with rowspan

Modified: trunk/LayoutTests/editing/spelling/editing-word-with-marker-2-expected.txt (261782 => 261783)


--- trunk/LayoutTests/editing/spelling/editing-word-with-marker-2-expected.txt	2020-05-16 15:27:52 UTC (rev 261782)
+++ trunk/LayoutTests/editing/spelling/editing-word-with-marker-2-expected.txt	2020-05-16 16:24:59 UTC (rev 261783)
@@ -1,18 +1,25 @@
-The test verifies if the spelling markers remain if a whitespace is added before or after the misspelled word. The test succeeds if the word 'meagesga' has red underline.
+The test verifies if the spelling markers remain if whitespace is added before or after the misspelled word or the caret is moved. The test succeeds if the word 'meagesga' has a red underline.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS internals.hasSpellingMarker(expectedMisspelledPosition, 8) became true
 
-execMoveSelectionBackwardByWordCommand()
+Test: Has misspelled word:
+PASS internals.hasSpellingMarker(7, 8) became true
+
+Test: Insert space before misspelled word:
+test.setSelectionRange(7, 7)
 typeCharacterCommand(' ')
-PASS internals.hasSpellingMarker(expectedMisspelledPosition, 8) became true
+PASS internals.hasSpellingMarker(8, 8) became true
 
-execMoveSelectionBackwardByCharacterCommand()
+Test: Insert space after misspelled word:
+test.setSelectionRange(15, 15)
 typeCharacterCommand(' ')
-PASS internals.hasSpellingMarker(expectedMisspelledPosition, 8) became true
+PASS internals.hasSpellingMarker(7, 8) became true
 
+Test: Move caret:
+execMoveSelectionBackwardByCharacterCommand()
+PASS internals.hasSpellingMarker(7, 8) became true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/editing/spelling/editing-word-with-marker-2.html (261782 => 261783)


--- trunk/LayoutTests/editing/spelling/editing-word-with-marker-2.html	2020-05-16 15:27:52 UTC (rev 261782)
+++ trunk/LayoutTests/editing/spelling/editing-word-with-marker-2.html	2020-05-16 16:24:59 UTC (rev 261783)
@@ -1,26 +1,37 @@
+<!DOCTYPE html>
 <html>
 <head>
 <script src=""
+<script src=""
+<script src=""
 </head>
 <body>
 <textarea id="test"></textarea>
-<script src=""
 <script>
-description("The test verifies if the spelling markers remain if a whitespace "
-    + "is added before or after the misspelled word. "
-    + "The test succeeds if the word 'meagesga' has red underline.");
+description("The test verifies if the spelling markers remain if whitespace "
+    + "is added before or after the misspelled word or the caret is moved. "
+    + "The test succeeds if the word 'meagesga' has a red underline.");
 
 jsTestIsAsync = true;
 
 if (window.internals) {
-    internals.settings.setUnifiedTextCheckerEnabled(true);
-    internals.settings.setAsynchronousSpellCheckingEnabled(true);
+    if (UIHelper.isIOSFamily() || !UIHelper.isWebKit2())
+        internals.setContinuousSpellCheckingEnabled(true);
+    else {
+        internals.settings.setUnifiedTextCheckerEnabled(true);
+        internals.settings.setAsynchronousSpellCheckingEnabled(true);
+    }
 }
 
-function resetText() {
-    document.getElementById('test').focus();
-    execSelectAllCommand();
-    execDeleteCommand();
+let textarea = document.getElementById("test");
+
+async function resetText() {
+    textarea.blur();
+    if (window.testRunner)
+        await UIHelper.activateElementAndWaitForInputSession(textarea);
+    else
+        textarea.focus();
+    textarea.value = "";
     typeCharacterCommand('i');
     typeCharacterCommand('t');
     typeCharacterCommand('\'');
@@ -39,52 +50,60 @@
     typeCharacterCommand(' ');
 }
 
-var expectedMisspelledPosition;
-function checkSpellingMarkerAfterAddingWhitespace(testCase)
+async function checkSpellingMarker(testCase)
 {
-    resetText();
+    await resetText();
 
-    if (testCase.updateCaretPosition) {
-        testCase.updateCaretPosition();
-        evalAndLog("typeCharacterCommand(' ')");
-    }
+    debug(`<br>Test: ${testCase.testName}:`);
+    testCase.run();
 
-   expectedMisspelledPosition = testCase.misspelledPosition;
-
-    if (window.internals) {
-        shouldBecomeEqual("internals.hasSpellingMarker(expectedMisspelledPosition, 8)", "true", function() {
-            debug("");
-            done();
-        });
-    } else
-        done();
+    if (window.internals)
+        shouldBecomeEqual(`internals.hasSpellingMarker(${testCase.expectedMisspelledWordStartPosition}, 8)`, "true", () => runNextTest());
+    else
+        runNextTest();
 }
 
 var testCases = [
     {
-        updateCaretPosition: null,
-        misspelledPosition: 7
+        testName: "Has misspelled word",
+        run: () => { /* Do nothing */ },
+        expectedMisspelledWordStartPosition: 7,
     },
     {
-        updateCaretPosition: function() { evalAndLog("execMoveSelectionBackwardByWordCommand()"); },
-        misspelledPosition: 8
+        testName: "Insert space before misspelled word",
+        run: () => {
+            evalAndLog("test.setSelectionRange(7, 7)");
+            evalAndLog("typeCharacterCommand(' ')");
+        },
+        expectedMisspelledWordStartPosition: 8,
     },
     {
-        updateCaretPosition: function() { evalAndLog("execMoveSelectionBackwardByCharacterCommand()"); },
-        misspelledPosition: 7
+        testName: "Insert space after misspelled word",
+        run: () => {
+            evalAndLog("test.setSelectionRange(15, 15)");
+            evalAndLog("typeCharacterCommand(' ')");
+        },
+        expectedMisspelledWordStartPosition: 7,
+    },
+    {
+        testName: "Move caret",
+        run: () => {
+            evalAndLog("execMoveSelectionBackwardByCharacterCommand()");
+        },
+        expectedMisspelledWordStartPosition: 7,
     }
 ];
 
-function done()
+function runNextTest()
 {
-    var testCase = testCases.shift();
-    if (testCase)
-        return setTimeout(checkSpellingMarkerAfterAddingWhitespace(testCase), 0);
-
+    let testCase = testCases.shift();
+    if (testCase) {
+        setTimeout(() => checkSpellingMarker(testCase), 0);
+        return;
+    }
     finishJSTest();
 }
-done();
+runNextTest();
 </script>
-<script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/platform/ios-wk1/TestExpectations (261782 => 261783)


--- trunk/LayoutTests/platform/ios-wk1/TestExpectations	2020-05-16 15:27:52 UTC (rev 261782)
+++ trunk/LayoutTests/platform/ios-wk1/TestExpectations	2020-05-16 16:24:59 UTC (rev 261783)
@@ -153,7 +153,6 @@
 editing/spelling/context-menu-suggestions-multiword-selection.html
 editing/spelling/delete-into-misspelled-word.html
 editing/spelling/design-mode-spellcheck-off.html
-editing/spelling/editing-word-with-marker-2.html
 editing/spelling/grammar-edit-word.html
 editing/spelling/grammar.html
 editing/spelling/inline-spelling-markers-hidpi.html

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (261782 => 261783)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2020-05-16 15:27:52 UTC (rev 261782)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2020-05-16 16:24:59 UTC (rev 261783)
@@ -704,7 +704,6 @@
 editing/selection/designmode-no-caret.html
 editing/selection/move-by-character-brute-force.html
 editing/spelling/delete-into-misspelled-word.html
-editing/spelling/editing-word-with-marker-2.html
 editing/spelling/grammar-edit-word.html
 editing/spelling/grammar.html
 editing/spelling/inline-spelling-markers-hidpi.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to