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 testFailed('unexpectedCallback was called') | |
19 finishJSTest(); | |
20 } | |
17 | 21 |
18 function requestFailed2(error) | 22 function expectedCreateOfferFailed7(error) |
tommi (sloooow) - chröme
2016/03/10 22:01:52
nit: fix whitespace. same below.
Guido Urdaneta
2016/03/11 08:39:06
Done.
| |
19 { | 23 { |
20 testPassed('requestFailed was called.'); | 24 testPassed('expectedCreateOfferFailed7 called.'); |
21 | |
22 window.error = error; | 25 window.error = error; |
23 shouldBe('error.name', '"OperationError"'); | 26 shouldBe('error.name', '"OperationError"'); |
24 shouldBe('error.toString()', '"OperationError: TEST_ERROR"'); | 27 shouldBe('error.toString()', '"OperationError: TEST_ERROR"'); |
25 | |
26 shouldNotThrow("pc.createOffer(dummy, dummy);"); | |
27 shouldNotThrow("pc.createOffer(dummy, dummy, {});"); | |
28 shouldNotThrow("pc.createOffer(dummy, dummy, {voiceActivityDetection:false}) ;"); | |
29 shouldNotThrow("pc.createOffer(dummy, dummy, {iceRestart:true});"); | |
30 shouldNotThrow("pc.createOffer(dummy, dummy, {voiceActivityDetection:false, iceRestart:true});"); | |
31 | |
32 // Deprecated. | |
33 shouldThrow("pc.createOffer(dummy, dummy, {offerToReceiveVideo:-1, offerToRe ceiveAudio:0});"); | |
34 shouldThrow("pc.createOffer(dummy, dummy, {offerToReceiveVideo:0, offerToRec eiveAudio:-1});"); | |
35 shouldNotThrow("pc.createOffer(dummy, dummy, {offerToReceiveVideo:1, offerTo ReceiveAudio:0, voiceActivityDetection:false, iceRestart:true});"); | |
36 | |
37 finishJSTest(); | 28 finishJSTest(); |
38 } | 29 } |
39 | 30 |
40 function requestSucceeded2(sd) | 31 function expectedCreateOfferFailed6(error) |
41 { | 32 { |
42 testFailed('requestSucceeded was called.'); | 33 testPassed('expectedCreateOfferFailed6 called.'); |
43 finishJSTest(); | 34 window.error = error; |
35 shouldBe('error.name', '"OperationError"'); | |
36 shouldBe('error.toString()', '"OperationError: TEST_ERROR"'); | |
37 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedCreateOfferFailed 7, {offerToReceiveVideo:0, offerToReceiveAudio:-1});"); | |
44 } | 38 } |
45 | 39 |
46 function requestFailed1() | 40 function expectedCreateOfferFailed5(error) { |
47 { | 41 testPassed('expectedCreateOfferFailed5 was called.'); |
48 testFailed('requestFailed was called.'); | 42 window.error = error; |
49 finishJSTest(); | 43 shouldBe('error.name', '"OperationError"'); |
44 shouldBe('error.toString()', '"OperationError: TEST_ERROR"'); | |
45 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedCreateOfferFailed 6, {offerToReceiveVideo:-1, offerToReceiveAudio:0});"); | |
50 } | 46 } |
51 | 47 |
52 function requestSucceeded1(sd) | 48 function createOfferSucceeded2() { |
53 { | 49 testPassed('createOfferSucceeded2 was called.'); |
54 testPassed('requestSucceeded was called.'); | 50 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedCreateOfferFailed 5, {offerToReceiveVideo:1, offerToReceiveAudio:0, voiceActivityDetection:false, iceRestart:true});"); |
55 | |
56 sessionDescription = sd; | |
57 shouldBe('sessionDescription.type', '"offer"'); | |
58 | |
59 pc.createOffer(requestSucceeded2, requestFailed2); | |
60 } | 51 } |
61 | 52 |
53 function expectedCreateOfferFailed4(error) { | |
54 testPassed('expectedCreateOfferFailed4 was called.'); | |
55 window.error = error; | |
56 shouldBe('error.name', '"OperationError"'); | |
57 shouldBe('error.toString()', '"OperationError: TEST_ERROR"'); | |
58 shouldNotThrow("pc.createOffer(createOfferSucceeded2, unexpectedCallback, {i ceRestart:true});"); | |
59 } | |
60 | |
61 function expectedCreateOfferFailed3(error) { | |
62 testPassed('expectedCreateOfferFailed3 was called.'); | |
63 window.error = error; | |
64 shouldBe('error.name', '"OperationError"'); | |
65 shouldBe('error.toString()', '"OperationError: TEST_ERROR"'); | |
66 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedCreateOfferFailed 4, {voiceActivityDetection:false});"); | |
67 } | |
68 | |
69 function expectedCreateOfferFailed2(error) { | |
70 testPassed('expectedCreateOfferFailed2 was called.'); | |
71 window.error = error; | |
72 shouldBe('error.name', '"OperationError"'); | |
73 shouldBe('error.toString()', '"OperationError: TEST_ERROR"'); | |
74 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedCreateOfferFailed 3, {});"); | |
75 } | |
76 | |
77 function expectedCreateOfferFailed1(error) | |
78 { | |
79 testPassed('expectedCreateOfferFailed1 was called.'); | |
80 window.error = error; | |
81 shouldBe('error.name', '"OperationError"'); | |
82 shouldBe('error.toString()', '"OperationError: TEST_ERROR"'); | |
83 shouldNotThrow("pc.createOffer(unexpectedCallback, expectedCreateOfferFailed 2);"); | |
84 } | |
85 | |
86 function createOfferSucceeded1(sessionDescription) | |
87 { | |
88 testPassed('createOfferSucceeded1 was called.'); | |
89 window.sessionDescription = sessionDescription; | |
90 shouldBe('sessionDescription.type', '"offer"'); | |
91 shouldNotThrow('pc.createOffer(unexpectedCallback, expectedCreateOfferFailed 1);'); | |
92 } | |
93 | |
94 function testExecutionOrderClosedConnection() | |
95 { | |
96 var localPeerConnection = new webkitRTCPeerConnection(null, null); | |
97 localPeerConnection.close(); | |
98 var counter = 0; | |
99 window.events = []; | |
100 Promise.resolve().then(_ => window.events[counter++] = 1); | |
101 localPeerConnection.createOffer(unexpectedCallback, error => { | |
102 window.error = error; | |
103 shouldBe('error.name', '"InvalidStateError"'); | |
104 shouldBe('error.toString()', '"InvalidStateError: The RTCPeerConnection\ 's signalingState is \'closed\'."'); | |
105 window.events[counter++] = 2; | |
106 }); | |
107 Promise.resolve().then(_ => { | |
108 window.events[counter++] = 3; | |
109 shouldBe('events', '[1,2,3]'); | |
110 }); | |
111 } | |
112 | |
113 shouldNotThrow('testExecutionOrderClosedConnection()'); | |
62 pc = new webkitRTCPeerConnection(null); | 114 pc = new webkitRTCPeerConnection(null); |
63 pc.createOffer(requestSucceeded1, requestFailed1, {voiceActivityDetection:true, iceRestart:true}); | 115 shouldNotThrow('pc.createOffer(createOfferSucceeded1, unexpectedCallback, {voice ActivityDetection:true, iceRestart:true});'); |
64 | 116 |
65 window.jsTestIsAsync = true; | 117 window.jsTestIsAsync = true; |
66 window.successfullyParsed = true; | 118 window.successfullyParsed = true; |
67 </script> | 119 </script> |
68 </body> | 120 </body> |
69 </html> | 121 </html> |
OLD | NEW |