diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/encrypted-media/scripts/expiration.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/encrypted-media/scripts/expiration.js')
-rw-r--r-- | testing/web-platform/tests/encrypted-media/scripts/expiration.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/scripts/expiration.js b/testing/web-platform/tests/encrypted-media/scripts/expiration.js new file mode 100644 index 0000000000..96b7fbfeef --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/scripts/expiration.js @@ -0,0 +1,43 @@ +function runTest(config,qualifier) { + + var testname = testnamePrefix(qualifier, config.keysystem) + ', expiration'; + + var configuration = getSimpleConfigurationForContent(config.content); + if (config.initDataType && config.initData) { + configuration.initDataTypes = [config.initDataType]; + } + + async_test(function(test) { + + var _mediaKeys, + _mediaKeySession; + + function onFailure(error) { + forceTestFailureFromPromise(test, error); + } + + function onMessage(event) { + assert_equals(event.target, _mediaKeySession); + assert_true(event instanceof window.MediaKeyMessageEvent); + assert_equals(event.type, 'message'); + + assert_in_array(event.messageType, [ 'license-request', 'individualization-request' ] ); + + config.messagehandler(event.messageType, event.message, {expiration: config.expiration}).then(function(response) { + return event.target.update(response); + }).then(test.step_func(function() { + assert_approx_equals(event.target.expiration, config.expiration, 4000, "expiration attribute should equal provided expiration time"); + test.done(); + })).catch(onFailure); + } + + navigator.requestMediaKeySystemAccess(config.keysystem, [configuration]).then(function(access) { + return access.createMediaKeys(); + }).then(function(mediaKeys) { + _mediaKeys = mediaKeys; + _mediaKeySession = _mediaKeys.createSession( 'temporary' ); + waitForEventAndRunStep('message', _mediaKeySession, onMessage, test); + return _mediaKeySession.generateRequest(config.initDataType, config.initData); + }).catch(onFailure); + }, testname); +} |