Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Unified Diff: LayoutTests/fast/harness/should-be-now.html

Issue 69813015: Add shouldBeNow() to js-tests.js in LayoutTests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased against master. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>
« no previous file with comments | « no previous file | LayoutTests/fast/harness/should-be-now-expected.txt » ('j') | LayoutTests/resources/js-test.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698