2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / animations / animation-test-helpers.js
blob3b59629c4cbc72a0660ce2f1f70a32c02acbb82f
1 if (window.layoutTestController) {
2   layoutTestController.dumpAsText();
3   layoutTestController.waitUntilDone();
6 result = "";
8 function isCloseEnough(actual, desired, tolerance)
10     if (tolerance == undefined || tolerance == 0)
11         tolerance = defaultTolerance;
12     var diff = Math.abs(actual - desired);
13     return diff < tolerance;
16 function checkExpectedValue(index)
18     var property = expected[index][1];
19     var id = expected[index][2];
20     var expectedValue = expected[index][3];
21   
22     var computedStyle = window.getComputedStyle(document.getElementById(id)).getPropertyCSSValue(property);
24     var computedValue = computedStyle.getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
25     if (isCloseEnough(computedValue, expectedValue))
26         result += "PASS - " + id + " at " + expected[index][0] + " saw something close to: " + expectedValue + "<br>";
27     else
28         result += "FAIL - " + id + " at " + expected[index][0] + " expected: " + expectedValue + " but saw: " + computedValue + "<br>";
31 function checkFunctionWithParameter(i)
33   return function() {
34     checkExpectedValue(i);
35   };
38 function setup()
40     for (var i=0; i < expected.length; i++) {
41         window.setTimeout(checkFunctionWithParameter(i), expected[i][0]);
42     }
45 function cleanup()
47     document.getElementById('result').innerHTML = result;
48     if (window.layoutTestController)
49         layoutTestController.notifyDone();