Commit 37927191 authored by foolip's avatar foolip Committed by Commit bot

Convert Dictionary handling to RTCConfiguration IDL dictionary

This preserves behavior as far as possible and adds use counters for
cases that aren't per spec. One intentional change is that the first
argument of the RTCPeerConnection constructor is made optional, as that
is a very low risk change, and requiring the dictionary makes no sense
when providing null, undefined and {iceServers:[]} already work.

Without custom bindings it is unfortunately not possible to distinguish
{certificates:null} from no certificates specified, so that is not
measured.

BUG=649343

Review-Url: https://codereview.chromium.org/2442763002
Cr-Commit-Position: refs/heads/master@{#427065}
parent eebbdeca
......@@ -8,31 +8,32 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS new webkitRTCPeerConnection(null); did not throw exception.
PASS new webkitRTCPeerConnection(undefined); did not throw exception.
PASS new webkitRTCPeerConnection(); threw exception TypeError: Failed to construct 'RTCPeerConnection': 1 argument required, but only 0 present..
PASS new webkitRTCPeerConnection(''); threw exception TypeError: Failed to construct 'RTCPeerConnection': parameter 1 ('rtcConfiguration') is not an object..
PASS new webkitRTCPeerConnection({}); did not throw exception.
PASS new webkitRTCPeerConnection(); did not throw exception.
PASS new webkitRTCPeerConnection(''); threw exception TypeError: Failed to construct 'RTCPeerConnection': parameter 1 ('configuration') is not an object..
PASS new webkitRTCPeerConnection({iceServers:[]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{url:'stun:foo.com'}]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', credential:'x'}]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', credential:'x'},{url:'stun:bar.com'}]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{urls:['stun:foo.com', 'turn:foo.com']}]}); did not throw exception.
PASS new webkitRTCPeerConnection({fooServers:[]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCConfiguration.
PASS new webkitRTCPeerConnection({iceServers:true}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCConfiguration.
PASS new webkitRTCPeerConnection({iceServers:[1, 2, 3]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCIceServer.
PASS new webkitRTCPeerConnection({fooServers:[]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:true}); threw exception TypeError: Failed to construct 'RTCPeerConnection': The value provided is neither an array, nor does it have indexed properties..
PASS new webkitRTCPeerConnection({iceServers:[1, 2, 3]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': cannot convert to dictionary..
PASS new webkitRTCPeerConnection({iceServers:[{}]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCIceServer.
PASS new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed URL.
PASS new webkitRTCPeerConnection({iceServers:[{urls:[1, 'turn:foo.com']}]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed URL.
PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'none'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'relay'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'all'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCIceTransports.
PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': The provided value 'foo' is not a valid enum value of type RTCIceTransports..
PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'balanced'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'max-bundle'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'max-compat'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCBundlePolicy.
PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': The provided value 'foo' is not a valid enum value of type RTCBundlePolicy..
PASS new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'negotiate'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'require'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCRtcpMuxPolicy.
PASS new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': The provided value 'foo' is not a valid enum value of type RTCRtcpMuxPolicy..
PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1}}); did not throw exception.
PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1, valid_and_supported_2:1}}); did not throw exception.
PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0}]}); did not throw exception.
......@@ -49,9 +50,10 @@ PASS new webkitRTCPeerConnection(null, {valid_and_supported_1:1}); threw excepti
PASS new webkitRTCPeerConnection(null, {valid_but_unsupported_1:1}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object..
PASS new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandatory:{valid_and_supported_1:1}}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object..
PASS new webkitRTCPeerConnection({iceServers:[], certificates:null}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:undefined}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[null]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed sequence<RTCCertificate>.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[1337]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed sequence<RTCCertificate>.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[null]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Invalid Array element type.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[1337]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Invalid Array element type.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[certRSA]}, null); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[certECDSA]}, null); did not throw exception.
PASS certExpired.expires <= new Date().getTime() is true
......
......@@ -9,7 +9,8 @@ description("Tests the RTCPeerConnection constructor.");
shouldNotThrow("new webkitRTCPeerConnection(null);");
shouldNotThrow("new webkitRTCPeerConnection(undefined);");
shouldThrow("new webkitRTCPeerConnection();");
shouldNotThrow("new webkitRTCPeerConnection({});");
shouldNotThrow("new webkitRTCPeerConnection();");
shouldThrow("new webkitRTCPeerConnection('');");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[]});");
......@@ -19,7 +20,7 @@ shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', cr
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{urls:['stun:foo.com', 'turn:foo.com']}]});");
shouldThrow("new webkitRTCPeerConnection({fooServers:[]});");
shouldNotThrow("new webkitRTCPeerConnection({fooServers:[]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:true});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[1, 2, 3]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[{}]});");
......@@ -60,6 +61,7 @@ shouldThrow("new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandato
// Construct with certificates.
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:null});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:undefined});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[null]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[1337]});");
......
......@@ -1376,6 +1376,9 @@ class CORE_EXPORT UseCounter {
LoopbackEmbeddedInSecureContext = 1652,
LoopbackEmbeddedInNonSecureContext = 1653,
BlinkMacSystemFont = 1654,
RTCConfigurationIceTransportsNone = 1655,
RTCIceServerURL = 1656,
RTCIceServerURLs = 1657,
// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
......
......@@ -446,8 +446,10 @@ modules_dictionary_idl_files =
"payments/PaymentRequestUpdateEventInit.idl",
"payments/PaymentShippingOption.idl",
"peerconnection/RTCAnswerOptions.idl",
"peerconnection/RTCConfiguration.idl",
"peerconnection/RTCDTMFToneChangeEventInit.idl",
"peerconnection/RTCIceCandidateInit.idl",
"peerconnection/RTCIceServer.idl",
"peerconnection/RTCOfferAnswerOptions.idl",
"peerconnection/RTCOfferOptions.idl",
"peerconnection/RTCSessionDescriptionInit.idl",
......@@ -766,10 +768,14 @@ generated_modules_dictionary_files = [
"$blink_modules_output_dir/payments/PaymentShippingOption.h",
"$blink_modules_output_dir/peerconnection/RTCAnswerOptions.cpp",
"$blink_modules_output_dir/peerconnection/RTCAnswerOptions.h",
"$blink_modules_output_dir/peerconnection/RTCConfiguration.cpp",
"$blink_modules_output_dir/peerconnection/RTCConfiguration.h",
"$blink_modules_output_dir/peerconnection/RTCDTMFToneChangeEventInit.cpp",
"$blink_modules_output_dir/peerconnection/RTCDTMFToneChangeEventInit.h",
"$blink_modules_output_dir/peerconnection/RTCIceCandidateInit.cpp",
"$blink_modules_output_dir/peerconnection/RTCIceCandidateInit.h",
"$blink_modules_output_dir/peerconnection/RTCIceServer.cpp",
"$blink_modules_output_dir/peerconnection/RTCIceServer.h",
"$blink_modules_output_dir/peerconnection/RTCOfferAnswerOptions.cpp",
"$blink_modules_output_dir/peerconnection/RTCOfferAnswerOptions.h",
"$blink_modules_output_dir/peerconnection/RTCOfferOptions.cpp",
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://w3c.github.io/webrtc-pc/#rtcicetransportpolicy-enum
// TODO(foolip): This is called RTCIceTransportPolicy in the spec, and that enum
// does not have "none" as one of its values.
enum RTCIceTransports {
"none",
"relay",
"all"
};
// https://w3c.github.io/webrtc-pc/#rtcbundlepolicy-enum
enum RTCBundlePolicy {
"balanced",
"max-compat",
"max-bundle"
};
// https://w3c.github.io/webrtc-pc/#rtcrtcpmuxpolicy-enum
enum RTCRtcpMuxPolicy {
"negotiate",
"require"
};
// https://w3c.github.io/webrtc-pc/#rtcconfiguration-dictionary
dictionary RTCConfiguration {
sequence<RTCIceServer> iceServers;
// TODO(foolip): |iceTransports| should be |iceTransportPolicy|.
RTCIceTransports iceTransports = "all";
RTCBundlePolicy bundlePolicy = "balanced";
// TODO(foolip): |rtcpMuxPolicy| default should be "require".
RTCRtcpMuxPolicy rtcpMuxPolicy;
// TODO(foolip): DOMString peerIdentity;
// TODO(foolip): |certificates| should not be nullable.
sequence<RTCCertificate>? certificates;
// TODO(foolip): unsigned short iceCandidatePoolSize = 0;
};
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://w3c.github.io/webrtc-pc/#rtciceserver-dictionary
dictionary RTCIceServer {
// TODO(foolip): |urls| should be required and |url| is not in the spec.
(DOMString or sequence<DOMString>) urls;
DOMString url;
DOMString username;
DOMString credential;
// TODO(foolip): RTCIceCredentialType credentialType = "password";
};
......@@ -32,7 +32,6 @@
#define RTCPeerConnection_h
#include "bindings/core/v8/ActiveScriptWrappable.h"
#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ScriptPromise.h"
#include "core/dom/ActiveDOMObject.h"
#include "modules/EventTargetModules.h"
......@@ -49,6 +48,7 @@ namespace blink {
class ExceptionState;
class MediaStreamTrack;
class RTCAnswerOptions;
class RTCConfiguration;
class RTCDTMFSender;
class RTCDataChannel;
class RTCIceCandidateInitOrRTCIceCandidate;
......@@ -72,7 +72,7 @@ class RTCPeerConnection final : public EventTargetWithInlineData,
public:
static RTCPeerConnection* create(ExecutionContext*,
const Dictionary&,
const RTCConfiguration&,
const Dictionary&,
ExceptionState&);
~RTCPeerConnection() override;
......@@ -107,7 +107,8 @@ class RTCPeerConnection final : public EventTargetWithInlineData,
String signalingState() const;
void updateIce(const Dictionary& rtcConfiguration,
void updateIce(ExecutionContext*,
const RTCConfiguration&,
const Dictionary& mediaConstraints,
ExceptionState&);
......
......@@ -63,9 +63,8 @@ enum RTCIceConnectionState {
[
ActiveScriptWrappable,
DependentLifetime,
// TODO(guidou): There should only be one constructor argument, and it
// should be optional.
Constructor(Dictionary rtcConfiguration, optional Dictionary mediaConstraints),
// TODO(guidou): There should only be one constructor argument.
Constructor(optional RTCConfiguration configuration, optional Dictionary mediaConstraints),
ConstructorCallWith=ExecutionContext,
NoInterfaceObject,
RaisesException=Constructor,
......@@ -122,7 +121,7 @@ enum RTCIceConnectionState {
[RaisesException, CallWith=ScriptState] static Promise<RTCCertificate> generateCertificate(AlgorithmIdentifier keygenAlgorithm);
// Non-standard or removed from the spec:
[Measure, RaisesException] void updateIce(optional Dictionary configuration, optional Dictionary mediaConstraints);
[Measure, CallWith=ExecutionContext, RaisesException] void updateIce(optional RTCConfiguration configuration, optional Dictionary mediaConstraints);
[Measure] sequence<MediaStream> getLocalStreams();
[Measure] sequence<MediaStream> getRemoteStreams();
[Measure] MediaStream getStreamById(DOMString streamId);
......
......@@ -84592,6 +84592,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<int value="1652" label="LoopbackEmbeddedInSecureContext"/>
<int value="1653" label="LoopbackEmbeddedInNonSecureContext"/>
<int value="1654" label="BlinkMacSystemFont"/>
<int value="1655" label="RTCConfigurationIceTransportsNone"/>
<int value="1656" label="RTCIceServerURL"/>
<int value="1657" label="RTCIceServerURLs"/>
</enum>
<enum name="FetchRequestMode" type="int">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment