Title: [163615] trunk/LayoutTests
Revision
163615
Author
[email protected]
Date
2014-02-07 01:20:03 -0800 (Fri, 07 Feb 2014)

Log Message

Verify misspellings after lines merge/split asynchronously
https://bugs.webkit.org/show_bug.cgi?id=128305

Reviewed by Ryosuke Niwa.

Adapt two spelling tests to use asynchronous spellchecking.

* editing/spelling/script-tests/spelling-backspace-between-lines.js:
(testTwoLinesMisspellings):
(testMisspellingsAfterLineMergeUsingDelete):
(testMisspellingsAfterLineMergeUsingForwardDelete):
Group test cases into separated methods.
Use shouldBeEqualToString to compare strings.
Add newly created div elements instead of overriding
the previous one in order that non DumpRenderTree users
can see what has been tested.

* editing/spelling/spelling-backspace-between-lines-expected.txt:
* editing/spelling/spelling-linebreak-expected.txt:
* editing/spelling/spelling-linebreak.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (163614 => 163615)


--- trunk/LayoutTests/ChangeLog	2014-02-07 08:32:30 UTC (rev 163614)
+++ trunk/LayoutTests/ChangeLog	2014-02-07 09:20:03 UTC (rev 163615)
@@ -1,3 +1,26 @@
+2014-02-07  Grzegorz Czajkowski  <[email protected]>
+
+        Verify misspellings after lines merge/split asynchronously
+        https://bugs.webkit.org/show_bug.cgi?id=128305
+
+        Reviewed by Ryosuke Niwa.
+
+        Adapt two spelling tests to use asynchronous spellchecking.
+
+        * editing/spelling/script-tests/spelling-backspace-between-lines.js:
+        (testTwoLinesMisspellings):
+        (testMisspellingsAfterLineMergeUsingDelete):
+        (testMisspellingsAfterLineMergeUsingForwardDelete):
+        Group test cases into separated methods.
+        Use shouldBeEqualToString to compare strings.
+        Add newly created div elements instead of overriding
+        the previous one in order that non DumpRenderTree users
+        can see what has been tested.
+
+        * editing/spelling/spelling-backspace-between-lines-expected.txt:
+        * editing/spelling/spelling-linebreak-expected.txt:
+        * editing/spelling/spelling-linebreak.html:
+
 2014-02-06  Gyuyoung Kim  <[email protected]>
 
         Add a test case for navigator.isProtocolHandlerRegistered

Modified: trunk/LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js (163614 => 163615)


--- trunk/LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js	2014-02-07 08:32:30 UTC (rev 163614)
+++ trunk/LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js	2014-02-07 09:20:03 UTC (rev 163615)
@@ -1,65 +1,97 @@
+description('Spelling markers should remain while merging two lines.');
 
-description('For Bug 41423: Spelling marker should remain after hitting a backspace key.');
+jsTestIsAsync = true;
 
+if (window.internals) {
+    internals.settings.setUnifiedTextCheckerEnabled(true);
+    internals.settings.setAsynchronousSpellCheckingEnabled(true);
+}
+
 var testRoot = document.createElement("div");
 document.body.insertBefore(testRoot, document.body.firstChild);
 
 function setup(targetName)
 {
-    testRoot.innerHTML = "<div id='" + targetName + "' contentEditable><div>OK</div><div>OK zz OK</div></div>";
-    document.getElementById(targetName).focus();
+    var div = document.createElement("div");
+    div.id = targetName;
+    div.contentEditable = true;
+    div.innerHTML = "<div>OK</div><div>OK zz OK</div>";
+    testRoot.appendChild(div);
+
+    div.focus();
     return document.getSelection();
 }
 
-function firstLineText()
+function firstLineText(targetName)
 {
-    return testRoot.firstChild.firstChild.innerText.trim();
+    var div = document.getElementById(targetName);
+    return div.firstChild.innerText.trim();
 }
 
-function testWithDelete()
+function testTwoLinesMisspellings()
 {
-    window.sel = setup("target1");
+    window.sel = setup("target1"); // ^OK
 
-    sel.modify("move", "forward", "line");
-    for (var i = 0; i < 3; i++) // 3 for ["OK, "zz", "OK"].length
+    sel.modify("move", "forward", "line"); // ^OK zz OK
+    for (var i = 0; i < 3; i++)
         sel.modify("move", "forward", "word");
 
-    shouldBe("firstLineText()", "'OK'");
-    shouldBe("sel.anchorNode.data", "'OK zz OK'");
-    shouldBeTrue("internals.hasSpellingMarker(3, 2)");
+    shouldBeEqualToString("firstLineText('target1')", "OK");
+    shouldBeEqualToString("sel.anchorNode.data", "OK zz OK");
+    if (window.internals)
+        shouldBecomeEqual("internals.hasSpellingMarker(3, 2)", "true", done);
+    else
+        done();
+}
 
