Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for bug https://github.com/prebid/Prebid.js/issues/866 #867

Merged
merged 9 commits into from
Dec 16, 2016
11 changes: 11 additions & 0 deletions src/adapters/pulsepoint.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var bidfactory = require('../bidfactory.js');
var bidmanager = require('../bidmanager.js');
var adloader = require('../adloader.js');
var utils = require('../utils.js');

var PulsePointAdapter = function PulsePointAdapter() {

Expand All @@ -19,8 +20,18 @@ var PulsePointAdapter = function PulsePointAdapter() {
var bids = params.bids;
for (var i = 0; i < bids.length; i++) {
var bidRequest = bids[i];
requestBid(bidRequest);
}
}

function requestBid(bidRequest) {
try {
var ppBidRequest = new window.pp.Ad(bidRequestOptions(bidRequest));
ppBidRequest.display();
} catch(e) {
//register passback on any exceptions while attempting to fetch response.
utils.logError('pulsepoint.requestBid', 'ERROR', e);
bidResponseAvailable(bidRequest);
}
}

Expand Down
14 changes: 14 additions & 0 deletions test/spec/adapters/pulsepoint_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,18 @@ describe("PulsePoint Adapter Tests", () => {
expect(bidCall.args[1]).to.be.a('object');
});

//related to issue https://github.com/prebid/Prebid.js/issues/866
it('Verify Passbacks when window.pp is not available', () => {
window.pp = function() {};
pulsepointAdapter.callBids(slotConfigs);
let placement = bidManager.addBidResponse.firstCall.args[0];
let bid = bidManager.addBidResponse.firstCall.args[1];
//verify that we passed back without exceptions, should window.pp be already taken.
expect(placement).to.equal('/DfpAccount1/slot1');
expect(bid.bidderCode).to.equal('pulsepoint');
expect(bid).to.not.have.property('ad');
expect(bid).to.not.have.property('cpm');
expect(bid.adId).to.equal('bid12345');
});

});