diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/encrypted-media/scripts/onencrypted.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/encrypted-media/scripts/onencrypted.js')
-rw-r--r-- | testing/web-platform/tests/encrypted-media/scripts/onencrypted.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/scripts/onencrypted.js b/testing/web-platform/tests/encrypted-media/scripts/onencrypted.js new file mode 100644 index 000000000..7c969a9e5 --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/scripts/onencrypted.js @@ -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; +} |