-    sel.modify("move", "left", "lineboundary");
-    document.execCommand("Delete", false);
-    sel.modify("move", "right", "line"); // Moves to the line ending to focus the "OK zz OK" text.
+function testMisspellingsAfterLineMergeUsingDelete()
+{
+    window.sel = setup("target2"); // ^OK
 
-    shouldBe("sel.anchorNode.data", "'OKOK zz OK'");
-    shouldBe("firstLineText()", "'OKOK zz OK'");
-    shouldBeTrue("internals.hasSpellingMarker(5, 2)");
+    sel.modify("move", "forward", "line"); // ^OK zz OK
+    document.execCommand("Delete", false); // OK^OK zz OK
+    sel.modify("move", "right", "line"); // OKOK zz OK^
+
+    shouldBeEqualToString("firstLineText('target2')", "OKOK zz OK");
+    shouldBeEqualToString("sel.anchorNode.data", "OKOK zz OK");
+    if (window.internals)
+        shouldBecomeEqual("internals.hasSpellingMarker(5, 2)", "true", done);
+    else
+        done();
 }
 
-function testWithForwardDelete()
+function testMisspellingsAfterLineMergeUsingForwardDelete()
 {
-    window.sel = setup("target1");
+    window.sel = setup("target3"); // ^OK
 
-    sel.modify("move", "forward", "line");
-    for (var i = 0; i < 3; i++) // 3 for ["OK, "zz", "OK"].length
-        sel.modify("move", "forward", "word");
+    sel.modify("move", "forward", "word"); // OK^
+    document.execCommand("ForwardDelete", false); // OK^OK zz OK
+    sel.modify("move", "right", "line"); // OKOK zz OK^
 
-    shouldBe("firstLineText()", "'OK'");
-    shouldBe("sel.anchorNode.data", "'OK zz OK'");
-    shouldBeTrue("internals.hasSpellingMarker(3, 2)");
+    shouldBeEqualToString("firstLineText('target3')", "OKOK zz OK");
+    shouldBeEqualToString("sel.anchorNode.data", "OKOK zz OK");
+    if (window.internals)
+        shouldBecomeEqual("internals.hasSpellingMarker(5, 2)", "true", done);
+    else
+        done();
+}
 
-    sel.modify("move", "left", "line");
-    document.execCommand("ForwardDelete", false);
-    sel.modify("move", "right", "line"); // Moves to the line ending to focus the "OK zz OK" text.
+var tests = [ function() { testTwoLinesMisspellings(); },
+              function() { testMisspellingsAfterLineMergeUsingDelete(); },
+              function() { testMisspellingsAfterLineMergeUsingForwardDelete(); }
+];
 
-    shouldBe("firstLineText()", "'OKOK zz OK'");
-    shouldBe("sel.anchorNode.data", "'OKOK zz OK'");
-    shouldBeTrue("internals.hasSpellingMarker(5, 2)");
+function done()
+{
+    var next = tests.shift();
+    if (next)
+        return window.setTimeout(next, 0);
+
+    if (window.internals)
+        testRoot.style.display = "none";
+
+    finishJSTest();
 }
+done();
 
-testWithDelete();
-testWithForwardDelete();
-testRoot.style.display = "none";
-
 var successfullyParsed = true;

Modified: trunk/LayoutTests/editing/spelling/spelling-backspace-between-lines-expected.txt (163614 => 163615)


