Bad configuration parameters should make RTCPeerConnection constructor throw
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Mar 2018 22:41:31 +0000 (22:41 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Mar 2018 22:41:31 +0000 (22:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183615

Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

* web-platform-tests/webrtc/RTCConfiguration-bundlePolicy-expected.txt:
* web-platform-tests/webrtc/RTCConfiguration-iceServers-expected.txt:
* web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-constructor-expected.txt:

Source/WebCore:

Implement more of https://w3c.github.io/webrtc-pc/#set-pc-configuration.
Throw an error whenever underlying libwebrtc set configuration fails.

Covered by rebased test.

* Modules/mediastream/PeerConnectionBackend.h:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::iceServersFromConfiguration):
(WebCore::RTCPeerConnection::initializeConfiguration):
(WebCore::RTCPeerConnection::setConfiguration):
* Modules/mediastream/RTCPeerConnection.js:
(initializeRTCPeerConnection):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:

LayoutTests:

Removed tests that are subsumed by WPT ones.

* fast/mediastream/RTCPeerConnection-expected.txt: Removed.
* fast/mediastream/RTCPeerConnection-getConfiguration-expected.txt: Removed.
* fast/mediastream/RTCPeerConnection-getConfiguration.html: Removed.
* fast/mediastream/RTCPeerConnection.html: Removed.
* platform/gtk/TestExpectations:
* platform/ios/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229645 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/RTCPeerConnection-expected.txt [deleted file]
LayoutTests/fast/mediastream/RTCPeerConnection-getConfiguration-expected.txt [deleted file]
LayoutTests/fast/mediastream/RTCPeerConnection-getConfiguration.html [deleted file]
LayoutTests/fast/mediastream/RTCPeerConnection.html [deleted file]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCConfiguration-bundlePolicy-expected.txt
LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCConfiguration-iceServers-expected.txt
LayoutTests/imported/w3c/web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-constructor-expected.txt
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/ios/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/RTCPeerConnection.js
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h

index 18b8aaf..ffed8b8 100644 (file)
@@ -1,5 +1,21 @@
 2018-03-15  Youenn Fablet  <youenn@apple.com>
 
+        Bad configuration parameters should make RTCPeerConnection constructor throw
+        https://bugs.webkit.org/show_bug.cgi?id=183615
+
+        Reviewed by Eric Carlson.
+
+        Removed tests that are subsumed by WPT ones.
+
+        * fast/mediastream/RTCPeerConnection-expected.txt: Removed.
+        * fast/mediastream/RTCPeerConnection-getConfiguration-expected.txt: Removed.
+        * fast/mediastream/RTCPeerConnection-getConfiguration.html: Removed.
+        * fast/mediastream/RTCPeerConnection.html: Removed.
+        * platform/gtk/TestExpectations:
+        * platform/ios/TestExpectations:
+
+2018-03-15  Youenn Fablet  <youenn@apple.com>
+
         replaceTrack triggers negotiationneeded
         https://bugs.webkit.org/show_bug.cgi?id=180342
         <rdar://problem/35822426>
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-expected.txt b/LayoutTests/fast/mediastream/RTCPeerConnection-expected.txt
deleted file mode 100644 (file)
index b8ecb46..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-Tests the RTCPeerConnection constructor.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS new RTCPeerConnection(null); did not throw exception.
-PASS new RTCPeerConnection(''); threw exception TypeError: RTCPeerConnection argument must be a valid dictionary.
-PASS new RTCPeerConnection({}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[]}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{url:'stun:foo.com'}]}); threw exception TypeError: Error creating RTCPeerConnection.
-PASS new RTCPeerConnection({iceServers:[{urls:'http:foo.com'}]}); threw exception TypeError: Error creating RTCPeerConnection.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:['stun:foo.com', 'turn:foo.com']}]}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}, {urls:['stun:foo.com', 'turn:bar.com']}]}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'none'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'relay'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'all'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], requestIdentity:'yes'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], requestIdentity:'no'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], requestIdentity:'ifconfigured'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'foo', requestIdentity:'bar'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'none', requestIdentity:'bar'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'foo', requestIdentity:'no'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'none', requestIdentity:'yes'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'none', requestIdentity:'no'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'none', requestIdentity:'ifconfigured'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'relay', requestIdentity:'yes'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'relay', requestIdentity:'no'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'relay', requestIdentity:'ifconfigured'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'all', requestIdentity:'yes'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'all', requestIdentity:'no'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'all', requestIdentity:'ifconfigured'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', credential:'x'}]}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', credential:'x'},{urls:'stun:bar.com'}]}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com', username:'user'}]}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', username:'user', credential:'x'}]}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', username:'user', credential:'x'},{urls:'stun:bar.com', username:'user2', credential:'x'}]}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', username:'user', credential:'x'},{urls:['stun:bar.com', 'turn:foo.com', 'turn:foo2.com'], username:'user2', credential:'x'}]}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', credential:'x'}], iceTransports:'all', requestIdentity:'ifconfigured'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', credential:'x'},{urls:'stun:bar.com'}], iceTransports:'all', requestIdentity:'ifconfigured'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'stun:foo.com', username:'user'}], iceTransports:'all', requestIdentity:'ifconfigured'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', username:'user', credential:'x'}], iceTransports:'all', requestIdentity:'ifconfigured'}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', username:'user', credential:'x'},{urls:'stun:bar.com', username:'user2', credential:'x'}], iceTransports:'all', requestIdentity:'ifconfigured'}); did not throw exception.
-PASS new RTCPeerConnection({fooServers:[]}); did not throw exception.
-PASS new RTCPeerConnection({iceServers:true}); threw exception TypeError: Error creating RTCPeerConnection.
-PASS new RTCPeerConnection({iceServers:[1, 2, 3]}); threw exception TypeError: Error creating RTCPeerConnection.
-PASS new RTCPeerConnection({iceServers:[{}]}); threw exception TypeError: Error creating RTCPeerConnection.
-PASS new RTCPeerConnection({iceServers:[{urls:'foo'}]}); threw exception TypeError: Error creating RTCPeerConnection.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-getConfiguration-expected.txt b/LayoutTests/fast/mediastream/RTCPeerConnection-getConfiguration-expected.txt
deleted file mode 100644 (file)
index 230d99a..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-Tests RTCPeerConnection get/setConfiguration.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS iceServers.length is 1
-PASS configuration.iceTransportPolicy is "all"
-PASS configuration.bundlePolicy is "balanced"
-PASS "username" in iceServers[i] is false
-PASS "credential" in iceServers[i] is false
-PASS urls[j] is "stun:foo.com"
-PASS iceServers.length is 2
-PASS configuration.iceTransportPolicy is "all"
-PASS configuration.bundlePolicy is "balanced"
-PASS iceServers[i].username is "user"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "turn:foo.com"
-PASS iceServers[i].username is "user2"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "stun:bar.com"
-PASS iceServers.length is 2
-PASS configuration.iceTransportPolicy is "all"
-PASS configuration.bundlePolicy is "balanced"
-PASS iceServers[i].username is "user"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "turn:foo.com"
-PASS iceServers[i].username is "user2"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "stun:bar.com"
-PASS urls[j] is "turn:foo.com"
-PASS urls[j] is "turn:foo2.com"
-PASS iceServers.length is 1
-PASS configuration.iceTransportPolicy is "relay"
-PASS configuration.bundlePolicy is "balanced"
-PASS "username" in iceServers[i] is false
-PASS "credential" in iceServers[i] is false
-PASS urls[j] is "stun:foo.com"
-PASS iceServers.length is 1
-PASS configuration.iceTransportPolicy is "relay"
-PASS configuration.bundlePolicy is "max-compat"
-PASS "username" in iceServers[i] is false
-PASS "credential" in iceServers[i] is false
-PASS urls[j] is "stun:foo.com"
-PASS iceServers.length is 2
-PASS configuration.iceTransportPolicy is "relay"
-PASS configuration.bundlePolicy is "max-bundle"
-PASS iceServers[i].username is "user"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "turn:foo.com"
-PASS iceServers[i].username is "user2"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "stun:bar.com"
-PASS urls[j] is "turn:foo.com"
-PASS urls[j] is "turn:foo2.com"
-PASS iceServers.length is 1
-PASS configuration.iceTransportPolicy is "all"
-PASS configuration.bundlePolicy is "balanced"
-PASS "username" in iceServers[i] is false
-PASS "credential" in iceServers[i] is false
-PASS urls[j] is "stun:foo.com"
-PASS iceServers.length is 2
-PASS configuration.iceTransportPolicy is "all"
-PASS configuration.bundlePolicy is "balanced"
-PASS iceServers[i].username is "user"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "turn:foo.com"
-PASS iceServers[i].username is "user2"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "stun:bar.com"
-PASS iceServers.length is 2
-PASS configuration.iceTransportPolicy is "all"
-PASS configuration.bundlePolicy is "balanced"
-PASS iceServers[i].username is "user"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "turn:foo.com"
-PASS iceServers[i].username is "user2"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "stun:bar.com"
-PASS urls[j] is "turn:foo.com"
-PASS urls[j] is "turn:foo2.com"
-PASS iceServers.length is 1
-PASS configuration.iceTransportPolicy is "relay"
-PASS configuration.bundlePolicy is "balanced"
-PASS "username" in iceServers[i] is false
-PASS "credential" in iceServers[i] is false
-PASS urls[j] is "stun:foo.com"
-PASS iceServers.length is 1
-PASS configuration.iceTransportPolicy is "relay"
-PASS configuration.bundlePolicy is "max-compat"
-PASS "username" in iceServers[i] is false
-PASS "credential" in iceServers[i] is false
-PASS urls[j] is "stun:foo.com"
-PASS iceServers.length is 2
-PASS configuration.iceTransportPolicy is "relay"
-PASS configuration.bundlePolicy is "max-bundle"
-PASS iceServers[i].username is "user"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "turn:foo.com"
-PASS iceServers[i].username is "user2"
-PASS iceServers[i].credential is "x"
-PASS urls[j] is "stun:bar.com"
-PASS urls[j] is "turn:foo.com"
-PASS urls[j] is "turn:foo2.com"
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-getConfiguration.html b/LayoutTests/fast/mediastream/RTCPeerConnection-getConfiguration.html
deleted file mode 100644 (file)
index 4d8dbb2..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-    <head>
-        <script src="../../resources/js-test-pre.js"></script>
-    </head>
-    <body>
-        <script>
-            description("Tests RTCPeerConnection get/setConfiguration.");
-
-            var pc = null;
-            var configuration = null;
-            var iceServers = null;
-            var urls = null;
-
-            function checkConfiguration(serversList, iceTransportPolicy, bundlePolicy)
-            {
-                iceServers = configuration.iceServers
-                shouldBe('iceServers.length', serversList.length.toString());
-                shouldBeEqualToString('configuration.iceTransportPolicy', iceTransportPolicy);
-                shouldBeEqualToString('configuration.bundlePolicy', bundlePolicy);
-                for (i = 0; i < iceServers.length; ++i) {
-                    if ("username" in serversList[i])
-                        shouldBeEqualToString('iceServers[i].username', serversList[i].username);
-                    else
-                        shouldBeFalse('"username" in iceServers[i]');
-                    if ("credential" in serversList[i])
-                        shouldBeEqualToString('iceServers[i].credential', serversList[i].credential);
-                    else
-                        shouldBeFalse('"credential" in iceServers[i]');
-
-                    urls = iceServers[i].urls;
-                    for (j = 0; j < urls.length; ++j)
-                        shouldBeEqualToString('urls[j]', serversList[i].urls[j]);
-                }
-            }
-
-            pc = new RTCPeerConnection({iceServers:[{urls:['stun:foo.com']}]});
-            var servers = [{urls:['stun:foo.com']}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'all', 'balanced');
-
-            pc = new RTCPeerConnection({iceServers:[{urls:['turn:foo.com'], username:'user', credential:'x'},{urls:['stun:bar.com'], username:'user2', credential:'x'}]});
-            servers = [{urls:['turn:foo.com'], username:'user', credential:'x'}, {urls:['stun:bar.com'], username:'user2', credential:'x'}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'all', 'balanced');
-
-            pc = new RTCPeerConnection({iceServers:[{urls:['turn:foo.com'], username:'user', credential:'x'},{urls:['stun:bar.com', 'turn:foo.com', 'turn:foo2.com'], username:'user2', credential:'x'}]});
-            servers = [{urls:['turn:foo.com'], username:'user', credential:'x'},{urls:['stun:bar.com', 'turn:foo.com', 'turn:foo2.com'], username:'user2', credential:'x'}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'all', 'balanced');
-
-            pc = new RTCPeerConnection({iceServers:[{urls:['stun:foo.com']}], iceTransportPolicy:'relay', bundlePolicy:'balanced'});
-            var servers = [{urls:['stun:foo.com']}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'relay', 'balanced');
-
-            pc = new RTCPeerConnection({iceServers:[{urls:['stun:foo.com']}], iceTransportPolicy:'relay', bundlePolicy:'max-compat'});
-            var servers = [{urls:['stun:foo.com']}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'relay', 'max-compat');
-
-            pc = new RTCPeerConnection({iceServers:[{urls:['turn:foo.com'], username:'user', credential:'x'},{urls:['stun:bar.com', 'turn:foo.com', 'turn:foo2.com'], username:'user2', credential:'x'}], iceTransportPolicy:'relay', bundlePolicy:'max-bundle'});
-            servers = [{urls:['turn:foo.com'], username:'user', credential:'x'},{urls:['stun:bar.com', 'turn:foo.com', 'turn:foo2.com'], username:'user2', credential:'x'}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'relay', 'max-bundle');
-
-            pc.setConfiguration({iceServers:[{urls:['stun:foo.com']}]});
-            var servers = [{urls:['stun:foo.com']}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'all', 'balanced');
-
-            pc.setConfiguration({iceServers:[{urls:['turn:foo.com'], username:'user', credential:'x'},{urls:['stun:bar.com'], username:'user2', credential:'x'}]});
-            servers = [{urls:['turn:foo.com'], username:'user', credential:'x'}, {urls:['stun:bar.com'], username:'user2', credential:'x'}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'all', 'balanced');
-
-            pc.setConfiguration({iceServers:[{urls:['turn:foo.com'], username:'user', credential:'x'},{urls:['stun:bar.com', 'turn:foo.com', 'turn:foo2.com'], username:'user2', credential:'x'}]});
-            servers = [{urls:['turn:foo.com'], username:'user', credential:'x'},{urls:['stun:bar.com', 'turn:foo.com', 'turn:foo2.com'], username:'user2', credential:'x'}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'all', 'balanced');
-
-            pc.setConfiguration({iceServers:[{urls:['stun:foo.com']}], iceTransportPolicy:'relay', bundlePolicy:'balanced'});
-            var servers = [{urls:['stun:foo.com']}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'relay', 'balanced');
-
-            pc.setConfiguration({iceServers:[{urls:['stun:foo.com']}], iceTransportPolicy:'relay', bundlePolicy:'max-compat'});
-            var servers = [{urls:['stun:foo.com']}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'relay', 'max-compat');
-
-            pc.setConfiguration({iceServers:[{urls:['turn:foo.com'], username:'user', credential:'x'},{urls:['stun:bar.com', 'turn:foo.com', 'turn:foo2.com'], username:'user2', credential:'x'}], iceTransportPolicy:'relay', bundlePolicy:'max-bundle'});
-            servers = [{urls:['turn:foo.com'], username:'user', credential:'x'},{urls:['stun:bar.com', 'turn:foo.com', 'turn:foo2.com'], username:'user2', credential:'x'}];
-            configuration = pc.getConfiguration();
-            checkConfiguration(servers, 'relay', 'max-bundle');
-
-            finishJSTest();
-
-            window.jsTestIsAsync = true;
-            window.successfullyParsed = true;
-        </script>
-        <script src="../../resources/js-test-post.js"></script>
-    </body>
-</html>
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection.html b/LayoutTests/fast/mediastream/RTCPeerConnection.html
deleted file mode 100644 (file)
index 509c62a..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-    <head>
-        <script src="../../resources/js-test-pre.js"></script>
-    </head>
-    <body>
-        <script>
-            description("Tests the RTCPeerConnection constructor.");
-
-            shouldNotThrow("new RTCPeerConnection(null);");
-            shouldThrow("new RTCPeerConnection('');");
-            shouldNotThrow("new RTCPeerConnection({});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[]});");
-            shouldThrow("new RTCPeerConnection({iceServers:[{url:'stun:foo.com'}]});");
-            shouldThrow("new RTCPeerConnection({iceServers:[{urls:'http:foo.com'}]});");
-
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:['stun:foo.com', 'turn:foo.com']}]});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}, {urls:['stun:foo.com', 'turn:bar.com']}]});");
-
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'none'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'relay'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'all'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], requestIdentity:'yes'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], requestIdentity:'no'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], requestIdentity:'ifconfigured'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'foo', requestIdentity:'bar'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'none', requestIdentity:'bar'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'foo', requestIdentity:'no'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'none', requestIdentity:'yes'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'none', requestIdentity:'no'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'none', requestIdentity:'ifconfigured'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'relay', requestIdentity:'yes'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'relay', requestIdentity:'no'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'relay', requestIdentity:'ifconfigured'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'all', requestIdentity:'yes'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'all', requestIdentity:'no'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}], iceTransports:'all', requestIdentity:'ifconfigured'});");
-
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', credential:'x'}]});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', credential:'x'},{urls:'stun:bar.com'}]});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com', username:'user'}]});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', username:'user', credential:'x'}]});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', username:'user', credential:'x'},{urls:'stun:bar.com', username:'user2', credential:'x'}]});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', username:'user', credential:'x'},{urls:['stun:bar.com', 'turn:foo.com', 'turn:foo2.com'], username:'user2', credential:'x'}]});");
-
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', credential:'x'}], iceTransports:'all', requestIdentity:'ifconfigured'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', credential:'x'},{urls:'stun:bar.com'}], iceTransports:'all', requestIdentity:'ifconfigured'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'stun:foo.com', username:'user'}], iceTransports:'all', requestIdentity:'ifconfigured'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', username:'user', credential:'x'}], iceTransports:'all', requestIdentity:'ifconfigured'});");
-            shouldNotThrow("new RTCPeerConnection({iceServers:[{urls:'turn:foo.com', username:'user', credential:'x'},{urls:'stun:bar.com', username:'user2', credential:'x'}], iceTransports:'all', requestIdentity:'ifconfigured'});");
-
-            shouldNotThrow("new RTCPeerConnection({fooServers:[]});");
-            shouldThrow("new RTCPeerConnection({iceServers:true});");
-            shouldThrow("new RTCPeerConnection({iceServers:[1, 2, 3]});");
-            shouldThrow("new RTCPeerConnection({iceServers:[{}]});");
-            shouldThrow("new RTCPeerConnection({iceServers:[{urls:'foo'}]});");
-        </script>
-        <script src="../../resources/js-test-post.js"></script>
-    </body>
-</html>
index 2e284e4..2a70740 100644 (file)
@@ -1,3 +1,14 @@
+2018-03-15  Youenn Fablet  <youenn@apple.com>
+
+        Bad configuration parameters should make RTCPeerConnection constructor throw
+        https://bugs.webkit.org/show_bug.cgi?id=183615
+
+        Reviewed by Eric Carlson.
+
+        * web-platform-tests/webrtc/RTCConfiguration-bundlePolicy-expected.txt:
+        * web-platform-tests/webrtc/RTCConfiguration-iceServers-expected.txt:
+        * web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-constructor-expected.txt:
+
 2018-03-14  Frederic Wang  <fwang@igalia.com>
 
         Finish migration to MathML WPT tests
