Bug 1172785 - RTCCertificate interfaces draft
authorMartin Thomson <martin.thomson@gmail.com>
Tue, 30 Jun 2015 11:24:18 -0700
changeset 274805 21ccafad8c97728abb876c9e9f33741420c9ac24
parent 274804 a14f28f537a0061adc66a57c7587a7ea3c3c9f6d
child 274806 91a66a5b45011062c65665dd51276535bca12e96
push id3125
push usermartin.thomson@gmail.com
push dateTue, 30 Jun 2015 18:24:25 +0000
bugs1172785
milestone42.0a1
Bug 1172785 - RTCCertificate interfaces
dom/tests/mochitest/general/test_interfaces.html
dom/webidl/PeerConnectionImpl.webidl
dom/webidl/RTCCertificate.webidl
dom/webidl/RTCConfiguration.webidl
dom/webidl/RTCPeerConnection.webidl
dom/webidl/moz.build
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -920,16 +920,18 @@ var interfaceNamesInGlobalScope =
     "Rect",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "Request",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "Response",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "RGBColor",
 // IMPORTANT: Do not change this list without review from a DOM peer!
+    "RTCCertificate",
+// IMPORTANT: Do not change this list without review from a DOM peer!
     "RTCDataChannelEvent",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "RTCPeerConnectionIceEvent",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "RTCRtpReceiver",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "RTCRtpSender",
 // IMPORTANT: Do not change this list without review from a DOM peer!
@@ -1429,32 +1431,32 @@ function createInterfaceMap(isXBLScope) 
   var interfaceMap = {};
 
   function addInterfaces(interfaces)
   {
     for (var entry of interfaces) {
       if (typeof(entry) === "string") {
         interfaceMap[entry] = true;
       } else {
-	ok(!("pref" in entry), "Bogus pref annotation for " + entry.name);
-	if ((entry.nightly === !isNightly) ||
+        ok(!("pref" in entry), "Bogus pref annotation for " + entry.name);
+        if ((entry.nightly === !isNightly) ||
             (entry.xbl === !isXBLScope) ||
             (entry.desktop === !isDesktop) ||
             (entry.b2g === !isB2G) ||
             (entry.windows === !isWindows) ||
             (entry.mac === !isMac) ||
             (entry.linux === !isLinux) ||
             (entry.android === !isAndroid) ||
             (entry.release === !isRelease) ||
             (entry.permission && !hasPermission(entry.permission)) ||
             entry.disabled) {
           interfaceMap[entry.name] = false;
-	} else {
+        } else {
           interfaceMap[entry.name] = true;
-	}
+        }
       }
     }
   }
 
   addInterfaces(ecmaGlobals);
   addInterfaces(interfaceNamesInGlobalScope);
   if (isXBLScope) {
     // We expose QueryInterface to XBL scopes. It's not an interface but we
--- a/dom/webidl/PeerConnectionImpl.webidl
+++ b/dom/webidl/PeerConnectionImpl.webidl
@@ -18,16 +18,17 @@ interface nsISupports;
 /* Must be created first. Observer events will be dispatched on the thread provided */
 [ChromeOnly, Constructor]
 interface PeerConnectionImpl  {
   /* Must be called first. Observer events dispatched on the thread provided */
   [Throws]
   void initialize(PeerConnectionObserver observer, Window window,
                   RTCConfiguration iceServers,
                   nsISupports thread);
+
   /* JSEP calls */
   [Throws]
   void createOffer(optional RTCOfferOptions options);
   [Throws]
   void createAnswer();
   [Throws]
   void setLocalDescription(long action, DOMString sdp);
   [Throws]
@@ -61,16 +62,21 @@ interface PeerConnectionImpl  {
 
   /* Puts the SIPCC engine back to 'kIdle', shuts down threads, deletes state */
   void close();
 
   /* Notify DOM window if this plugin crash is ours. */
   boolean pluginCrash(unsigned long long pluginId, DOMString name);
 
   /* Attributes */
+  /* This provides the implementation with the certificate it uses to
+   * authenticate itself.  The JS side must set this before calling
+   * createOffer/createAnswer or retrieving the value of fingerprint.  This has
+   * to be delayed because generating the certificate takes some time. */
+  attribute RTCCertificate certificate;
   [Constant]
   readonly attribute DOMString fingerprint;
   readonly attribute DOMString localDescription;
   readonly attribute DOMString remoteDescription;
 
   readonly attribute PCImplIceConnectionState iceConnectionState;
   readonly attribute PCImplIceGatheringState iceGatheringState;
   readonly attribute PCImplSignalingState signalingState;
new file mode 100644
--- /dev/null
+++ b/dom/webidl/RTCCertificate.webidl
@@ -0,0 +1,12 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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;
+};
--- a/dom/webidl/RTCConfiguration.webidl
+++ b/dom/webidl/RTCConfiguration.webidl
@@ -12,9 +12,10 @@ dictionary RTCIceServer {
     DOMString  url; //deprecated
     DOMString? credential = null;
     DOMString? username = null;
 };
 
 dictionary RTCConfiguration {
     sequence<RTCIceServer> iceServers;
     DOMString? peerIdentity = null;
+    sequence<RTCCertificate> certificates;
 };
--- a/dom/webidl/RTCPeerConnection.webidl
+++ b/dom/webidl/RTCPeerConnection.webidl
@@ -73,16 +73,19 @@ dictionary DeprecatedRTCOfferOptionsSet 
 interface RTCDataChannel;
 
 [Pref="media.peerconnection.enabled",
  JSImplementation="@mozilla.org/dom/peerconnection;1",
  Constructor (optional RTCConfiguration configuration,
               optional object? constraints)]
 // moz-prefixed until sufficiently standardized.
 interface mozRTCPeerConnection : EventTarget  {
+  [Throws, StaticClassOverride="mozilla::dom::RTCCertificate"]
+  static Promise<RTCCertificate> generateCertificate (AlgorithmIdentifier keygenAlgorithm);
+
   [Pref="media.peerconnection.identity.enabled"]
   void setIdentityProvider (DOMString provider,
                             optional DOMString protocol,
                             optional DOMString username);
   [Pref="media.peerconnection.identity.enabled"]
   Promise<DOMString> getIdentityAssertion();
   Promise<mozRTCSessionDescription> createOffer (optional RTCOfferOptions options);
   Promise<mozRTCSessionDescription> createAnswer ();
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -365,16 +365,17 @@ WEBIDL_FILES = [
     'Rect.webidl',
     'Request.webidl',
     'RequestSyncManager.webidl',
     'RequestSyncScheduler.webidl',
     'ResourceStats.webidl',
     'ResourceStatsManager.webidl',
     'Response.webidl',
     'RGBColor.webidl',
+    'RTCCertificate.webidl',
     'RTCConfiguration.webidl',
     'RTCIceCandidate.webidl',
     'RTCIdentityAssertion.webidl',
     'RTCIdentityProvider.webidl',
     'RTCPeerConnection.webidl',
     'RTCPeerConnectionStatic.webidl',
     'RTCRtpReceiver.webidl',
     'RTCRtpSender.webidl',