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

Unified Diff: LayoutTests/resources-tests/should-become-equal-test.html

Issue 906193003: shouldBecomeEqual() behaves as shouldBe() if the testing expression returns the expected value Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add regression test Created 5 years, 10 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/resources-tests/should-become-equal-test.html
diff --git a/LayoutTests/resources-tests/should-become-equal-test.html b/LayoutTests/resources-tests/should-become-equal-test.html
new file mode 100644
index 0000000000000000000000000000000000000000..829ea10ceeb1894441ea3ee08289728d2ad026a1
--- /dev/null
+++ b/LayoutTests/resources-tests/should-become-equal-test.html
@@ -0,0 +1,48 @@
+<html>
yosin_UTC9 2016/09/01 01:49:06 Could you use w3c test harness to test |shouldBeco
+<body onload="runTest()">
+<script src="../resources/js-test.js"></script>
+<div id="testElement" contenteditable></div>
+<script>
+jsTestIsAsync = true;
+
+description("This test verifies whether shouldBecomeEqual asynchronously "
+ + "checks condition when testing expression returns the expected value.<br>"
+ + "Otherwise, there will be no difference between:<br><br>"
+ + "shouldBecomeEqual(internals.hasSpellingMarker(welllcome), false)<br> "
+ + "shouldBecomeEqual(internals.hasSpellingMarker(welcome), false)<br>");
+
+function runTest()
+{
+ if (!window.internals)
+ return;
+
+ internals.settings.setAsynchronousSpellCheckingEnabled(true);
+ internals.settings.setUnifiedTextCheckerEnabled(true);
+
+ var testElement = document.getElementById("testElement");
+ testElement.focus();
+ document.execCommand("InsertText", false, "wellcome ");
+ // Because async path of spellchecing is turned on it's unlikely to have
+ // spelling markers at this point so that first call of hasSpellingMarker()
+ // will probably return false and shouldBecomeEqual shouldn't report it as PASS.
+ shouldBecomeEqual("internals.hasSpellingMarker(document, 0, 8)", "false", function() {
please use gerrit instead 2015/02/17 16:28:48 You probably should not be testing shouldBecomeEqu
+ testFailed("wellcome will have marker");
+ finishJSTest();
+ });
+
+ // We assume that the test passes if the test is not finished which means that
+ // shouldBecomeEqual's completion handler was not called.
+ setTimeout(function() { fallback(10); }, 0);
+ function fallback(nretry)
+ {
+ if (nretry)
+ return setTimeout(function() { fallback(nretry - 1); }, 0);
+ else {
+ testPassed("");
+ finishJSTest();
+ }
+ }
+}
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698