index 28af5fe..bb587c9 100644 (file)
@@ -12,8 +12,6 @@ PASS setConfiguration({ bundlePolicy: 'max-compat' }) with initial bundlePolicy
 PASS setConfiguration({ bundlePolicy: 'max-bundle' }) with initial bundlePolicy max-bundle should succeed 
 PASS new RTCPeerConnection({ bundlePolicy: null }) should throw TypeError 
 PASS new RTCPeerConnection({ bundlePolicy: 'invalid' }) should throw TypeError 
-FAIL setConfiguration({ bundlePolicy: 'max-compat' }) with initial bundlePolicy max-bundle should throw InvalidModificationError assert_throws: function "() =>
-      pc.setConfiguration({ bundlePolicy: 'max-compat' })" did not throw
-FAIL setConfiguration({}) with initial bundlePolicy max-bundle should throw InvalidModificationError assert_throws: function "() =>
-      pc.setConfiguration({})" did not throw
+PASS setConfiguration({ bundlePolicy: 'max-compat' }) with initial bundlePolicy max-bundle should throw InvalidModificationError 
+PASS setConfiguration({}) with initial bundlePolicy max-bundle should throw InvalidModificationError 
 
index 2eabcc2..cd680aa 100644 (file)
@@ -22,102 +22,58 @@ FAIL new RTCPeerConnection(config) - with 2 stun servers should succeed assert_e
 FAIL setConfiguration(config) - with 2 stun servers should succeed assert_equals: expected (string) "password" but got (undefined) undefined
 FAIL new RTCPeerConnection(config) - with turn server, username, credential should succeed assert_array_equals: value is "turn:turn.example.org", expected array
 FAIL setConfiguration(config) - with turn server, username, credential should succeed assert_array_equals: value is "turn:turn.example.org", expected array
