dom/media/test/test_eme_canvas_blocked.html
author JW Wang <jwwang@mozilla.com>
Fri, 09 Jan 2015 01:46:00 +0100
changeset 250181 00ac75ab182f
parent 242772 f989781e9a23
child 250279 dd9bfd410f7e
permissions -rw-r--r--
Bug 1081251 - register error handlers for all media elements in EME mochitests. r=cpearce a=lmandel

<!DOCTYPE HTML>
<html>
<head>
  <title>Test Encrypted Media Extensions</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>
  <script type="text/javascript" src="eme.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
var manager = new MediaTestManager;

function startTest(test, token)
{
  manager.started(token);

  var sessions = [];

  var v = SetupEME(test, token);
  v.preload = "auto"; // Required due to "canplay" not firing for MSE unless we do this.

  v.addEventListener("loadeddata", function(ev) {
    var video = ev.target;
    var canvas = document.createElement("canvas");
    canvas.width = video.videoWidth;
    canvas.height = video.videoHeight;
    document.body.appendChild(canvas);
    var ctx = canvas.getContext("2d");
    var threwError = false;
    try {
      ctx.drawImage(video, 0, 0);
    } catch (ex) {
      threwError = true;
    }
    ok(threwError, TimeStamp(token) + " - Should throw an error when trying to draw EME video to canvas.");
    manager.finished(token);
  });

  LoadTest(test, v, token);
}

function beginTest() {
  manager.runTests(gEMETests, startTest);
}

var prefs = [
  [ "media.mediasource.enabled", true ],
  [ "media.mediasource.youtubeonly", false ],
  [ "media.mediasource.mp4.enabled", true ],
];

if (/Linux/.test(navigator.userAgent) ||
    !document.createElement('video').canPlayType("video/mp4")) {
  // XXX remove once we have mp4 PlatformDecoderModules on all platforms.
  prefs.push([ "media.fragmented-mp4.exposed", true ]);
  prefs.push([ "media.fragmented-mp4.use-blank-decoder", true ]);
}

SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({ "set" : prefs }, beginTest);
</script>
</pre>
</body>
</html>