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

Unified Diff: LayoutTests/editing/spelling/script-tests/spelling-attribute-change.js

Issue 190663014: Verify spellcheck attribute asynchronously (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: apply tony and groby comments 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/editing/spelling/script-tests/spelling-attribute-change.js
diff --git a/LayoutTests/editing/spelling/script-tests/spelling-attribute-change.js b/LayoutTests/editing/spelling/script-tests/spelling-attribute-change.js
index ff4eaa7b76fba3e1121bc105e789559f42ea8312..fe25f6a04cd29a2a79cc85a62b8914bdc445c723 100644
--- a/LayoutTests/editing/spelling/script-tests/spelling-attribute-change.js
+++ b/LayoutTests/editing/spelling/script-tests/spelling-attribute-change.js
@@ -1,4 +1,12 @@
-description('Tests if the spellchecker behavior change after the spellcheck attribute changed by the script.');
+description('Tests if the spellchecker behaves correctly when the spellcheck attribute '
+ + 'is being changed by the script.');
+
+jsTestIsAsync = true;
+
+if (window.internals) {
+ internals.settings.setUnifiedTextCheckerEnabled(true);
+ internals.settings.setAsynchronousSpellCheckingEnabled(true);
+}
var parent = document.createElement("div");
document.body.appendChild(parent);
@@ -22,7 +30,10 @@ function testSpellCheckingEnabled(target, enabled)
window.target = target;
shouldBe("target.spellcheck", enabled ? "true" : "false");
- shouldBe("internals.hasSpellingMarker(document, 6, 2)", enabled ? "true" : "false");
+ if (window.internals)
+ shouldBecomeEqual("internals.hasSpellingMarker(document, 6, 2)", enabled ? "true" : "false", done);
+ else
+ done();
}
function createElement(tagName, spellcheck)
@@ -35,52 +46,49 @@ function createElement(tagName, spellcheck)
return target;
}
-function testFor(tagName, initialAttribute, expectation)
+function testFor(tagName, spellCheckAttribueValues)
{
- var target = createElement(tagName, initialAttribute);
+ var target = createElement(tagName, spellCheckAttribueValues.initialValue);
parent.appendChild(target);
- testSpellCheckingEnabled(target, expectation);
- parent.innerHTML = "";
+ testSpellCheckingEnabled(target, spellCheckAttribueValues.destinationValue);
}
-// default -> true
-testFor("SPAN", undefined, true);
-// default -> false
-testFor("SPAN", undefined, false);
-// true -> true
-testFor("SPAN", true, true);
-// true -> false
-testFor("SPAN", true, false);
-// false -> true
-testFor("SPAN", false, true);
-// false -> false
-testFor("SPAN", false, false);
-
-// default -> true
-testFor("INPUT", undefined, true);
-// default -> false
-testFor("INPUT", undefined, false);
-// true -> true
-testFor("INPUT", true, true);
-// true -> false
-testFor("INPUT", true, false);
-// false -> true
-testFor("INPUT", false, true);
-// false -> false
-testFor("INPUT", false, false);
-
-// default -> true
-testFor("TEXTAREA", undefined, true);
-// default -> false
-testFor("TEXTAREA", undefined, false);
-// true -> true
-testFor("TEXTAREA", true, true);
-// true -> false
-testFor("TEXTAREA", true, false);
-// false -> true
-testFor("TEXTAREA", false, true);
-// false -> false
-testFor("TEXTAREA", false, false);
+var testElements = [
+ "SPAN",
+ "INPUT",
+ "TEXTAREA"
+];
+
+const spellcheckAttributeVariances = [
+ { initialValue: undefined, destinationValue: true },
+ { initialValue: undefined, destinationValue: false },
+ { initialValue: true, destinationValue: true },
+ { initialValue: true, destinationValue: false },
+ { initialValue: false, destinationValue: true },
+ { initialValue: false, destinationValue: false }
+];
+
+var iterator = 0;
+var currentElement = null;
+
+function done()
+{
+ if (!currentElement) {
+ currentElement = testElements.shift();
+ // All elements have been already taken.
+ if (!currentElement)
+ return finishJSTest();
+ }
+
+ if (iterator != spellcheckAttributeVariances.length)
+ setTimeout(testFor(currentElement, spellcheckAttributeVariances[iterator++]), 0);
+ else {
+ iterator = 0;
+ currentElement = null;
+ done();
+ }
+}
+done();
var successfullyParsed = true;

Powered by Google App Engine
This is Rietveld 408576698