Skip to content

Commit

Permalink
consentManagementUsp: fix bug where data deletion events are triggere…
Browse files Browse the repository at this point in the history
…d when CMP does not support `registerDeletion` (#10574)
  • Loading branch information
dgirardi committed Oct 4, 2023
1 parent 3396f47 commit 8f10237
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/consentManagementUsp.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function lookupUspConsent({onSuccess, onError}) {

cmp({
command: 'registerDeletion',
callback: adapterManager.callDataDeletionRequest
callback: (res, success) => (success == null || success) && adapterManager.callDataDeletionRequest(res)
}).catch(e => {
logError('Error invoking CMP `registerDeletion`:', e);
});
Expand Down
13 changes: 13 additions & 0 deletions test/spec/modules/consentManagementUsp_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,19 @@ describe('consentManagement', function () {
setConsentConfig(goodConfig);
expect(uspDataHandler.getConsentData()).to.eql('string');
});

it('does not invoke registerDeletion if the CMP calls back with an error', () => {
sandbox.stub(window, '__uspapi').callsFake((cmd, _, cb) => {
if (cmd === 'registerDeletion') {
cb(null, false);
} else {
// eslint-disable-next-line standard/no-callback-literal
cb({uspString: 'string'}, true);
}
});
setConsentConfig(goodConfig);
sinon.assert.notCalled(adapterManager.callDataDeletionRequest);
})
});
});
});

0 comments on commit 8f10237

Please sign in to comment.