Chromium Code Reviews| 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 <p id="description"></p> |
| 8 <div id="console"></div> | 9 <div id="console"></div> |
| 9 <script> | 10 <script> |
| 10 description("Tests RTCIceCandidate."); | 11 function getInitializer() { |
| 12 return { | |
| 13 candidate: 'foo', | |
| 14 sdpMid:'bar', | |
| 15 sdpMLineIndex: 6 | |
| 16 }; | |
| 17 } | |
| 11 | 18 |
| 12 var initializer = {candidate:"foo", sdpMid:"bar", sdpMLineIndex:6}; | 19 test(function() { |
| 13 var candidate; | 20 let candidate = new RTCIceCandidate(getInitializer()); |
| 14 shouldNotThrow('candidate = new RTCIceCandidate(initializer);'); | 21 assert_equals(candidate.candidate, 'foo'); |
| 15 shouldBeEqualToString('candidate.candidate', 'foo'); | 22 assert_equals(candidate.sdpMid, 'bar'); |
| 16 shouldBeEqualToString('candidate.sdpMid', 'bar'); | 23 assert_equals(candidate.sdpMLineIndex, 6); |
| 17 shouldBe('candidate.sdpMLineIndex', '6'); | |
| 18 | 24 |
| 19 shouldNotThrow('initializer = JSON.parse(JSON.stringify(candidate));'); | 25 const initializer = JSON.parse(JSON.stringify(candidate)); |
| 26 candidate = new RTCIceCandidate(initializer); | |
| 27 assert_equals(candidate.candidate, 'foo'); | |
| 28 assert_equals(candidate.sdpMid, 'bar'); | |
| 29 assert_equals(candidate.sdpMLineIndex, 6); | |
| 30 }); | |
| 20 | 31 |
| 21 shouldNotThrow('candidate = new RTCIceCandidate(initializer);'); | 32 assert_throws('TypeMismatchError', () => new RTCIceCandidate({})); |
|
qyearsley
2016/08/26 21:34:05
This is the first time I've seen ES6 arrow functio
| |
| 22 shouldBeEqualToString('candidate.candidate', 'foo'); | 33 assert_throws({name: 'TypeError'}, () => new RTCIceCandidate(5)); |
| 23 shouldBeEqualToString('candidate.sdpMid', 'bar'); | 34 assert_throws({name: 'TypeError'}, () => new RTCIceCandidate('foobar')); |
| 24 shouldBe('candidate.sdpMLineIndex', '6'); | 35 assert_throws('TypeMismatchError', () => new RTCIceCandidate({candidate: ''})); |
|
qyearsley
2016/08/26 21:34:05
Should these asserts be inside of a function passe
| |
| 25 | 36 |
| 26 shouldThrow('new RTCIceCandidate({});'); | 37 test(() => new RTCIceCandidate({candidate: 'x'})); |
|
qyearsley
2016/08/26 21:34:05
To make it explicit that we're expecting no except
| |
| 27 shouldThrow('new RTCIceCandidate(5);'); | |
| 28 shouldThrow('new RTCIceCandidate("foobar");'); | |
| 29 shouldThrow('new RTCIceCandidate({candidate:""});'); | |
| 30 | 38 |
| 31 shouldNotThrow('new RTCIceCandidate({candidate:"x"});'); | 39 test(function() { |
| 40 const candidate = new RTCIceCandidate(getInitializer()); | |
| 41 candidate.candidate = 'bar'; | |
| 42 candidate.sdpMid = 'foo'; | |
| 43 candidate.sdpMLineIndex = 0; | |
| 44 assert_equals(candidate.candidate, 'bar'); | |
| 45 assert_equals(candidate.sdpMid, 'foo'); | |
| 46 assert_equals(candidate.sdpMLineIndex, 0); | |
| 32 | 47 |
| 33 candidate = new RTCIceCandidate(initializer); | 48 candidate.candidate = null; |
| 34 candidate.candidate = "bar"; | 49 candidate.sdpMid = null; |
| 35 candidate.sdpMid = "foo"; | 50 assert_equals(candidate.candidate, 'null'); |
| 36 candidate.sdpMLineIndex = 0; | 51 assert_equals(candidate.sdpMid, 'null'); |
| 37 shouldBeEqualToString('candidate.candidate', 'bar'); | 52 }); |
|
qyearsley
2016/08/26 21:34:05
Although, it wasn't in the original code, if we co
| |
| 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> | 53 </script> |
| 48 </body> | 54 </body> |
| 49 </html> | 55 </html> |
| OLD | NEW |