Skip to content

Commit

Permalink
consentManagementGPP: do not cancel auctions when CMP is not version …
Browse files Browse the repository at this point in the history
…1.0 (#10247)
  • Loading branch information
dgirardi authored Jul 19, 2023
1 parent 8a3869c commit a318783
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/consentManagementGpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,20 @@ export function lookupIabConsent({onSuccess, onError}, mkClient = cmpClient) {
: 'Detected GPP CMP is outside the current iframe where Prebid.js is located, calling it now...';
logInfo(startupMsg);

let versionMismatch = false;

cmp({
command: 'addEventListener',
callback: function (evt) {
if (evt) {
if (evt && !versionMismatch) {
logInfo(`Received a ${(cmp.isDirect ? 'direct' : 'postmsg')} response from GPP CMP for event`, evt);
const cmpVer = evt?.pingData?.gppVersion;
if (cmpVer != null && cmpVer !== '1.0') {
logWarn(`Unsupported GPP CMP version: ${cmpVer}. Continuing auction without consent`);
versionMismatch = true;
onSuccess(storeConsentData());
return;
}
if (evt.eventName === 'sectionChange' || evt.pingData.cmpStatus === 'loaded') {
cmp({command: 'getGPPData'}).then((gppData) => {
logInfo(`Received a ${cmp.isDirect ? 'direct' : 'postmsg'} response from GPP CMP for getGPPData`, gppData);
Expand Down
16 changes: 16 additions & 0 deletions test/spec/modules/consentManagementGpp_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ describe('consentManagementGpp', function () {
expect(res.sectionData).to.eql(sectionData);
})
});

it('continues with no consent when CMP version is not 1.0', () => {
const pm = runLookup();
mockCmpEvent({
eventName: 'listenerRegistered',
pingData: {
gppVersion: '1.1'
}
});
return pm.then((res) => {
sinon.assert.match(res, {
gppString: undefined,
applicableSections: []
})
})
})
})

describe('static consent string setConsentConfig value', () => {
Expand Down

0 comments on commit a318783

Please sign in to comment.