Bug 1474626 - fix timestamp test and values, r=rpl a=lizzard
authorShane Caraveo <scaraveo@mozilla.com>
Wed, 11 Jul 2018 14:54:03 -0300
changeset 477954 54ec00f46350
parent 477953 f98d084dff6c
child 477955 6055650e6d31
push id9475
push userarchaeopteryx@coole-files.de
push date2018-07-13 21:33 +0000
treeherdermozilla-beta@d7ab2f3df084 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl, lizzard
bugs1474626
milestone62.0
Bug 1474626 - fix timestamp test and values, r=rpl a=lizzard The test was incorrect and the timestamp should be milliseconds, not microseconds. MozReview-Commit-ID: 2d79r6PHH4Z
toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html
toolkit/modules/addons/SecurityInfo.jsm
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html
@@ -33,17 +33,21 @@ function getExtension() {
 
       if (options.certificateChain) {
         // Some of the tests here only produce a single cert in the chain.
         browser.test.assertTrue(securityInfo.certificates.length >= 1, "have certificate chain");
       } else {
         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");
         }
       }
     }
 
     browser.webRequest.onHeadersReceived.addListener(async (details) => {
--- a/toolkit/modules/addons/SecurityInfo.jsm
+++ b/toolkit/modules/addons/SecurityInfo.jsm
@@ -209,18 +209,18 @@ const SecurityInfo = {
     if (!cert) {
       return {};
     }
 
     let certData = {
       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,
         sha256: cert.sha256Fingerprint,
       },
       serialNumber: cert.serialNumber,
       isBuiltInRoot: cert.isBuiltInRoot,
       subjectPublicKeyInfoDigest: {