2009-05-14 01:52:50 +04:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=489415
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 489415</title>
|
|
|
|
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
2018-03-28 06:56:37 +03:00
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
2010-05-31 02:02:06 +04:00
|
|
|
<script type="text/javascript" src="manifest.js"></script>
|
2018-03-28 06:56:37 +03:00
|
|
|
<style>
|
|
|
|
video {
|
|
|
|
width: 40%;
|
|
|
|
border: solid black 1px;
|
|
|
|
}
|
|
|
|
</style>
|
2009-05-14 01:52:50 +04:00
|
|
|
</head>
|
|
|
|
|
2018-03-28 06:56:37 +03:00
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=489415">Mozilla Bug 489415</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="text/javascript">
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2009-05-14 01:52:50 +04:00
|
|
|
|
2018-03-28 06:56:37 +03:00
|
|
|
var pushPrefs = (...p) => SpecialPowers.pushPrefEnv({ set: p });
|
|
|
|
var count = 0;
|
2016-10-03 12:48:03 +03:00
|
|
|
|
2018-03-28 06:56:37 +03:00
|
|
|
function canReadBack(video) {
|
|
|
|
var c = document.createElement("canvas");
|
|
|
|
var ctx = c.getContext("2d");
|
|
|
|
ctx.drawImage(video, 0, 0);
|
|
|
|
try {
|
|
|
|
c.toDataURL();
|
|
|
|
return true;
|
|
|
|
} catch (ex) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2009-05-14 01:52:50 +04:00
|
|
|
|
2018-03-28 06:56:37 +03:00
|
|
|
function runTest(origin, shouldReadBackOnLoad) {
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
// Load will redirect mid-flight, which will be detected and should error,
|
|
|
|
// and we should no longer be able to readback.
|
|
|
|
var video = document.createElement("video");
|
|
|
|
video.preload = "metadata";
|
|
|
|
video.controls = true;
|
2018-04-04 05:30:15 +03:00
|
|
|
var url = "http://" + origin + "/tests/dom/media/test/midflight-redirect.sjs"
|
|
|
|
+ "?resource=pixel_aspect_ratio.mp4&type=video/mp4";
|
2018-03-28 06:56:37 +03:00
|
|
|
SimpleTest.info("Loading from " + url);
|
|
|
|
video.src = url;
|
|
|
|
document.body.appendChild(video);
|
2009-05-14 01:52:50 +04:00
|
|
|
|
2018-03-28 06:56:37 +03:00
|
|
|
once(video, "loadeddata", () => {
|
|
|
|
is(canReadBack(video), shouldReadBackOnLoad, "Should be able to readback");
|
|
|
|
video.play();
|
|
|
|
});
|
2016-10-03 12:48:03 +03:00
|
|
|
|
2018-03-28 06:56:37 +03:00
|
|
|
once(video, "error", () => {
|
|
|
|
is(canReadBack(video), false, "Should not be able to readback after error");
|
|
|
|
removeNodeAndSource(video);
|
|
|
|
resolve();
|
|
|
|
});
|
2016-10-03 12:48:03 +03:00
|
|
|
|
2018-03-28 06:56:37 +03:00
|
|
|
once(video, "ended", () => {
|
|
|
|
ok(false, "Should not be able to playback to end, we should have errored!");
|
|
|
|
removeNodeAndSource(video);
|
|
|
|
resolve();
|
|
|
|
});
|
2016-10-13 12:32:45 +03:00
|
|
|
|
2018-03-28 06:56:37 +03:00
|
|
|
});
|
2016-10-03 12:48:03 +03:00
|
|
|
}
|
|
|
|
|
2018-03-28 06:56:37 +03:00
|
|
|
Promise.all([
|
|
|
|
runTest("mochi.test:8888", true),
|
|
|
|
runTest("example.org", false),
|
|
|
|
]).then(SimpleTest.finish);
|
2016-10-03 12:48:03 +03:00
|
|
|
|
2018-03-28 06:56:37 +03:00
|
|
|
</script>
|
2009-05-14 01:52:50 +04:00
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|