mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-15 16:06:41 +03:00
07894ecf14
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
35 lines
1.1 KiB
JavaScript
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();
|
|
});
|
|
});
|
|
});
|