-FAIL new RTCPeerConnection(config) - with turns server and empty string username, credential should succeed assert_array_equals: value is "turns:turn.example.org", expected array
-FAIL setConfiguration(config) - with turns server and empty string username, credential should succeed assert_array_equals: value is "turns:turn.example.org", expected array
-FAIL new RTCPeerConnection(config) - with turn server and empty string username, credential should succeed assert_array_equals: value is "turn:turn.example.org", expected array
-FAIL setConfiguration(config) - with turn server and empty string username, credential should succeed assert_array_equals: value is "turn:turn.example.org", expected array
+FAIL new RTCPeerConnection(config) - with turns server and empty string username, credential should succeed Bad Configuration Parameters
+FAIL setConfiguration(config) - with turns server and empty string username, credential should succeed Bad Configuration Parameters
+FAIL new RTCPeerConnection(config) - with turn server and empty string username, credential should succeed Bad Configuration Parameters
+FAIL setConfiguration(config) - with turn server and empty string username, credential should succeed Bad Configuration Parameters
 PASS new RTCPeerConnection(config) - with one turns server, one turn server, username, credential should succeed 
 PASS setConfiguration(config) - with one turns server, one turn server, username, credential should succeed 
 FAIL new RTCPeerConnection(config) - with stun server and credentialType password should succeed assert_array_equals: value is "stun:stun1.example.net", expected array
 FAIL setConfiguration(config) - with stun server and credentialType password should succeed assert_array_equals: value is "stun:stun1.example.net", expected array