--- trunk/LayoutTests/editing/spelling/spelling-backspace-between-lines-expected.txt	2014-02-07 08:32:30 UTC (rev 163614)
+++ trunk/LayoutTests/editing/spelling/spelling-backspace-between-lines-expected.txt	2014-02-07 09:20:03 UTC (rev 163615)
@@ -1,20 +1,17 @@
-For Bug 41423: Spelling marker should remain after hitting a backspace key.
+Spelling markers should remain while merging two lines.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS firstLineText() is 'OK'
-PASS sel.anchorNode.data is 'OK zz OK'
-PASS internals.hasSpellingMarker(3, 2) is true
-PASS sel.anchorNode.data is 'OKOK zz OK'
-PASS firstLineText() is 'OKOK zz OK'
-PASS internals.hasSpellingMarker(5, 2) is true
-PASS firstLineText() is 'OK'
-PASS sel.anchorNode.data is 'OK zz OK'
-PASS internals.hasSpellingMarker(3, 2) is true
-PASS firstLineText() is 'OKOK zz OK'
-PASS sel.anchorNode.data is 'OKOK zz OK'
-PASS internals.hasSpellingMarker(5, 2) is true
+PASS firstLineText('target1') is "OK"
+PASS sel.anchorNode.data is "OK zz OK"
+PASS internals.hasSpellingMarker(3, 2) became true
+PASS firstLineText('target2') is "OKOK zz OK"
+PASS sel.anchorNode.data is "OKOK zz OK"
+PASS internals.hasSpellingMarker(5, 2) became true
+PASS firstLineText('target3') is "OKOK zz OK"
+PASS sel.anchorNode.data is "OKOK zz OK"
+PASS internals.hasSpellingMarker(5, 2) became true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/editing/spelling/spelling-linebreak-expected.txt (163614 => 163615)


--- trunk/LayoutTests/editing/spelling/spelling-linebreak-expected.txt	2014-02-07 08:32:30 UTC (rev 163614)
+++ trunk/LayoutTests/editing/spelling/spelling-linebreak-expected.txt	2014-02-07 09:20:03 UTC (rev 163615)
@@ -1,3 +1,10 @@
-You should see 'zz a' on the first line below, and 'a' on the second line. 'zz' (and only 'zz') should be marked as misspelled.
-PASS
+Misspellings should be preserved when a line-break command splits a text node. You should see 'Hello,zz a' on the first line below, and 'a' on the second line. This test succeeds when 'zz' (and only 'zz') is marked as misspelled.
 
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.hasSpellingMarker(6, 2) became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/LayoutTests/editing/spelling/spelling-linebreak.html (163614 => 163615)


--- trunk/LayoutTests/editing/spelling/spelling-linebreak.html	2014-02-07 08:32:30 UTC (rev 163614)
+++ trunk/LayoutTests/editing/spelling/spelling-linebreak.html	2014-02-07 09:20:03 UTC (rev 163615)
@@ -8,17 +8,20 @@
     font-size: 24px; 
 }
 </style>
+<script src=""
 <script src="" language="_javascript_" type="text/_javascript_" ></script>
 
 <script>
-function log(msg) {
-    document.getElementById("console").innerHTML += (msg + "\n");
+
+jsTestIsAsync = true;
+
+if (window.internals) {
+    internals.settings.setUnifiedTextCheckerEnabled(true);
+    internals.settings.setAsynchronousSpellCheckingEnabled(true);
 }
 
 function editingTest() {
 
-    if (window.testRunner)
-        testRunner.dumpAsText();
     var elem = document.getElementById("test");
     var selection = window.getSelection();
     selection.setPosition(elem, 6);
@@ -34,11 +37,10 @@
 
     if (window.testRunner) {
         selection.setPosition(elem, 0);
-        if (internals.hasSpellingMarker(6, 2))
-           log("PASS");
-        else
-           log("FAIL");
-        document.getElementById("root").style.display = "none";
+        shouldBecomeEqual("internals.hasSpellingMarker(6, 2)", "true", function() {
+            document.getElementById("root").style.display = "none";
+            finishJSTest();
+        });
     }
 
 }
@@ -48,15 +50,19 @@
 <title>Editing Test</title> 
 </head> 
 <body>
-<div>You should see 'zz a' on the first line below, and 'a' on the second line. 'zz' (and only 'zz') should be marked as misspelled.</div>
+<script>
+description("Misspellings should be preserved when a line-break command "
+    + "splits a text node. You should see 'Hello,zz a' on the first line below, "
+    + "and 'a' on the second line. "
+    + "This test succeeds when 'zz' (and only 'zz') is marked as misspelled.");
+</script>
 <div contenteditable id="root" class="editing">
 <!-- wee need leading "Hello," to preserve the marker even after setPosition() -->
 <span id="test">Hello,</span>
 </div>
-<pre id="console"></pre>
 <script>
 editingTest();
 </script>
-
+<script src=""
 </body>
 </html>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to