Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: LayoutTests/media/mediastream-srcobject.html

Issue 545933002: Implement HTMLMediaElement::srcObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed sofs easy comments. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/media/mediastream-srcobject.html
diff --git a/LayoutTests/media/mediastream-srcobject.html b/LayoutTests/media/mediastream-srcobject.html
new file mode 100644
index 0000000000000000000000000000000000000000..b541769c4826082c954dc2eb917d6b226b7f1f02
--- /dev/null
+++ b/LayoutTests/media/mediastream-srcobject.html
@@ -0,0 +1,88 @@
+<!DOCTYPE HTML">
+<html>
+<head>
+<script src=media-file.js></script>
+<script src=video-test.js></script>
+
+<script type="text/javascript">
+
+function playingFromFileOnce()
+{
+ testExpected(video.currentSrc.length > 0, 1);
+ consoleWrite("EVENT(playingFromFile)<br>");
+ createAndPlayMediaStream();
+}
+
+function playingSrcObject()
+{
+ consoleWrite("EVENT(playingVideo)<br>");
+ video.setAttribute('onplaying', "playingFromFileTwice()");
+ consoleWrite("MediaStream is playing. Set srcObject = null.");
+ video.srcObject=null;
+}
+
+function playingFromFileTwice()
+{
+ consoleWrite("EVENT(playingFromFile)<br>");
+ endTest();
+}
+
+function startPlayFile()
+{
+ findMediaElement();
+ waitForEvent("loadstart");
+ waitForEvent("waiting");
+ waitForEvent("ratechange");
+ waitForEvent("durationchange");
+ waitForEvent("pause");
+ waitForEvent("play");
+ waitForEvent("canplaythrough");
+ waitForEvent('loadeddata');
+
+ consoleWrite("Set src to local file.");
+ video.setAttribute('onplaying', "playingFromFileOnce()");
+
+ var mediaFile;
+ for (var i = 0; i < videoCodecs.length; ++i) {
+ if (video.canPlayType(videoCodecs[i][0])) {
+ mediaFile = "content/test." + videoCodecs[i][1];
+ break;
+ }
+ }
+ video.src = mediaFile;
+}
+
+function gotStream(stream)
+{
+ consoleWrite("Got a MediaStream. Start playing it.");
+ video.setAttribute('onplaying', "playingSrcObject()");
+ video.playbackRate = 2;
+ video.srcObject = stream;
+ testExpected(video.playbackRate, 1);
+ testExpected(video.currentSrc.length, 0);
+}
+
+function gotStreamFailed(error)
+{
+ consoleWrite("Failed to get access to local media. Error code was " + error.code);
+}
+
+function createAndPlayMediaStream()
+{
+ try {
+ consoleWrite("Request access to local media.");
+ navigator.webkitGetUserMedia({video:true}, gotStream, gotStreamFailed);
+ } catch (e) {
+ consoleWrite("getUserMedia error " + "(" + e.name + " / " + e.message + ")");
+ }
+}
+
+</script>
+</head>
+
+<body onload="startPlayFile()">
+<p>Test that setting the HTMLMediaElement.srcObject overrides setting the src attribute and if the srcObect is set to null, media is reloaded from the src attribute.</p>
+<video width="320" height="240" autoplay="autoplay"></video>
+</body>
+</html>
+

Powered by Google App Engine
This is Rietveld 408576698