-FAIL new RTCPeerConnection(config) - with turn server and no credentials should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turn:turn.example.net'
-      }] })" did not throw
-FAIL setConfiguration(config) - with turn server and no credentials should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turn:turn.example.net'
-      }] })" did not throw
-FAIL new RTCPeerConnection(config) - with turn server and only username should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turn:turn.example.net',
-        username: 'user'
-      }] })" did not throw
-FAIL setConfiguration(config) - with turn server and only username should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turn:turn.example.net',
-        username: 'user'
-      }] })" did not throw
-FAIL new RTCPeerConnection(config) - with turn server and only credential should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turn:turn.example.net',
-        credential: 'cred'
-      }] })" did not throw
-FAIL setConfiguration(config) - with turn server and only credential should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turn:turn.example.net',
-        credential: 'cred'
-      }] })" did not throw
-FAIL new RTCPeerConnection(config) - with turns server and no credentials should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turns:turn.example.net'
-      }] })" did not throw
-FAIL setConfiguration(config) - with turns server and no credentials should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turns:turn.example.net'
-      }] })" did not throw
-FAIL new RTCPeerConnection(config) - with turns server and only username should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turns:turn.example.net',
-        username: 'user'
-      }] })" did not throw
-FAIL setConfiguration(config) - with turns server and only username should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turns:turn.example.net',
-        username: 'user'
-      }] })" did not throw
-FAIL new RTCPeerConnection(config) - with turns server and only credential should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turns:turn.example.net',
-        credential: 'cred'
-      }] })" did not throw
-FAIL setConfiguration(config) - with turns server and only credential should throw InvalidAccessError assert_throws: function "() =>
-      makePc({ iceServers: [{
-        urls: 'turns:turn.example.net',
-        credential: 'cred'
-      }] })" did not throw
+PASS new RTCPeerConnection(config) - with turn server and no credentials should throw InvalidAccessError 
+PASS setConfiguration(config) - with turn server and no credentials should throw InvalidAccessError 
+PASS new RTCPeerConnection(config) - with turn server and only username should throw InvalidAccessError 
+PASS setConfiguration(config) - with turn server and only username should throw InvalidAccessError 
+PASS new RTCPeerConnection(config) - with turn server and only credential should throw InvalidAccessError 
+PASS setConfiguration(config) - with turn server and only credential should throw InvalidAccessError 
+PASS new RTCPeerConnection(config) - with turns server and no credentials should throw InvalidAccessError 
+PASS setConfiguration(config) - with turns server and no credentials should throw InvalidAccessError 
+PASS new RTCPeerConnection(config) - with turns server and only username should throw InvalidAccessError 
+PASS setConfiguration(config) - with turns server and only username should throw InvalidAccessError 
+PASS new RTCPeerConnection(config) - with turns server and only credential should throw InvalidAccessError 
+PASS setConfiguration(config) - with turns server and only credential should throw InvalidAccessError 
 FAIL new RTCPeerConnection(config) - with relative url should throw SyntaxError assert_throws: function "() =>
       makePc({ iceServers: [{
         urls: 'relative-url'
-      }] })" threw object "TypeError: Error creating RTCPeerConnection" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
+      }] })" threw object "NotSupportedError: ICE server protocol not supported" that is not a DOMException SyntaxError: property "code" is equal to 9, expected 12
 FAIL setConfiguration(config) - with relative url should throw SyntaxError assert_throws: function "() =>
       makePc({ iceServers: [{
         urls: 'relative-url'
-      }] })" threw object "InvalidAccessError: The object does not support the operation or argument." that is not a DOMException SyntaxError: property "code" is equal to 15, expected 12
+      }] })" threw object "NotSupportedError: ICE server protocol not supported" that is not a DOMException SyntaxError: property "code" is equal to 9, expected 12
 FAIL new RTCPeerConnection(config) - with http url should throw SyntaxError assert_throws: function "() =>
       makePc({ iceServers: [{
         urls: 'http://example.com'
-      }] })" threw object "TypeError: Error creating RTCPeerConnection" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
+      }] })" threw object "NotSupportedError: ICE server protocol not supported" that is not a DOMException SyntaxError: property "code" is equal to 9, expected 12
 FAIL setConfiguration(config) - with http url should throw SyntaxError assert_throws: function "() =>
       makePc({ iceServers: [{
         urls: 'http://example.com'
-      }] })" threw object "InvalidAccessError: The object does not support the operation or argument." that is not a DOMException SyntaxError: property "code" is equal to 15, expected 12
+      }] })" threw object "NotSupportedError: ICE server protocol not supported" that is not a DOMException SyntaxError: property "code" is equal to 9, expected 12
 FAIL new RTCPeerConnection(config) - with invalid turn url should throw SyntaxError assert_throws: function "() =>
       makePc({ iceServers: [{
         urls: 'turn://example.org/foo?x=y'
-      }] })" did not throw
+      }] })" threw object "InvalidAccessError: TURN/TURNS server requires both username and credential" that is not a DOMException SyntaxError: property "code" is equal to 15, expected 12
 FAIL setConfiguration(config) - with invalid turn url should throw SyntaxError assert_throws: function "() =>
       makePc({ iceServers: [{
         urls: 'turn://example.org/foo?x=y'
-      }] })" did not throw
+      }] })" threw object "InvalidAccessError: TURN/TURNS server requires both username and credential" that is not a DOMException SyntaxError: property "code" is equal to 15, expected 12
 FAIL new RTCPeerConnection(config) - with invalid stun url should throw SyntaxError assert_throws: function "() =>
       makePc({ iceServers: [{
         urls: 'stun://example.org/foo?x=y'
-      }] })" did not throw
+      }] })" threw object "InvalidAccessError: Bad Configuration Parameters" that is not a DOMException SyntaxError: property "code" is equal to 15, expected 12
 FAIL setConfiguration(config) - with invalid stun url should throw SyntaxError assert_throws: function "() =>
       makePc({ iceServers: [{
         urls: 'stun://example.org/foo?x=y'
-      }] })" did not throw
+      }] })" threw object "InvalidAccessError: Bad Configuration Parameters" that is not a DOMException SyntaxError: property "code" is equal to 15, expected 12
 FAIL new RTCPeerConnection(config) - with empty urls and credentialType password should succeed assert_equals: expected (string) "password" but got (undefined) undefined
 FAIL setConfiguration(config) - with empty urls and credentialType password should succeed assert_equals: expected (string) "password" but got (undefined) undefined
 FAIL new RTCPeerConnection(config) - with empty urls and credentialType oauth should succeed assert_equals: expected (string) "oauth" but got (undefined) undefined
index 4ce1a24..481744b 100644 (file)
@@ -16,35 +16,23 @@ PASS new RTCPeerConnection({ iceServers: [{ urls: ["stun:stun1.example.net"] }]
 PASS new RTCPeerConnection({ iceServers: [{ urls: ["stun:stun1.example.net", "stun:stun2.example.net"] }] }) 
 PASS new RTCPeerConnection({ iceServers: [{ urls: "turns:turn.example.org", username: "user", credential: "cred" }] }) 
 PASS new RTCPeerConnection({ iceServers: [{ urls: "turn:turn.example.net", username: "user", credential: "cred" }] }) 
-PASS new RTCPeerConnection({ iceServers: [{ urls: "turns:turn.example.org", username: "", credential: "" }] }) 
-PASS new RTCPeerConnection({ iceServers: [{ urls: "turn:turn.example.net", username: "", credential: "" }] }) 
+FAIL new RTCPeerConnection({ iceServers: [{ urls: "turns:turn.example.org", username: "", credential: "" }] }) Bad Configuration Parameters
+FAIL new RTCPeerConnection({ iceServers: [{ urls: "turn:turn.example.net", username: "", credential: "" }] }) Bad Configuration Parameters
 PASS new RTCPeerConnection({ iceServers: [{ urls: ["turns:turn.example.org", "turn:turn.example.net"], username: "user", credential: "cred" }] }) 
 PASS new RTCPeerConnection({ iceServers: [{ urls: "stun:stun1.example.net", credentialType: "password" }] }) 
 PASS new RTCPeerConnection({ iceServers: [{ urls: "stun:stun1.example.net", credentialType: "token" }] }) 
-FAIL new RTCPeerConnection({ iceServers: [{ urls: "turn:turn.example.net" }] }) assert_throws: function "function () {
-        eval(expr);
-      }" did not throw
-FAIL new RTCPeerConnection({ iceServers: [{ urls: "turn:turn.example.net", username: "user" }] }) assert_throws: function "function () {
-        eval(expr);
-      }" did not throw
-FAIL new RTCPeerConnection({ iceServers: [{ urls: "turn:turn.example.net", credential: "cred" }] }) assert_throws: function "function () {
-        eval(expr);
-      }" did not throw
-FAIL new RTCPeerConnection({ iceServers: [{ urls: "turns:turn.example.org" }] }) assert_throws: function "function () {
-        eval(expr);
-      }" did not throw
-FAIL new RTCPeerConnection({ iceServers: [{ urls: "turns:turn.example.org", username: "user" }] }) assert_throws: function "function () {
-        eval(expr);
-      }" did not throw
-FAIL new RTCPeerConnection({ iceServers: [{ urls: "turns:turn.example.org", credential: "cred" }] }) assert_throws: function "function () {
-        eval(expr);
-      }" did not throw
+PASS new RTCPeerConnection({ iceServers: [{ urls: "turn:turn.example.net" }] }) 
+PASS new RTCPeerConnection({ iceServers: [{ urls: "turn:turn.example.net", username: "user" }] }) 
+PASS new RTCPeerConnection({ iceServers: [{ urls: "turn:turn.example.net", credential: "cred" }] }) 
+PASS new RTCPeerConnection({ iceServers: [{ urls: "turns:turn.example.org" }] }) 
+PASS new RTCPeerConnection({ iceServers: [{ urls: "turns:turn.example.org", username: "user" }] }) 
+PASS new RTCPeerConnection({ iceServers: [{ urls: "turns:turn.example.org", credential: "cred" }] }) 
 FAIL new RTCPeerConnection({ iceServers: [{ urls: "relative-url" }] }) assert_throws: function "function () {
         eval(expr);
