Bug 879717 - Part 3 - Test video dimensions set on loadedmetadata

From 7426ccfec0b1bb8b420dddc628361a4833dc52fa Mon Sep 17 00:00:00 2001
 event. r=roc
---
 dom/media/test/manifest.js                |  2 +-
 dom/media/test/mochitest.ini              |  1 +
 dom/media/test/test_video_dimensions.html | 72 +++++++++++++++++++++++++++++++
 3 files changed, 74 insertions(+), 1 deletion(-)
 create mode 100644 dom/media/test/test_video_dimensions.html
This commit is contained in:
Andreas Pehrson 2014-12-19 01:25:00 +01:00
Родитель 9098eab06e
Коммит 54ac43e9bb
3 изменённых файлов: 74 добавлений и 1 удалений

Просмотреть файл

@ -14,7 +14,7 @@ var gSmallTests = [
{ name:"seek.webm", type:"video/webm", width:320, height:240, duration:3.966 },
{ name:"vp9.webm", type:"video/webm", width:320, height:240, duration:4 },
{ name:"detodos.opus", type:"audio/ogg; codecs=opus", duration:2.9135 },
{ name:"gizmo.mp4", type:"video/mp4", duration:5.56 },
{ name:"gizmo.mp4", type:"video/mp4", width:560, height:320, duration:5.56 },
{ name:"bogus.duh", type:"bogus/duh" }
];

Просмотреть файл

@ -471,6 +471,7 @@ skip-if = (toolkit == 'android' && processor == 'x86') #x86 only
skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439
[test_reset_events_async.html]
[test_reset_src.html]
[test_video_dimensions.html]
[test_resume.html]
skip-if = true # bug 1021673
[test_seek_out_of_range.html]

Просмотреть файл

@ -0,0 +1,72 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test that a video element has set video dimensions on loadedmetadata</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>
<pre id="test">
<script class="testbody" type="text/javascript">
var manager = new MediaTestManager;
var startTest = function(test, token) {
manager.started(token);
var v1 = document.createElement('video');
var v2 = document.createElement('video');
var vout = document.createElement('video');
// Avoid a race for hardware resources between v1 and v2 on platforms with
// a hardware decoder, like B2G.
v1.preload = 'none';
v2.preload = 'none';
var numVideoElementsFinished = 0;
var onloadedmetadata = function(ev) {
var v = ev.target;
ok(!v.loadedmetadata, v.testName + " should only fire loadedmetadata once");
v.loadedmetadata = true;
is(v.videoWidth, test.width, v.testName + " video width should be set on loadedmetadata");
is(v.videoHeight, test.height, v.testName + " video height should be set on loadedmetadata");
numVideoElementsFinished += 1;
if (v === v1) {
removeNodeAndSource(v1);
v2.play();
vout.play();
}
if (numVideoElementsFinished === 3) {
removeNodeAndSource(v2);
removeNodeAndSource(vout);
manager.finished(token);
}
};
var setupElement = function(v, id) {
v.loadedmetadata = false;
v.onloadedmetadata = onloadedmetadata;
document.body.appendChild(v);
};
v1.testName = test.name;
v2.testName = test.name + " (Captured)";
vout.testName = test.name + " (Stream)";
v1.src = test.name;
v2.src = test.name;
vout.src = URL.createObjectURL(v2.mozCaptureStreamUntilEnded());
setupElement(v1, "v1");
setupElement(v2, "v2");
setupElement(vout, "vout");
v1.play();
};
manager.runTests(getPlayableVideos(gSmallTests), startTest);
</script>
</pre>
</body>
</html>