OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <title>RTCPeerConnection.createOffer</title> | |
5 <script src="../../resources/testharness.js"></script> | |
6 <script src="../../resources/testharnessreport.js"></script> | |
7 </head> | |
8 <body> | |
9 <script> | |
10 // Note: createOffer() calls in the test runner are successful if the | |
11 // voiceActivityDetection and iceRestart options are passed with a value | |
12 // of true and offerToReceiveAudio and offerToReceiveVideo are passed with | |
13 // a positive value. In all other cases, createOffer() fails in the test | |
14 // runner. | |
15 | |
16 defaultError = new DOMException('TEST_ERROR', 'OperationError') | |
17 pc = new webkitRTCPeerConnection(null); | |
18 | |
19 // Test that creating an offer with voiceActivityDetection, iceRestart, | |
20 // offerToReceiveAudio and offerToReceiveVideo returns an accepted promise
. | |
21 promise_test(function() { | |
22 return pc.createOffer({voiceActivityDetection:true, iceRestart:true, off
erToReceiveAudio:1, offerToReceiveVideo:1}) | |
23 }, 'createOffer({voiceActivityDetection:true, iceRestart:true})'); | |
24 | |
25 // Test that not explicitly setting voiceActivityDetection results in an | |
26 // accepted promise, since the default value for voiceActivityDetection | |
27 // is true. | |
28 promise_test(function() { | |
29 return pc.createOffer({iceRestart:true, offerToReceiveAudio:1, offerToRe
ceiveVideo:1}) | |
30 }, 'createOffer({iceRestart:true})'); | |
31 | |
32 // Test that other combinations return a rejected promise. | |
33 promise_test(function() { | |
34 return promise_rejects(this, defaultError, | |
35 pc.createOffer({voiceActivityDetection:true, iceRestart:true})); | |
36 }, 'createOffer({voiceActivityDetection:false, iceRestart:false})' ); | |
37 | |
38 promise_test(function() { | |
39 return promise_rejects(this, defaultError, | |
40 pc.createOffer({voiceActivityDetection:true, iceRestart:true, offerToR
eceiveAudio:0, offerToReceiveVideo: 0})); | |
41 }, 'createOffer({voiceActivityDetection:false, iceRestart:false})' ); | |
42 | |
43 promise_test(function() { | |
44 return promise_rejects(this, defaultError, | |
45 pc.createOffer({voiceActivityDetection:false, iceRestart:false})); | |
46 }, 'createOffer({voiceActivityDetection:false, iceRestart:false})' ); | |
47 | |
48 promise_test(function() { | |
49 return promise_rejects(this, defaultError, | |
50 pc.createOffer({voiceActivityDetection:false, iceRestart:true})); | |
51 }, 'createOffer({voiceActivityDetection:false, iceRestart:true})' ); | |
52 | |
53 promise_test(function() { | |
54 return promise_rejects(this, defaultError, | |
55 pc.createOffer({voiceActivityDetection:true, iceRestart:false})); | |
56 }, 'createOffer({voiceActivityDetection:true, iceRestart:false})' ); | |
57 | |
58 promise_test(function() { | |
59 return promise_rejects(this, defaultError, pc.createOffer({})); | |
60 }, 'createOffer({})' ); | |
61 | |
62 promise_test(function() { | |
63 return promise_rejects(this, defaultError, pc.createOffer()); | |
64 }, 'createOffer()' ); | |
65 | |
66 // Test type error | |
67 promise_test(function() { | |
68 return promise_rejects(this, new TypeError(), pc.createOffer(1)); | |
69 }, 'createOffer(1)' ); | |
70 | |
71 // Test closed connection | |
72 closedPC = new webkitRTCPeerConnection(null); | |
73 closedPC.close(); | |
74 promise_test(function() { | |
75 var invalidStateError = new DOMException('', 'InvalidStateError'); | |
76 return promise_rejects(this, invalidStateError, closedPC.createOffer({ic
eRestart:true})); | |
77 }, 'createOffer() with closed peer connection' ); | |
78 </script> | |
79 </body> | |
80 </html> | |
OLD | NEW |