gecko/dom/media/test/test_streams_srcObject.html
Andreas Pehrson 18b5a687fc Bug 879717 - Part 1. Delay entering HAVE_CURRENT_DATA state until a
From 4c9aef7ec548ee20df2802f5509e457f66c051ef Mon Sep 17 00:00:00 2001
 video frame has been stored in the image container. r=roc
---
 dom/html/HTMLMediaElement.cpp              | 124 +++++++++++++++++++++++------
 dom/html/HTMLMediaElement.h                |   9 +++
 dom/media/test/test_streams_srcObject.html |   2 +
 3 files changed, 112 insertions(+), 23 deletions(-)
2014-10-10 11:34:57 +02:00

55 lines
1.7 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test interactions of src and srcObject</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body onload="doTest()">
<audio id="a"></audio>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
var a = document.getElementById('a');
a.src = getPlayableAudio(gSmallTests).name;
var b = new Audio();
function doTest() {
var newSrc = a.src + "?2";
b.src = newSrc;
is(b.mozSrcObject, null, "Initial srcObject is null");
var stream = a.mozCaptureStream();
b.mozSrcObject = stream;
is(b.mozSrcObject, stream, "Stream set correctly");
try {
b.mozSrcObject = "invalid";
ok(false, "Setting mozSrcObject to an invalid value should throw.");
} catch (e) {
ok(e instanceof TypeError, "Exception should be a TypeError");
}
is(b.mozSrcObject, stream, "Stream not set to invalid value");
is(b.src, newSrc, "src attribute not affected by setting srcObject");
var step = 0;
b.addEventListener("loadedmetadata", function() {
if (step == 0) {
is(b.currentSrc, "", "currentSrc set to empty string while playing srcObject");
b.mozSrcObject = null;
is(b.mozSrcObject, null, "Stream set to null");
// The resource selection algorithm will run again and choose b.src
} else if (step == 1) {
is(b.currentSrc, b.src, "currentSrc set to src now that srcObject is null");
SimpleTest.finish();
}
++step;
});
a.play();
b.play();
}
</script>
</pre>
</body>
</html>