mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
dd26dee475
--HG-- extra : rebase_source : b9ee2200c86a0c3fa06cdb163a39a183aa313380
144 lines
5.3 KiB
HTML
144 lines
5.3 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Media test: media selection</title>
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
function maketest(expect_load, attach_media, name, type, check_metadata) {
|
|
return function (testNum) {
|
|
var e = document.createElement('video');
|
|
|
|
if (expect_load) {
|
|
// this could be loadedmetadata, but needs bug 466410 fixed
|
|
e.addEventListener('loadeddata', function () {
|
|
ok(e.readyState >= HTMLMediaElement.HAVE_METADATA,
|
|
'test ' + testNum + ' networkState ' + e.networkState + ' expected >= ' + e.LOADED_METADATA);
|
|
is(e.currentSrc.substring(e.currentSrc.length - name.length), name, 'test ' + testNum);
|
|
check_metadata(e);
|
|
e.parentNode.removeChild(e);
|
|
runNextTest();
|
|
}, false);
|
|
}
|
|
|
|
attach_media(e, name, type);
|
|
|
|
if (expect_load) {
|
|
ok(e.networkState >= HTMLMediaElement.NETWORK_LOADING,
|
|
'test ' + testNum + ' networkState ' + e.networkState + ' expected >= ' + e.LOADING);
|
|
} else {
|
|
ok(e.networkState == HTMLMediaElement.NETWORK_EMPTY,
|
|
'test ' + testNum + ' networkState ' + e.networkState + ' expected ' + e.EMPTY);
|
|
is(e.currentSrc, '', 'test ' + testNum);
|
|
e.parentNode.removeChild(e);
|
|
runNextTest();
|
|
}
|
|
}
|
|
}
|
|
|
|
function set_src(element, name, type) {
|
|
element.src = name;
|
|
document.body.appendChild(element);
|
|
}
|
|
|
|
function add_source(element, name, type) {
|
|
do_add_source(element, name, type);
|
|
document.body.appendChild(element);
|
|
}
|
|
|
|
function do_add_source(element, name, type) {
|
|
var source = document.createElement('source');
|
|
if (type) {
|
|
source.type = type;
|
|
}
|
|
source.src = name;
|
|
element.appendChild(source);
|
|
}
|
|
|
|
function add_sources_last(element, name, type) {
|
|
do_add_source(element, name, 'unsupported/type');
|
|
do_add_source(element, name, type);
|
|
document.body.appendChild(element);
|
|
}
|
|
|
|
function add_sources_first(element, name, type) {
|
|
do_add_source(element, name, type);
|
|
do_add_source(element, name, 'unsupported/type');
|
|
document.body.appendChild(element);
|
|
}
|
|
|
|
function late_add_sources_last(element, name, type) {
|
|
document.body.appendChild(element);
|
|
do_add_source(element, name, 'unsupported/type');
|
|
do_add_source(element, name, type);
|
|
}
|
|
|
|
function late_add_sources_first(element, name, type) {
|
|
document.body.appendChild(element);
|
|
do_add_source(element, name, type);
|
|
do_add_source(element, name, 'unsupported/type');
|
|
}
|
|
|
|
function check_ogg(e) {
|
|
ok(e.videoWidth == 320 && e.videoHeight == 240, "video should be 320x240");
|
|
}
|
|
|
|
function check_wav(e) {
|
|
ok(e.duration > 0.9 && e.duration < 1.1, "duration should be around 1.0");
|
|
}
|
|
|
|
var nextTest = 0;
|
|
var subTests = [
|
|
maketest(true, set_src, '320x240.ogv', null, check_ogg),
|
|
maketest(true, add_source, '320x240.ogv', null, check_ogg),
|
|
maketest(true, add_source, '320x240.ogv', 'application/ogg', check_ogg),
|
|
maketest(true, add_sources_last, '320x240.ogv', null, check_ogg),
|
|
maketest(true, add_sources_first, '320x240.ogv', 'application/ogg', check_ogg),
|
|
maketest(true, set_src, 'r11025_u8_c1.wav', null, check_wav),
|
|
maketest(true, add_source, 'r11025_u8_c1.wav', null, check_wav),
|
|
maketest(true, add_source, 'r11025_u8_c1.wav', 'audio/x-wav', check_wav),
|
|
maketest(true, add_sources_last, 'r11025_u8_c1.wav', null, check_wav),
|
|
maketest(true, add_sources_first, 'r11025_u8_c1.wav', 'audio/x-wav', check_wav),
|
|
|
|
// type hint matches a decoder, actual type matches different decoder
|
|
maketest(true, add_source, '320x240.ogv', 'audio/x-wav', check_ogg),
|
|
maketest(true, add_source, 'r11025_u8_c1.wav', 'application/ogg', check_wav),
|
|
|
|
// should not start loading, type excludes it from media candiate list
|
|
maketest(false, add_source, '320x240.ogv', 'bogus/type', null),
|
|
maketest(false, add_source, 'r11025_u8_c1.wav', 'bogus/type', null),
|
|
maketest(false, add_source, 'unknown.raw', 'bogus/type', null),
|
|
|
|
// should start loading, then fire error, needs bug 462455 fixed
|
|
// maketest(true, add_source, 'unknown.raw', 'application/ogg', null),
|
|
// maketest(true, add_source, 'unknown.raw', 'audio/x-wav', null),
|
|
|
|
// element doesn't notice source children attached later, needs bug 462455 fixed
|
|
// maketest(true, late_add_sources_last, '320x240.ogv', null, 0.2, 0.4),
|
|
// maketest(true, late_add_sources_first, '320x240.ogv', 'application/ogg', 0.2, 0.4),
|
|
// maketest(true, late_add_sources_last, 'r11025_u8_c1.wav', null, 0.2, 0.4),
|
|
// maketest(true, late_add_sources_first, 'r11025_u8_c1.wav', 'audio/x-wav', 0.2, 0.4),
|
|
|
|
SimpleTest.finish
|
|
];
|
|
|
|
function runNextTest() {
|
|
setTimeout(function () {
|
|
dump('subtest ' + nextTest + '\n');
|
|
subTests[nextTest](nextTest);
|
|
nextTest += 1;
|
|
}, 0);
|
|
}
|
|
|
|
addLoadEvent(runNextTest);
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|