Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js

Issue 197403002: Verify misspellings after lines merge/split asynchronously (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix expectations to meet new target names (should have been done in the patch #2) Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/editing/spelling/spelling-backspace-between-lines-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 description('Spelling markers should remain while merging two lines.');
1 2
2 description('For Bug 41423: Spelling marker should remain after hitting a backsp ace key.'); 3 jsTestIsAsync = true;
4
5 if (window.internals) {
6 internals.settings.setUnifiedTextCheckerEnabled(true);
7 internals.settings.setAsynchronousSpellCheckingEnabled(true);
8 }
3 9
4 var testRoot = document.createElement("div"); 10 var testRoot = document.createElement("div");
5 document.body.insertBefore(testRoot, document.body.firstChild); 11 document.body.insertBefore(testRoot, document.body.firstChild);
6 12
7 function setup(targetName) 13 function setup(targetName)
8 { 14 {
9 testRoot.innerHTML = "<div id='" + targetName + "' contentEditable><div>OK</ div><div>OK zz OK</div></div>"; 15 var div = document.createElement("div");
10 document.getElementById(targetName).focus(); 16 div.id = targetName;
17 div.contentEditable = true;
18 div.innerHTML = "<div>OK</div><div>OK zz OK</div>";
19 testRoot.appendChild(div);
20
21 div.focus();
11 return document.getSelection(); 22 return document.getSelection();
12 } 23 }
13 24
14 function firstLineText() 25 function firstLineText(targetName)
15 { 26 {
16 return testRoot.firstChild.firstChild.innerText.trim(); 27 var div = document.getElementById(targetName);
28 return div.firstChild.innerText.trim();
17 } 29 }
18 30
19 function testWithDelete() 31 function testTwoLinesMisspellings()
20 { 32 {
21 window.sel = setup("target1"); 33 window.sel = setup("two-lines"); // ^OK
22 34
23 sel.modify("move", "forward", "line"); 35 sel.modify("move", "forward", "line"); // ^OK zz OK
24 for (var i = 0; i < 3; i++) // 3 for ["OK, "zz", "OK"].length 36 for (var i = 0; i < 3; i++)
25 sel.modify("move", "forward", "word"); 37 sel.modify("move", "forward", "word");
26 38
27 shouldBe("firstLineText()", "'OK'"); 39 shouldBeEqualToString("firstLineText('two-lines')", "OK");
28 shouldBe("sel.anchorNode.data", "'OK zz OK'"); 40 shouldBeEqualToString("sel.anchorNode.data", "OK zz OK");
29 shouldBeTrue("internals.hasSpellingMarker(document, 3, 2)"); 41 if (window.internals)
30 42 shouldBecomeEqual("internals.hasSpellingMarker(document, 3, 2)", "true", done);
31 sel.modify("move", "left", "lineboundary"); 43 else
32 document.execCommand("Delete", false); 44 done();
33 sel.modify("move", "right", "line"); // Moves to the line ending to focus th e "OK zz OK" text.
34
35 shouldBe("sel.anchorNode.data", "'OKOK zz OK'");
36 shouldBe("firstLineText()", "'OKOK zz OK'");
37 shouldBeTrue("internals.hasSpellingMarker(document, 5, 2)");
38 } 45 }
39 46
40 function testWithForwardDelete() 47 function testMisspellingsAfterLineMergeUsingDelete()
41 { 48 {
42 window.sel = setup("target1"); 49 window.sel = setup("merged-lines-delete-command"); // ^OK
43 50
44 sel.modify("move", "forward", "line"); 51 sel.modify("move", "forward", "line"); // ^OK zz OK
45 for (var i = 0; i < 3; i++) // 3 for ["OK, "zz", "OK"].length 52 document.execCommand("Delete", false); // OK^OK zz OK
46 sel.modify("move", "forward", "word"); 53 sel.modify("move", "right", "line"); // OKOK zz OK^
47 54
48 shouldBe("firstLineText()", "'OK'"); 55 shouldBeEqualToString("firstLineText('merged-lines-delete-command')", "OKOK zz OK");
49 shouldBe("sel.anchorNode.data", "'OK zz OK'"); 56 shouldBeEqualToString("sel.anchorNode.data", "OKOK zz OK");
50 shouldBeTrue("internals.hasSpellingMarker(document, 3, 2)"); 57 if (window.internals)
51 58 shouldBecomeEqual("internals.hasSpellingMarker(document, 5, 2)", "true", done);
52 sel.modify("move", "left", "line"); 59 else
53 document.execCommand("ForwardDelete", false); 60 done();
54 sel.modify("move", "right", "line"); // Moves to the line ending to focus th e "OK zz OK" text.
55
56 shouldBe("firstLineText()", "'OKOK zz OK'");
57 shouldBe("sel.anchorNode.data", "'OKOK zz OK'");
58 shouldBeTrue("internals.hasSpellingMarker(document, 5, 2)");
59 } 61 }
60 62
61 testWithDelete(); 63 function testMisspellingsAfterLineMergeUsingForwardDelete()
62 testWithForwardDelete(); 64 {
63 testRoot.style.display = "none"; 65 window.sel = setup("merged-lines-forward-delete-command"); // ^OK
66
67 sel.modify("move", "forward", "character"); // O^K
68 sel.modify("move", "forward", "character"); // OK^
69 document.execCommand("ForwardDelete", false); // OK^OK zz OK
70 sel.modify("move", "right", "line"); // OKOK zz OK^
71
72 shouldBeEqualToString("firstLineText('merged-lines-forward-delete-command')" , "OKOK zz OK");
73 shouldBeEqualToString("sel.anchorNode.data", "OKOK zz OK");
74 if (window.internals)
75 shouldBecomeEqual("internals.hasSpellingMarker(document, 5, 2)", "true", done);
76 else
77 done();
78 }
79
80 var tests = [
81 function() { testTwoLinesMisspellings(); },
82 function() { testMisspellingsAfterLineMergeUsingDelete(); },
83 function() { testMisspellingsAfterLineMergeUsingForwardDelete(); }
84 ];
85
86 function done()
87 {
88 var next = tests.shift();
89 if (next)
90 return setTimeout(next, 0);
91
92 if (window.internals)
93 testRoot.style.display = "none";
94
95 finishJSTest();
96 }
97 done();
64 98
65 var successfullyParsed = true; 99 var successfullyParsed = true;
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/editing/spelling/spelling-backspace-between-lines-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698