Skip to content

Commit 0af369d

Browse files
authored
Consent management: fix bug with adUnits without a size causing exception in GPDR processing (#8305)
1 parent 12b8e9f commit 0af369d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

modules/consentManagement.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ export function requestBidsHook(fn, reqBidsConfigObj) {
335335
let height = 1;
336336
if (Array.isArray(adUnits) && adUnits.length > 0) {
337337
let sizes = getAdUnitSizes(adUnits[0]);
338-
width = sizes[0][0];
339-
height = sizes[0][1];
338+
width = sizes?.[0]?.[0] || 1;
339+
height = sizes?.[0]?.[1] || 1;
340340
}
341341

342342
return function (cb) {

test/spec/modules/consentManagement_spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ describe('consentManagement', function () {
299299
allowAuctionWithoutConsent: true
300300
};
301301

302+
const staticConfig = {
303+
cmpApi: 'static',
304+
timeout: 7500,
305+
consentData: {
306+
getTCData: {}
307+
}
308+
}
309+
302310
let didHookReturn;
303311

304312
afterEach(function () {
@@ -357,6 +365,17 @@ describe('consentManagement', function () {
357365
expect(consent).to.be.null;
358366
expect(gdprDataHandler.ready).to.be.true;
359367
});
368+
369+
it('should not trip when adUnits have no size', () => {
370+
setConsentConfig(staticConfig);
371+
let ran = false;
372+
requestBidsHook(() => {
373+
ran = true;
374+
}, {adUnits: [{code: 'test', mediaTypes: {video: {}}}]});
375+
return gdprDataHandler.promise.then(() => {
376+
expect(ran).to.be.true;
377+
});
378+
})
360379
});
361380

362381
describe('already known consentData:', function () {

0 commit comments

Comments
 (0)