зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1101304 - Test that EME works with CORS - r=cpearce
This commit is contained in:
Родитель
592f17b93a
Коммит
e8b8c8effc
|
@ -13,6 +13,9 @@ function parseQuery(request, key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var types = {
|
var types = {
|
||||||
|
js: "text/javascript",
|
||||||
|
m4s: "video/mp4",
|
||||||
|
mp4: "video/mp4",
|
||||||
ogg: "video/ogg",
|
ogg: "video/ogg",
|
||||||
ogv: "video/ogg",
|
ogv: "video/ogg",
|
||||||
oga: "audio/ogg",
|
oga: "audio/ogg",
|
||||||
|
|
|
@ -114,6 +114,15 @@ function UpdateSessionFunc(test, token, sessionType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function MaybeCrossOriginURI(test, uri)
|
||||||
|
{
|
||||||
|
if (test.crossOrigin) {
|
||||||
|
return "http://test2.mochi.test:8888/tests/dom/media/test/allowed.sjs?" + uri;
|
||||||
|
} else {
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function PlayFragmented(test, elem, token)
|
function PlayFragmented(test, elem, token)
|
||||||
{
|
{
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
|
@ -140,7 +149,7 @@ function PlayFragmented(test, elem, token)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var fragmentFile = test.fragments[curFragment++];
|
var fragmentFile = MaybeCrossOriginURI(test, test.fragments[curFragment++]);
|
||||||
|
|
||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
req.open("GET", fragmentFile);
|
req.open("GET", fragmentFile);
|
||||||
|
@ -179,7 +188,7 @@ function LoadTest(test, elem, token)
|
||||||
|
|
||||||
// This file isn't fragmented; set the media source normally.
|
// This file isn't fragmented; set the media source normally.
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
elem.src = test.name;
|
elem.src = MaybeCrossOriginURI(test, test.name);
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -187,6 +196,7 @@ function LoadTest(test, elem, token)
|
||||||
function SetupEME(test, token, params)
|
function SetupEME(test, token, params)
|
||||||
{
|
{
|
||||||
var v = document.createElement("video");
|
var v = document.createElement("video");
|
||||||
|
v.crossOrigin = test.crossOrigin || false;
|
||||||
|
|
||||||
// Log events dispatched to make debugging easier...
|
// Log events dispatched to make debugging easier...
|
||||||
[ "canplay", "canplaythrough", "ended", "error", "loadeddata",
|
[ "canplay", "canplaythrough", "ended", "error", "loadeddata",
|
||||||
|
|
|
@ -652,6 +652,18 @@ var gEMETests = [
|
||||||
sessionType:"temporary",
|
sessionType:"temporary",
|
||||||
duration:0.47
|
duration:0.47
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name:"short-cenc.mp4",
|
||||||
|
type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
|
||||||
|
keys: {
|
||||||
|
// "keyid" : "key"
|
||||||
|
"7e571d017e571d017e571d017e571d01" : "7e5711117e5711117e5711117e571111",
|
||||||
|
"7e571d027e571d027e571d027e571d02" : "7e5722227e5722227e5722227e572222",
|
||||||
|
},
|
||||||
|
sessionType:"temporary",
|
||||||
|
duration:0.47,
|
||||||
|
crossOrigin:true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name:"gizmo-frag-cencinit.mp4",
|
name:"gizmo-frag-cencinit.mp4",
|
||||||
fragments: [ "gizmo-frag-cencinit.mp4", "gizmo-frag-cenc1.m4s", "gizmo-frag-cenc2.m4s" ],
|
fragments: [ "gizmo-frag-cencinit.mp4", "gizmo-frag-cenc1.m4s", "gizmo-frag-cenc2.m4s" ],
|
||||||
|
@ -664,6 +676,19 @@ var gEMETests = [
|
||||||
sessionType:"temporary",
|
sessionType:"temporary",
|
||||||
duration:2.00,
|
duration:2.00,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name:"gizmo-frag-cencinit.mp4",
|
||||||
|
fragments: [ "gizmo-frag-cencinit.mp4", "gizmo-frag-cenc1.m4s", "gizmo-frag-cenc2.m4s" ],
|
||||||
|
type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
|
||||||
|
keys: {
|
||||||
|
// "keyid" : "key"
|
||||||
|
"7e571d037e571d037e571d037e571d03" : "7e5733337e5733337e5733337e573333",
|
||||||
|
"7e571d047e571d047e571d047e571d04" : "7e5744447e5744447e5744447e574444",
|
||||||
|
},
|
||||||
|
sessionType:"temporary",
|
||||||
|
duration:2.00,
|
||||||
|
crossOrigin:true,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
function checkMetadata(msg, e, test) {
|
function checkMetadata(msg, e, test) {
|
||||||
|
|
|
@ -364,6 +364,8 @@ skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439
|
||||||
[test_defaultMuted.html]
|
[test_defaultMuted.html]
|
||||||
[test_delay_load.html]
|
[test_delay_load.html]
|
||||||
skip-if = buildapp == 'b2g' && toolkit != 'gonk' # bug 1082984
|
skip-if = buildapp == 'b2g' && toolkit != 'gonk' # bug 1082984
|
||||||
|
[test_eme_access_control.html]
|
||||||
|
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # bug 1043403, bug 1057908
|
||||||
[test_eme_canvas_blocked.html]
|
[test_eme_canvas_blocked.html]
|
||||||
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # bug 1043403, bug 1057908
|
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # bug 1043403, bug 1057908
|
||||||
[test_eme_persistent_sessions.html]
|
[test_eme_persistent_sessions.html]
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Test EME blocked cross-origin</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 TestNoCORS(test, token)
|
||||||
|
{
|
||||||
|
var token = token + "_nocors";
|
||||||
|
|
||||||
|
manager.started(token);
|
||||||
|
|
||||||
|
var v = document.createElement("video");
|
||||||
|
|
||||||
|
v.addEventListener("encrypted", function(ev) {
|
||||||
|
is(ev.initDataType, "", "initDataType should be empty for CORS cross-origin media");
|
||||||
|
is(ev.initData, null, "initData should be null for CORS cross-origin media");
|
||||||
|
|
||||||
|
manager.finished(token);
|
||||||
|
});
|
||||||
|
|
||||||
|
v.addEventListener("error", function() {
|
||||||
|
ok(false, "Should not receive error loading cross-origin media without crossorigin attribute");
|
||||||
|
});
|
||||||
|
|
||||||
|
v.src = test.uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
function TestCORSFailure(test, token)
|
||||||
|
{
|
||||||
|
var token = token + "_corsfail";
|
||||||
|
|
||||||
|
manager.started(token);
|
||||||
|
|
||||||
|
var v = document.createElement("video");
|
||||||
|
v.crossOrigin = true;
|
||||||
|
|
||||||
|
v.addEventListener("error", function(ev) {
|
||||||
|
ok(true, "Should get error loading cross-origin media");
|
||||||
|
manager.finished(token);
|
||||||
|
});
|
||||||
|
|
||||||
|
v.addEventListener("encrypted", function() {
|
||||||
|
ok(false, "Should not receive encrypted event loading cross-origin media");
|
||||||
|
});
|
||||||
|
|
||||||
|
v.src = test.uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
function TestCORSSuccess(test, token)
|
||||||
|
{
|
||||||
|
var token = token + "_corsok";
|
||||||
|
|
||||||
|
manager.started(token);
|
||||||
|
|
||||||
|
var v = document.createElement("video");
|
||||||
|
v.crossOrigin = true;
|
||||||
|
|
||||||
|
v.addEventListener("error", function(ev) {
|
||||||
|
ok(false, "Should not get error loading cross-origin media");
|
||||||
|
});
|
||||||
|
|
||||||
|
v.addEventListener("encrypted", function(ev) {
|
||||||
|
ok(ev.initData.byteLength > 0, "Should get encryption initData loading cross-origin media");
|
||||||
|
is(ev.initDataType, "cenc", "Should get correct encryption initDataType loading cross-origin media");
|
||||||
|
manager.finished(token);
|
||||||
|
});
|
||||||
|
|
||||||
|
v.src = test.uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
function startTest(test, token)
|
||||||
|
{
|
||||||
|
test.uri = "http://test1.mochi.test:8888/tests/dom/media/test/" + test.name;
|
||||||
|
TestNoCORS(test, token);
|
||||||
|
TestCORSFailure(test, token);
|
||||||
|
|
||||||
|
test.uri = "http://test1.mochi.test:8888/tests/dom/media/test/allowed.sjs?" + test.name;
|
||||||
|
TestCORSSuccess(test, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
function beginTest() {
|
||||||
|
manager.runTests(gEMETests.filter(t => t.crossOrigin), 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>
|
|
@ -5,7 +5,7 @@
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
<script type="text/javascript" src="manifest.js"></script>
|
<script type="text/javascript" src="manifest.js"></script>
|
||||||
<script type="text/javascript" src="eme.js"></script>
|
<script type="text/javascript" src="http://test1.mochi.test:8888/tests/dom/media/test/eme.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<pre id="test">
|
<pre id="test">
|
||||||
|
|
Загрузка…
Ссылка в новой задаче