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

Side by Side 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 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2
3 <script src="../../resources/js-test.js"></script>
4 <script>
5 description('Test shouldBeNow() in js-test.js');
6
7 shouldBeNow("Date.now()");
8 shouldBeNow("new Date()");
9
10 debug("Testing type checking with a string. This should fail.");
11 shouldBeNow("'Hello world!'");
12
13 function stubDateNow(stubValue, callback)
14 {
15 var realDateNow = Date.now;
16 Date.now = function() { return stubValue; }
17 try {
18 callback();
19 } finally {
20 Date.now = realDateNow;
21 }
22 }
23
24 debug("Testing past dates. This should fail.");
25 stubDateNow(60000, function() {
26 shouldBeNow("50000");
27 });
28
29 debug("Testing future dates. This should fail.");
30 stubDateNow(60000, function() {
31 shouldBeNow("70000");
32 });
33
34 debug("Simulating a defective clock that always goes backwards. The test below s hould fail.");
35 var badClock = Date.now();
36 var realDateNow = Date.now;
37 Date.now = function() { return --badClock; }
38 shouldBeNow("new Date()");
39 Date.now = realDateNow;
40 </script>
OLDNEW
« 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