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

fix(Ads): Avoid adding custom interstitials without URI #7696

Merged
merged 1 commit into from
Nov 29, 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
8 changes: 8 additions & 0 deletions lib/ads/interstitial_ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,18 @@ shaka.ads.InterstitialAdManager = class {
addInterstitials(interstitials) {
let cuepointsChanged = false;
for (const interstitial of interstitials) {
if (!interstitial.uri) {
shaka.log.alwaysWarn('Missing URL in interstitial', interstitial);
continue;
}
const interstitialId = interstitial.id || JSON.stringify(interstitial);
if (this.interstitialIds_.has(interstitialId)) {
continue;
}
if (interstitial.loop && !interstitial.overlay) {
shaka.log.alwaysWarn('Loop is only supported in overlay interstitials',
interstitial);
}
if (!interstitial.overlay) {
cuepointsChanged = true;
}
Expand Down
26 changes: 26 additions & 0 deletions test/ads/interstitial_ad_manager_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,32 @@ describe('Interstitial Ad manager', () => {
expect(onEventSpy).toHaveBeenCalledWith(
jasmine.objectContaining(eventValue1));
});

it('ignore invalid interstitial', async () => {
// It is not valid because it does not have an interstitial URL
const interstitial = {
id: null,
startTime: 10,
endTime: null,
uri: '',
mimeType: null,
isSkippable: true,
skipOffset: 10,
skipFor: null,
canJump: false,
resumeOffset: null,
playoutLimit: null,
once: true,
pre: false,
post: false,
timelineRange: false,
loop: false,
overlay: null,
};
await interstitialAdManager.addInterstitials([interstitial]);

expect(onEventSpy).not.toHaveBeenCalled();
});
});

describe('VAST', () => {
Expand Down
Loading