DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for Bug 1189506</title>
  <script 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>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1189506">Mozilla Bug 1189506</a>
<p id="display"></p>
<video id="vin"></video>
<video id="vout"></video>
<video id="vout_cors" crossorigin></video>
<canvas id="cin" width="40" height="30"></canvas>
<canvas id="cout" width="40" height="30"></canvas>
<canvas id="cout_cors" width="40" height="30"></canvas>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/* global vin, vout, vout_cors, cin, cout, cout_cors */

/** Test for Bug 1189506 **/

SimpleTest.waitForExplicitFinish();

async function start() {
  const resource = getPlayableVideo(gSmallTests).name;
  vin.src = "http://example.org:8000/tests/dom/media/test/" + resource;
  vin.preload = "metadata";

  await new Promise(r => vin.onloadedmetadata = r);
  vout.srcObject = vin.mozCaptureStreamUntilEnded();
  vout_cors.srcObject = vin.mozCaptureStreamUntilEnded();
  vin.play();
  vout.play();
  vout_cors.play();

  await new Promise(r => vout.onended = r);
  is(vin.ended, vout.ended, "Source media element ends first");

  const ctxin = SpecialPowers.wrap(cin.getContext("2d"));
  ctxin.drawImage(vin, 0, 0);

  {
    info("Testing that the last frame is rendered");
    const powerCtx = SpecialPowers.wrap(cout.getContext("2d"));
    powerCtx.drawImage(vout, 0, 0);
    const datain = ctxin.getImageData(0, 0, cin.width, cin.height);
    const dataout = powerCtx.getImageData(0, 0, cout.width, cout.height);
    for (let i = 0; i < datain.data.length; i += 4) {
      const pixelin = datain.data.slice(i, i + 4).join(',');
      const pixelout = dataout.data.slice(i, i + 4).join(',');
      if (pixelin != pixelout) {
        is(pixelout, pixelin, `Pixel #${i/4} is rendered as expected`);
        break;
      }
    }
    is(datain.data.length / 4, cin.width * cin.height,
      "Checked expected number of pixels");
  }

  {
    info("Testing that the principal is set");
    const ctx = cout.getContext("2d");
    ctx.drawImage(vout, 0, 0);
    SimpleTest.doesThrow(() => ctx.getImageData(0, 0, cout.width, cout.height),
      "SecurityError");
  }

  {
    info("Testing that the crossorigin attribute is ignored for MediaStreams");
    const ctx = cout_cors.getContext("2d");
    ctx.drawImage(vout_cors, 0, 0);
    SimpleTest.doesThrow(
      () => ctx.getImageData(0, 0, cout_cors.width, cout_cors.height),
      "SecurityError");
  }
}

(async () => {
  try { await start(); }
  catch(e) { ok(false, `Rejected with ${e}`); }
  finally { SimpleTest.finish(); }
})();
</script>
</pre>
</body>
</html>