-      }" threw object "TypeError: Error creating RTCPeerConnection" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
+      }" threw object "NotSupportedError: ICE server protocol not supported" that is not a DOMException SyntaxError: property "code" is equal to 9, expected 12
 FAIL new RTCPeerConnection({ iceServers: [{ urls: "http://example.com" }] }) assert_throws: function "function () {
         eval(expr);
-      }" threw object "TypeError: Error creating RTCPeerConnection" that is not a DOMException SyntaxError: property "code" is equal to undefined, expected 12
+      }" threw object "NotSupportedError: ICE server protocol not supported" that is not a DOMException SyntaxError: property "code" is equal to 9, expected 12
 PASS new RTCPeerConnection({ iceServers: [{ urls: [], credentialType: "password" }] }) 
 PASS new RTCPeerConnection({ iceServers: [{ urls: [], credentialType: "token" }] }) 
 FAIL new RTCPeerConnection({ iceServers: [{ urls: [], credentialType: "invalid" }] }) assert_throws: function "function () {
index f3bcea6..97733ed 100644 (file)
@@ -594,7 +594,6 @@ webkit.org/b/79203 fast/mediastream/RTCPeerConnection-closed-state.html [ Failur
 webkit.org/b/79203 fast/mediastream/RTCPeerConnection-createAnswer.html [ Failure ]
 webkit.org/b/79203 fast/mediastream/RTCPeerConnection-createOffer.html [ Failure ]
 webkit.org/b/79203 fast/mediastream/RTCPeerConnection-datachannel.html [ Failure ]
-webkit.org/b/79203 fast/mediastream/RTCPeerConnection-getConfiguration.html [ Failure ]
 webkit.org/b/79203 fast/mediastream/RTCPeerConnection-have-local-offer.html [ Failure ]
 webkit.org/b/79203 fast/mediastream/RTCPeerConnection-have-local-pranswer.html [ Failure ]
 webkit.org/b/79203 fast/mediastream/RTCPeerConnection-have-remote-offer.html [ Failure ]
@@ -614,7 +613,6 @@ webkit.org/b/79203 fast/mediastream/RTCPeerConnection-overloaded-operations.html
 webkit.org/b/79203 fast/mediastream/RTCPeerConnection-remoteDescription.html [ Failure ]
 webkit.org/b/79203 fast/mediastream/RTCPeerConnection-stable.html [ Failure ]
 webkit.org/b/79203 fast/mediastream/RTCPeerConnection-statsSelector.html [ Failure ]
-webkit.org/b/79203 fast/mediastream/RTCPeerConnection.html [ Failure ]
 webkit.org/b/79203 fast/mediastream/RTCTrackEvent-constructor.html [ Failure ]
 webkit.org/b/79203 webaudio/mediastreamaudiosourcenode.html [ Failure ]
 webkit.org/b/79203 fast/mediastream/MediaStream-video-element-displays-buffer.html [ Crash ]
index 129df93..87d7fae 100644 (file)
@@ -1054,7 +1054,6 @@ fast/mediastream/RTCPeerConnection-addTransceiver.html [ Pass ]
 fast/mediastream/RTCPeerConnection-createAnswer.html [ Pass ]
 fast/mediastream/RTCPeerConnection-createOffer.html [ Pass ]
 fast/mediastream/RTCPeerConnection-datachannel.html [ Pass ]
-fast/mediastream/RTCPeerConnection-getConfiguration.html [ Pass ]
 fast/mediastream/RTCPeerConnection-have-local-offer.html [ Pass ]
 fast/mediastream/RTCPeerConnection-have-local-pranswer.html [ Pass ]
 fast/mediastream/RTCPeerConnection-have-remote-offer.html [ Pass ]
@@ -1072,7 +1071,6 @@ fast/mediastream/RTCPeerConnection-setLocalDescription-offer.html [ Pass ]
 fast/mediastream/RTCPeerConnection-setRemoteDescription-offer.html [ Pass ]
 fast/mediastream/RTCPeerConnection-stable.html [ Pass ]
 fast/mediastream/RTCPeerConnection-statsSelector.html [ Pass ]
-fast/mediastream/RTCPeerConnection.html [ Pass ]
 fast/mediastream/RTCSessionDescription.html [ Pass ]
 fast/mediastream/RTCTrackEvent-constructor.html [ Pass ]
 
index e7d3fc3..99752fd 100644 (file)
@@ -1,5 +1,26 @@
 2018-03-15  Youenn Fablet  <youenn@apple.com>
 
+        Bad configuration parameters should make RTCPeerConnection constructor throw
+        https://bugs.webkit.org/show_bug.cgi?id=183615
+
+        Reviewed by Eric Carlson.
+
+        Implement more of https://w3c.github.io/webrtc-pc/#set-pc-configuration.
+        Throw an error whenever underlying libwebrtc set configuration fails.
+
+        Covered by rebased test.
+
+        * Modules/mediastream/PeerConnectionBackend.h:
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::iceServersFromConfiguration):
+        (WebCore::RTCPeerConnection::initializeConfiguration):
+        (WebCore::RTCPeerConnection::setConfiguration):
+        * Modules/mediastream/RTCPeerConnection.js:
+        (initializeRTCPeerConnection):
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
+
+2018-03-15  Youenn Fablet  <youenn@apple.com>
+
         replaceTrack triggers negotiationneeded
         https://bugs.webkit.org/show_bug.cgi?id=180342
         <rdar://problem/35822426>
