summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/encrypted-media/scripts/events.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/encrypted-media/scripts/events.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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/events.js')
-rw-r--r--testing/web-platform/tests/encrypted-media/scripts/events.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/scripts/events.js b/testing/web-platform/tests/encrypted-media/scripts/events.js
new file mode 100644
index 000000000..85c86ae78
--- /dev/null
+++ b/testing/web-platform/tests/encrypted-media/scripts/events.js
@@ -0,0 +1,59 @@
+function runTest(config,qualifier) {
+
+ var testname = testnamePrefix(qualifier, config.keysystem) + ', basic events';
+
+ var configuration = getSimpleConfigurationForContent(config.content);
+
+ if (config.initDataType && config.initData) {
+ configuration.initDataTypes = [config.initDataType];
+ }
+
+ async_test(function(test)
+ {
+ var initDataType;
+ var initData;
+ var mediaKeySession;
+
+ function onFailure(error) {
+ forceTestFailureFromPromise(test, error);
+ }
+
+ function processMessage(event)
+ {
+ assert_true(event instanceof window.MediaKeyMessageEvent);
+ assert_equals(event.target, mediaKeySession);
+ assert_equals(event.type, 'message');
+ assert_in_array(event.messageType,['license-request', 'individualization-request']);
+
+ config.messagehandler( event.messageType, event.message ).then(function(response) {
+ waitForEventAndRunStep('keystatuseschange', mediaKeySession, test.step_func(processKeyStatusesChange), test);
+ return mediaKeySession.update( response );
+ }).catch(onFailure);
+ }
+
+ function processKeyStatusesChange(event)
+ {
+ assert_true(event instanceof Event);
+ assert_equals(event.target, mediaKeySession);
+ assert_equals(event.type, 'keystatuseschange');
+ test.done();
+ }
+
+ navigator.requestMediaKeySystemAccess(config.keysystem,[configuration]).then(function(access) {
+ initDataType = access.getConfiguration().initDataTypes[0];
+
+ if (config.initDataType && config.initData) {
+ initData = config.initData;
+ } else {
+ initData = getInitData(config.content, initDataType);
+ }
+
+ return access.createMediaKeys();
+ }).then(test.step_func(function(mediaKeys) {
+ mediaKeySession = mediaKeys.createSession();
+ waitForEventAndRunStep('message', mediaKeySession, test.step_func(processMessage), test);
+ return mediaKeySession.generateRequest(initDataType, initData);
+ })).catch(onFailure);
+ }, testname );
+
+}