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

Prebid 8: do not call bidder methods (onBidWon, onBidBillable, ...) for S2S bids #9919

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/adapterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,11 @@ function invokeBidderMethod(bidder, method, spec, fn, ...params) {
}

function tryCallBidderMethod(bidder, method, param) {
const target = getBidderMethod(bidder, method);
if (target != null) {
invokeBidderMethod(bidder, method, ...target, param);
if (param?.src !== CONSTANTS.S2S.SRC) {
const target = getBidderMethod(bidder, method);
if (target != null) {
invokeBidderMethod(bidder, method, ...target, param);
}
}
}

Expand Down
126 changes: 51 additions & 75 deletions test/spec/unit/core/adapterManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,103 +353,79 @@ describe('adapterManager tests', function () {
});
}); // end callTimedOutBidders

describe('onBidWon', function () {
var criteoSpec = { onBidWon: sinon.stub() }
var criteoAdapter = {
bidder: 'criteo',
getSpec: function() { return criteoSpec; }
}
describe('bidder spec methods', () => {
let adUnits, bids, criteoSpec;
before(function () {
config.setConfig({s2sConfig: { enabled: false }});
});

beforeEach(function () {
adapterManager.bidderRegistry['criteo'] = criteoAdapter;
});

afterEach(function () {
delete adapterManager.bidderRegistry['criteo'];
});

it('should call spec\'s onBidWon callback when a bid is won', function () {
const bids = [
beforeEach(() => {
criteoSpec = {}
adapterManager.bidderRegistry['criteo'] = {
bidder: 'criteo',
getSpec: function() { return criteoSpec; },
}
bids = [
{bidder: 'criteo', params: {placementId: 'id'}},
];
const adUnits = [{
adUnits = [{
code: 'adUnit-code',
sizes: [[728, 90]],
bids
}];

adapterManager.callBidWonBidder(bids[0].bidder, bids[0], adUnits);
sinon.assert.called(criteoSpec.onBidWon);
});
}); // end onBidWon

describe('onSetTargeting', function () {
var criteoSpec = { onSetTargeting: sinon.stub() }
var criteoAdapter = {
bidder: 'criteo',
getSpec: function() { return criteoSpec; }
}
before(function () {
config.setConfig({s2sConfig: { enabled: false }});
});

beforeEach(function () {
adapterManager.bidderRegistry['criteo'] = criteoAdapter;
});

afterEach(function () {
delete adapterManager.bidderRegistry['criteo'];
});

it('should call spec\'s onSetTargeting callback when setTargeting is called', function () {
const bids = [
{bidder: 'criteo', params: {placementId: 'id'}},
];
const adUnits = [{
code: 'adUnit-code',
sizes: [[728, 90]],
bids
}];
adapterManager.callSetTargetingBidder(bids[0].bidder, bids[0], adUnits);
sinon.assert.called(criteoSpec.onSetTargeting);
});
}); // end onSetTargeting
describe('onBidWon', function () {
beforeEach(() => {
criteoSpec.onBidWon = sinon.stub()
});
it('should call spec\'s onBidWon callback when a bid is won', function () {
adapterManager.callBidWonBidder(bids[0].bidder, bids[0], adUnits);
sinon.assert.called(criteoSpec.onBidWon);
});

describe('onBidViewable', function () {
var criteoSpec = { onBidViewable: sinon.stub() }
var criteoAdapter = {
bidder: 'criteo',
getSpec: function() { return criteoSpec; }
}
before(function () {
config.setConfig({s2sConfig: { enabled: false }});
it('should NOT call onBidWon when the bid is S2S', () => {
bids[0].src = CONSTANTS.S2S.SRC
adapterManager.callBidWonBidder(bids[0].bidder, bids[0], adUnits);
sinon.assert.notCalled(criteoSpec.onBidWon);
})
});

beforeEach(function () {
adapterManager.bidderRegistry['criteo'] = criteoAdapter;
});
describe('onSetTargeting', function () {
beforeEach(() => {
criteoSpec.onSetTargeting = sinon.stub()
})

afterEach(function () {
delete adapterManager.bidderRegistry['criteo'];
});
it('should call spec\'s onSetTargeting callback when setTargeting is called', function () {
adapterManager.callSetTargetingBidder(bids[0].bidder, bids[0], adUnits);
sinon.assert.called(criteoSpec.onSetTargeting);
});

it('should call spec\'s onBidViewable callback when callBidViewableBidder is called', function () {
const bids = [
{bidder: 'criteo', params: {placementId: 'id'}},
];
const adUnits = [{
code: 'adUnit-code',
sizes: [[728, 90]],
bids
}];
adapterManager.callBidViewableBidder(bids[0].bidder, bids[0]);
sinon.assert.called(criteoSpec.onBidViewable);
it('should NOT call onSetTargeting when bid is S2S', () => {
bids[0].src = CONSTANTS.S2S.SRC;
adapterManager.callSetTargetingBidder(bids[0].bidder, bids[0], adUnits);
sinon.assert.notCalled(criteoSpec.onSetTargeting);
})
}); // end onSetTargeting
describe('onBidViewable', function () {
beforeEach(() => {
criteoSpec.onBidViewable = sinon.stub();
})
it('should call spec\'s onBidViewable callback when callBidViewableBidder is called', function () {
adapterManager.callBidViewableBidder(bids[0].bidder, bids[0]);
sinon.assert.called(criteoSpec.onBidViewable);
});
it('should NOT call onBidViewable when bid is S2S', () => {
bids[0].src = CONSTANTS.S2S.SRC;
adapterManager.callBidViewableBidder(bids[0].bidder, bids[0]);
sinon.assert.notCalled(criteoSpec.onBidViewable);
})
});
}); // end onBidViewable

})
describe('onBidderError', function () {
const bidder = 'appnexus';
const appnexusSpec = { onBidderError: sinon.stub() };
Expand Down