Skip to content

Commit

Permalink
Merge branch 'master' into prebid-3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Fawke committed Nov 29, 2019
2 parents 82f2963 + dcf904b commit 549f273
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 19 deletions.
17 changes: 10 additions & 7 deletions modules/oneVideoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const spec = {
/** removing adding local protocal since we
* can get cookie data only if we call with https. */
url: spec.ENDPOINT + bid.params.pubId,
data: getRequestData(bid, consentData),
data: getRequestData(bid, consentData, bidRequest),
bidRequest: bid
}
})
Expand Down Expand Up @@ -138,10 +138,10 @@ function isConsentRequired(consentData) {
return !!(consentData && consentData.gdprApplies);
}

function getRequestData(bid, consentData) {
let loc = utils.getTopWindowLocation();
function getRequestData(bid, consentData, bidRequest) {
let loc = bidRequest.refererInfo.referer;
let page = (bid.params.site && bid.params.site.page) ? (bid.params.site.page) : (loc.href);
let ref = (bid.params.site && bid.params.site.referrer) ? bid.params.site.referrer : utils.getTopWindowReferrer();
let ref = (bid.params.site && bid.params.site.referrer) ? bid.params.site.referrer : bidRequest.refererInfo.referer;
let bidData = {
id: utils.generateUUID(),
at: 2,
Expand Down Expand Up @@ -198,16 +198,16 @@ function getRequestData(bid, consentData) {
if (bid.params.video.rewarded) {
bidData.imp[0].ext.rewarded = bid.params.video.rewarded
}
if (bid.params.site && bid.params.site.id) {
bidData.site.id = bid.params.site.id
}
} else if (bid.params.video.display == 1) {
bidData.imp[0].banner = {
mimes: bid.params.video.mimes,
w: bid.params.video.playerWidth,
h: bid.params.video.playerHeight,
pos: bid.params.video.position,
};
if (bid.params.video.placement) {
bidData.imp[0].banner.placement = bid.params.video.placement
}
}
if (bid.params.video.inventoryid) {
bidData.imp[0].ext.inventoryid = bid.params.video.inventoryid
Expand All @@ -225,6 +225,9 @@ function getRequestData(bid, consentData) {
}
}
}
if (bid.params.site && bid.params.site.id) {
bidData.site.id = bid.params.site.id
}
if (isConsentRequired(consentData)) {
bidData.regs = {
ext: {
Expand Down
53 changes: 41 additions & 12 deletions test/spec/modules/oneVideoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@ import {config} from 'src/config';

describe('OneVideoBidAdapter', function () {
let bidRequest;
let bidderRequest;
let bidderRequest = {
'bidderCode': 'oneVideo',
'auctionId': 'e158486f-8c7f-472f-94ce-b0cbfbb50ab4',
'bidderRequestId': '1e498b84fffc39',
'bids': bidRequest,
'auctionStart': 1520001292880,
'timeout': 3000,
'start': 1520001292884,
'doneCbCallCount': 0,
'refererInfo': {
'numIframes': 1,
'reachedTop': true,
'referer': 'test.com'
}
};
let mockConfig;

beforeEach(function () {
Expand Down Expand Up @@ -105,18 +119,18 @@ describe('OneVideoBidAdapter', function () {

describe('spec.buildRequests', function () {
it('should create a POST request for every bid', function () {
const requests = spec.buildRequests([ bidRequest ]);
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
expect(requests[0].method).to.equal('POST');
expect(requests[0].url).to.equal(spec.ENDPOINT + bidRequest.params.pubId);
});

it('should attach the bid request object', function () {
const requests = spec.buildRequests([ bidRequest ]);
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
expect(requests[0].bidRequest).to.equal(bidRequest);
});

it('should attach request data', function () {
const requests = spec.buildRequests([ bidRequest ]);
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
const [ width, height ] = bidRequest.sizes;
const placement = bidRequest.params.video.placement;
Expand All @@ -134,7 +148,7 @@ describe('OneVideoBidAdapter', function () {
const width = 640;
const height = 480;
bidRequest.sizes = [[ width, height ]];
const requests = spec.buildRequests([ bidRequest ]);
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
expect(data.imp[0].video.w).to.equal(width);
expect(data.imp[0].video.h).to.equal(height);
Expand Down Expand Up @@ -185,9 +199,22 @@ describe('OneVideoBidAdapter', function () {
describe('when GDPR applies', function () {
beforeEach(function () {
bidderRequest = {
gdprConsent: {
consentString: 'test-gdpr-consent-string',
gdprApplies: true
'gdprConsent': {
'consentString': 'test-gdpr-consent-string',
'gdprApplies': true
},
'bidderCode': 'oneVideo',
'auctionId': 'e158486f-8c7f-472f-94ce-b0cbfbb50ab4',
'bidderRequestId': '1e498b84fffc39',
'bids': bidRequest,
'auctionStart': 1520001292880,
'timeout': 3000,
'start': 1520001292884,
'doneCbCallCount': 0,
'refererInfo': {
'numIframes': 1,
'reachedTop': true,
'referer': 'test.com'
}
};

Expand All @@ -211,7 +238,7 @@ describe('OneVideoBidAdapter', function () {
});

it('should send schain object', function () {
const requests = spec.buildRequests([ bidRequest ]);
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
expect(data.source.ext.schain.nodes[0].sid).to.equal(bidRequest.params.video.sid);
expect(data.source.ext.schain.nodes[0].rid).to.equal(data.id);
Expand Down Expand Up @@ -253,7 +280,7 @@ describe('OneVideoBidAdapter', function () {
pubId: 'OneMDisplay'
}
};
const requests = spec.buildRequests([ bidRequest ]);
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
const width = bidRequest.params.video.playerWidth;
const height = bidRequest.params.video.playerHeight;
Expand All @@ -264,6 +291,8 @@ describe('OneVideoBidAdapter', function () {
expect(data.imp[0].banner.pos).to.equal(position);
expect(data.imp[0].ext.inventoryid).to.equal(bidRequest.params.video.inventoryid);
expect(data.imp[0].banner.mimes).to.equal(bidRequest.params.video.mimes);
expect(data.imp[0].banner.placement).to.equal(bidRequest.params.video.placement);
expect(data.site.id).to.equal(bidRequest.params.site.id);
});
it('should send video object when display is other than 1', function () {
bidRequest = {
Expand Down Expand Up @@ -299,7 +328,7 @@ describe('OneVideoBidAdapter', function () {
pubId: 'OneMDisplay'
}
};
const requests = spec.buildRequests([ bidRequest ]);
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
const width = bidRequest.params.video.playerWidth;
const height = bidRequest.params.video.playerHeight;
Expand Down Expand Up @@ -343,7 +372,7 @@ describe('OneVideoBidAdapter', function () {
pubId: 'OneMDisplay'
}
};
const requests = spec.buildRequests([ bidRequest ]);
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
const width = bidRequest.params.video.playerWidth;
const height = bidRequest.params.video.playerHeight;
Expand Down

0 comments on commit 549f273

Please sign in to comment.