From c0c28d73e2103f5349b72116971c0148230dc5fc Mon Sep 17 00:00:00 2001 From: Rachel Joyce Date: Wed, 7 Feb 2018 17:04:16 -0700 Subject: [PATCH 1/4] fix sovrn dealid --- modules/sovrnBidAdapter.js | 2 +- test/spec/modules/sovrnBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index bf2f7f7b777..13f04395afa 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -66,7 +66,7 @@ export const spec = { width: parseInt(sovrnBid.w), height: parseInt(sovrnBid.h), creativeId: sovrnBid.id, - dealId: sovrnBid.dealId || null, + dealId: sovrnBid.dealid || null, currency: 'USD', netRevenue: true, mediaType: BANNER, diff --git a/test/spec/modules/sovrnBidAdapter_spec.js b/test/spec/modules/sovrnBidAdapter_spec.js index c4eadd02738..43307f35527 100644 --- a/test/spec/modules/sovrnBidAdapter_spec.js +++ b/test/spec/modules/sovrnBidAdapter_spec.js @@ -103,7 +103,7 @@ describe('sovrnBidAdapter', function() { }); it('should get correct bid response when dealId is passed', () => { - response.body.dealId = 'baking'; + response.body.dealid = 'baking'; let expectedResponse = [{ 'requestId': '263c448586f5a1', From cf0ca21492c6dace7bd63a245002d3ea59bba5dd Mon Sep 17 00:00:00 2001 From: Ankit Prakash Date: Tue, 13 Feb 2018 17:39:40 -0700 Subject: [PATCH 2/4] send 'iv' param if present --- modules/sovrnBidAdapter.js | 4 ++++ test/spec/modules/sovrnBidAdapter_spec.js | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index 13f04395afa..e32b95a698d 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -23,7 +23,9 @@ export const spec = { */ buildRequests: function(bidReqs) { let sovrnImps = []; + let iv; utils._each(bidReqs, function (bid) { + iv = iv || utils.getBidIdParameter('iv', bid.params); sovrnImps.push({ id: bid.bidId, banner: { w: 1, h: 1 }, @@ -39,6 +41,8 @@ export const spec = { page: window.location.pathname + location.search + location.hash } }; + if (iv) sovrnBidReq.iv = iv; + return { method: 'POST', url: `//ap.lijit.com/rtb/bid?src=${REPO_AND_VERSION}`, diff --git a/test/spec/modules/sovrnBidAdapter_spec.js b/test/spec/modules/sovrnBidAdapter_spec.js index 43307f35527..5fc7cb6a62a 100644 --- a/test/spec/modules/sovrnBidAdapter_spec.js +++ b/test/spec/modules/sovrnBidAdapter_spec.js @@ -40,7 +40,7 @@ describe('sovrnBidAdapter', function() { }); describe('buildRequests', () => { - let bidRequests = [{ + const bidRequests = [{ 'bidder': 'sovrn', 'params': { 'tagid': '403370' @@ -63,6 +63,26 @@ describe('sovrnBidAdapter', function() { it('attaches source and version to endpoint URL as query params', () => { expect(request.url).to.equal(ENDPOINT) }); + + it('sends \'iv\' as query param if present', () => { + const ivBidRequests = [{ + 'bidder': 'sovrn', + 'params': { + 'tagid': '403370', + 'iv': 'vet' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250] + ], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475' + }]; + const request = spec.buildRequests(ivBidRequests); + + expect(request.data).to.contain('"iv":"vet"') + }) }); describe('interpretResponse', () => { From f89135c791c0a9c2c5d08cc9387316000b0276cd Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 14 Feb 2018 11:44:05 -0700 Subject: [PATCH 3/4] `page` field in `site` object sends full url --- modules/sovrnBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index e32b95a698d..d13331b9179 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -38,7 +38,7 @@ export const spec = { imp: sovrnImps, site: { domain: window.location.host, - page: window.location.pathname + location.search + location.hash + page: window.location.host + window.location.pathname + location.search + location.hash } }; if (iv) sovrnBidReq.iv = iv; From c2f23505650d2bf17cd0cece722c4171dcca9420 Mon Sep 17 00:00:00 2001 From: Rachel Joyce Date: Fri, 16 Feb 2018 16:03:18 -0700 Subject: [PATCH 4/4] Enhance location detection within util function. --- modules/sovrnBidAdapter.js | 5 ++-- src/utils.js | 47 ++++++++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index d13331b9179..f8c10fd8605 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -22,6 +22,7 @@ export const spec = { * @return object of parameters for Prebid AJAX request */ buildRequests: function(bidReqs) { + const loc = utils.getTopWindowLocation(); let sovrnImps = []; let iv; utils._each(bidReqs, function (bid) { @@ -37,8 +38,8 @@ export const spec = { id: utils.getUniqueIdentifierStr(), imp: sovrnImps, site: { - domain: window.location.host, - page: window.location.host + window.location.pathname + location.search + location.hash + domain: loc.host, + page: loc.host + loc.pathname + loc.search + loc.hash } }; if (iv) sovrnBidReq.iv = iv; diff --git a/src/utils.js b/src/utils.js index 7126f293c02..9fd0fb72ac5 100644 --- a/src/utils.js +++ b/src/utils.js @@ -157,17 +157,50 @@ export function parseGPTSingleSizeArray(singleSize) { } }; -exports.getTopWindowLocation = function () { - let location; +export function getTopWindowLocation() { + if (this.inIframe()) { + return getIframeParentLoc(); + } else { + return window.location; + } +} + +const getIframeParentLoc = function() { + let loc = window.location; try { - // force an exception in x-domain enviornments. #1509 - window.top.location.toString(); - location = window.top.location; + if (window.$sf) { + loc = window.document.referrer; + } else { + if (window.document.location && window.document.location.ancestorOrigins && + window.document.location.ancestorOrigins.length >= 1) { + loc = window.document.location.ancestorOrigins[window.document.location.ancestorOrigins.length - 1]; + } else if (window.document.location) { + loc = getNonWebKitIframeParentLoc(); + } + } + loc = parseFullUrl(loc); } catch (e) { - location = window.location; + this.logMessage('getTopParentLoc failure', e); + } + return loc; +}; + +const getNonWebKitIframeParentLoc = function() { + let referrerLoc = ''; + let currentWindow; + do { + currentWindow = currentWindow ? currentWindow.parent : window; + if (currentWindow.document && currentWindow.document.referrer) { + referrerLoc = currentWindow.document.referrer; + } } + while (currentWindow !== window.top); + return referrerLoc; +}; - return location; +const parseFullUrl = function(locString) { + const match = locString.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/); + return match && {protocol: match[1], host: match[2], hostname: match[3], port: match[4], pathname: match[5], search: match[6], hash: match[7], href: match.input}; }; exports.getTopWindowUrl = function () {