[Chromium] Layout test does not return correct misspelling positions if there are...
[WebKit-https.git] / LayoutTests / editing / spelling / script-tests / spellcheck-paste.js
index 013d2b0946c11c363009be8d37815fac17157a0b..797fe9b8c4d40ee709522dd0b7954659be6f3782 100644 (file)
@@ -25,6 +25,10 @@ var testSourceDecorated = document.createElement("div");
 testSourceDecorated.innerHTML = "fo<b>o ba</b>r";
 testRoot.appendChild(testSourceDecorated);
 
+var testSourceMulti = document.createElement("div");
+testSourceMulti.innerHTML = "zz zz zz";
+testRoot.appendChild(testSourceMulti);
+
 var sel = window.getSelection();
 
 var tests = [];
@@ -45,7 +49,11 @@ function verifyMarker(node, expectedMarked)
     } else {
         sel.selectAllChildren(node);
     }
-    return layoutTestController.hasSpellingMarker(expectedMarked[0], expectedMarked[1]);
+
+    var ok = true;
+    for (var i = 0; ok && i < expectedMarked.length; ++i)
+        ok = layoutTestController.hasSpellingMarker(expectedMarked[i][0], expectedMarked[i][1]);
+    return ok;
 }
 
 function pasteAndVerify(source, dest, expectedMarked)
@@ -87,12 +95,15 @@ function pasteAndVerify(source, dest, expectedMarked)
 if (window.layoutTestController)
     layoutTestController.setAsynchronousSpellCheckingEnabled(true);
 
-tests.push(function() { pasteAndVerify(testSourcePlain, testInput, [0, 3]); });
-tests.push(function() { pasteAndVerify(testSourceDecorated, testInput, [0, 3]); });
-tests.push(function() { pasteAndVerify(testSourcePlain, testTextArea, [0, 3]); });
-tests.push(function() { pasteAndVerify(testSourceDecorated, testTextArea, [0, 3]); });
-tests.push(function() { pasteAndVerify(testSourcePlain, testEditable, [0, 3]); });
-tests.push(function() { pasteAndVerify(testSourceDecorated, testEditable, [0, 2]); }); // To check "fo" part of foo.
+tests.push(function() { pasteAndVerify(testSourcePlain, testInput, [[0, 3]]); });
+tests.push(function() { pasteAndVerify(testSourceDecorated, testInput, [[0, 3]]); });
+tests.push(function() { pasteAndVerify(testSourceMulti, testInput, [[0, 2], [3, 2]]); });
+tests.push(function() { pasteAndVerify(testSourcePlain, testTextArea, [[0, 3]]); });
+tests.push(function() { pasteAndVerify(testSourceDecorated, testTextArea, [[0, 3]]); });
+tests.push(function() { pasteAndVerify(testSourceMulti, testTextArea, [[0, 2], [3, 2]]); });
+tests.push(function() { pasteAndVerify(testSourcePlain, testEditable, [[0, 3]]); });
+tests.push(function() { pasteAndVerify(testSourceDecorated, testEditable, [[0, 2]]); }); // To check "fo" part of foo.
+tests.push(function() { pasteAndVerify(testSourceMulti, testEditable, [[0, 2], [3, 2]]); });
 done();
 
 var successfullyParsed = true;