prebid.js 5.18.0 → 5.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browsers.json +1 -0
- package/integrationExamples/gpt/akamaidap_segments_example.html +132 -0
- package/modules/.submodules.json +1 -0
- package/modules/adfBidAdapter.js +21 -16
- package/modules/adtelligentBidAdapter.js +2 -1
- package/modules/adxcgBidAdapter.js +311 -359
- package/modules/airgridRtdProvider.js +1 -1
- package/modules/akamaiDapRtdProvider.js +474 -0
- package/modules/akamaiDapRtdProvider.md +47 -0
- package/modules/appnexusBidAdapter.js +9 -3
- package/modules/atsAnalyticsAdapter.js +67 -46
- package/modules/atsAnalyticsAdapter.md +1 -0
- package/modules/betweenBidAdapter.js +20 -3
- package/modules/browsiRtdProvider.js +106 -18
- package/modules/cleanioRtdProvider.js +192 -0
- package/modules/cleanioRtdProvider.md +59 -0
- package/modules/codefuelBidAdapter.js +183 -0
- package/modules/codefuelBidAdapter.md +111 -0
- package/modules/connectIdSystem.js +104 -0
- package/modules/connectIdSystem.md +33 -0
- package/modules/deepintentBidAdapter.js +106 -9
- package/modules/deepintentBidAdapter.md +36 -1
- package/modules/deltaprojectsBidAdapter.js +252 -0
- package/modules/deltaprojectsBidAdapter.md +32 -0
- package/modules/engageyaBidAdapter.js +157 -0
- package/modules/gridBidAdapter.js +1 -0
- package/modules/gumgumBidAdapter.js +8 -0
- package/modules/inskinBidAdapter.js +7 -3
- package/modules/ipromBidAdapter.js +79 -0
- package/modules/ixBidAdapter.js +8 -1
- package/modules/jixieBidAdapter.js +8 -2
- package/modules/justpremiumBidAdapter.js +6 -1
- package/modules/kinessoIdSystem.js +1 -1
- package/modules/limelightDigitalBidAdapter.js +22 -2
- package/modules/livewrappedAnalyticsAdapter.js +49 -1
- package/modules/multibid/index.js +3 -3
- package/modules/nativoBidAdapter.js +5 -1
- package/modules/nextMillenniumBidAdapter.js +12 -3
- package/modules/oguryBidAdapter.js +14 -1
- package/modules/openxBidAdapter.js +34 -22
- package/modules/operaadsBidAdapter.js +21 -1
- package/modules/otmBidAdapter.js +146 -0
- package/modules/otmBidAdapter.md +27 -26
- package/modules/outbrainBidAdapter.js +5 -0
- package/modules/playwireBidAdapter.md +61 -0
- package/modules/publinkIdSystem.js +11 -6
- package/modules/rtdModule/index.js +2 -2
- package/modules/sonobiBidAdapter.js +7 -0
- package/modules/sortableBidAdapter.js +1 -0
- package/modules/teadsBidAdapter.js +3 -0
- package/modules/tripleliftBidAdapter.js +22 -5
- package/modules/trustxBidAdapter.js +8 -6
- package/modules/undertoneBidAdapter.js +9 -5
- package/modules/undertoneBidAdapter.md +5 -1
- package/modules/userId/eids.js +18 -0
- package/modules/userId/eids.md +7 -0
- package/modules/userId/userId.md +12 -0
- package/modules/ventesBidAdapter.js +370 -0
- package/modules/ventesBidAdapter.md +94 -0
- package/modules/videobyteBidAdapter.js +13 -6
- package/modules/videobyteBidAdapter.md +49 -0
- package/modules/yahoosspBidAdapter.js +6 -6
- package/modules/yieldmoSyntheticInventoryModule.js +46 -0
- package/modules/yieldmoSyntheticInventoryModule.md +68 -0
- package/package.json +1 -1
- package/src/adapterManager.js +5 -0
- package/src/adapters/bidderFactory.js +4 -3
- package/src/auction.js +11 -11
- package/src/constants.json +1 -0
- package/src/secureCreatives.js +6 -7
- package/src/targeting.js +11 -9
- package/test/spec/modules/adfBidAdapter_spec.js +83 -29
- package/test/spec/modules/adtelligentBidAdapter_spec.js +1 -0
- package/test/spec/modules/adxcgBidAdapter_spec.js +827 -571
- package/test/spec/modules/akamaiDapRtdProvider_spec.js +246 -0
- package/test/spec/modules/appnexusBidAdapter_spec.js +16 -1
- package/test/spec/modules/atsAnalyticsAdapter_spec.js +42 -9
- package/test/spec/modules/betweenBidAdapter_spec.js +41 -0
- package/test/spec/modules/browsiRtdProvider_spec.js +62 -7
- package/test/spec/modules/cleanioRtdProvider_spec.js +188 -0
- package/test/spec/modules/codefuelBidAdapter_spec.js +316 -0
- package/test/spec/modules/connectIdSystem_spec.js +189 -0
- package/test/spec/modules/deepintentBidAdapter_spec.js +153 -3
- package/test/spec/modules/deltaprojectsBidAdapter_spec.js +399 -0
- package/test/spec/modules/engageyaBidAdapter_spec.js +286 -0
- package/test/spec/modules/eplanningBidAdapter_spec.js +8 -8
- package/test/spec/modules/gumgumBidAdapter_spec.js +5 -1
- package/test/spec/modules/ipromBidAdapter_spec.js +195 -0
- package/test/spec/modules/ixBidAdapter_spec.js +13 -3
- package/test/spec/modules/jixieBidAdapter_spec.js +13 -11
- package/test/spec/modules/justpremiumBidAdapter_spec.js +9 -2
- package/test/spec/modules/limelightDigitalBidAdapter_spec.js +155 -1
- package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +52 -7
- package/test/spec/modules/multibid_spec.js +31 -31
- package/test/spec/modules/nextMillenniumBidAdapter_spec.js +13 -1
- package/test/spec/modules/oguryBidAdapter_spec.js +53 -12
- package/test/spec/modules/openxBidAdapter_spec.js +85 -13
- package/test/spec/modules/operaadsBidAdapter_spec.js +38 -6
- package/test/spec/modules/otmBidAdapter_spec.js +67 -0
- package/test/spec/modules/outbrainBidAdapter_spec.js +18 -0
- package/test/spec/modules/publinkIdSystem_spec.js +6 -6
- package/test/spec/modules/sonobiBidAdapter_spec.js +34 -1
- package/test/spec/modules/sortableBidAdapter_spec.js +11 -0
- package/test/spec/modules/teadsBidAdapter_spec.js +132 -0
- package/test/spec/modules/tripleliftBidAdapter_spec.js +128 -0
- package/test/spec/modules/trustxBidAdapter_spec.js +3 -3
- package/test/spec/modules/undertoneBidAdapter_spec.js +52 -0
- package/test/spec/modules/ventesBidAdapter_spec.js +845 -0
- package/test/spec/modules/videobyteBidAdapter_spec.js +2 -2
- package/test/spec/modules/yieldmoSyntheticInventoryModule_spec.js +89 -0
- package/test/spec/unit/core/adapterManager_spec.js +37 -2
- package/test/spec/unit/core/bidderFactory_spec.js +61 -1
- package/test/spec/unit/pbjs_api_spec.js +37 -2
- package/test/spec/unit/secureCreatives_spec.js +54 -25
|
@@ -153,7 +153,7 @@ describe('VideoByteBidAdapter', function () {
|
|
|
153
153
|
it('should create a POST request for every bid', function () {
|
|
154
154
|
const requests = spec.buildRequests([bidRequest], bidderRequest);
|
|
155
155
|
expect(requests[0].method).to.equal('POST');
|
|
156
|
-
expect(requests[0].url).to.equal(spec.ENDPOINT + bidRequest.params.pubId);
|
|
156
|
+
expect(requests[0].url).to.equal(spec.ENDPOINT + '?pid=' + bidRequest.params.pubId);
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
it('should attach request data', function () {
|
|
@@ -172,7 +172,7 @@ describe('VideoByteBidAdapter', function () {
|
|
|
172
172
|
bidRequest.params.video.e2etest = true;
|
|
173
173
|
const requests = spec.buildRequests([bidRequest], bidderRequest);
|
|
174
174
|
expect(requests[0].method).to.equal('POST');
|
|
175
|
-
expect(requests[0].url).to.equal(spec.ENDPOINT + 'e2etest');
|
|
175
|
+
expect(requests[0].url).to.equal(spec.ENDPOINT + '?pid=e2etest');
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
it('should attach End 2 End test data', function () {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import {
|
|
3
|
+
init,
|
|
4
|
+
MODULE_NAME,
|
|
5
|
+
validateConfig
|
|
6
|
+
} from 'modules/yieldmoSyntheticInventoryModule';
|
|
7
|
+
|
|
8
|
+
const mockedYmConfig = {
|
|
9
|
+
placementId: '123456',
|
|
10
|
+
adUnitPath: '/6355419/ad_unit_name_used_in_gam'
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const setGoogletag = () => {
|
|
14
|
+
window.googletag = {
|
|
15
|
+
cmd: [],
|
|
16
|
+
defineSlot: sinon.stub(),
|
|
17
|
+
addService: sinon.stub(),
|
|
18
|
+
pubads: sinon.stub(),
|
|
19
|
+
setTargeting: sinon.stub(),
|
|
20
|
+
enableServices: sinon.stub(),
|
|
21
|
+
display: sinon.stub(),
|
|
22
|
+
};
|
|
23
|
+
window.googletag.defineSlot.returns(window.googletag);
|
|
24
|
+
window.googletag.addService.returns(window.googletag);
|
|
25
|
+
window.googletag.pubads.returns({getSlots: sinon.stub()});
|
|
26
|
+
return window.googletag;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe('Yieldmo Synthetic Inventory Module', function() {
|
|
30
|
+
let config = Object.assign({}, mockedYmConfig);
|
|
31
|
+
let googletagBkp;
|
|
32
|
+
|
|
33
|
+
beforeEach(function () {
|
|
34
|
+
googletagBkp = window.googletag;
|
|
35
|
+
delete window.googletag;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterEach(function () {
|
|
39
|
+
window.googletag = googletagBkp;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should be enabled with valid required params', function() {
|
|
43
|
+
expect(function () {
|
|
44
|
+
init(mockedYmConfig);
|
|
45
|
+
}).not.to.throw()
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should throw an error if placementId is missed', function() {
|
|
49
|
+
const {placementId, ...config} = mockedYmConfig;
|
|
50
|
+
|
|
51
|
+
expect(function () {
|
|
52
|
+
validateConfig(config);
|
|
53
|
+
}).throw(`${MODULE_NAME}: placementId required`)
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should throw an error if adUnitPath is missed', function() {
|
|
57
|
+
const {adUnitPath, ...config} = mockedYmConfig;
|
|
58
|
+
|
|
59
|
+
expect(function () {
|
|
60
|
+
validateConfig(config);
|
|
61
|
+
}).throw(`${MODULE_NAME}: adUnitPath required`)
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should add correct googletag.cmd', function() {
|
|
65
|
+
const containerName = 'ym_sim_container_' + mockedYmConfig.placementId;
|
|
66
|
+
const gtag = setGoogletag();
|
|
67
|
+
|
|
68
|
+
init(mockedYmConfig);
|
|
69
|
+
|
|
70
|
+
expect(gtag.cmd.length).to.equal(1);
|
|
71
|
+
|
|
72
|
+
gtag.cmd[0]();
|
|
73
|
+
|
|
74
|
+
expect(gtag.addService.getCall(0)).to.not.be.null;
|
|
75
|
+
expect(gtag.setTargeting.getCall(0)).to.not.be.null;
|
|
76
|
+
expect(gtag.setTargeting.getCall(0).args[0]).to.exist.and.to.equal('ym_sim_p_id');
|
|
77
|
+
expect(gtag.setTargeting.getCall(0).args[1]).to.exist.and.to.equal(mockedYmConfig.placementId);
|
|
78
|
+
expect(gtag.defineSlot.getCall(0)).to.not.be.null;
|
|
79
|
+
expect(gtag.enableServices.getCall(0)).to.not.be.null;
|
|
80
|
+
expect(gtag.display.getCall(0)).to.not.be.null;
|
|
81
|
+
expect(gtag.display.getCall(0).args[0]).to.exist.and.to.equal(containerName);
|
|
82
|
+
expect(gtag.pubads.getCall(0)).to.not.be.null;
|
|
83
|
+
|
|
84
|
+
const gamContainerEl = window.document.getElementById(containerName);
|
|
85
|
+
expect(gamContainerEl).to.not.be.null;
|
|
86
|
+
|
|
87
|
+
gamContainerEl.parentNode.removeChild(gamContainerEl);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -436,6 +436,38 @@ describe('adapterManager tests', function () {
|
|
|
436
436
|
});
|
|
437
437
|
}); // end onBidViewable
|
|
438
438
|
|
|
439
|
+
describe('onBidderError', function () {
|
|
440
|
+
const bidder = 'appnexus';
|
|
441
|
+
const appnexusSpec = { onBidderError: sinon.stub() };
|
|
442
|
+
const appnexusAdapter = {
|
|
443
|
+
bidder,
|
|
444
|
+
getSpec: function() { return appnexusSpec; },
|
|
445
|
+
}
|
|
446
|
+
before(function () {
|
|
447
|
+
config.setConfig({s2sConfig: { enabled: false }});
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
beforeEach(function () {
|
|
451
|
+
adapterManager.bidderRegistry[bidder] = appnexusAdapter;
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
afterEach(function () {
|
|
455
|
+
delete adapterManager.bidderRegistry[bidder];
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
it('should call spec\'s onBidderError callback when callBidderError is called', function () {
|
|
459
|
+
const bidRequests = getBidRequests();
|
|
460
|
+
const bidderRequest = find(bidRequests, bidRequest => bidRequest.bidderCode === bidder);
|
|
461
|
+
const xhrErrorMock = {
|
|
462
|
+
status: 500,
|
|
463
|
+
statusText: 'Internal Server Error'
|
|
464
|
+
};
|
|
465
|
+
adapterManager.callBidderError(bidder, xhrErrorMock, bidderRequest);
|
|
466
|
+
sinon.assert.calledOnce(appnexusSpec.onBidderError);
|
|
467
|
+
sinon.assert.calledWithExactly(appnexusSpec.onBidderError, { error: xhrErrorMock, bidderRequest });
|
|
468
|
+
});
|
|
469
|
+
}); // end onBidderError
|
|
470
|
+
|
|
439
471
|
describe('S2S tests', function () {
|
|
440
472
|
beforeEach(function () {
|
|
441
473
|
config.setConfig({s2sConfig: CONFIG});
|
|
@@ -1665,14 +1697,17 @@ describe('adapterManager tests', function () {
|
|
|
1665
1697
|
});
|
|
1666
1698
|
|
|
1667
1699
|
describe('sizeMapping', function () {
|
|
1700
|
+
let sandbox;
|
|
1668
1701
|
beforeEach(function () {
|
|
1702
|
+
sandbox = sinon.sandbox.create();
|
|
1669
1703
|
allS2SBidders.length = 0;
|
|
1670
1704
|
clientTestAdapters.length = 0;
|
|
1671
|
-
|
|
1705
|
+
// always have matchMedia return true for us
|
|
1706
|
+
sandbox.stub(utils.getWindowTop(), 'matchMedia').callsFake(() => ({matches: true}));
|
|
1672
1707
|
});
|
|
1673
1708
|
|
|
1674
1709
|
afterEach(function () {
|
|
1675
|
-
|
|
1710
|
+
sandbox.restore();
|
|
1676
1711
|
config.resetConfig();
|
|
1677
1712
|
setSizeConfig([]);
|
|
1678
1713
|
});
|
|
@@ -552,17 +552,27 @@ describe('bidders created by newBidder', function () {
|
|
|
552
552
|
|
|
553
553
|
describe('when the ajax call fails', function () {
|
|
554
554
|
let ajaxStub;
|
|
555
|
+
let callBidderErrorStub;
|
|
556
|
+
let eventEmitterStub;
|
|
557
|
+
let xhrErrorMock = {
|
|
558
|
+
status: 500,
|
|
559
|
+
statusText: 'Internal Server Error'
|
|
560
|
+
};
|
|
555
561
|
|
|
556
562
|
beforeEach(function () {
|
|
557
563
|
ajaxStub = sinon.stub(ajax, 'ajax').callsFake(function(url, callbacks) {
|
|
558
|
-
callbacks.error('ajax call failed.');
|
|
564
|
+
callbacks.error('ajax call failed.', xhrErrorMock);
|
|
559
565
|
});
|
|
566
|
+
callBidderErrorStub = sinon.stub(adapterManager, 'callBidderError');
|
|
567
|
+
eventEmitterStub = sinon.stub(events, 'emit');
|
|
560
568
|
addBidResponseStub.reset();
|
|
561
569
|
doneStub.reset();
|
|
562
570
|
});
|
|
563
571
|
|
|
564
572
|
afterEach(function () {
|
|
565
573
|
ajaxStub.restore();
|
|
574
|
+
callBidderErrorStub.restore();
|
|
575
|
+
eventEmitterStub.restore();
|
|
566
576
|
});
|
|
567
577
|
|
|
568
578
|
it('should not spec.interpretResponse()', function () {
|
|
@@ -580,6 +590,14 @@ describe('bidders created by newBidder', function () {
|
|
|
580
590
|
|
|
581
591
|
expect(spec.interpretResponse.called).to.equal(false);
|
|
582
592
|
expect(doneStub.calledOnce).to.equal(true);
|
|
593
|
+
expect(callBidderErrorStub.calledOnce).to.equal(true);
|
|
594
|
+
expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE);
|
|
595
|
+
expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock);
|
|
596
|
+
expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST);
|
|
597
|
+
sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, {
|
|
598
|
+
error: xhrErrorMock,
|
|
599
|
+
bidderRequest: MOCK_BIDS_REQUEST
|
|
600
|
+
});
|
|
583
601
|
});
|
|
584
602
|
|
|
585
603
|
it('should not add bids for each adunit code into the auction', function () {
|
|
@@ -598,6 +616,14 @@ describe('bidders created by newBidder', function () {
|
|
|
598
616
|
|
|
599
617
|
expect(addBidResponseStub.callCount).to.equal(0);
|
|
600
618
|
expect(doneStub.calledOnce).to.equal(true);
|
|
619
|
+
expect(callBidderErrorStub.calledOnce).to.equal(true);
|
|
620
|
+
expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE);
|
|
621
|
+
expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock);
|
|
622
|
+
expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST);
|
|
623
|
+
sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, {
|
|
624
|
+
error: xhrErrorMock,
|
|
625
|
+
bidderRequest: MOCK_BIDS_REQUEST
|
|
626
|
+
});
|
|
601
627
|
});
|
|
602
628
|
|
|
603
629
|
it('should call spec.getUserSyncs() with no responses', function () {
|
|
@@ -616,6 +642,40 @@ describe('bidders created by newBidder', function () {
|
|
|
616
642
|
expect(spec.getUserSyncs.calledOnce).to.equal(true);
|
|
617
643
|
expect(spec.getUserSyncs.firstCall.args[1]).to.deep.equal([]);
|
|
618
644
|
expect(doneStub.calledOnce).to.equal(true);
|
|
645
|
+
expect(callBidderErrorStub.calledOnce).to.equal(true);
|
|
646
|
+
expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE);
|
|
647
|
+
expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock);
|
|
648
|
+
expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST);
|
|
649
|
+
sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, {
|
|
650
|
+
error: xhrErrorMock,
|
|
651
|
+
bidderRequest: MOCK_BIDS_REQUEST
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
it('should call spec.getUserSyncs() with no responses', function () {
|
|
656
|
+
const bidder = newBidder(spec);
|
|
657
|
+
|
|
658
|
+
spec.isBidRequestValid.returns(true);
|
|
659
|
+
spec.buildRequests.returns({
|
|
660
|
+
method: 'POST',
|
|
661
|
+
url: 'test.url.com',
|
|
662
|
+
data: {}
|
|
663
|
+
});
|
|
664
|
+
spec.getUserSyncs.returns([]);
|
|
665
|
+
|
|
666
|
+
bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
|
|
667
|
+
|
|
668
|
+
expect(spec.getUserSyncs.calledOnce).to.equal(true);
|
|
669
|
+
expect(spec.getUserSyncs.firstCall.args[1]).to.deep.equal([]);
|
|
670
|
+
expect(doneStub.calledOnce).to.equal(true);
|
|
671
|
+
expect(callBidderErrorStub.calledOnce).to.equal(true);
|
|
672
|
+
expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE);
|
|
673
|
+
expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock);
|
|
674
|
+
expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST);
|
|
675
|
+
sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, {
|
|
676
|
+
error: xhrErrorMock,
|
|
677
|
+
bidderRequest: MOCK_BIDS_REQUEST
|
|
678
|
+
});
|
|
619
679
|
});
|
|
620
680
|
});
|
|
621
681
|
});
|
|
@@ -98,7 +98,6 @@ var createSlotArrayScenario2 = function createSlotArrayScenario2() {
|
|
|
98
98
|
var slot1 = new Slot(config.adUnitElementIDs[0], config.adUnitCodes[0]);
|
|
99
99
|
slot1.setTargeting('pos1', '750x350');
|
|
100
100
|
var slot2 = new Slot(config.adUnitElementIDs[1], config.adUnitCodes[0]);
|
|
101
|
-
slot2.setTargeting('gender', ['male', 'female']);
|
|
102
101
|
return [
|
|
103
102
|
slot1,
|
|
104
103
|
slot2
|
|
@@ -862,6 +861,9 @@ describe('Unit: Prebid Module', function () {
|
|
|
862
861
|
|
|
863
862
|
it('should set googletag targeting keys after calling setTargetingForGPTAsync function', function () {
|
|
864
863
|
var slots = createSlotArrayScenario2();
|
|
864
|
+
|
|
865
|
+
// explicitly setting some PBJS key value pairs to verify whether these are removed befor new keys are set
|
|
866
|
+
|
|
865
867
|
window.googletag.pubads().setSlots(slots);
|
|
866
868
|
$$PREBID_GLOBAL$$.setTargetingForGPTAsync([config.adUnitCodes[0]]);
|
|
867
869
|
|
|
@@ -869,7 +871,7 @@ describe('Unit: Prebid Module', function () {
|
|
|
869
871
|
// googletag's targeting structure
|
|
870
872
|
// googletag setTargeting will override old value if invoked with same key
|
|
871
873
|
|
|
872
|
-
|
|
874
|
+
let targeting = [];
|
|
873
875
|
slots[1].getTargetingKeys().map(function (key) {
|
|
874
876
|
const value = slots[1].getTargeting(key);
|
|
875
877
|
targeting.push([key, value]);
|
|
@@ -887,6 +889,39 @@ describe('Unit: Prebid Module', function () {
|
|
|
887
889
|
invokedTargeting.push([key, value]);
|
|
888
890
|
});
|
|
889
891
|
assert.deepEqual(targeting, invokedTargeting, 'google tag targeting options not matching');
|
|
892
|
+
|
|
893
|
+
// resetPresetTargeting: initiate a new auction with no winning bids, now old targeting should be removed
|
|
894
|
+
|
|
895
|
+
resetAuction();
|
|
896
|
+
auction.getBidsReceived = function() { return [] };
|
|
897
|
+
|
|
898
|
+
var slots = createSlotArrayScenario2();
|
|
899
|
+
window.googletag.pubads().setSlots(slots);
|
|
900
|
+
|
|
901
|
+
$$PREBID_GLOBAL$$.setTargetingForGPTAsync([config.adUnitCodes[0]]);
|
|
902
|
+
|
|
903
|
+
targeting = [];
|
|
904
|
+
slots[1].getTargetingKeys().map(function (key) {
|
|
905
|
+
const value = slots[1].getTargeting(key);
|
|
906
|
+
targeting.push([key, value]);
|
|
907
|
+
});
|
|
908
|
+
|
|
909
|
+
invokedTargetingMap = {};
|
|
910
|
+
slots[1].spySetTargeting.args.map(function (entry) {
|
|
911
|
+
invokedTargetingMap[entry[0]] = entry[1];
|
|
912
|
+
});
|
|
913
|
+
|
|
914
|
+
var invokedTargeting = [];
|
|
915
|
+
|
|
916
|
+
Object.getOwnPropertyNames(invokedTargetingMap).map(function (key) {
|
|
917
|
+
const value = Array.isArray(invokedTargetingMap[key]) ? invokedTargetingMap[key] : [invokedTargetingMap[key]]; // values are always returned as array in googletag
|
|
918
|
+
invokedTargeting.push([key, value]);
|
|
919
|
+
});
|
|
920
|
+
assert.deepEqual(targeting, invokedTargeting, 'google tag targeting options not matching');
|
|
921
|
+
targeting.forEach(function(e) {
|
|
922
|
+
// here e[0] is key and e[1] is value in array that should be [null] as we are un-setting prebid keys in resetPresetTargeting
|
|
923
|
+
assert.deepEqual(e[1], [null], 'resetPresetTargeting: the value of the key ' + e[0] + ' should be [null]');
|
|
924
|
+
});
|
|
890
925
|
});
|
|
891
926
|
|
|
892
927
|
it('should set googletag targeting keys to specific slot with customSlotMatching', function () {
|
|
@@ -116,7 +116,7 @@ describe('secureCreatives', () => {
|
|
|
116
116
|
beforeEach(function() {
|
|
117
117
|
spyAddWinningBid = sinon.spy(auctionManager, 'addWinningBid');
|
|
118
118
|
spyLogWarn = sinon.spy(utils, 'logWarn');
|
|
119
|
-
stubFireNativeTrackers = sinon.stub(native, 'fireNativeTrackers');
|
|
119
|
+
stubFireNativeTrackers = sinon.stub(native, 'fireNativeTrackers').callsFake(message => { return message.action; });
|
|
120
120
|
stubGetAllAssetsMessage = sinon.stub(native, 'getAllAssetsMessage');
|
|
121
121
|
stubEmit = sinon.stub(events, 'emit');
|
|
122
122
|
});
|
|
@@ -263,10 +263,9 @@ describe('secureCreatives', () => {
|
|
|
263
263
|
sinon.assert.calledOnce(stubGetAllAssetsMessage);
|
|
264
264
|
sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse);
|
|
265
265
|
sinon.assert.calledOnce(ev.source.postMessage);
|
|
266
|
-
sinon.assert.
|
|
267
|
-
sinon.assert.
|
|
268
|
-
sinon.assert.
|
|
269
|
-
sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse);
|
|
266
|
+
sinon.assert.notCalled(stubFireNativeTrackers);
|
|
267
|
+
sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON);
|
|
268
|
+
sinon.assert.notCalled(spyAddWinningBid);
|
|
270
269
|
sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER);
|
|
271
270
|
});
|
|
272
271
|
|
|
@@ -293,14 +292,11 @@ describe('secureCreatives', () => {
|
|
|
293
292
|
sinon.assert.calledOnce(stubGetAllAssetsMessage);
|
|
294
293
|
sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse);
|
|
295
294
|
sinon.assert.calledOnce(ev.source.postMessage);
|
|
296
|
-
sinon.assert.
|
|
297
|
-
sinon.assert.
|
|
298
|
-
sinon.assert.
|
|
299
|
-
sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse);
|
|
295
|
+
sinon.assert.notCalled(stubFireNativeTrackers);
|
|
296
|
+
sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON);
|
|
297
|
+
sinon.assert.notCalled(spyAddWinningBid);
|
|
300
298
|
sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER);
|
|
301
299
|
|
|
302
|
-
expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED);
|
|
303
|
-
|
|
304
300
|
resetHistories(ev.source.postMessage);
|
|
305
301
|
|
|
306
302
|
receiveMessage(ev);
|
|
@@ -309,10 +305,9 @@ describe('secureCreatives', () => {
|
|
|
309
305
|
sinon.assert.calledOnce(stubGetAllAssetsMessage);
|
|
310
306
|
sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse);
|
|
311
307
|
sinon.assert.calledOnce(ev.source.postMessage);
|
|
312
|
-
sinon.assert.
|
|
313
|
-
sinon.assert.
|
|
314
|
-
sinon.assert.
|
|
315
|
-
sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse);
|
|
308
|
+
sinon.assert.notCalled(stubFireNativeTrackers);
|
|
309
|
+
sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON);
|
|
310
|
+
sinon.assert.notCalled(spyAddWinningBid);
|
|
316
311
|
sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER);
|
|
317
312
|
});
|
|
318
313
|
|
|
@@ -341,14 +336,11 @@ describe('secureCreatives', () => {
|
|
|
341
336
|
sinon.assert.calledOnce(stubGetAllAssetsMessage);
|
|
342
337
|
sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse);
|
|
343
338
|
sinon.assert.calledOnce(ev.source.postMessage);
|
|
344
|
-
sinon.assert.
|
|
345
|
-
sinon.assert.
|
|
346
|
-
sinon.assert.
|
|
347
|
-
sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse);
|
|
339
|
+
sinon.assert.notCalled(stubFireNativeTrackers);
|
|
340
|
+
sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON);
|
|
341
|
+
sinon.assert.notCalled(spyAddWinningBid);
|
|
348
342
|
sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER);
|
|
349
343
|
|
|
350
|
-
expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED);
|
|
351
|
-
|
|
352
344
|
resetHistories(ev.source.postMessage);
|
|
353
345
|
|
|
354
346
|
receiveMessage(ev);
|
|
@@ -357,14 +349,51 @@ describe('secureCreatives', () => {
|
|
|
357
349
|
sinon.assert.calledOnce(stubGetAllAssetsMessage);
|
|
358
350
|
sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse);
|
|
359
351
|
sinon.assert.calledOnce(ev.source.postMessage);
|
|
360
|
-
sinon.assert.
|
|
361
|
-
sinon.assert.
|
|
362
|
-
sinon.assert.
|
|
363
|
-
sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse);
|
|
352
|
+
sinon.assert.notCalled(stubFireNativeTrackers);
|
|
353
|
+
sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON);
|
|
354
|
+
sinon.assert.notCalled(spyAddWinningBid);
|
|
364
355
|
sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER);
|
|
365
356
|
|
|
366
357
|
configObj.setConfig({'auctionOptions': {}});
|
|
367
358
|
});
|
|
359
|
+
|
|
360
|
+
it('Prebid native should fire trackers', function () {
|
|
361
|
+
pushBidResponseToAuction({});
|
|
362
|
+
|
|
363
|
+
const data = {
|
|
364
|
+
adId: bidId,
|
|
365
|
+
message: 'Prebid Native',
|
|
366
|
+
action: 'click',
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const ev = {
|
|
370
|
+
data: JSON.stringify(data),
|
|
371
|
+
source: {
|
|
372
|
+
postMessage: sinon.stub()
|
|
373
|
+
},
|
|
374
|
+
origin: 'any origin'
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
receiveMessage(ev);
|
|
378
|
+
|
|
379
|
+
sinon.assert.neverCalledWith(spyLogWarn, warning);
|
|
380
|
+
sinon.assert.calledOnce(stubFireNativeTrackers);
|
|
381
|
+
sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON);
|
|
382
|
+
sinon.assert.notCalled(spyAddWinningBid);
|
|
383
|
+
|
|
384
|
+
resetHistories(ev.source.postMessage);
|
|
385
|
+
|
|
386
|
+
delete data.action;
|
|
387
|
+
ev.data = JSON.stringify(data);
|
|
388
|
+
receiveMessage(ev);
|
|
389
|
+
|
|
390
|
+
sinon.assert.neverCalledWith(spyLogWarn, warning);
|
|
391
|
+
sinon.assert.calledOnce(stubFireNativeTrackers);
|
|
392
|
+
sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse);
|
|
393
|
+
sinon.assert.calledOnce(spyAddWinningBid);
|
|
394
|
+
|
|
395
|
+
expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED);
|
|
396
|
+
});
|
|
368
397
|
});
|
|
369
398
|
});
|
|
370
399
|
});
|