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