Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Deduplicate platform support check #7450

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/cast/cast_receiver_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ filterDescribe('CastReceiver', castReceiverIntegrationSupport, () => {
});
});

const widevineSupport =
() => window['shakaSupport'].drm['com.widevine.alpha'];
const widevineSupport = () => shakaSupport.drm['com.widevine.alpha'];
filterDescribe('with drm', widevineSupport, () => {
drmIt('sends reasonably-sized updates', async () => {
// Use an encrypted asset, to make sure DRM info doesn't balloon the size.
Expand Down
2 changes: 1 addition & 1 deletion test/dash/dash_parser_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('DashParser', () => {
let waiter;

function checkClearKeySupport() {
const clearKeySupport = window['shakaSupport'].drm['org.w3.clearkey'];
const clearKeySupport = shakaSupport.drm['org.w3.clearkey'];
if (!clearKeySupport) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion test/hls/hls_parser_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('HlsParser', () => {
let waiter;

function checkClearKeySupport() {
const clearKeySupport = window['shakaSupport'].drm['org.w3.clearkey'];
const clearKeySupport = shakaSupport.drm['org.w3.clearkey'];
if (!clearKeySupport) {
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions test/media/drm_engine_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ describe('DrmEngine', () => {
// https://testweb.playready.microsoft.com/Server/ServiceQueryStringSyntax
return false;
}
return window['shakaSupport'].drm['com.widevine.alpha'] ||
window['shakaSupport'].drm['com.microsoft.playready'];
return shakaSupport.drm['com.widevine.alpha'] ||
shakaSupport.drm['com.microsoft.playready'];
}

function checkClearKeySupport() {
return window['shakaSupport'].drm['org.w3.clearkey'];
return shakaSupport.drm['org.w3.clearkey'];
}

filterDescribe('basic flow', checkTrueDrmSupport, () => {
Expand Down
4 changes: 2 additions & 2 deletions test/mss/mss_player_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ describe('MSS Player', () => {

function checkPlayReadySupport() {
const playReadySupport =
window['shakaSupport'].drm['com.microsoft.playready'] ||
window['shakaSupport'].drm['com.chromecast.playready'];
shakaSupport.drm['com.microsoft.playready'] ||
shakaSupport.drm['com.chromecast.playready'];
if (!playReadySupport) {
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions test/offline/offline_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ filterDescribe('Offline', supportsStorage, () => {
video = shaka.test.UiUtils.createVideoElement();
document.body.appendChild(video);

widevineSupport = window['shakaSupport'].drm['com.widevine.alpha'];
playreadySupport = window['shakaSupport'].drm['com.microsoft.playready'] ||
window['shakaSupport'].drm['com.chromecast.playready'];
widevineSupport = shakaSupport.drm['com.widevine.alpha'];
playreadySupport = shakaSupport.drm['com.microsoft.playready'] ||
shakaSupport.drm['com.chromecast.playready'];
});

afterAll(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/offline/storage_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function drmStorageSupport() {
return false;
}

const widevineSupport = window['shakaSupport'].drm['com.widevine.alpha'];
const widevineSupport = shakaSupport.drm['com.widevine.alpha'];
return !!(widevineSupport && widevineSupport.persistentState);
}

Expand Down
6 changes: 3 additions & 3 deletions test/player_external.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ describe('Player', () => {
!asset.drm.some((keySystem) => {
// Demo assets use an enum here, which we look up in idFor.
// Command-line assets use a direct key system ID.
return window['shakaSupport'].drm[idFor(keySystem)] ||
window['shakaSupport'].drm[keySystem];
return shakaSupport.drm[idFor(keySystem)] ||
shakaSupport.drm[keySystem];
})) {
pending('None of the required key systems are supported.');
}
Expand All @@ -124,7 +124,7 @@ describe('Player', () => {
mimeTypes.push('video/mp4; codecs="dvh1.20.01"');
}
if (mimeTypes.length &&
!mimeTypes.some((type) => window['shakaSupport'].media[type])) {
!mimeTypes.some((type) => shakaSupport.media[type])) {
pending('None of the required MIME types are supported.');
}
}
Expand Down
7 changes: 3 additions & 4 deletions test/player_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -1242,10 +1242,9 @@ describe('Player', () => {
/** Regression test for Issue #2741 */
describe('unloading', () => {
drmIt('unloads properly after DRM error', async () => {
const drmSupport = await shaka.media.DrmEngine.probeSupport();
if (!drmSupport['com.widevine.alpha'] &&
!drmSupport['com.microsoft.playready'] &&
!drmSupport['com.chromecast.playready']) {
if (!shakaSupport.drm['com.widevine.alpha'] &&
!shakaSupport.drm['com.microsoft.playready'] &&
!shakaSupport.drm['com.chromecast.playready']) {
pending('Skipping DRM error test, only runs on Widevine and PlayReady');
}

Expand Down
12 changes: 7 additions & 5 deletions test/test/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,14 @@ async function loadDaiScript() {
});
}

async function logSupport() {
async function checkSupport() {
try {
const support = await shaka.Player.probeSupport();
const startMs = Date.now();
window.shakaSupport = await shaka.Player.probeSupport();
const endMs = Date.now();
// Bypass Karma's log settings and dump this to the console.
window.dump('Platform support: ' + JSON.stringify(support, null, 2));
window['shakaSupport'] = support;
window.dump('Platform support: ' + JSON.stringify(shakaSupport, null, 2));
window.dump(`Platform support check took ${endMs - startMs} ms.`);
// eslint-disable-next-line no-restricted-syntax
} catch (error) {
window.dump('Support check failed at boot: ' + error);
Expand All @@ -491,7 +493,7 @@ async function setupTestEnvironment() {
// detected.
shaka.polyfill.installAll();

await logSupport();
await checkSupport();

configureJasmineEnvironment();
}
Expand Down
16 changes: 16 additions & 0 deletions test/test/externs/support.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @fileoverview Externs for a global map of platform support used in tests.
* @externs
*/


/**
* @type {shaka.extern.SupportType}
*/
var shakaSupport;
Loading