| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../../resources/js-test.js"></script> |
| </head> |
| <body> |
| <script> |
| description("Test cloning mediastreams and their tracks."); |
| |
| var stream; |
| var stream2; |
| var cloned_stream; |
| var track; |
| var cloned_track; |
| |
| function error() { |
| testFailed('Stream generation failed.'); |
| finishJSTest(); |
| } |
| |
| function getUserMedia(dictionary, callback) { |
| try { |
| navigator.webkitGetUserMedia(dictionary, callback, error); |
| } catch (e) { |
| testFailed('webkitGetUserMedia threw exception :' + e); |
| finishJSTest(); |
| } |
| } |
| |
| function gotStream2(s) { |
| stream2 = s; |
| track = stream2.getAudioTracks()[0]; |
| cloned_track = track.clone(); |
| shouldNotBe('track', 'cloned_track'); |
| shouldNotBe('track.id', 'cloned_track.id'); |
| stream.addTrack(cloned_track); |
| shouldBe('stream.getAudioTracks().length', '2'); |
| finishJSTest(); |
| } |
| |
| function gotStream(s) { |
| stream = s; |
| shouldBe('stream.getAudioTracks().length', '1'); |
| shouldBe('stream.getVideoTracks().length', '1'); |
| |
| cloned_stream = stream.clone(); |
| shouldNotBe('stream.id', 'cloned_stream.id'); |
| shouldBe('cloned_stream.getAudioTracks().length', '1'); |
| shouldBe('cloned_stream.getVideoTracks().length', '1'); |
| |
| shouldNotBe('stream.getAudioTracks()[0]', 'cloned_stream.getAudioTracks()[0]'); |
| shouldNotBe('stream.getVideoTracks()[0]', 'cloned_stream.getVideoTracks()[0]'); |
| shouldNotBe('stream.getAudioTracks()[0].id', 'cloned_stream.getAudioTracks()[0].id'); |
| shouldNotBe('stream.getVideoTracks()[0].id', 'cloned_stream.getVideoTracks()[0].id'); |
| |
| getUserMedia({audio:true, video:true}, gotStream2); |
| } |
| |
| getUserMedia({audio:true, video:true}, gotStream); |
| |
| window.jsTestIsAsync = true; |
| window.successfullyParsed = true; |
| </script> |
| </body> |
| </html> |