Bug 1215519 - Switch to DOMTimeStamp for RTCCertificate. r=bz
authorMartin Thomson <martin.thomson@gmail.com>
Wed, 21 Oct 2015 10:08:40 -0700
changeset 304090 7dc8fdb76c6aa24741c9e82ac8dd13975349bb86
parent 304089 a347985a7a1e480a2aceba2916c3b5b0a1a7eda0
child 304091 feb0f7522ece30fdcc264ccb8df5e580c4f27a07
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1215519
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1215519 - Switch to DOMTimeStamp for RTCCertificate. r=bz
dom/media/PeerConnection.js
dom/media/tests/mochitest/test_peerConnection_certificates.html
dom/media/webrtc/RTCCertificate.h
dom/webidl/RTCCertificate.webidl
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -446,17 +446,17 @@ RTCPeerConnection.prototype = {
   _initCertificate: function(certificates) {
     let certPromise;
     if (certificates && certificates.length > 0) {
       if (certificates.length > 1) {
         throw new this._win.DOMException(
           "RTCPeerConnection does not currently support multiple certificates",
           "NotSupportedError");
       }
-      let cert = certificates.find(c => c.expires.getTime() > Date.now());
+      let cert = certificates.find(c => c.expires > Date.now());
       if (!cert) {
         throw new this._win.DOMException(
           "Unable to create RTCPeerConnection with an expired certificate",
           "InvalidParameterError");
       }
       certPromise = Promise.resolve(cert);
     } else {
       certPromise = this._win.RTCPeerConnection.generateCertificate({
--- a/dom/media/tests/mochitest/test_peerConnection_certificates.html
+++ b/dom/media/tests/mochitest/test_peerConnection_certificates.html
@@ -102,25 +102,25 @@
     var expiredCert;
     return Promise.resolve()
       .then(() => RTCPeerConnection.generateCertificate({
         name: "ECDSA",
         namedCurve: "P-256",
         expires: 1 // smallest possible expiration window
       }))
       .then(cert => {
-        ok(cert.expires instanceof Date, 'cert has expiration time');
-        info('Expires at ' + cert.expires);
+        ok(!isNaN(cert.expires), 'cert has expiration time');
+        info('Expires at ' + new Date(cert.expires));
         expiredCert = cert;
       })
 
       .then(() => checkBadParameters())
 
       .then(() => {
-        var delay = expiredCert.expires.getTime() - Date.now();
+        var delay = expiredCert.expires - Date.now();
         // Hopefully this delay is never needed.
         if (delay > 0) {
           return new Promise(r => setTimeout(r, delay));
         }
       })
       .then(() => {
         ok(expiredCert.expires <= Date.now(), 'Cert should be at or past expiration');
         try {
--- a/dom/media/webrtc/RTCCertificate.h
+++ b/dom/media/webrtc/RTCCertificate.h
@@ -13,20 +13,18 @@
 #include "nsNSSShutDown.h"
 #include "prtime.h"
 #include "sslt.h"
 #include "ScopedNSSTypes.h"
 
 #include "mozilla/ErrorResult.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/RefPtr.h"
-#include "mozilla/dom/Date.h"
 #include "mozilla/dom/CryptoKey.h"
 #include "mtransport/dtlsidentity.h"
-#include "js/Date.h"
 #include "js/StructuredClone.h"
 #include "js/TypeDecls.h"
 
 namespace mozilla {
 namespace dom {
 
 class ObjectOrString;
 
@@ -50,19 +48,19 @@ public:
                  PRTime aExpires);
 
   nsIGlobalObject* GetParentObject() const { return mGlobal; }
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
   // WebIDL expires attribute.  Note: JS dates are milliseconds since epoch;
   // NSPR PRTime is in microseconds since the same epoch.
-  JS::ClippedTime Expires() const
+  uint64_t Expires() const
   {
-    return JS::TimeClip(mExpires / PR_USEC_PER_MSEC);
+    return mExpires / PR_USEC_PER_MSEC;
   }
 
   // Accessors for use by PeerConnectionImpl.
   RefPtr<DtlsIdentity> CreateDtlsIdentity() const;
   CERTCertificate* Certificate() const { return mCertificate; }
 
   // For nsNSSShutDownObject
   virtual void virtualDestroyNSSReference() override;
--- a/dom/webidl/RTCCertificate.webidl
+++ b/dom/webidl/RTCCertificate.webidl
@@ -3,10 +3,10 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * Specification: http://w3c.github.io/webrtc-pc/#certificate-management
  */
 
 [Pref="media.peerconnection.enabled"]
 interface RTCCertificate {
-  readonly attribute Date expires;
+  readonly attribute DOMTimeStamp expires;
 };