diff --git a/modules/quantcastBidAdapter.js b/modules/quantcastBidAdapter.js index 739cf75c555..673a7f41c00 100644 --- a/modules/quantcastBidAdapter.js +++ b/modules/quantcastBidAdapter.js @@ -11,27 +11,8 @@ export const QUANTCAST_TEST_DOMAIN = 's2s-canary.quantserve.com'; export const QUANTCAST_NET_REVENUE = true; export const QUANTCAST_TEST_PUBLISHER = 'test-publisher'; export const QUANTCAST_TTL = 4; -export const QUANTCAST_PROTOCOL = - window.location.protocol === 'http:' - ? 'http' - : 'https'; -export const QUANTCAST_PORT = - QUANTCAST_PROTOCOL === 'http' - ? '8080' - : '8443'; - -function extractBidSizes(bid) { - const bidSizes = []; - - bid.sizes.forEach(size => { - bidSizes.push({ - width: size[0], - height: size[1] - }); - }); - - return bidSizes; -} +export const QUANTCAST_PROTOCOL = 'https'; +export const QUANTCAST_PORT = '8443'; function makeVideoImp(bid) { const video = {}; @@ -67,10 +48,17 @@ function makeVideoImp(bid) { } function makeBannerImp(bid) { + const sizes = bid.sizes || bid.mediaTypes.banner.sizes; + return { banner: { battr: bid.params.battr, - sizes: extractBidSizes(bid), + sizes: sizes.map(size => { + return { + width: size[0], + height: size[1] + }; + }) }, placementCode: bid.placementCode, bidFloor: bid.params.bidFloor || DEFAULT_BID_FLOOR diff --git a/test/spec/modules/quantcastBidAdapter_spec.js b/test/spec/modules/quantcastBidAdapter_spec.js index b553cf5d37e..b91536689db 100644 --- a/test/spec/modules/quantcastBidAdapter_spec.js +++ b/test/spec/modules/quantcastBidAdapter_spec.js @@ -28,7 +28,11 @@ describe('Quantcast adapter', function () { publisherId: QUANTCAST_TEST_PUBLISHER, // REQUIRED - Publisher ID provided by Quantcast battr: [1, 2] // OPTIONAL - Array of blocked creative attributes as per OpenRTB Spec List 5.3 }, - sizes: [[300, 250]] + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } }; bidderRequest = { @@ -83,17 +87,10 @@ describe('Quantcast adapter', function () { }); describe('`buildRequests`', function () { - it('selects protocol and port', function () { - switch (window.location.protocol) { - case 'https:': - expect(QUANTCAST_PROTOCOL).to.equal('https'); - expect(QUANTCAST_PORT).to.equal('8443'); - break; - default: - expect(QUANTCAST_PROTOCOL).to.equal('http'); - expect(QUANTCAST_PORT).to.equal('8080'); - break; - } + it('sends secure bid requests', function () { + const requests = qcSpec.buildRequests([bidRequest]); + const url = parse(requests[0]['url']); + expect(url.protocol).to.equal('https'); }); it('sends bid requests to Quantcast Canary Endpoint if `publisherId` is `test-publisher`', function () { @@ -120,30 +117,39 @@ describe('Quantcast adapter', function () { expect(requests[0].method).to.equal('POST'); }); + const expectedBannerBidRequest = { + publisherId: QUANTCAST_TEST_PUBLISHER, + requestId: '2f7b179d443f14', + imp: [ + { + banner: { + battr: [1, 2], + sizes: [{ width: 300, height: 250 }] + }, + placementCode: 'div-gpt-ad-1438287399331-0', + bidFloor: 1e-10 + } + ], + site: { + page: 'http://example.com/hello.html', + referrer: 'http://example.com/hello.html', + domain: 'example.com' + }, + bidId: '2f7b179d443f14', + gdprSignal: 0, + prebidJsVersion: '$prebid.version$' + }; + it('sends banner bid requests contains all the required parameters', function () { const requests = qcSpec.buildRequests([bidRequest], bidderRequest); - const expectedBannerBidRequest = { - publisherId: QUANTCAST_TEST_PUBLISHER, - requestId: '2f7b179d443f14', - imp: [ - { - banner: { - battr: [1, 2], - sizes: [{ width: 300, height: 250 }] - }, - placementCode: 'div-gpt-ad-1438287399331-0', - bidFloor: 1e-10 - } - ], - site: { - page: 'http://example.com/hello.html', - referrer: 'http://example.com/hello.html', - domain: 'example.com' - }, - bidId: '2f7b179d443f14', - gdprSignal: 0, - prebidJsVersion: '$prebid.version$' - }; + + expect(requests[0].data).to.equal(JSON.stringify(expectedBannerBidRequest)); + }); + + it('supports deprecated banner format', function () { + bidRequest.sizes = bidRequest.mediaTypes.banner.sizes; + delete bidRequest.mediaTypes; + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); expect(requests[0].data).to.equal(JSON.stringify(expectedBannerBidRequest)); }); @@ -297,7 +303,6 @@ describe('Quantcast adapter', function () { playerSize: [[550, 310]] } }; - bidRequest.sizes = [[300, 250], [728, 90], [250, 250], [468, 60], [320, 50]]; const requests = qcSpec.buildRequests([bidRequest], bidderRequest); const expectedBidRequest = {