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

Side by Side Diff: third_party/WebKit/LayoutTests/editing/spelling/mixed-paste-short.html

Issue 2449743002: Convert editing/spelling/mixed-paste-*.html with spellcheck_test (Closed)
Patch Set: Wed Oct 26 14:57:43 JST 2016 Created 4 years, 1 month 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
OLDNEW
(Empty)
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10
11 description('For bug cr571988: Spell checking for pasted mixed content.');
12
13 jsTestIsAsync = true;
14 if (window.testRunner)
15 testRunner.setMockSpellCheckerEnabled(true);
16
17 var testRoot = document.createElement("div");
18 document.body.insertBefore(testRoot, document.body.firstChild);
19
20 var testEditable = document.createElement("div");
21 testEditable.setAttribute("contentEditable", "true");
22 testRoot.appendChild(testEditable);
23
24 var testSourceDecorated = document.createElement("div");
25 testSourceDecorated.innerHTML = "<img src='../resources/abe.png'> zz zz.";
26 testRoot.appendChild(testSourceDecorated);
27
28 var sel = window.getSelection();
29
30 var tests = [];
31
32 function done()
33 {
34 var next = tests.shift();
35 if (next)
36 return window.setTimeout(next, 0);
37 testRoot.style.display = "none";
38 finishJSTest();
39 }
40
41 function verifyMarker(node, expectedMarked)
42 {
43 if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) {
44 node.focus();
45 } else {
46 sel.selectAllChildren(node);
47 }
48
49 var count = 0;
50 for (var i = 0; i < node.childNodes.length; ++i)
51 count += internals.markerCountForNode(node.childNodes[i], 'spelling');
52
53 if (count == expectedMarked) {
54 var nodeContent = node instanceof HTMLInputElement || node instanceof HT MLTextAreaElement ? node.value : node.innerHTML;
55 testPassed(node.tagName + " has " + expectedMarked + " markers on '" + n odeContent + "'");
56 }
57
58 return count == expectedMarked;
59 }
60
61 var destination = null;
62 var misspelledCount = null;
63 function pasteAndVerify(source, dest, expectedMarked)
64 {
65 sel.selectAllChildren(source);
66 document.execCommand("Copy");
67 if (dest instanceof HTMLInputElement || dest instanceof HTMLTextAreaElement) {
68 dest.value = "";
69 dest.focus();
70 } else {
71 dest.innerHTML = "";
72 sel.selectAllChildren(dest);
73 }
74 document.execCommand("Paste");
75
76 if (window.internals) {
77 destination = dest;
78 misspelledCount = expectedMarked;
79 shouldBecomeEqual('verifyMarker(destination, misspelledCount)', 'true', done);
80 }
81 };
82
83 tests.push(function() { pasteAndVerify(testSourceDecorated, testEditable, testSo urceDecorated.innerHTML.match(/zz/g).length); });
84 done();
85
86 var successfullyParsed = true;
87 </script>
88 </body>
89 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698