mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
|
|
@ -0,0 +1,47 @@
|
|||
function runTest(config) {
|
||||
var expectedInitData = [];
|
||||
expectedInitData.push(stringToUint8Array(atob(config.keys[0].initData)));
|
||||
expectedInitData.push(stringToUint8Array(atob(config.keys[1].initData)));
|
||||
|
||||
// Will get 2 identical events, one for audio, one for video.
|
||||
var expectedEvents = 2;
|
||||
var currentData;
|
||||
|
||||
async_test(function (test) {
|
||||
var video = config.video,
|
||||
mediaSource,
|
||||
onEncrypted = function (event) {
|
||||
currentData = new Uint8Array(event.initData);
|
||||
assert_equals(event.target, config.video);
|
||||
assert_true(event instanceof window.MediaEncryptedEvent);
|
||||
assert_equals(event.type, 'encrypted');
|
||||
assert_equals(event.initDataType, 'cenc');
|
||||
// At this point we do not know if the event is related to audio or video. So check for both expected init data
|
||||
assert_true(checkInitData(currentData, expectedInitData[0]) || checkInitData(currentData, expectedInitData[1]));
|
||||
|
||||
if (--expectedEvents === 0) {
|
||||
test.done();
|
||||
}
|
||||
};
|
||||
|
||||
waitForEventAndRunStep('encrypted', video, onEncrypted, test);
|
||||
return testmediasource(config).then(test.step_func(function (source) {
|
||||
mediaSource = source;
|
||||
config.video.src = URL.createObjectURL(mediaSource);
|
||||
video.play();
|
||||
}));
|
||||
}, 'encrypted fired on encrypted media file.'
|
||||
);
|
||||
}
|
||||
|
||||
function checkInitData(data, expectedData) {
|
||||
if (data.length !== expectedData.length) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (data[i] !== expectedData[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue