diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/encrypted-media/scripts/invalid-license.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/encrypted-media/scripts/invalid-license.js')
-rw-r--r-- | testing/web-platform/tests/encrypted-media/scripts/invalid-license.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/scripts/invalid-license.js b/testing/web-platform/tests/encrypted-media/scripts/invalid-license.js new file mode 100644 index 0000000000..89d43769e5 --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/scripts/invalid-license.js @@ -0,0 +1,38 @@ +function runTest(config) +{ + promise_test(function (test) { + var initDataType; + var initData; + var keySystem = config.keysystem; + var invalidLicense = new Uint8Array([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77]); + var messageEventFired = false; + + var p = navigator.requestMediaKeySystemAccess(keySystem, getSimpleConfiguration()).then(function (access) { + initDataType = access.getConfiguration().initDataTypes[0]; + initData = getInitData(initDataType); + return access.createMediaKeys(); + }).then(function (mediaKeys) { + var keySession = mediaKeys.createSession(); + var eventWatcher = new EventWatcher(test, keySession, ['message']); + var promise = eventWatcher.wait_for('message'); + keySession.generateRequest(initDataType, initData); + return promise; + }).then(function (messageEvent) { + messageEventFired = true; + return messageEvent.target.update(invalidLicense); + }).catch(function (error) { + // Ensure we reached the update() call we are trying to test. + if (!messageEventFired) { + assert_unreached( + `Failed to reach the update() call. Error: '${error.name}' '${error.message}'`); + } + + // Propagate the error on through. + throw error; + }); + + return promise_rejects_js( + test, TypeError, p, + 'update() should fail because of an invalid license.'); + }, 'Update with invalid Clear Key license'); +} |