1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
8 description("Tests RTCPeerConnection [add|remove]Stream.");
15 testFailed('Stream generation failed.');
19 function getUserMedia(dictionary
, callback
) {
21 navigator
.webkitGetUserMedia(dictionary
, callback
, error
);
23 testFailed('webkitGetUserMedia threw exception :' + e
);
28 function onErroneousNegotiationNeeded() {
29 testFailed('onErroneousNegotiationNeeded was called.');
33 function onRemoveStream(event
) {
34 testPassed('onRemoveStream was called.');
36 shouldBe('pc.getLocalStreams().length', '0');
41 function onAddStream(event
) {
42 testPassed('onAddStream was called.');
44 shouldBe('pc.getStreamById(stream.id)', 'stream');
45 shouldBe('pc.getStreamById(stream2.id)', 'null');
47 pc
.onnegotiationneeded
= onErroneousNegotiationNeeded
;
49 shouldBe('pc.getLocalStreams().length', '1');
50 pc
.removeStream(stream2
);
51 shouldBe('pc.getLocalStreams().length', '1');
53 pc
.onnegotiationneeded
= onRemoveStream
;
54 pc
.removeStream(stream
);
57 function gotStream2(s
) {
58 testPassed('Got another stream.');
61 shouldBeFalse("stream.id === stream2.id");
63 pc
= new webkitRTCPeerConnection(null, null);
64 pc
.onnegotiationneeded
= onAddStream
;
68 function gotStream1(s
) {
69 testPassed('Got a stream.');
72 getUserMedia({audio
:true, video
:true}, gotStream2
);
75 getUserMedia({audio
:true, video
:true}, gotStream1
);
77 window
.jsTestIsAsync
= true;
78 window
.successfullyParsed
= true;