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/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <script> | 7 <script> |
8 description("Tests RTCPeerConnection createOffer."); | 8 description("Tests RTCPeerConnection createOffer."); |
9 | 9 |
10 // Note: createOffer() calls in the test runner are successful if the | 10 // Note: createOffer() calls in the test runner are successful if the |
11 // voiceActivityDetection and iceRestart options are passed with a value of true
. | 11 // voiceActivityDetection and iceRestart options are passed with a value of true
. |
12 // In all other cases, createOffer() fails in the test runner. | 12 // In all other cases, createOffer() fails in the test runner. |
13 | 13 |
14 var pc = null; | 14 var pc = null; |
15 | 15 |
16 function dummy() {} | 16 function unexpectedCallback() |
17 | |
18 function requestFailed2(reason) | |
19 { | 17 { |
20 testPassed('requestFailed was called.'); | 18 testFailed('unexpectedCallback was called') |
21 | |
22 errorReason = reason; | |
23 shouldBe('errorReason', '"TEST_ERROR"'); | |
24 | |
25 shouldNotThrow("pc.createOffer(dummy, dummy);"); | |
26 shouldNotThrow("pc.createOffer(dummy, dummy, {});"); | |
27 shouldNotThrow("pc.createOffer(dummy, dummy, {voiceActivityDetection:false})
;"); | |
28 shouldNotThrow("pc.createOffer(dummy, dummy, {iceRestart:true});"); | |
29 shouldNotThrow("pc.createOffer(dummy, dummy, {voiceActivityDetection:false,
iceRestart:true});"); | |
30 | |
31 // Deprecated. | |
32 shouldThrow("pc.createOffer(dummy, dummy, {offerToReceiveVideo:-1, offerToRe
ceiveAudio:0});"); | |
33 shouldThrow("pc.createOffer(dummy, dummy, {offerToReceiveVideo:0, offerToRec
eiveAudio:-1});"); | |
34 shouldNotThrow("pc.createOffer(dummy, dummy, {offerToReceiveVideo:1, offerTo
ReceiveAudio:0, voiceActivityDetection:false, iceRestart:true});"); | |
35 | |
36 finishJSTest(); | 19 finishJSTest(); |
37 } | 20 } |
38 | 21 |
39 function requestSucceeded2(sd) | 22 function expectedInvalidOfferToReceiveAudio(reason) |
40 { | 23 { |
41 testFailed('requestSucceeded was called.'); | 24 testPassed('expectedInvalidOfferToReceiveVideo called.'); |
| 25 window.error = reason; |
| 26 shouldBe('error', '"Invalid offerToReceiveAudio"'); |
42 finishJSTest(); | 27 finishJSTest(); |
43 } | 28 } |
44 | 29 |
45 function requestFailed1() | 30 function expectedInvalidOfferToReceiveVideo(reason) |
46 { | 31 { |
47 testFailed('requestFailed was called.'); | 32 testPassed('expectedInvalidOfferToReceiveVideo called.'); |
48 finishJSTest(); | 33 window.error = reason; |
| 34 shouldBe('error', '"Invalid offerToReceiveVideo"'); |
| 35 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedInvalidOfferToRec
eiveAudio, {offerToReceiveVideo:0, offerToReceiveAudio:-1});"); |
49 } | 36 } |
50 | 37 |
51 function requestSucceeded1(sd) | 38 function expectedCreateOfferFailed5(reason) { |
52 { | 39 testPassed('expectedCreateOfferFailed5 was called.'); |
53 testPassed('requestSucceeded was called.'); | 40 window.error = reason; |
54 | 41 shouldBe('error', '"TEST_ERROR"'); |
55 sessionDescription = sd; | 42 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedInvalidOfferToRec
eiveVideo, {offerToReceiveVideo:-1, offerToReceiveAudio:0});"); |
56 shouldBe('sessionDescription.type', '"offer"'); | |
57 | |
58 pc.createOffer(requestSucceeded2, requestFailed2); | |
59 } | 43 } |
60 | 44 |
| 45 function createOfferSucceeded2() { |
| 46 testPassed('createOfferSucceeded2 was called.'); |
| 47 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedCreateOfferFailed
5, {offerToReceiveVideo:1, offerToReceiveAudio:0, voiceActivityDetection:false,
iceRestart:true});"); |
| 48 } |
| 49 |
| 50 function expectedCreateOfferFailed4(reason) { |
| 51 testPassed('expectedCreateOfferFailed4 was called.'); |
| 52 window.error = reason; |
| 53 shouldBe('error', '"TEST_ERROR"'); |
| 54 shouldNotThrow("pc.createOffer(createOfferSucceeded2, unexpectedCallback, {i
ceRestart:true});"); |
| 55 } |
| 56 |
| 57 function expectedCreateOfferFailed3(reason) { |
| 58 testPassed('expectedCreateOfferFailed3 was called.'); |
| 59 window.error = reason; |
| 60 shouldBe('error', '"TEST_ERROR"'); |
| 61 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedCreateOfferFailed
4, {voiceActivityDetection:false});"); |
| 62 } |
| 63 |
| 64 function expectedCreateOfferFailed2(reason) { |
| 65 testPassed('expectedCreateOfferFailed2 was called.'); |
| 66 window.error = reason; |
| 67 shouldBe('error', '"TEST_ERROR"'); |
| 68 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedCreateOfferFailed
3, {});"); |
| 69 } |
| 70 |
| 71 function expectedCreateOfferFailed1(reason) |
| 72 { |
| 73 testPassed('expectedCreateOfferFailed1 was called.'); |
| 74 window.error = reason; |
| 75 shouldBe('error', '"TEST_ERROR"'); |
| 76 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedCreateOfferFailed
2);"); |
| 77 } |
| 78 |
| 79 function createOfferSucceeded1(sessionDescription) |
| 80 { |
| 81 testPassed('createOfferSucceeded1 was called.'); |
| 82 window.sessionDescription = sessionDescription; |
| 83 shouldBe('sessionDescription.type', '"offer"'); |
| 84 shouldNotThrow('pc.createOffer(unexpectedCallback, expectedCreateOfferFailed
1);'); |
| 85 } |
| 86 |
| 87 function testExecutionOrderClosedConnection() |
| 88 { |
| 89 var localPeerConnection = new webkitRTCPeerConnection(null, null); |
| 90 localPeerConnection.close(); |
| 91 var counter = 0; |
| 92 window.events = []; |
| 93 Promise.resolve().then(_ => window.events[counter++] = 1); |
| 94 localPeerConnection.createOffer(unexpectedCallback, (reason) => { |
| 95 window.error = reason; |
| 96 shouldBe('error', '"The RTCPeerConnection\'s signalingState is \'closed\
'."'); |
| 97 window.events[counter++] = 2; |
| 98 }); |
| 99 Promise.resolve().then(_ => { |
| 100 window.events[counter++] = 3; |
| 101 shouldBe('events', '[1,2,3]'); |
| 102 }); |
| 103 } |
| 104 |
| 105 shouldNotThrow('testExecutionOrderClosedConnection()'); |
61 pc = new webkitRTCPeerConnection(null); | 106 pc = new webkitRTCPeerConnection(null); |
62 pc.createOffer(requestSucceeded1, requestFailed1, {voiceActivityDetection:true,
iceRestart:true}); | 107 shouldNotThrow('pc.createOffer(createOfferSucceeded1, unexpectedCallback, {voice
ActivityDetection:true, iceRestart:true});'); |
63 | 108 |
64 window.jsTestIsAsync = true; | 109 window.jsTestIsAsync = true; |
65 window.successfullyParsed = true; | 110 window.successfullyParsed = true; |
66 </script> | 111 </script> |
67 </body> | 112 </body> |
68 </html> | 113 </html> |
OLD | NEW |