Index: content/test/data/media/getusermedia.html |
diff --git a/content/test/data/media/getusermedia.html b/content/test/data/media/getusermedia.html |
index 92037cfb53752b854b205e66e6a1587f8776a1de..7481613291288c2a410d50ad87e206be27bfc33c 100644 |
--- a/content/test/data/media/getusermedia.html |
+++ b/content/test/data/media/getusermedia.html |
@@ -64,25 +64,61 @@ |
createAndRenderClone, failedCallback); |
} |
+ // Creates two MediaStream and renders them locally. When the video of both |
+ // streams are detected to be rolling, we stop the local stream. Since both |
+ // streams have the same source, both video streams should stop. If they do, |
+ // the test succeeds. |
+ function twoGetUserMediaAndStop(constraints) { |
+ document.title = 'Calling Two GetUserMedia'; |
+ navigator.webkitGetUserMedia( |
+ constraints, |
+ function(stream) { |
+ displayAndDetectVideo(stream, requestSecondGetUserMedia); |
+ }, |
+ failedCallback); |
+ var requestSecondGetUserMedia = function() { |
+ navigator.webkitGetUserMedia( |
+ constraints, |
+ function(stream) { |
+ displayIntoVideoElement(stream, |
+ stopStreamAndVerifyAllLocalViewsDontPlayVideo, 'local-view-2'); |
+ }, |
+ failedCallback); |
+ }; |
+ |
+ var stopStreamAndVerifyAllLocalViewsDontPlayVideo = function() { |
+ gLocalStream.getVideoTracks()[0].stop(); |
+ |
+ // Since local-view and local-view-2 are playing the video from the same |
+ // source, both of them should stop. |
+ waitForVideoToStop('local-view'); |
+ waitForVideoToStop('local-view-2'); |
+ }; |
+ } |
+ |
function failedCallback(error) { |
document.title = 'GetUserMedia call failed with code ' + error.code; |
sendValueToTest(document.title); |
} |
- function plugStreamIntoLocalView(stream) { |
+ function plugStreamIntoVideoElement(stream, videoElement) { |
gLocalStream = stream; |
var localStreamUrl = URL.createObjectURL(stream); |
- $('local-view').src = localStreamUrl; |
+ $(videoElement).src = localStreamUrl; |
} |
- function displayAndDetectVideo(stream, callback) { |
- plugStreamIntoLocalView(stream); |
+ function displayIntoVideoElement(stream, callback, videoElement) { |
+ plugStreamIntoVideoElement(stream, videoElement); |
document.title = 'Waiting for video...'; |
- detectVideoPlaying('local-view', callback); |
+ detectVideoPlaying(videoElement, callback); |
+ } |
+ |
+ function displayAndDetectVideo(stream, callback) { |
+ displayIntoVideoElement(stream, callback, 'local-view'); |
} |
function displayDetectAndAnalyzeVideo(stream) { |
- plugStreamIntoLocalView(stream); |
+ plugStreamIntoVideoElement(stream, 'local-view'); |
analyzeVideo(); |
} |
@@ -134,10 +170,19 @@ |
<tr> |
<td><video width="320" height="240" id="local-view" |
autoplay="autoplay"></video></td> |
- <!-- Canvases are named after their corresponding video elements. --> |
<td><canvas width="320" height="240" id="local-view-canvas" |
style="display:none"></canvas></td> |
</tr> |
+ <tr> |
+ <td>Local Preview 2</td> |
+ </tr> |
+ <tr> |
+ <td><video width="320" height="240" id="local-view-2" |
+ autoplay="autoplay"></video></td> |
+ <!-- Canvases are named after their corresponding video elements. --> |
+ <td><canvas width="320" height="240" id="local-view-2-canvas" |
+ style="display:none"></canvas></td> |
+ </tr> |
</table> |
</body> |
</html> |