From 80c1d922485d4f07febac29fa9a0af3066b9902a Mon Sep 17 00:00:00 2001 From: Yunjia Lu Date: Wed, 21 Nov 2018 12:56:40 -0800 Subject: [PATCH] support image pixel type for user sync --- modules/openxBidAdapter.js | 7 ++- test/spec/modules/openxBidAdapter_spec.js | 68 +++++++++++++++++------ 2 files changed, 56 insertions(+), 19 deletions(-) diff --git a/modules/openxBidAdapter.js b/modules/openxBidAdapter.js index 7119d669cb4..446c790fded 100644 --- a/modules/openxBidAdapter.js +++ b/modules/openxBidAdapter.js @@ -8,7 +8,7 @@ import {parse} from 'src/url'; const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; const BIDDER_CODE = 'openx'; const BIDDER_CONFIG = 'hb_pb'; -const BIDDER_VERSION = '2.1.5'; +const BIDDER_VERSION = '2.1.6'; let shouldSendBoPixel = true; @@ -55,12 +55,13 @@ export const spec = { : createBannerBidResponses(oxResponseObj, serverRequest.payload); }, getUserSyncs: function (syncOptions, responses) { - if (syncOptions.iframeEnabled) { + if (syncOptions.iframeEnabled || syncOptions.pixelEnabled) { + let pixelType = syncOptions.iframeEnabled ? 'iframe' : 'image'; let url = utils.deepAccess(responses, '0.body.ads.pixels') || utils.deepAccess(responses, '0.body.pixels') || '//u.openx.net/w/1.0/pd'; return [{ - type: 'iframe', + type: pixelType, url: url }]; } diff --git a/test/spec/modules/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js index 8a602dc479b..4d9266169a0 100644 --- a/test/spec/modules/openxBidAdapter_spec.js +++ b/test/spec/modules/openxBidAdapter_spec.js @@ -1450,28 +1450,64 @@ describe('OpenxAdapter', function () { describe('user sync', function () { const syncUrl = 'http://testpixels.net'; - it('should register the pixel iframe from banner ad response', function () { - let syncs = spec.getUserSyncs( - {iframeEnabled: true}, - [{body: {ads: {pixels: syncUrl}}}] - ); - expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]); + describe('iframe sync', function () { + it('should register the pixel iframe from banner ad response', function () { + let syncs = spec.getUserSyncs( + {iframeEnabled: true}, + [{body: {ads: {pixels: syncUrl}}}] + ); + expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]); + }); + + it('should register the pixel iframe from video ad response', function () { + let syncs = spec.getUserSyncs( + {iframeEnabled: true}, + [{body: {pixels: syncUrl}}] + ); + expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]); + }); + + it('should register the default iframe if no pixels available', function () { + let syncs = spec.getUserSyncs( + {iframeEnabled: true}, + [] + ); + expect(syncs).to.deep.equal([{type: 'iframe', url: '//u.openx.net/w/1.0/pd'}]); + }); }); - it('should register the pixel iframe from video ad response', function () { - let syncs = spec.getUserSyncs( - {iframeEnabled: true}, - [{body: {pixels: syncUrl}}] - ); - expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]); + describe('pixel sync', function () { + it('should register the image pixel from banner ad response', function () { + let syncs = spec.getUserSyncs( + {pixelEnabled: true}, + [{body: {ads: {pixels: syncUrl}}}] + ); + expect(syncs).to.deep.equal([{type: 'image', url: syncUrl}]); + }); + + it('should register the image pixel from video ad response', function () { + let syncs = spec.getUserSyncs( + {pixelEnabled: true}, + [{body: {pixels: syncUrl}}] + ); + expect(syncs).to.deep.equal([{type: 'image', url: syncUrl}]); + }); + + it('should register the default image pixel if no pixels available', function () { + let syncs = spec.getUserSyncs( + {pixelEnabled: true}, + [] + ); + expect(syncs).to.deep.equal([{type: 'image', url: '//u.openx.net/w/1.0/pd'}]); + }); }); - it('should register the default iframe if no pixels available', function () { + it('should prioritize iframe over image for user sync', function () { let syncs = spec.getUserSyncs( - {iframeEnabled: true}, - [] + {iframeEnabled: true, pixelEnabled: true}, + [{body: {ads: {pixels: syncUrl}}}] ); - expect(syncs).to.deep.equal([{type: 'iframe', url: '//u.openx.net/w/1.0/pd'}]); + expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]); }); });