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

Unified Diff: LayoutTests/editing/spelling/grammar-markers.html

Issue 23534071: Use shouldBecomeEqual in asynchronous spellchecking tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Apply Tony's review and use asynchronous spellchecking in two tests Created 7 years, 3 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/grammar-markers.html
diff --git a/LayoutTests/editing/spelling/grammar-markers.html b/LayoutTests/editing/spelling/grammar-markers.html
index 7d732a7212be6d15d4861e064180f2eab8e7e928..df0d8baf7214353ec59b96f32a590cd2121a0dc8 100644
--- a/LayoutTests/editing/spelling/grammar-markers.html
+++ b/LayoutTests/editing/spelling/grammar-markers.html
@@ -18,6 +18,15 @@ if (window.internals)
if (window.testRunner)
testRunner.dumpAsText(true);
+function verifyGrammarMarker(destination, ungrammaticalPhrase)
+{
+ if (window.internals && internals.hasGrammarMarker(document, destination.innerHTML.indexOf(ungrammaticalPhrase), ungrammaticalPhrase.length)) {
+ testPassed("ungrammatical phrase '" + ungrammaticalPhrase + "' on '" + destination.innerHTML + "'");
+ return true;
+ } else
+ return false;
+}
+
var source = document.getElementById('source');
window.getSelection().selectAllChildren(source);
document.execCommand('Copy');
@@ -25,23 +34,7 @@ var target = document.getElementById('target');
window.getSelection().selectAllChildren(target);
document.execCommand('Paste');
-var retryCount = 10;
-var sleepPeriod = 1;
-var ungrammaticalPhrase = 'has';
-var hasMarker;
-function verifyMarker() {
- hasMarker = internals.hasGrammarMarker(document, target.innerHTML.indexOf(ungrammaticalPhrase), ungrammaticalPhrase.length);
- if (!hasMarker && --retryCount > 0) {
- sleepPeriod *= 2;
- window.setTimeout(verifyMarker, sleepPeriod);
- return;
- }
-
- shouldBeTrue('hasMarker');
- finishJSTest();
-};
-
-window.setTimeout(verifyMarker, sleepPeriod);
+shouldBecomeEqual('verifyGrammarMarker(target, "has")', 'true', finishJSTest);
</script>
<script src="../../fast/js/resources/js-test-post.js"></script>

Powered by Google App Engine
This is Rietveld 408576698