summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_streams_capture_origin.html
blob: 916163e9cba9f5363ebca9704ccfe2e45f5d4aec (plain)
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
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for Bug 1189506</title>
  <script type="application/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>
</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" style="position:absolute; top:0; left:0"></video>
<canvas id="c"></canvas>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">

/** Test for Bug 1189506 **/

SimpleTest.waitForExplicitFinish();

var resource = getPlayableVideo(gSmallTests).name;

vin.src = "http://example.org:8000/tests/dom/media/test/" + resource;
vin.preload = "metadata";

vin.onloadedmetadata = function () {
  vout.srcObject = vin.mozCaptureStreamUntilEnded();
  vin.play();
  vout.play();
};

vout.onended = function() {
  var ctx = SpecialPowers.wrap(c.getContext("2d"));
  ctx.drawWindow(window, 0, 0, 10, 10, "rgb(255, 255, 0)", 0);
  var data = ctx.getImageData(2, 2, 1, 1);
  // Captured cross-origin video streams should render entirely black.
  is(data.data.join(','), "0,0,0,255", "expected black");
  vout.style.position = "";
  SimpleTest.finish();
};
</script>
</pre>
</body>
</html>