|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=603159 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 603159</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
10 </head> |
|
11 <body> |
|
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=603159">Mozilla Bug 603159</a> |
|
13 <p id="display"></p> |
|
14 <div id="content" style="display: none"></div> |
|
15 <pre id="test"> |
|
16 <script type="application/javascript"> |
|
17 |
|
18 /** Test for Bug 603159 **/ |
|
19 |
|
20 var style = |
|
21 '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' + |
|
22 'xmlns:date="http://exslt.org/dates-and-times" '+ |
|
23 'version="1.0">' + |
|
24 '<xsl:output method="html"/>' + |
|
25 '<xsl:template match="/">' + |
|
26 '<xsl:value-of select="date:date-time()" /> ' + |
|
27 '</xsl:template>' + |
|
28 '</xsl:stylesheet>'; |
|
29 var styleDoc = new DOMParser().parseFromString (style, "text/xml"); |
|
30 |
|
31 var data = '<root/>'; |
|
32 var originalDoc = new DOMParser().parseFromString(data, "text/xml"); |
|
33 |
|
34 var processor = new XSLTProcessor(); |
|
35 processor.importStylesheet(styleDoc); |
|
36 |
|
37 var fragment = processor.transformToFragment(originalDoc, document); |
|
38 var content = document.getElementById("content"); |
|
39 content.appendChild(fragment); |
|
40 |
|
41 // use Gecko's Date.parse to parse, then compare the milliseconds since epoch |
|
42 var xslt_ms = Date.parse(content.innerHTML); |
|
43 var now_ms = new Date().getTime(); |
|
44 var accepted_diff = 30 * 60 * 1000; // 30 minutes |
|
45 var diff = Math.abs(now_ms - xslt_ms); |
|
46 |
|
47 ok(diff < accepted_diff, "generated timestamp should be not more than " |
|
48 + accepted_diff + " ms before 'now', but the difference was: " + diff); |
|
49 |
|
50 content.innerHTML = ''; |
|
51 </script> |
|
52 </pre> |
|
53 </body> |
|
54 </html> |