diff --git a/dom/media/test/eme.js b/dom/media/test/eme.js index cf9dc6bc79fb..fb741a4792b0 100644 --- a/dom/media/test/eme.js +++ b/dom/media/test/eme.js @@ -156,6 +156,17 @@ function MaybeCrossOriginURI(test, uri) } } +function BSD16(a) +{ + var c = 0x1234; + var i = 0; + var l = a.length; + for (i = 0; i < l; i++) { + c = (((((c >>> 1) + ((c & 1) << 15)) | 0) + (a[i] & 0xff)) & 0xffff) | 0; + } + return c; +}; + function AppendTrack(test, ms, track, token) { return new Promise(function(resolve, reject) { @@ -172,15 +183,31 @@ function AppendTrack(test, ms, track, token) return; } - fragmentFile = MaybeCrossOriginURI(test, track.fragments[curFragment++]); + var fragment = track.fragments[curFragment++]; + if (typeof fragment === "string") { + fragment = { file:fragment, size:-1, bsd16:-1 }; + } + + fragmentFile = MaybeCrossOriginURI(test, fragment.file); var req = new XMLHttpRequest(); req.open("GET", fragmentFile); req.responseType = "arraybuffer"; req.addEventListener("load", function() { + var u8array = new Uint8Array(req.response); + if (fragment.size !== undefined && fragment.size >= 0) { + is(u8array.length, fragment.size, + token + " fragment '" + fragmentFile + "' size: expected " + + fragment.size + ", got " + u8array.length); + } + if (fragment.bsd16 !== undefined && fragment.bsd16 >= 0) { + is(BSD16(u8array), fragment.bsd16, + token + " fragment '" + fragmentFile + "' checksum: expected " + + fragment.bsd16 + ", got " + BSD16(u8array)); + } Log(token, track.name + ": fetch of " + fragmentFile + " complete, appending"); - sb.appendBuffer(new Uint8Array(req.response)); + sb.appendBuffer(u8array); }); req.addEventListener("error", function(){info(token + " error fetching " + fragmentFile);}); diff --git a/dom/media/test/manifest.js b/dom/media/test/manifest.js index 82fd44285ba1..4a77e0d99c1f 100644 --- a/dom/media/test/manifest.js +++ b/dom/media/test/manifest.js @@ -652,9 +652,9 @@ var gEMETests = [ { name:"video", type:"video/mp4; codecs=\"avc1.64000d\"", - fragments:[ "bipbop-cenc-videoinit.mp4", - "bipbop-cenc-video1.m4s", - "bipbop-cenc-video2.m4s", + fragments:[ { file:"bipbop-cenc-videoinit.mp4", size:1058, bsd16:63578 }, + { file:"bipbop-cenc-video1.m4s", size:25211, bsd16:39494 }, + { file:"bipbop-cenc-video2.m4s", size:22934, bsd16:24908 }, ] } ], @@ -673,9 +673,9 @@ var gEMETests = [ { name:"video", type:"video/mp4; codecs=\"avc1.64000d\"", - fragments:[ "bipbop-cenc-videoinit.mp4", - "bipbop-cenc-video1.m4s", - "bipbop-cenc-video2.m4s", + fragments:[ { file:"bipbop-cenc-videoinit.mp4", size:1058, bsd16:63578 }, + { file:"bipbop-cenc-video1.m4s", size:25211, bsd16:39494 }, + { file:"bipbop-cenc-video2.m4s", size:22934, bsd16:24908 }, ] } ], @@ -695,19 +695,19 @@ var gEMETests = [ { name:"audio", type:"audio/mp4; codecs=\"mp4a.40.2\"", - fragments:[ "bipbop-cenc-audioinit.mp4", - "bipbop-cenc-audio1.m4s", - "bipbop-cenc-audio2.m4s", - "bipbop-cenc-audio3.m4s", + fragments:[ { file:"bipbop-cenc-audioinit.mp4", size:1000, bsd16:50248 }, + { file:"bipbop-cenc-audio1.m4s", size:921, bsd16:21737 }, + { file:"bipbop-cenc-audio2.m4s", size:565, bsd16:14663 }, + { file:"bipbop-cenc-audio3.m4s", size:977, bsd16:38572 }, ], }, { name:"video", type:"video/mp4; codecs=\"avc1.64000d\"", - fragments:[ "bipbop-cenc-videoinit.mp4", - "bipbop-cenc-video1.m4s", - "bipbop-cenc-video2.m4s", - ], + fragments:[ { file:"bipbop-cenc-videoinit.mp4", size:1058, bsd16:63578 }, + { file:"bipbop-cenc-video1.m4s", size:25211, bsd16:39494 }, + { file:"bipbop-cenc-video2.m4s", size:22934, bsd16:24908 }, + ] }, ], keys: { @@ -725,19 +725,19 @@ var gEMETests = [ { name:"audio", type:"audio/mp4; codecs=\"mp4a.40.2\"", - fragments:[ "bipbop-cenc-audioinit.mp4", - "bipbop-cenc-audio1.m4s", - "bipbop-cenc-audio2.m4s", - "bipbop-cenc-audio3.m4s", + fragments:[ { file:"bipbop-cenc-audioinit.mp4", size:1000, bsd16:50248 }, + { file:"bipbop-cenc-audio1.m4s", size:921, bsd16:21737 }, + { file:"bipbop-cenc-audio2.m4s", size:565, bsd16:14663 }, + { file:"bipbop-cenc-audio3.m4s", size:977, bsd16:38572 }, ], }, { name:"video", type:"video/mp4; codecs=\"avc1.64000d\"", - fragments:[ "bipbop-cenc-videoinit.mp4", - "bipbop-cenc-video1.m4s", - "bipbop-cenc-video2.m4s", - ], + fragments:[ { file:"bipbop-cenc-videoinit.mp4", size:1058, bsd16:63578 }, + { file:"bipbop-cenc-video1.m4s", size:25211, bsd16:39494 }, + { file:"bipbop-cenc-video2.m4s", size:22934, bsd16:24908 }, + ] }, ], keys: {