diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index a7b7589795d..020725f4043 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -9,7 +9,6 @@ import { parseSizesInput, parseUrl } from '../src/utils.js'; -import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {Renderer} from '../src/Renderer.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; @@ -305,16 +304,7 @@ function isBannerBidValid(bid) { } function getTopWindowLocation(bidderRequest) { - let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer; - return parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true }); -} - -function getTopWindowReferrer() { - try { - return window.top.document.referrer; - } catch (e) { - return ''; - } + return parseUrl(bidderRequest?.refererInfo?.page, { decodeSearchAsString: true }); } function getEids(bid) { @@ -433,7 +423,7 @@ function createVideoRequestData(bid, bidderRequest) { function createBannerRequestData(bids, bidderRequest) { let topLocation = getTopWindowLocation(bidderRequest); - let topReferrer = getTopWindowReferrer(); + let topReferrer = bidderRequest.refererInfo?.ref; let slots = bids.map(bid => { return { slot: bid.adUnitCode, diff --git a/test/spec/modules/appierBidAdapter_spec.js b/test/spec/modules/appierBidAdapter_spec.js index 5b6ccf14162..8b6ad5c2f6f 100644 --- a/test/spec/modules/appierBidAdapter_spec.js +++ b/test/spec/modules/appierBidAdapter_spec.js @@ -64,12 +64,16 @@ describe('AppierAdapter', function () { 'auctionId': '1d1a030790a475', }; const fakeBidRequests = [bid]; - const fakeBidderRequest = {refererInfo: { - 'referer': 'fakeReferer', - 'reachedTop': true, - 'numIframes': 1, - 'stack': [] - }}; + const fakeBidderRequest = { + refererInfo: { + legacy: { + 'referer': 'fakeReferer', + 'reachedTop': true, + 'numIframes': 1, + 'stack': [] + } + } + }; const builtRequests = spec.buildRequests(fakeBidRequests, fakeBidderRequest); expect(builtRequests.length).to.equal(1); @@ -77,7 +81,7 @@ describe('AppierAdapter', function () { expect(builtRequests[0].url).match(/v1\/prebid\/bid/); expect(builtRequests[0].data).deep.equal({ 'bids': fakeBidRequests, - 'refererInfo': fakeBidderRequest.refererInfo, + 'refererInfo': fakeBidderRequest.refererInfo.legacy, 'version': ADAPTER_VERSION }); }); diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index 3ead712b725..c4ee9c40b64 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -155,7 +155,7 @@ describe('BeachfrontAdapter', function () { const topLocation = parseUrl('http://www.example.com?foo=bar', { decodeSearchAsString: true }); const bidderRequest = { refererInfo: { - referer: topLocation.href + page: topLocation.href } }; const requests = spec.buildRequests([ bidRequest ], bidderRequest); @@ -398,7 +398,7 @@ describe('BeachfrontAdapter', function () { const topLocation = parseUrl('http://www.example.com?foo=bar', { decodeSearchAsString: true }); const bidderRequest = { refererInfo: { - referer: topLocation.href + page: topLocation.href } }; const requests = spec.buildRequests([ bidRequest ], bidderRequest); @@ -572,7 +572,7 @@ describe('BeachfrontAdapter', function () { bidRequest.mediaTypes = { video: {} }; const bidderRequest = { refererInfo: { - referer: 'http://example.com/page.html' + page: 'http://example.com/page.html' }, ortb2 }; diff --git a/test/spec/refererDetection_spec.js b/test/spec/refererDetection_spec.js index 8ebfa793f90..69534f0e822 100644 --- a/test/spec/refererDetection_spec.js +++ b/test/spec/refererDetection_spec.js @@ -102,7 +102,7 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page'], 'https://othersite.com/'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { topmostLocation: 'https://example.com/some/page', location: 'https://example.com/some/page', reachedTop: true, @@ -120,7 +120,7 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page'], 'https://othersite.com/', 'https://example.com/canonical/page'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { topmostLocation: 'https://example.com/some/page', location: 'https://example.com/some/page', reachedTop: true, @@ -140,7 +140,7 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://example.com/other/page', 'https://example.com/third/page'], 'https://othersite.com/'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { topmostLocation: 'https://example.com/some/page', location: 'https://example.com/some/page', reachedTop: true, @@ -162,7 +162,7 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://example.com/other/page', 'https://example.com/third/page'], 'https://othersite.com/', 'https://example.com/canonical/page'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { topmostLocation: 'https://example.com/some/page', location: 'https://example.com/some/page', reachedTop: true, @@ -186,7 +186,7 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://example.com/other/page', 'https://example.com/third/page'], 'https://othersite.com/', 'https://example.com/canonical/page'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { topmostLocation: 'https://example.com/some/page', location: 'https://example.com/some/page', reachedTop: true, @@ -211,7 +211,7 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad'], 'https://othersite.com/', 'https://canonical.example.com/'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { location: 'https://example.com/some/page', topmostLocation: 'https://example.com/some/page', reachedTop: true, @@ -232,7 +232,7 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad', 'https://safe.frame/ad'], 'https://othersite.com/', 'https://canonical.example.com/'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { topmostLocation: 'https://example.com/some/page', location: 'https://example.com/some/page', reachedTop: true, @@ -254,7 +254,7 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad', 'https://otherfr.ame/ad'], 'https://othersite.com/', 'https://canonical.example.com/'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { topmostLocation: 'https://safe.frame/ad', location: null, reachedTop: false, @@ -276,7 +276,7 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad', 'https://otherfr.ame/ad'], 'https://othersite.com/', 'https://canonical.example.com/', true), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { topmostLocation: 'https://example.com/', location: 'https://example.com/', reachedTop: false, @@ -306,7 +306,7 @@ describe('Referer detection', () => { const result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { location: 'https://example.com/some/page/amp/', topmostLocation: 'https://example.com/some/page/amp/', reachedTop: true, @@ -333,7 +333,7 @@ describe('Referer detection', () => { const result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { topmostLocation: 'https://example.com/some/page/amp/', location: 'https://example.com/some/page/amp/', reachedTop: true, @@ -361,7 +361,7 @@ describe('Referer detection', () => { const result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { topmostLocation: 'https://example.com/some/page/amp/', location: 'https://example.com/some/page/amp/', reachedTop: false, @@ -389,7 +389,7 @@ describe('Referer detection', () => { const result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { location: 'https://example.com/some/page/amp/', topmostLocation: 'https://example.com/some/page/amp/', reachedTop: false, @@ -417,7 +417,7 @@ describe('Referer detection', () => { const result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ + sinon.assert.match(result, { location: 'https://example.com/some/page/amp/', topmostLocation: 'https://example.com/some/page/amp/', reachedTop: false,