Title: [177501] trunk/LayoutTests
Revision
177501
Author
[email protected]
Date
2014-12-18 09:44:18 -0800 (Thu, 18 Dec 2014)

Log Message

Remove timeout from shouldBecome* functions in js-test.js
https://bugs.webkit.org/show_bug.cgi?id=139767

Reviewed by Darin Adler.

r156678 has removed this timeout from shouldBecome* in js-test-pre.js.
Get rid of it from js-test.js as well to make shouldBecome* functions sync
between js-test.js and js-test-pre.js

Additionally, sync minor coding style changes between them.

* resources/js-test.js:
(_waitForCondition):
(.condition):
(shouldBecomeEqual):
(shouldBecomeEqualToString):
(shouldBecomeDifferent):
(._condition): Deleted.
(._failureHandler): Deleted.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (177500 => 177501)


--- trunk/LayoutTests/ChangeLog	2014-12-18 17:44:09 UTC (rev 177500)
+++ trunk/LayoutTests/ChangeLog	2014-12-18 17:44:18 UTC (rev 177501)
@@ -1,3 +1,26 @@
+2014-12-18  Grzegorz Czajkowski  <[email protected]>
+
+        Remove timeout from shouldBecome* functions in js-test.js
+        https://bugs.webkit.org/show_bug.cgi?id=139767
+
+        Reviewed by Darin Adler.
+
+        r156678 has removed this timeout from shouldBecome* in js-test-pre.js.
+        Get rid of it from js-test.js as well to make shouldBecome* functions sync
+        between js-test.js and js-test-pre.js
+
+        Additionally, sync minor coding style changes between them.
+
+        * resources/js-test.js:
+        (_waitForCondition):
+        (.condition):
+        (shouldBecomeEqual):
+        (shouldBecomeEqualToString):
+        (shouldBecomeDifferent):
+        (._condition): Deleted.
+        (._failureHandler): Deleted.
+
+
 2014-12-18  Csaba Osztrogonác  <[email protected]>
 
         [EFL] Fix test expectations after r177363

Modified: trunk/LayoutTests/resources/js-test.js (177500 => 177501)


--- trunk/LayoutTests/resources/js-test.js	2014-12-18 17:44:09 UTC (rev 177500)
+++ trunk/LayoutTests/resources/js-test.js	2014-12-18 17:44:18 UTC (rev 177501)
@@ -242,59 +242,46 @@
     testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
 }
 
-// Execute condition every 5 milliseconds until it succeed or failureTime is reached.
-// completionHandler is executed on success, failureHandler is executed on timeout.
-function _waitForCondition(condition, failureTime, completionHandler, failureHandler)
+// Execute condition every 5 milliseconds until it succeeds.
+function _waitForCondition(condition, completionHandler)
 {
-  if (condition()) {
+  if (condition())
     completionHandler();
-  } else if (Date.now() > failureTime) {
-    failureHandler();
-  } else {
-    setTimeout(_waitForCondition, 5, condition, failureTime, completionHandler, failureHandler);
-  }
+  else
+    setTimeout(_waitForCondition, 5, condition, completionHandler);
 }
 
-function shouldBecomeEqual(_a, _b, _completionHandler, _timeout)
+function shouldBecomeEqual(_a, _b, completionHandler)
 {
   if (typeof _a != "string" || typeof _b != "string")
     debug("WARN: shouldBecomeEqual() expects string arguments");
 
-  if (_timeout === undefined)
-    _timeout = 500;
-
-  var _bv;
-  var _condition = function() {
-    var _exception;
+  var condition = function() {
+    var exception;
     var _av;
     try {
       _av = eval(_a);
     } catch (e) {
-        _exception = e;
+      exception = e;
     }
-    _bv = eval(_b);
-    if (_exception)
-      testFailed(_a + " should become " + _bv + ". Threw exception " + _exception);
+    var _bv = eval(_b);
+    if (exception)
+      testFailed(_a + " should become " + _bv + ". Threw exception " + exception);
     if (isResultCorrect(_av, _bv)) {
       testPassed(_a + " became " + _b);
       return true;
     }
     return false;
   };
-  var _failureTime = Date.now() + _timeout;
-  var _failureHandler = function () {
-    testFailed(_a + " failed to change to " + _bv + " in " + (_timeout / 1000) + " seconds.");
-    _completionHandler();
-  };
-  _waitForCondition(_condition, _failureTime, _completionHandler, _failureHandler);
+  _waitForCondition(condition, completionHandler);
 }
 
-function shouldBecomeEqualToString(value, reference, completionHandler, timeout)
+function shouldBecomeEqualToString(value, reference, completionHandler)
 {
   if (typeof value !== "string" || typeof reference !== "string")
     debug("WARN: shouldBecomeEqualToString() expects string arguments");
   var unevaledString = JSON.stringify(reference);
-  shouldBecomeEqual(value, unevaledString, completionHandler, timeout);
+  shouldBecomeEqual(value, unevaledString, completionHandler);
 }
 
 function shouldBeType(_a, _type) {
@@ -376,37 +363,29 @@
     testFailed(_a + " should not be " + _bv + ".");
 }
 
-function shouldBecomeDifferent(_a, _b, _completionHandler, _timeout)
+function shouldBecomeDifferent(_a, _b, completionHandler)
 {
   if (typeof _a != "string" || typeof _b != "string")
     debug("WARN: shouldBecomeDifferent() expects string arguments");
-  if (_timeout === undefined)
-    _timeout = 500;
 
-  var _bv;
-  var _condition = function() {
-    var _exception;
+  var condition = function() {
+    var exception;
     var _av;
     try {
       _av = eval(_a);
     } catch (e) {
-      _exception = e;
+      exception = e;
     }
-    _bv = eval(_b);
-    if (_exception)
-      testFailed(_a + " should became not equal to " + _bv + ". Threw exception " + _exception);
+    var _bv = eval(_b);
+    if (exception)
+      testFailed(_a + " should became not equal to " + _bv + ". Threw exception " + exception);
     if (!isResultCorrect(_av, _bv)) {
       testPassed(_a + " became different from " + _b);
       return true;
     }
     return false;
   };
-  var _failureTime = Date.now() + _timeout;
-  var _failureHandler = function () {
-    testFailed(_a + " did not become different from " + _bv + " in " + (_timeout / 1000) + " seconds.");
-    _completionHandler();
-  };
-  _waitForCondition(_condition, _failureTime, _completionHandler, _failureHandler);
+  _waitForCondition(condition, completionHandler);
 }
 
 function shouldBeTrue(a, quiet) { shouldBe(a, "true", quiet); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to