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 that RTCPeerConnection event callbacks are async so that for
example close can be called safely. The order of the messages is very important.
"); | |
9 | |
10 var stream = null; | |
11 var pc = null; | |
12 | |
13 function error() { | |
14 testFailed('Stream generation failed.'); | |
15 finishJSTest(); | |
16 } | |
17 | |
18 function getUserMedia(dictionary, callback) { | |
19 try { | |
20 navigator.webkitGetUserMedia(dictionary, callback, error); | |
21 } catch (e) { | |
22 testFailed('webkitGetUserMedia threw exception :' + e); | |
23 finishJSTest(); | |
24 } | |
25 } | |
26 | |
27 function onStateChange(event) { | |
28 testPassed('onStateChange was called.'); | |
29 shouldBe("pc.signalingState", "'closed'"); | |
30 finishJSTest(); | |
31 } | |
32 | |
33 function onNegotiationNeeded(event) { | |
34 testPassed('onNegotiationNeeded was called.'); | |
35 pc.onsignalingstatechange = onStateChange; | |
36 pc.close(); | |
37 testPassed('onNegotiationNeeded done.') | |
38 } | |
39 | |
40 function gotStream(s) { | |
41 testPassed('gotStream was called.'); | |
42 stream = s; | |
43 | |
44 pc = new webkitRTCPeerConnection(null, null); | |
45 pc.onnegotiationneeded = onNegotiationNeeded; | |
46 | |
47 pc.addStream(stream); | |
48 testPassed('gotStream done.'); | |
49 } | |
50 | |
51 getUserMedia({audio:true, video:true}, gotStream); | |
52 | |
53 window.jsTestIsAsync = true; | |
54 window.successfullyParsed = true; | |
55 | |
56 | |
57 </script> | |
58 </body> | |
59 </html> | |
OLD | NEW |