From e8b8c8effc5371e498ed0d6b77ac532fc0713328 Mon Sep 17 00:00:00 2001 From: Edwin Flores Date: Thu, 29 Jan 2015 20:30:38 +1300 Subject: [PATCH] Bug 1101304 - Test that EME works with CORS - r=cpearce --- dom/media/test/allowed.sjs | 3 + dom/media/test/eme.js | 14 ++- dom/media/test/manifest.js | 25 +++++ dom/media/test/mochitest.ini | 2 + dom/media/test/test_eme_access_control.html | 112 ++++++++++++++++++++ dom/media/test/test_eme_playback.html | 2 +- 6 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 dom/media/test/test_eme_access_control.html diff --git a/dom/media/test/allowed.sjs b/dom/media/test/allowed.sjs index 281f8b43e188..3c2258557a1b 100644 --- a/dom/media/test/allowed.sjs +++ b/dom/media/test/allowed.sjs @@ -13,6 +13,9 @@ function parseQuery(request, key) { } var types = { + js: "text/javascript", + m4s: "video/mp4", + mp4: "video/mp4", ogg: "video/ogg", ogv: "video/ogg", oga: "audio/ogg", diff --git a/dom/media/test/eme.js b/dom/media/test/eme.js index 5772f6438a08..e7587a821e9a 100644 --- a/dom/media/test/eme.js +++ b/dom/media/test/eme.js @@ -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) { return new Promise(function(resolve, reject) { @@ -140,7 +149,7 @@ function PlayFragmented(test, elem, token) return; } - var fragmentFile = test.fragments[curFragment++]; + var fragmentFile = MaybeCrossOriginURI(test, test.fragments[curFragment++]); var req = new XMLHttpRequest(); req.open("GET", fragmentFile); @@ -179,7 +188,7 @@ function LoadTest(test, elem, token) // This file isn't fragmented; set the media source normally. return new Promise(function(resolve, reject) { - elem.src = test.name; + elem.src = MaybeCrossOriginURI(test, test.name); resolve(); }); } @@ -187,6 +196,7 @@ function LoadTest(test, elem, token) function SetupEME(test, token, params) { var v = document.createElement("video"); + v.crossOrigin = test.crossOrigin || false; // Log events dispatched to make debugging easier... [ "canplay", "canplaythrough", "ended", "error", "loadeddata", diff --git a/dom/media/test/manifest.js b/dom/media/test/manifest.js index 06c8902511c8..4c58cec06964 100644 --- a/dom/media/test/manifest.js +++ b/dom/media/test/manifest.js @@ -652,6 +652,18 @@ var gEMETests = [ sessionType:"temporary", 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", fragments: [ "gizmo-frag-cencinit.mp4", "gizmo-frag-cenc1.m4s", "gizmo-frag-cenc2.m4s" ], @@ -664,6 +676,19 @@ var gEMETests = [ sessionType:"temporary", 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) { diff --git a/dom/media/test/mochitest.ini b/dom/media/test/mochitest.ini index 91b425db75d4..f06f3b35b45f 100644 --- a/dom/media/test/mochitest.ini +++ b/dom/media/test/mochitest.ini @@ -364,6 +364,8 @@ skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439 [test_defaultMuted.html] [test_delay_load.html] 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] skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # bug 1043403, bug 1057908 [test_eme_persistent_sessions.html] diff --git a/dom/media/test/test_eme_access_control.html b/dom/media/test/test_eme_access_control.html new file mode 100644 index 000000000000..6429dab41aff --- /dev/null +++ b/dom/media/test/test_eme_access_control.html @@ -0,0 +1,112 @@ + + + + Test EME blocked cross-origin + + + + + + +
+
+
+ + diff --git a/dom/media/test/test_eme_playback.html b/dom/media/test/test_eme_playback.html index f5e34067b658..9202a7cc4d35 100644 --- a/dom/media/test/test_eme_playback.html +++ b/dom/media/test/test_eme_playback.html @@ -5,7 +5,7 @@ - +