Chromium Code Reviews| 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..9b0a545b6794f03a21b27bd7d6a4e103f01364b4 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"); |
|
groby-ooo-7-16
2014/03/12 16:37:36
Just out of curiosity: Why split this into "proper
grzegorz
2014/03/12 21:33:08
What I wanted to achieve here by creating separate
|
| + 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 |
|
groby-ooo-7-16
2014/03/12 16:37:36
Nit:"Why call this "target1"? Does it make sense t
grzegorz
2014/03/12 21:33:08
Thanks. Will do that.
|
| - 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('target1')", "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("target2"); // ^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('target2')", "OKOK zz OK"); |
| + shouldBeEqualToString("sel.anchorNode.data", "OKOK zz OK"); |
| + if (window.internals) |
|
groby-ooo-7-16
2014/03/12 16:37:36
I'd prefer moving that to the top of the file, as
grzegorz
2014/03/12 21:33:08
Actually, shouldBecome* helpers produces awful out
|
| + shouldBecomeEqual("internals.hasSpellingMarker(document, 5, 2)", "true", done); |
| + else |
| + done(); |
| } |
| -function testWithForwardDelete() |
| +function testMisspellingsAfterLineMergeUsingForwardDelete() |
| { |
| - window.sel = setup("target1"); |
| + window.sel = setup("target3"); // ^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('target3')", "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) |
|
groby-ooo-7-16
2014/03/12 16:37:36
Why would that be gated on window.internals?
tony
2014/03/12 16:42:01
It's to avoid dumping the output in the -expected.
groby-ooo-7-16
2014/03/12 16:44:30
So I take it we run these tests outside of DRT to
|
| + 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; |