Index: LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js |
diff --git a/LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js b/LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js |
index 616f001fd2f8ad868489bdf59574828d60a2f855..441f4bb19463191382673f2cd940ee580ed96511 100644 |
--- a/LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js |
+++ b/LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js |
@@ -1,65 +1,99 @@ |
+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("two-lines"); // ^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(document, 3, 2)"); |
- |
- 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. |
+ shouldBeEqualToString("firstLineText('two-lines')", "OK"); |
+ shouldBeEqualToString("sel.anchorNode.data", "OK zz OK"); |
+ if (window.internals) |
+ shouldBecomeEqual("internals.hasSpellingMarker(document, 3, 2)", "true", done); |
+ else |
+ done(); |
+} |
- shouldBe("sel.anchorNode.data", "'OKOK zz OK'"); |
- shouldBe("firstLineText()", "'OKOK zz OK'"); |
- shouldBeTrue("internals.hasSpellingMarker(document, 5, 2)"); |
+function testMisspellingsAfterLineMergeUsingDelete() |
+{ |
+ window.sel = setup("merged-lines-delete-command"); // ^OK |
+ |
+ 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('merged-lines-delete-command')", "OKOK zz OK"); |
+ shouldBeEqualToString("sel.anchorNode.data", "OKOK zz OK"); |
+ if (window.internals) |
+ shouldBecomeEqual("internals.hasSpellingMarker(document, 5, 2)", "true", done); |
+ else |
+ done(); |
} |
-function testWithForwardDelete() |
+function testMisspellingsAfterLineMergeUsingForwardDelete() |
{ |
- window.sel = setup("target1"); |
+ window.sel = setup("merged-lines-forward-delete-command"); // ^OK |
+ |
+ sel.modify("move", "forward", "character"); // O^K |
+ sel.modify("move", "forward", "character"); // OK^ |
+ document.execCommand("ForwardDelete", false); // OK^OK zz OK |
+ sel.modify("move", "right", "line"); // OKOK zz OK^ |
+ |
+ shouldBeEqualToString("firstLineText('merged-lines-forward-delete-command')", "OKOK zz OK"); |
+ shouldBeEqualToString("sel.anchorNode.data", "OKOK zz OK"); |
+ if (window.internals) |
+ shouldBecomeEqual("internals.hasSpellingMarker(document, 5, 2)", "true", done); |
+ else |
+ done(); |
+} |
- sel.modify("move", "forward", "line"); |
- for (var i = 0; i < 3; i++) // 3 for ["OK, "zz", "OK"].length |
- sel.modify("move", "forward", "word"); |
+var tests = [ |
+ function() { testTwoLinesMisspellings(); }, |
+ function() { testMisspellingsAfterLineMergeUsingDelete(); }, |
+ function() { testMisspellingsAfterLineMergeUsingForwardDelete(); } |
+]; |
- shouldBe("firstLineText()", "'OK'"); |
- shouldBe("sel.anchorNode.data", "'OK zz OK'"); |
- shouldBeTrue("internals.hasSpellingMarker(document, 3, 2)"); |
+function done() |
+{ |
+ var next = tests.shift(); |
+ if (next) |
+ return setTimeout(next, 0); |
- 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. |
+ if (window.internals) |
+ testRoot.style.display = "none"; |
- shouldBe("firstLineText()", "'OKOK zz OK'"); |
- shouldBe("sel.anchorNode.data", "'OKOK zz OK'"); |
- shouldBeTrue("internals.hasSpellingMarker(document, 5, 2)"); |
+ finishJSTest(); |
} |
- |
-testWithDelete(); |
-testWithForwardDelete(); |
-testRoot.style.display = "none"; |
+done(); |
var successfullyParsed = true; |