Changeset 156678 in webkit


Ignore:
Timestamp:
Sep 30, 2013 1:47:43 PM (11 years ago)
Author:
ap@apple.com
Message:

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

Reviewed by Ryosuke Niwa.

Removed timeout. A 0.5 sec timeout never makes sense, and if something is stuck,
a test should just time out normally.

  • resources/js-test-pre.js:

(_waitForCondition):
(shouldBecomeEqual):
(shouldBecomeEqualToString):
(shouldBecomeDifferent):

Location:
trunk/LayoutTests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r156664 r156678  
     12013-09-30  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Remove timeout from shouldBecome* functions in js-test-pre
     4        https://bugs.webkit.org/show_bug.cgi?id=122121
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Removed timeout. A 0.5 sec timeout never makes sense, and if something is stuck,
     9        a test should just time out normally.
     10
     11        * resources/js-test-pre.js:
     12        (_waitForCondition):
     13        (shouldBecomeEqual):
     14        (shouldBecomeEqualToString):
     15        (shouldBecomeDifferent):
     16
    1172013-09-30  Jer Noble  <jer.noble@apple.com>
    218
  • trunk/LayoutTests/resources/js-test-pre.js

    r155624 r156678  
    265265}
    266266
    267 // Execute condition every 5 milliseconds until it succeed or failureTime is reached.
    268 // completionHandler is executed on success, failureHandler is executed on timeout.
    269 function _waitForCondition(condition, failureTime, completionHandler, failureHandler)
    270 {
    271   if (condition()) {
     267// Execute condition every 5 milliseconds until it succeeds.
     268function _waitForCondition(condition, completionHandler)
     269{
     270  if (condition())
    272271    completionHandler();
    273   } else if (Date.now() > failureTime) {
    274     failureHandler();
    275   } else {
    276     setTimeout(_waitForCondition, 5, condition, failureTime, completionHandler, failureHandler);
    277   }
    278 }
    279 
    280 function shouldBecomeEqual(_a, _b, completionHandler, timeout)
     272  else
     273    setTimeout(_waitForCondition, 5, condition, completionHandler);
     274}
     275
     276function shouldBecomeEqual(_a, _b, completionHandler)
    281277{
    282278  if (typeof _a != "string" || typeof _b != "string")
    283279    debug("WARN: shouldBecomeEqual() expects string arguments");
    284 
    285   if (timeout === undefined)
    286     timeout = 500;
    287280
    288281  var condition = function() {
     
    303296    return false;
    304297  };
    305   var failureTime = Date.now() + timeout;
    306   var failureHandler = function () {
    307     testFailed(_a + " failed to change to " + _b + " in " + (timeout / 1000) + " seconds.");
    308     completionHandler();
    309   };
    310   _waitForCondition(condition, failureTime, completionHandler, failureHandler);
    311 }
    312 
    313 function shouldBecomeEqualToString(value, reference, completionHandler, timeout)
     298  _waitForCondition(condition, completionHandler);
     299}
     300
     301function shouldBecomeEqualToString(value, reference, completionHandler)
    314302{
    315303  if (typeof value !== "string" || typeof reference !== "string")
    316304    debug("WARN: shouldBecomeEqualToString() expects string arguments");
    317305  var unevaledString = JSON.stringify(reference);
    318   shouldBecomeEqual(value, unevaledString, completionHandler, timeout);
     306  shouldBecomeEqual(value, unevaledString, completionHandler);
    319307}
    320308
     
    398386}
    399387
    400 function shouldBecomeDifferent(_a, _b, completionHandler, timeout)
     388function shouldBecomeDifferent(_a, _b, completionHandler)
    401389{
    402390  if (typeof _a != "string" || typeof _b != "string")
    403391    debug("WARN: shouldBecomeDifferent() expects string arguments");
    404   if (timeout === undefined)
    405     timeout = 500;
    406392
    407393  var condition = function() {
     
    422408    return false;
    423409  };
    424   var failureTime = Date.now() + timeout;
    425   var failureHandler = function () {
    426     testFailed(_a + " did not become different from " + _b + " in " + (timeout / 1000) + " seconds.");
    427     completionHandler();
    428   };
    429   _waitForCondition(condition, failureTime, completionHandler, failureHandler);
     410  _waitForCondition(condition, completionHandler);
    430411}
    431412
Note: See TracChangeset for help on using the changeset viewer.