Bug 1523562 [wpt PR 15001] - [PeerConnection] Improve spec compliance of RTCIceCandidate constructor, a=testonly

Automatic update from web-platform-tests
[PeerConnection] Improve spec compliance of RTCIceCandidate constructor

The constructor should throw TypeError if sdpMid and sdpMLineIndex are
both null.
The RTCIceCandidateInit parameter in the RTCIceCandidate constructor is
optional.

This CL makes minor changes to WPT tests:
* RTCIceTransport-extension.https.html is made spec compliant by
constructing RTCIceCandidates that don't have both sdpMid and
sdpMLineIndex null.
* RTCIceCandidate-constructor.html has error-reporting improvements.

Bug: 683094
Change-Id: I875142d50bf761b934be3a0325029c458aa465c8
Reviewed-on: https://chromium-review.googlesource.com/c/1425616
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: Henrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626087}

--

wpt-commits: b1aba2545af037a8bd495dec2be6713f6144d000
wpt-pr: 15001
This commit is contained in:
Guido Urdaneta 2019-02-01 11:39:46 +00:00 коммит произвёл James Graham
Родитель 166457eb7c
Коммит 6e4d00ba02
2 изменённых файлов: 42 добавлений и 41 удалений

Просмотреть файл

@ -74,19 +74,19 @@
test(t => {
const candidate = new RTCIceCandidate({ sdpMid: 'audio' });
assert_equals(candidate.candidate, '');
assert_equals(candidate.sdpMid, 'audio');
assert_equals(candidate.sdpMLineIndex, null);
assert_equals(candidate.usernameFragment, null);
assert_equals(candidate.candidate, '', 'candidate');
assert_equals(candidate.sdpMid, 'audio', 'sdpMid');
assert_equals(candidate.sdpMLineIndex, null, 'sdpMLineIndex');
assert_equals(candidate.usernameFragment, null, 'usernameFragment');
}, `new RTCIceCandidate({ sdpMid: 'audio' })`);
test(t => {
const candidate = new RTCIceCandidate({ sdpMLineIndex: 0 });
assert_equals(candidate.candidate, '');
assert_equals(candidate.sdpMid, null);
assert_equals(candidate.sdpMLineIndex, 0);
assert_equals(candidate.usernameFragment, null);
assert_equals(candidate.candidate, '', 'candidate');
assert_equals(candidate.sdpMid, null, 'sdpMid');
assert_equals(candidate.sdpMLineIndex, 0, 'sdpMLineIndex');
assert_equals(candidate.usernameFragment, null, 'usernameFragment');
}, 'new RTCIceCandidate({ sdpMLineIndex: 0 })');
test(t => {
@ -95,10 +95,10 @@
sdpMLineIndex: 0
});
assert_equals(candidate.candidate, '');
assert_equals(candidate.sdpMid, 'audio');
assert_equals(candidate.sdpMLineIndex, 0);
assert_equals(candidate.usernameFragment, null);
assert_equals(candidate.candidate, '', 'candidate');
assert_equals(candidate.sdpMid, 'audio', 'sdpMid');
assert_equals(candidate.sdpMLineIndex, 0, 'sdpMLineIndex');
assert_equals(candidate.usernameFragment, null, 'usernameFragment');
}, `new RTCIceCandidate({ sdpMid: 'audio', sdpMLineIndex: 0 })`);
test(t => {
@ -107,10 +107,10 @@
sdpMid: 'audio'
});
assert_equals(candidate.candidate, '');
assert_equals(candidate.sdpMid, 'audio');
assert_equals(candidate.sdpMLineIndex, null);
assert_equals(candidate.usernameFragment, null);
assert_equals(candidate.candidate, '', 'candidate');
assert_equals(candidate.sdpMid, 'audio', 'sdpMid');
assert_equals(candidate.sdpMLineIndex, null, 'sdpMLineIndex');
assert_equals(candidate.usernameFragment, null, 'usernameFragment');
}, `new RTCIceCandidate({ candidate: '', sdpMid: 'audio' }`);
test(t => {
@ -119,10 +119,10 @@
sdpMLineIndex: 0
});
assert_equals(candidate.candidate, '');
assert_equals(candidate.sdpMid, null);
assert_equals(candidate.sdpMLineIndex, 0);
assert_equals(candidate.usernameFragment, null);
assert_equals(candidate.candidate, '', 'candidate');
assert_equals(candidate.sdpMid, null, 'sdpMid', 'sdpMid');
assert_equals(candidate.sdpMLineIndex, 0, 'sdpMLineIndex');
assert_equals(candidate.usernameFragment, null, 'usernameFragment');
}, `new RTCIceCandidate({ candidate: '', sdpMLineIndex: 0 }`);
test(t => {
@ -131,10 +131,10 @@
sdpMid: 'audio'
});
assert_equals(candidate.candidate, candidateString);
assert_equals(candidate.sdpMid, 'audio');
assert_equals(candidate.sdpMLineIndex, null);
assert_equals(candidate.usernameFragment, null);
assert_equals(candidate.candidate, candidateString, 'candidate');
assert_equals(candidate.sdpMid, 'audio', 'sdpMid');
assert_equals(candidate.sdpMLineIndex, null, 'sdpMLineIndex');
assert_equals(candidate.usernameFragment, null, 'usernameFragment');
}, 'new RTCIceCandidate({ ... }) with valid candidate string and sdpMid');
test(t =>{
@ -144,10 +144,10 @@
sdpMid: 'audio'
});
assert_equals(candidate.candidate, arbitraryString);
assert_equals(candidate.sdpMid, 'audio');
assert_equals(candidate.sdpMLineIndex, null);
assert_equals(candidate.usernameFragment, null);
assert_equals(candidate.candidate, arbitraryString, 'candidate');
assert_equals(candidate.sdpMid, 'audio', 'sdpMid');
assert_equals(candidate.sdpMLineIndex, null, 'sdpMLineIndex');
assert_equals(candidate.usernameFragment, null, 'usernameFragment');
}, 'new RTCIceCandidate({ ... }) with invalid candidate string and sdpMid');
test(t => {
@ -158,10 +158,10 @@
usernameFragment: 'test'
});
assert_equals(candidate.candidate, candidateString);
assert_equals(candidate.sdpMid, 'video');
assert_equals(candidate.sdpMLineIndex, 1);
assert_equals(candidate.usernameFragment, 'test');
assert_equals(candidate.candidate, candidateString, 'candidate');
assert_equals(candidate.sdpMid, 'video', 'sdpMid');
assert_equals(candidate.sdpMLineIndex, 1, 'sdpMLineIndex');
assert_equals(candidate.usernameFragment, 'test', 'usernameFragment');
}, 'new RTCIceCandidate({ ... }) with non default value for all fields');
@ -171,10 +171,10 @@
sdpMid: arbitraryString
});
assert_equals(candidate.candidate, '');
assert_equals(candidate.sdpMid, arbitraryString);
assert_equals(candidate.sdpMLineIndex, null);
assert_equals(candidate.usernameFragment, null);
assert_equals(candidate.candidate, '', 'candidate');
assert_equals(candidate.sdpMid, arbitraryString, 'sdpMid');
assert_equals(candidate.sdpMLineIndex, null, 'sdpMLineIndex');
assert_equals(candidate.usernameFragment, null, 'usernameFragment');
}, 'new RTCIceCandidate({ ... }) with invalid sdpMid');
@ -187,10 +187,10 @@
sdpMLineIndex: 65535
});
assert_equals(candidate.candidate, '');
assert_equals(candidate.sdpMid, null);
assert_equals(candidate.sdpMLineIndex, 65535);
assert_equals(candidate.usernameFragment, null);
assert_equals(candidate.candidate, '', 'candidate');
assert_equals(candidate.sdpMid, null, 'sdpMid');
assert_equals(candidate.sdpMLineIndex, 65535, 'sdpMLineIndex');
assert_equals(candidate.usernameFragment, null, 'usernameFragment');
}, 'new RTCIceCandidate({ ... }) with invalid sdpMLineIndex');
</script>

Просмотреть файл

@ -177,6 +177,7 @@ test(t => {
const candidate1 = new RTCIceCandidate({
candidate: 'candidate:1 1 udp 2113929471 203.0.113.100 10100 typ host',
sdpMid: '',
});
test(() => {
@ -191,7 +192,7 @@ test(() => {
const iceTransport = new RTCIceTransport();
assert_throws('OperationError',
() => iceTransport.addRemoteCandidate(
new RTCIceCandidate({ candidate: 'invalid' })));
new RTCIceCandidate({ candidate: 'invalid', sdpMid: '' })));
assert_array_equals(iceTransport.getRemoteCandidates(), []);
}, 'addRemoteCandidate() throws on invalid candidate');