shouldBecomeEqual() behaves as shouldBe() if the testing expression returns the expected value
https://bugs.webkit.org/show_bug.cgi?id=133939

Reviewed by Darin Adler.

First call of eval(expression) inside shouldBecomeEqual was always
made synchronously. If the testing expression returns the same value
as expected one then shouldBecomeEqual() will immediately report PASS,
for example,

shouldBecomeEqual(internals.hasSpellingMarker("wellcome"), false);

in consequence, assuming asynchronous path of spellchecking, spelling markers
may appear after a while.

The bug was caused by checking a condition at the beginning of shouldBecomeEqual(),
before calling a timer. As a result, queued asynchronous events doesn't effect
this checking.

* TestExpectations:
This fix reveals new bugs in execDeleteCommand() behaviour, two tests need
to marked as failure now.

* resources/js-test-pre.js:
(.condition):
(shouldBecomeEqual):
(shouldBecomeDifferent):
* resources/js-test.js:
(.condition):
(shouldBecomeEqual):
(shouldBecomeDifferent):
Always check a condition on timer.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/resources/js-test.js b/LayoutTests/resources/js-test.js
index d967611..bb82ed6 100644
--- a/LayoutTests/resources/js-test.js
+++ b/LayoutTests/resources/js-test.js
@@ -256,7 +256,7 @@
   if (typeof _a != "string" || typeof _b != "string")
     debug("WARN: shouldBecomeEqual() expects string arguments");
 
-  var condition = function() {
+  function condition() {
     var exception;
     var _av;
     try {
@@ -272,8 +272,8 @@
       return true;
     }
     return false;
-  };
-  _waitForCondition(condition, completionHandler);
+  }
+  setTimeout(_waitForCondition, 0, condition, completionHandler);
 }
 
 function shouldBecomeEqualToString(value, reference, completionHandler)
@@ -368,7 +368,7 @@
   if (typeof _a != "string" || typeof _b != "string")
     debug("WARN: shouldBecomeDifferent() expects string arguments");
 
-  var condition = function() {
+  function condition() {
     var exception;
     var _av;
     try {
@@ -384,8 +384,8 @@
       return true;
     }
     return false;
-  };
-  _waitForCondition(condition, completionHandler);
+  }
+  setTimeout(_waitForCondition, 0, condition, completionHandler);
 }
 
 function shouldBeTrue(a, quiet) { shouldBe(a, "true", quiet); }