[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-60.3.0esr-8.5-1] Bug 1474626 - fix timestamp test and values, r=rpl



commit b3d74f7db1cc0ddf54771e3e9e5de4b8549b0c88
Author: Shane Caraveo <scaraveo@xxxxxxxxxxx>
Date:   Wed Jul 11 14:54:03 2018 -0300

    Bug 1474626 - fix timestamp test and values, r=rpl
    
    The test was incorrect and the timestamp should be milliseconds, not microseconds.
    
    MozReview-Commit-ID: 2d79r6PHH4Z
    
    --HG--
    extra : rebase_source : edd97899f0646f2cae2fbf119206ec470a6b97a0
---
 .../extensions/test/mochitest/test_ext_webrequest_hsts.html         | 6 +++++-
 toolkit/modules/addons/SecurityInfo.jsm                             | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html
index df8b541808f9..b8385ca08843 100644
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html
@@ -38,7 +38,11 @@ function getExtension() {
         browser.test.assertTrue(securityInfo.certificates.length == 1, "no certificate chain");
       }
       let cert = securityInfo.certificates[0];
-      browser.test.assertTrue(cert.validity.start < Date.now() < cert.validity.end, "cert validity is correct");
+      let now = Date.now();
+      browser.test.assertTrue(Number.isInteger(cert.validity.start), "cert start is integer");
+      browser.test.assertTrue(Number.isInteger(cert.validity.end), "cert end is integer");
+      browser.test.assertTrue(cert.validity.start < now, "cert start validity is correct");
+      browser.test.assertTrue(now < cert.validity.end, "cert end validity is correct");
       if (options.rawDER) {
         for (let cert of securityInfo.certificates) {
           browser.test.assertTrue(cert.rawDER.length > 0, "have rawDER");
diff --git a/toolkit/modules/addons/SecurityInfo.jsm b/toolkit/modules/addons/SecurityInfo.jsm
index a931602b517a..de0084398aa6 100644
--- a/toolkit/modules/addons/SecurityInfo.jsm
+++ b/toolkit/modules/addons/SecurityInfo.jsm
@@ -214,8 +214,8 @@ const SecurityInfo = {
       subject: cert.subjectName,
       issuer: cert.issuerName,
       validity: {
-        start: cert.validity.notBefore,
-        end: cert.validity.notAfter,
+        start: cert.validity.notBefore ? Math.trunc(cert.validity.notBefore / 1000) : 0,
+        end: cert.validity.notAfter ? Math.trunc(cert.validity.notAfter / 1000) : 0,
       },
       fingerprint: {
         sha1: cert.sha1Fingerprint,

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits