diff --git a/modules/missenaBidAdapter.js b/modules/missenaBidAdapter.js index a06ba1ce29c..5e68f56ed1c 100644 --- a/modules/missenaBidAdapter.js +++ b/modules/missenaBidAdapter.js @@ -59,9 +59,11 @@ export const spec = { buildRequests: function (validBidRequests, bidderRequest) { const capKey = `missena.missena.capper.remove-bubble.${validBidRequests[0]?.params.apiKey}`; const capping = safeJSONParse(storage.getDataFromLocalStorage(capKey)); + const referer = bidderRequest?.refererInfo?.topmostLocation; if ( typeof capping?.expiry === 'number' && - new Date().getTime() < capping?.expiry + new Date().getTime() < capping?.expiry && + (!capping?.referer || capping?.referer == referer) ) { logInfo('Missena - Capped'); return []; diff --git a/test/spec/modules/missenaBidAdapter_spec.js b/test/spec/modules/missenaBidAdapter_spec.js index 15f9eff89e7..a51cb8bbac9 100644 --- a/test/spec/modules/missenaBidAdapter_spec.js +++ b/test/spec/modules/missenaBidAdapter_spec.js @@ -2,6 +2,9 @@ import { expect } from 'chai'; import { spec, storage } from 'modules/missenaBidAdapter.js'; import { BANNER } from '../../../src/mediaTypes.js'; +const REFERRER = 'https://referer'; +const REFERRER2 = 'https://referer2'; + describe('Missena Adapter', function () { $$PREBID_GLOBAL$$.bidderSettings = { missena: { @@ -50,7 +53,7 @@ describe('Missena Adapter', function () { gdprApplies: true, }, refererInfo: { - topmostLocation: 'https://referer', + topmostLocation: REFERRER, canonicalUrl: 'https://canonical', }, }; @@ -112,7 +115,7 @@ describe('Missena Adapter', function () { }); it('should send referer information to the request', function () { - expect(payload.referer).to.equal('https://referer'); + expect(payload.referer).to.equal(REFERRER); expect(payload.referer_canonical).to.equal('https://canonical'); }); @@ -146,6 +149,40 @@ describe('Missena Adapter', function () { it('should not participate if capped', function () { expect(cappedRequests.length).to.equal(0); }); + + const localStorageDataSamePage = { + [`missena.missena.capper.remove-bubble.${bid.params.apiKey}`]: + JSON.stringify({ + expiry: new Date().getTime() + 600_000, // 10 min into the future + referer: REFERRER, + }), + }; + + getDataFromLocalStorageStub.callsFake( + (key) => localStorageDataSamePage[key], + ); + const cappedRequestsSamePage = spec.buildRequests(bids, bidderRequest); + + it('should not participate if capped on same page', function () { + expect(cappedRequestsSamePage.length).to.equal(0); + }); + + const localStorageDataOtherPage = { + [`missena.missena.capper.remove-bubble.${bid.params.apiKey}`]: + JSON.stringify({ + expiry: new Date().getTime() + 600_000, // 10 min into the future + referer: REFERRER2, + }), + }; + + getDataFromLocalStorageStub.callsFake( + (key) => localStorageDataOtherPage[key], + ); + const cappedRequestsOtherPage = spec.buildRequests(bids, bidderRequest); + + it('should participate if capped on a different page', function () { + expect(cappedRequestsOtherPage.length).to.equal(2); + }); }); describe('interpretResponse', function () {