content/media/test/test_standalone.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/test/test_standalone.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Media test: standalone video documents</title>
     1.8 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.10 +  <script type="text/javascript" src="manifest.js"></script>
    1.11 +</head>
    1.12 +<body onload="doTest()">
    1.13 +
    1.14 +<pre id="test">
    1.15 +<script class="testbody" type="text/javascript">
    1.16 +
    1.17 +var iframes = [];
    1.18 +
    1.19 +for (var i=0; i<gSmallTests.length; ++i) {
    1.20 +  var test = gSmallTests[i];
    1.21 +
    1.22 +  // We can't play WAV files in stand alone documents, so just don't
    1.23 +  // run the test on non-video content types.
    1.24 +  var tag = getMajorMimeType(test.type);
    1.25 +  if (tag != "video" || !document.createElement("video").canPlayType(test.type))
    1.26 +    continue;
    1.27 +  
    1.28 +  var f = document.createElement("iframe");
    1.29 +  f.src = test.name;
    1.30 +  f._test = test;
    1.31 +  f.id = "frame" + i;
    1.32 +  iframes.push(f);
    1.33 +  document.body.appendChild(f);
    1.34 +}
    1.35 +
    1.36 +
    1.37 +function filename(uri) {
    1.38 +  return uri.substr(uri.lastIndexOf("/")+1);
    1.39 +}
    1.40 +
    1.41 +function doTest()
    1.42 +{
    1.43 +  for (var i=0; i<iframes.length; ++i) {
    1.44 +    var f = document.getElementById(iframes[i].id);
    1.45 +    var v = f.contentDocument.body.firstChild;
    1.46 +    is(v.tagName.toLowerCase(), "video", "Is video element");
    1.47 +    var src = filename(v.currentSrc);
    1.48 +    is(src, iframes[i]._test.name, "Name ("+src+") should match ("+iframes[i]._test.name+")");
    1.49 +    is(v.controls, true, "Controls set (" + src + ")");
    1.50 +    is(v.autoplay, true, "Autoplay set (" + src + ")");
    1.51 +  }
    1.52 +  SimpleTest.finish();
    1.53 +}
    1.54 +
    1.55 +if (iframes.length == 0) {
    1.56 +  todo(false, "No types supported");
    1.57 +} else {
    1.58 +  SimpleTest.waitForExplicitFinish();
    1.59 +}
    1.60 +
    1.61 +</script>
    1.62 +</pre>
    1.63 +</body>
    1.64 +</html>

mercurial