Files
shaka-player/test/util/functional_unit.js
T
Daniel Mariño 07894ecf14 fix: Timeout unfulfilled request to decodingInfo and requestMediaKeySystemAccess (#7682)
On some (Android) WebView environments,
decodingInfo and requestMediaKeySystemAccess will
not resolve or reject, at least if RESOURCE_PROTECTED_MEDIA_ID is not
set.
This is a workaround for that issue.

Closes #7680
2024-11-29 12:06:32 +01:00

35 lines
1.1 KiB
JavaScript

/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
describe('Functional', () => {
const Functional = shaka.util.Functional;
describe('promiseWithTimeout', () => {
it('resolves if asyncProcess resolves within the timeout', async () => {
const asyncProcess = new Promise((resolve) =>
setTimeout(() => resolve('success'), 100),
);
const result = await Functional.promiseWithTimeout(1, asyncProcess);
expect(result).toBe('success');
});
it('rejects if asyncProcess rejects', async () => {
const asyncProcess = new Promise((_, reject) =>
setTimeout(() => reject('error'), 100),
);
const promise = Functional.promiseWithTimeout(1, asyncProcess);
await expectAsync(promise).toBeRejectedWith('error');
});
it('rejects if asyncProcess takes longer than the timeout', async () => {
const asyncProcess = new Promise((resolve) =>
setTimeout(() => resolve('success'), 2000),
);
const promise = Functional.promiseWithTimeout(1, asyncProcess);
await expectAsync(promise).toBeRejected();
});
});
});