content/media/test/test_decoder_disable.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/test/test_decoder_disable.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=448600
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 448600</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=448600">Mozilla Bug 448600</a>
    1.16 +<p id="display"></p>
    1.17 +
    1.18 +
    1.19 +<pre id="test">
    1.20 +<script type="application/javascript">
    1.21 +
    1.22 +function filename(uri) {
    1.23 +  return uri.substr(uri.lastIndexOf("/")+1);
    1.24 +}
    1.25 +
    1.26 +function e(id) {
    1.27 +  return document.getElementById(id);
    1.28 +}
    1.29 +
    1.30 +var gLoadError = new Object();
    1.31 +
    1.32 +gLoadError['video1'] = 0; 
    1.33 +gLoadError['video2'] = 0;
    1.34 +gLoadError['video3'] = 0;
    1.35 +
    1.36 +var gErrorCount = 0;
    1.37 +
    1.38 +SimpleTest.waitForExplicitFinish();
    1.39 +
    1.40 +function finishTest() {
    1.41 +  is(e('video1').currentSrc,
    1.42 +     "",
    1.43 +     'video1 currentSrc should be empty when there\'s no playable typed source children');
    1.44 +  is(filename(e('video2').currentSrc),
    1.45 +     filename(e('video2').src),
    1.46 +     'video2 currentSrc should match src');
    1.47 +  is(filename(e('video3').currentSrc),
    1.48 +     filename(e('video3').src),
    1.49 +     'video3 currentSrc should match src');
    1.50 +
    1.51 +  is(gLoadError['video1'], 2, "Expect one error per invalid source child on video1");
    1.52 +  is(gLoadError['video2'], 1, "Expect one error on video2");
    1.53 +  is(gLoadError['video3'], 1, "Expect one error on video3");
    1.54 +
    1.55 +  SimpleTest.finish();
    1.56 +}
    1.57 +
    1.58 +function videoError(event, id) {
    1.59 +  gLoadError[id]++;
    1.60 +  gErrorCount++;
    1.61 +  if (gErrorCount >= 4) {
    1.62 +    finishTest();
    1.63 +  }
    1.64 +}
    1.65 +
    1.66 +</script>
    1.67 +<!-- We make the resource URIs unique to ensure that they are (re)loaded with the new disable-decoder prefs. -->
    1.68 +<div id="content">
    1.69 +</div>
    1.70 +<script>
    1.71 +function makeVideos() {
    1.72 +  document.getElementById('content').innerHTML = '<video id="video1" preload="metadata"><source type="video/ogg" src="320x240.ogv?decoder_disabled=1" onerror="videoError(event, \'video1\');"/><source type="audio/wave" src="r11025_u8_c1.wav?decoder_disabled=1" id=\'s2\' onerror="videoError(event, \'video1\');"/></video><video id="video2" preload="metadata" src="320x240.ogv?decoder_disabled=2" onerror="videoError(event, \'video2\');"></video><video id="video3" preload="metadata" src="r11025_u8_c1.wav?decoder_disabled=2" onerror="videoError(event, \'video3\');"></video>';
    1.73 +}
    1.74 +
    1.75 +SpecialPowers.pushPrefEnv({"set": [["media.ogg.enabled", false], ["media.wave.enabled", false]]}, makeVideos);
    1.76 +</script>
    1.77 +
    1.78 +</pre>
    1.79 +
    1.80 +</body>
    1.81 +</html>

mercurial