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

Unified Diff: third_party/WebKit/LayoutTests/editing/spelling/spellcheck-queue.html

Issue 2454353002: Convert editing/spelling/spellcheck-queue.html with spellcheck_test (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/editing/spelling/spellcheck-queue-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/editing/spelling/spellcheck-queue.html
diff --git a/third_party/WebKit/LayoutTests/editing/spelling/spellcheck-queue.html b/third_party/WebKit/LayoutTests/editing/spelling/spellcheck-queue.html
index b97a8e88de225be8afa019440f94abb92694e412..8f1e88840de763932008b9e85a0ba6ae45525dcb 100644
--- a/third_party/WebKit/LayoutTests/editing/spelling/spellcheck-queue.html
+++ b/third_party/WebKit/LayoutTests/editing/spelling/spellcheck-queue.html
@@ -1,182 +1,56 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
-<body>
-<p id="description"></p>
-<div id="console"></div>
-<script>
-description('For Bug 72939: Asynchronous SpellChecker should consider multiple requests.');
-
-jsTestIsAsync = true;
-if (window.testRunner)
- testRunner.setMockSpellCheckerEnabled(true);
-
-var testRoot = document.createElement("div");
-document.body.insertBefore(testRoot, document.body.firstChild);
-
-var source1 = document.createElement("div");
-source1.innerHTML = "foo bar";
-testRoot.appendChild(source1);
-
-var source2 = document.createElement("div");
-source2.innerHTML = "zz apple orange";
-testRoot.appendChild(source2);
-
-function createInput(testRoot) {
- var e = document.createElement('input');
- e.setAttribute("type", "text");
- testRoot.appendChild(e);
-
- return e;
-}
-
-function createTextArea(testRoot) {
- var e = document.createElement("textarea");
- testRoot.appendChild(e);
-
- return e;
-}
-
-function createContentEditable(testRoot) {
- var e = document.createElement("div");
- e.setAttribute("contentEditable", "true");
- testRoot.appendChild(e);
-
- return e;
-}
-
-var destinations = [
- createInput(testRoot),
- createTextArea(testRoot),
- createContentEditable(testRoot),
- createInput(testRoot),
- createTextArea(testRoot),
- createContentEditable(testRoot),
- createInput(testRoot),
- createTextArea(testRoot),
- createContentEditable(testRoot),
-];
-
-var sel = window.getSelection();
-
-var tests = [];
-for (var i = 0; i < destinations.length; ++i) {
- var t = function(i) {
- return function() { verify(source2, destinations[i], ["zz"]); }
- }(i);
- tests.push(t);
-}
-
-function verifyIfAny()
-{
- var next = tests.shift();
- if (next) {
- next();
- return;
- }
-
- testRoot.style.display = "none";
- finishJSTest();
-}
-
-function findFirstTextNode(node)
-{
- function iterToFindFirstTextNode(node)
- {
- if (node instanceof Text)
- return node;
-
- var childNodes = node.childNodes;
- for (var i = 0; i < childNodes.length; ++i) {
- var n = iterToFindFirstTextNode(childNodes[i]);
- if (n)
- return n;
- }
+<!doctype html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../assert_selection.js"></script>
+<script src="spellcheck_test.js"></script>
- return null;
- }
-
-
- if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement)
- return iterToFindFirstTextNode(internals.shadowRoot(node));
- else
- return iterToFindFirstTextNode(node);
-}
-
-function verifyMarker(node, expectedMarked)
-{
- if (!window.testRunner || !window.internals)
- return false;
-
- var textNode = findFirstTextNode(node);
-
- var num = internals.markerCountForNode(textNode, "spelling");
- if (num != expectedMarked.length)
- return false;
- for (var i = 0; i < num; ++i) {
- var range = internals.markerRangeForNode(textNode, "spelling", i);
- if (range.toString() != expectedMarked[i])
- return false;
- }
-
- return true;
-}
-
-function copyAndPaste(source, dest)
-{
- sel.selectAllChildren(source);
- document.execCommand("Copy");
-
- if (dest instanceof HTMLInputElement || dest instanceof HTMLTextAreaElement) {
- dest.value = "";
- dest.focus();
+<script>
+function pasteToAllChildren(text, container) {
+ const document = container.ownerDocument;
+ const selection = document.getSelection();
+ selection.setClipboardData(text);
+ container.childNodes.forEach(child => {
+ if (child.nodeName === 'DIV') {
+ selection.selectAllChildren(child);
} else {
- dest.innerHTML = "";
- sel.selectAllChildren(dest);
+ child.value = '';
+ child.focus();
}
- document.execCommand("Paste");
-}
-
-function verify(source, dest, expectedMarked)
-{
- var nretry = 10;
- var nsleep = 1;
- function trial() {
- var verified = verifyMarker(dest, expectedMarked);
- if (verified) {
- testPassed(dest.tagName + " has a marker on '" + source.innerHTML + "'");
- verifyIfAny();
- return;
- }
-
- nretry--;
- if (0 == nretry) {
- testFailed(dest.tagName + " should have a marker on for '" + source.innerHTML + "'");
- verifyIfAny();
- return;
- }
-
- nsleep *= 2;
- window.setTimeout(trial, nsleep);
- };
- trial();
-}
-
-
-// paste "foo bar"
-for (var i = 0; i < destinations.length; ++i)
- copyAndPaste(source1, destinations[i]);
-
-// paste "zz apple orange"
-for (var i = 0; i < destinations.length; ++i)
- copyAndPaste(source2, destinations[i]);
-
-verifyIfAny();
-
-var successfullyParsed = true;
-
+ document.execCommand('paste');
+ });
+}
+
+spellcheck_test(
+ [
+ '<div id="container">',
+ '<input>',
+ '<textarea></textarea>',
+ '<div contenteditable></div>',
+ '<input>',
+ '<textarea></textarea>',
+ '<div contenteditable></div>',
+ '<input>',
+ '<textarea></textarea>',
+ '<div contenteditable></div>',
+ '</div>'
+ ].join(''),
+ document => {
+ const container = document.getElementById('container');
+ pasteToAllChildren('foo bar', container);
+ pasteToAllChildren('zz apple orange', container);
+ },
+ [
+ '<div id="container">',
+ '<input value="#zz# apple orange">',
+ '<textarea>#zz# apple orange</textarea>',
+ '<div contenteditable>#zz# apple orange</div>',
+ '<input value="#zz# apple orange">',
+ '<textarea>#zz# apple orange</textarea>',
+ '<div contenteditable>#zz# apple orange</div>',
+ '<input value="#zz# apple orange">',
+ '<textarea>#zz# apple orange</textarea>',
+ '<div contenteditable>#zz# apple orange</div>',
+ '</div>'
+ ].join(''),
+ 'Spellchecker handles multiple requests.');
</script>
-</body>
-</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/editing/spelling/spellcheck-queue-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698