1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/xslt/tests/mochitest/test_bug603159.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=603159 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 603159</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=603159">Mozilla Bug 603159</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"></div> 1.18 +<pre id="test"> 1.19 +<script type="application/javascript"> 1.20 + 1.21 +/** Test for Bug 603159 **/ 1.22 + 1.23 + var style = 1.24 + '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' + 1.25 + 'xmlns:date="http://exslt.org/dates-and-times" '+ 1.26 + 'version="1.0">' + 1.27 + '<xsl:output method="html"/>' + 1.28 + '<xsl:template match="/">' + 1.29 + '<xsl:value-of select="date:date-time()" /> ' + 1.30 + '</xsl:template>' + 1.31 + '</xsl:stylesheet>'; 1.32 + var styleDoc = new DOMParser().parseFromString (style, "text/xml"); 1.33 + 1.34 + var data = '<root/>'; 1.35 + var originalDoc = new DOMParser().parseFromString(data, "text/xml"); 1.36 + 1.37 + var processor = new XSLTProcessor(); 1.38 + processor.importStylesheet(styleDoc); 1.39 + 1.40 + var fragment = processor.transformToFragment(originalDoc, document); 1.41 + var content = document.getElementById("content"); 1.42 + content.appendChild(fragment); 1.43 + 1.44 + // use Gecko's Date.parse to parse, then compare the milliseconds since epoch 1.45 + var xslt_ms = Date.parse(content.innerHTML); 1.46 + var now_ms = new Date().getTime(); 1.47 + var accepted_diff = 30 * 60 * 1000; // 30 minutes 1.48 + var diff = Math.abs(now_ms - xslt_ms); 1.49 + 1.50 + ok(diff < accepted_diff, "generated timestamp should be not more than " 1.51 + + accepted_diff + " ms before 'now', but the difference was: " + diff); 1.52 + 1.53 + content.innerHTML = ''; 1.54 +</script> 1.55 +</pre> 1.56 +</body> 1.57 +</html>