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/events-session-closed-event.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.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/events-session-closed-event.js')
-rw-r--r-- | testing/web-platform/tests/encrypted-media/scripts/events-session-closed-event.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/scripts/events-session-closed-event.js b/testing/web-platform/tests/encrypted-media/scripts/events-session-closed-event.js new file mode 100644 index 0000000000..44f683eac8 --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/scripts/events-session-closed-event.js @@ -0,0 +1,52 @@ +function runTest(config, qualifier) +{ + var testname = testnamePrefix(qualifier, config.keysystem) + ' test MediaKeySession closed event.'; + + var configuration = { + initDataTypes: [config.initDataType], + audioCapabilities: [{ + contentType: config.audioType + }], + videoCapabilities: [{ + contentType: config.videoType + }], + sessionTypes: ['temporary'] + }; + + promise_test(function (test) { + var initDataType; + var initData; + var mediaKeySession; + + return navigator.requestMediaKeySystemAccess(config.keysystem, [configuration]).then(function (access) { + initDataType = access.getConfiguration().initDataTypes[0]; + return access.createMediaKeys(); + }).then(function (mediaKeys) { + mediaKeySession = mediaKeys.createSession(); + if(config.initData) { + initData = config.initData; + } else { + initData = stringToUint8Array(atob(config.content.keys[0].initData)); + } + return mediaKeySession.generateRequest(initDataType, initData); + }).then(function() { + // close() should result in the closed promise being + // fulfilled. + return mediaKeySession.close(); + }).then(function (result) { + assert_equals(result, undefined); + // Wait for the session to be closed. + return mediaKeySession.closed; + }).then(function (result) { + assert_equals(result, undefined); + // Now that the session is closed, verify that the + // closed attribute immediately returns a fulfilled + // promise. + return mediaKeySession.closed; + }).then(function (result) { + assert_equals(result, undefined); + }).catch(function(error) { + assert_unreached('Error: ' + error.name); + }); + }, testname); +}
\ No newline at end of file |