Index: LayoutTests/fast/harness/should-be-now.html |
diff --git a/LayoutTests/fast/harness/should-be-now.html b/LayoutTests/fast/harness/should-be-now.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f60a549c425a2eb944505c5411b05d69d9a7cae1 |
--- /dev/null |
+++ b/LayoutTests/fast/harness/should-be-now.html |
@@ -0,0 +1,40 @@ |
+<!DOCTYPE html> |
+ |
+<script src="../../resources/js-test.js"></script> |
+<script> |
+description('Test shouldBeNow() in js-test.js'); |
+ |
+shouldBeNow("Date.now()"); |
+shouldBeNow("new Date()"); |
+ |
+debug("Testing type checking with a string. This should fail."); |
+shouldBeNow("'Hello world!'"); |
+ |
+function stubDateNow(stubValue, callback) |
+{ |
+ var realDateNow = Date.now; |
+ Date.now = function() { return stubValue; } |
+ try { |
+ callback(); |
+ } finally { |
+ Date.now = realDateNow; |
+ } |
+} |
+ |
+debug("Testing past dates. This should fail."); |
+stubDateNow(60000, function() { |
+ shouldBeNow("50000"); |
+}); |
+ |
+debug("Testing future dates. This should fail."); |
+stubDateNow(60000, function() { |
+ shouldBeNow("70000"); |
+}); |
+ |
+debug("Simulating a defective clock that always goes backwards. The test below should fail."); |
+var badClock = Date.now(); |
+var realDateNow = Date.now; |
+Date.now = function() { return --badClock; } |
+shouldBeNow("new Date()"); |
+Date.now = realDateNow; |
+</script> |