| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
| 5 </head> | 6 </head> |
| 6 <body> | 7 <body> |
| 7 <p id="description"></p> | |
| 8 <div id="console"></div> | |
| 9 <script> | 8 <script> |
| 10 description("Tests RTCIceCandidate."); | 9 function getInitializer() { |
| 10 return { |
| 11 candidate: 'foo', |
| 12 sdpMid:'bar', |
| 13 sdpMLineIndex: 6 |
| 14 }; |
| 15 } |
| 11 | 16 |
| 12 var initializer = {candidate:"foo", sdpMid:"bar", sdpMLineIndex:6}; | 17 test(function() { |
| 13 var candidate; | 18 let candidate = new RTCIceCandidate(getInitializer()); |
| 14 shouldNotThrow('candidate = new RTCIceCandidate(initializer);'); | 19 assert_equals(candidate.candidate, 'foo'); |
| 15 shouldBeEqualToString('candidate.candidate', 'foo'); | 20 assert_equals(candidate.sdpMid, 'bar'); |
| 16 shouldBeEqualToString('candidate.sdpMid', 'bar'); | 21 assert_equals(candidate.sdpMLineIndex, 6); |
| 17 shouldBe('candidate.sdpMLineIndex', '6'); | |
| 18 | 22 |
| 19 shouldNotThrow('initializer = JSON.parse(JSON.stringify(candidate));'); | 23 const initializer = JSON.parse(JSON.stringify(candidate)); |
| 24 candidate = new RTCIceCandidate(initializer); |
| 25 assert_equals(candidate.candidate, 'foo'); |
| 26 assert_equals(candidate.sdpMid, 'bar'); |
| 27 assert_equals(candidate.sdpMLineIndex, 6); |
| 28 }, 'Constructor can be initialized with output from another constructor'); |
| 20 | 29 |
| 21 shouldNotThrow('candidate = new RTCIceCandidate(initializer);'); | 30 test(function() { |
| 22 shouldBeEqualToString('candidate.candidate', 'foo'); | 31 assert_throws('TypeMismatchError', () => new RTCIceCandidate({})); |
| 23 shouldBeEqualToString('candidate.sdpMid', 'bar'); | 32 assert_throws({name: 'TypeError'}, () => new RTCIceCandidate(5)); |
| 24 shouldBe('candidate.sdpMLineIndex', '6'); | 33 assert_throws({name: 'TypeError'}, () => new RTCIceCandidate('foobar')); |
| 34 assert_throws('TypeMismatchError', () => new RTCIceCandidate({candidate: ''}
)); |
| 35 }, 'Constructor throws on invalid input'); |
| 25 | 36 |
| 26 shouldThrow('new RTCIceCandidate({});'); | 37 test(function() { |
| 27 shouldThrow('new RTCIceCandidate(5);'); | 38 new RTCIceCandidate({candidate: 'x'}) |
| 28 shouldThrow('new RTCIceCandidate("foobar");'); | 39 }, 'Constructor does not throw on valid input'); |
| 29 shouldThrow('new RTCIceCandidate({candidate:""});'); | |
| 30 | 40 |
| 31 shouldNotThrow('new RTCIceCandidate({candidate:"x"});'); | 41 test(function() { |
| 42 const candidate = new RTCIceCandidate(getInitializer()); |
| 43 candidate.candidate = 'bar'; |
| 44 candidate.sdpMid = 'foo'; |
| 45 candidate.sdpMLineIndex = 0; |
| 46 assert_equals(candidate.candidate, 'bar'); |
| 47 assert_equals(candidate.sdpMid, 'foo'); |
| 48 assert_equals(candidate.sdpMLineIndex, 0); |
| 32 | 49 |
| 33 candidate = new RTCIceCandidate(initializer); | 50 candidate.candidate = null; |
| 34 candidate.candidate = "bar"; | 51 candidate.sdpMid = null; |
| 35 candidate.sdpMid = "foo"; | 52 assert_equals(candidate.candidate, 'null'); |
| 36 candidate.sdpMLineIndex = 0; | 53 assert_equals(candidate.sdpMid, 'null'); |
| 37 shouldBeEqualToString('candidate.candidate', 'bar'); | 54 }, 'candidate, sdpMid, and sdpMLineIndex properties can be modified'); |
| 38 shouldBeEqualToString('candidate.sdpMid', 'foo'); | |
| 39 shouldBe('candidate.sdpMLineIndex', '0'); | |
| 40 | |
| 41 candidate.candidate = null; | |
| 42 candidate.sdpMid = null; | |
| 43 shouldBeEqualToString('candidate.candidate', 'null'); | |
| 44 shouldBeEqualToString('candidate.sdpMid', 'null'); | |
| 45 | |
| 46 window.successfullyParsed = true; | |
| 47 </script> | 55 </script> |
| 48 </body> | 56 </body> |
| 49 </html> | 57 </html> |
| OLD | NEW |