index 9ef42ea..61c1dc6 100644 (file)
@@ -125,6 +125,8 @@ public:
     WTFLogChannel& logChannel() const final;
 #endif
 
+    virtual bool isLocalDescriptionSet() const = 0;
+
 protected:
     void fireICECandidateEvent(RefPtr<RTCIceCandidate>&&);
     void doneGatheringCandidates();
index a5832b7..851c9c8 100644 (file)
@@ -300,12 +300,19 @@ void RTCPeerConnection::queuedAddIceCandidate(RTCIceCandidate* rtcCandidate, DOM
     m_backend->addIceCandidate(rtcCandidate, WTFMove(promise));
 }
 
-static inline std::optional<Vector<MediaEndpointConfiguration::IceServerInfo>> iceServersFromConfiguration(RTCConfiguration& configuration)
+// Implementation of https://w3c.github.io/webrtc-pc/#set-pc-configuration
+static inline ExceptionOr<Vector<MediaEndpointConfiguration::IceServerInfo>> iceServersFromConfiguration(RTCConfiguration& newConfiguration, std::optional<const RTCConfiguration&> existingConfiguration, bool isLocalDescriptionSet)
 {
+    if (existingConfiguration && newConfiguration.bundlePolicy != existingConfiguration->bundlePolicy)
+        return Exception { InvalidModificationError, "IceTransportPolicy does not match existing policy" };
+
+    if (existingConfiguration && newConfiguration.iceCandidatePoolSize != existingConfiguration->iceCandidatePoolSize && isLocalDescriptionSet)
+        return Exception { InvalidModificationError, "IceTransportPolicy pool size does not match existing pool size" };
+
     Vector<MediaEndpointConfiguration::IceServerInfo> servers;
-    if (configuration.iceServers) {
-        servers.reserveInitialCapacity(configuration.iceServers->size());
-        for (auto& server : configuration.iceServers.value()) {
+    if (newConfiguration.iceServers) {
+        servers.reserveInitialCapacity(newConfiguration.iceServers->size());
+        for (auto& server : newConfiguration.iceServers.value()) {
             Vector<URL> serverURLs;
             WTF::switchOn(server.urls, [&serverURLs] (const String& string) {
                 serverURLs.reserveInitialCapacity(1);
@@ -316,26 +323,31 @@ static inline std::optional<Vector<MediaEndpointConfiguration::IceServerInfo>> i
                     serverURLs.uncheckedAppend(URL { URL { }, string });
             });
             for (auto& serverURL : serverURLs) {
-                if (!(serverURL.protocolIs("turn") || serverURL.protocolIs("turns") || serverURL.protocolIs("stun")))
-                    return std::nullopt;
+                if (serverURL.isNull())
+                    return Exception { TypeError, "Bad ICE server URL" };
+                if (serverURL.protocolIs("turn") || serverURL.protocolIs("turns")) {
+                    if (server.credential.isNull() || server.username.isNull())
+                        return Exception { InvalidAccessError, "TURN/TURNS server requires both username and credential" };
+                } else if (!serverURL.protocolIs("stun"))
+                    return Exception { NotSupportedError, "ICE server protocol not supported" };
             }
-            servers.uncheckedAppend({ WTFMove(serverURLs), server.credential, server.username });
+            if (serverURLs.size())
+                servers.uncheckedAppend({ WTFMove(serverURLs), server.credential, server.username });
         }
     }
-    return servers;
+    return WTFMove(servers);
 }
 
 ExceptionOr<void> RTCPeerConnection::initializeConfiguration(RTCConfiguration&& configuration)
 {
     INFO_LOG(LOGIDENTIFIER);
 
-    auto servers = iceServersFromConfiguration(configuration);
-    if (!servers)
-        return Exception { InvalidAccessError };
+    auto servers = iceServersFromConfiguration(configuration, std::nullopt, false);
+    if (servers.hasException())
+        return servers.releaseException();
 
-    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=173938
-    // Also decide whether to report an exception or output a message in the console log if setting configuration fails.
-    m_backend->setConfiguration({ WTFMove(servers.value()), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.iceCandidatePoolSize });
+    if (!m_backend->setConfiguration({ servers.releaseReturnValue(), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.iceCandidatePoolSize }))
+        return Exception { InvalidAccessError, "Bad Configuration Parameters" };
 
     m_configuration = WTFMove(configuration);
     return { };
@@ -348,13 +360,13 @@ ExceptionOr<void> RTCPeerConnection::setConfiguration(RTCConfiguration&& configu
 
     INFO_LOG(LOGIDENTIFIER);
 
-    auto servers = iceServersFromConfiguration(configuration);
-    if (!servers)
-        return Exception { InvalidAccessError };
+    auto servers = iceServersFromConfiguration(configuration, m_configuration, m_backend->isLocalDescriptionSet());
+    if (servers.hasException())
+        return servers.releaseException();
+
+    if (!m_backend->setConfiguration({ servers.releaseReturnValue(), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.iceCandidatePoolSize }))
+        return Exception { InvalidAccessError, "Bad Configuration Parameters" };
 
-    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=173938
-    // Also decide whether to report an exception or output a message in the console log if setting configuration fails.
-    m_backend->setConfiguration({ WTFMove(servers.value()), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.iceCandidatePoolSize });
     m_configuration = WTFMove(configuration);
     return { };
 }
index 92f2f1c..2ce6749 100644 (file)
@@ -39,14 +39,7 @@ function initializeRTCPeerConnection(configuration)
     else if (!@isObject(configuration))
         @throwTypeError("RTCPeerConnection argument must be a valid dictionary");
 
-    // FIXME: Handle errors in a better way than catching and re-throwing (http://webkit.org/b/158936)
-    try {
-        this.@initializeWith(configuration);
-    } catch (e) {
-        const message = e.name === "TypeMismatchError" ? "Invalid RTCPeerConnection constructor arguments"
-            : "Error creating RTCPeerConnection";
-        @throwTypeError(message);
-    }
+    this.@initializeWith(configuration);
     this.@operations = [];
     this.@localStreams = [];
 
index 4f49d71..283a716 100644 (file)
@@ -105,6 +105,8 @@ private:
     AudioReceiver audioReceiver(String&& trackId);
 
 private:
+    bool isLocalDescriptionSet() const final { return m_isLocalDescriptionSet; }
+
     Ref<LibWebRTCMediaEndpoint> m_endpoint;
     bool m_isLocalDescriptionSet { false };
     bool m_isRemoteDescriptionSet { false };