OLD | NEW |
1 <?php | 1 <?php |
2 $date = $_GET['date']; | 2 $date = $_GET['date']; |
3 $expected = $_GET['expected']; | 3 $expected = $_GET['expected']; |
4 header("Last-Modified: $date"); | 4 header("Last-Modified: $date"); |
5 ?> | 5 ?> |
6 <script> | 6 <script> |
7 var expected = '<?=$expected?>'; | 7 var expected = '<?=$expected?>'; |
8 var lastModified = document.lastModified; | 8 var lastModified = document.lastModified; |
9 if (expected == lastModified) { | 9 |
| 10 // If expected is 'illformed-date', then the Last-Modified: header |
| 11 // is assumed to contain an unparseable date. For which we're supposed |
| 12 // to return the current time per spec. Simply verify that by checking |
| 13 // that the |lastModified| parses. |
| 14 if (expected === lastModified || |
| 15 (expected === "illformed-date" && !isNaN(Date.parse(lastModified)))) { |
10 document.write('PASS'); | 16 document.write('PASS'); |
11 } else { | 17 } else { |
12 document.write('FAIL: expect ' + expected + ', but got ' + lastModified); | 18 document.write('FAIL: expect ' + expected + ', but got ' + lastModified); |
13 } | 19 } |
14 </script> | 20 </script> |
OLD | NEW |