prebid.js 6.0.0 → 6.4.0

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.
Files changed (201) hide show
  1. package/.babelrc.js +1 -7
  2. package/.circleci/config.yml +1 -1
  3. package/README.md +1 -1
  4. package/browsers.json +13 -29
  5. package/gulpfile.js +88 -82
  6. package/integrationExamples/gpt/weboramaRtdProvider_example.html +23 -14
  7. package/karma.conf.maker.js +2 -2
  8. package/modules/33acrossBidAdapter.js +189 -102
  9. package/modules/adagioBidAdapter.js +1 -1
  10. package/modules/addefendBidAdapter.js +1 -0
  11. package/modules/adheseBidAdapter.js +7 -2
  12. package/modules/adkernelBidAdapter.js +147 -61
  13. package/modules/adlivetechBidAdapter.md +61 -0
  14. package/modules/adlooxAdServerVideo.js +2 -2
  15. package/modules/adlooxAnalyticsAdapter.js +4 -4
  16. package/modules/admanBidAdapter.js +1 -0
  17. package/modules/admixerBidAdapter.js +3 -2
  18. package/modules/adnuntiusBidAdapter.js +5 -2
  19. package/modules/adomikAnalyticsAdapter.js +16 -4
  20. package/modules/adplusBidAdapter.js +203 -0
  21. package/modules/adplusBidAdapter.md +39 -0
  22. package/modules/adxcgBidAdapter.js +311 -359
  23. package/modules/adxcgBidAdapter.md +22 -21
  24. package/modules/adyoulikeBidAdapter.js +7 -2
  25. package/modules/aniviewBidAdapter.js +1 -1
  26. package/modules/appnexusBidAdapter.js +23 -3
  27. package/modules/beachfrontBidAdapter.js +14 -17
  28. package/modules/beopBidAdapter.js +6 -4
  29. package/modules/bidViewability.js +3 -3
  30. package/modules/bidViewabilityIO.js +3 -3
  31. package/modules/codefuelBidAdapter.js +1 -3
  32. package/modules/codefuelBidAdapter.md +3 -3
  33. package/modules/colossussspBidAdapter.js +7 -0
  34. package/modules/compassBidAdapter.js +201 -0
  35. package/modules/compassBidAdapter.md +79 -0
  36. package/modules/craftBidAdapter.js +5 -3
  37. package/modules/criteoBidAdapter.js +1 -1
  38. package/modules/currency.js +2 -2
  39. package/modules/cwireBidAdapter.js +3 -0
  40. package/modules/dailyhuntBidAdapter.js +435 -0
  41. package/modules/dailyhuntBidAdapter.md +4 -0
  42. package/modules/datablocksBidAdapter.js +3 -3
  43. package/modules/dchain.js +149 -0
  44. package/modules/dchain.md +45 -0
  45. package/modules/deepintentBidAdapter.js +1 -1
  46. package/modules/dspxBidAdapter.js +1 -1
  47. package/modules/emx_digitalBidAdapter.js +9 -1
  48. package/modules/engageyaBidAdapter.js +68 -54
  49. package/modules/feedadBidAdapter.js +2 -2
  50. package/modules/feedadBidAdapter.md +4 -2
  51. package/modules/freewheel-sspBidAdapter.js +6 -0
  52. package/modules/futureads.md +48 -0
  53. package/modules/glimpseBidAdapter.js +44 -16
  54. package/modules/goldbachBidAdapter.js +1176 -0
  55. package/modules/goldbachBidAdapter.md +151 -0
  56. package/modules/gptPreAuction.js +11 -5
  57. package/modules/gridBidAdapter.js +5 -4
  58. package/modules/gumgumBidAdapter.js +7 -3
  59. package/modules/id5IdSystem.md +6 -6
  60. package/modules/imRtdProvider.js +31 -0
  61. package/modules/improvedigitalBidAdapter.js +19 -3
  62. package/modules/instreamTracking.js +4 -4
  63. package/modules/intersectionRtdProvider.js +114 -0
  64. package/modules/invibesBidAdapter.js +64 -14
  65. package/modules/invibesBidAdapter.md +2 -1
  66. package/modules/ipromBidAdapter.js +79 -0
  67. package/modules/ixBidAdapter.js +185 -22
  68. package/modules/kinessoIdSystem.js +1 -1
  69. package/modules/limelightDigitalBidAdapter.js +2 -1
  70. package/modules/livewrappedBidAdapter.js +8 -2
  71. package/modules/lotamePanoramaIdSystem.js +80 -8
  72. package/modules/luponmediaBidAdapter.js +570 -0
  73. package/modules/mediasquareBidAdapter.js +1 -9
  74. package/modules/merkleIdSystem.js +5 -0
  75. package/modules/missenaBidAdapter.js +89 -0
  76. package/modules/nativoBidAdapter.js +27 -1
  77. package/modules/nextMillenniumBidAdapter.js +37 -7
  78. package/modules/oguryBidAdapter.js +2 -1
  79. package/modules/openxBidAdapter.js +6 -1
  80. package/modules/prebidServerBidAdapter/index.js +19 -15
  81. package/modules/pubgeniusBidAdapter.js +1 -1
  82. package/modules/pubmaticBidAdapter.js +5 -3
  83. package/modules/pubxaiAnalyticsAdapter.js +17 -0
  84. package/modules/relaidoBidAdapter.js +86 -65
  85. package/modules/richaudienceBidAdapter.js +2 -3
  86. package/modules/rtdModule/index.js +48 -18
  87. package/modules/rubiconBidAdapter.js +31 -19
  88. package/modules/saambaaBidAdapter.js +420 -0
  89. package/modules/saambaaBidAdapter.md +65 -68
  90. package/modules/seedtagBidAdapter.js +6 -0
  91. package/modules/sharedIdSystem.js +27 -1
  92. package/modules/smaatoBidAdapter.js +9 -1
  93. package/modules/smartxBidAdapter.js +17 -1
  94. package/modules/sspBCBidAdapter.js +34 -3
  95. package/modules/tappxBidAdapter.js +3 -1
  96. package/modules/targetVideoBidAdapter.js +187 -0
  97. package/modules/targetVideoBidAdapter.md +34 -0
  98. package/modules/telariaBidAdapter.js +2 -2
  99. package/modules/trustxBidAdapter.js +18 -17
  100. package/modules/undertoneBidAdapter.js +8 -1
  101. package/modules/userId/index.js +27 -2
  102. package/modules/ventes.md +71 -0
  103. package/modules/ventesBidAdapter.js +104 -64
  104. package/modules/ventesBidAdapter.md +0 -1
  105. package/modules/vidoomyBidAdapter.js +65 -108
  106. package/modules/visxBidAdapter.js +20 -3
  107. package/modules/visxBidAdapter.md +4 -6
  108. package/modules/weboramaRtdProvider.js +288 -73
  109. package/modules/weboramaRtdProvider.md +27 -10
  110. package/modules/yahoosspBidAdapter.js +5 -1
  111. package/modules/yahoosspBidAdapter.md +1 -1
  112. package/modules/yieldlabBidAdapter.js +41 -10
  113. package/modules/yieldlabBidAdapter.md +91 -48
  114. package/modules/yieldoneBidAdapter.js +115 -11
  115. package/modules/zetaSspBidAdapter.md +33 -1
  116. package/modules/zeta_global_sspBidAdapter.js +22 -1
  117. package/package.json +6 -1
  118. package/plugins/pbjsGlobals.js +28 -1
  119. package/src/adapterManager.js +14 -8
  120. package/src/auction.js +5 -4
  121. package/src/prebid.js +1 -2
  122. package/src/targeting.js +24 -3
  123. package/src/utils.js +41 -7
  124. package/test/helpers/prebidGlobal.js +1 -0
  125. package/test/spec/integration/faker/googletag.js +6 -0
  126. package/test/spec/modules/33acrossBidAdapter_spec.js +300 -78
  127. package/test/spec/modules/adheseBidAdapter_spec.js +27 -1
  128. package/test/spec/modules/adlooxAnalyticsAdapter_spec.js +6 -6
  129. package/test/spec/modules/adnuntiusBidAdapter_spec.js +35 -0
  130. package/test/spec/modules/adomikAnalyticsAdapter_spec.js +9 -1
  131. package/test/spec/modules/adplusBidAdapter_spec.js +213 -0
  132. package/test/spec/modules/adxcgBidAdapter_spec.js +820 -571
  133. package/test/spec/modules/adyoulikeBidAdapter_spec.js +26 -0
  134. package/test/spec/modules/appnexusBidAdapter_spec.js +63 -1
  135. package/test/spec/modules/beachfrontBidAdapter_spec.js +65 -1
  136. package/test/spec/modules/beopBidAdapter_spec.js +1 -1
  137. package/test/spec/modules/bidViewabilityIO_spec.js +2 -2
  138. package/test/spec/modules/bidViewability_spec.js +4 -4
  139. package/test/spec/modules/codefuelBidAdapter_spec.js +1 -1
  140. package/test/spec/modules/colossussspBidAdapter_spec.js +9 -0
  141. package/test/spec/modules/compassBidAdapter_spec.js +397 -0
  142. package/test/spec/modules/cwireBidAdapter_spec.js +10 -8
  143. package/test/spec/modules/dailyhuntBidAdapter_spec.js +404 -0
  144. package/test/spec/modules/datablocksBidAdapter_spec.js +3 -3
  145. package/test/spec/modules/dchain_spec.js +329 -0
  146. package/test/spec/modules/emx_digitalBidAdapter_spec.js +10 -0
  147. package/test/spec/modules/engageyaBidAdapter_spec.js +231 -95
  148. package/test/spec/modules/eplanningBidAdapter_spec.js +8 -8
  149. package/test/spec/modules/feedadBidAdapter_spec.js +15 -0
  150. package/test/spec/modules/freewheel-sspBidAdapter_spec.js +19 -0
  151. package/test/spec/modules/glimpseBidAdapter_spec.js +33 -0
  152. package/test/spec/modules/goldbachBidAdapter_spec.js +1359 -0
  153. package/test/spec/modules/gptPreAuction_spec.js +58 -4
  154. package/test/spec/modules/gumgumBidAdapter_spec.js +6 -0
  155. package/test/spec/modules/imRtdProvider_spec.js +25 -0
  156. package/test/spec/modules/improvedigitalBidAdapter_spec.js +3 -1
  157. package/test/spec/modules/intersectionRtdProvider_spec.js +141 -0
  158. package/test/spec/modules/invibesBidAdapter_spec.js +148 -4
  159. package/test/spec/modules/ipromBidAdapter_spec.js +195 -0
  160. package/test/spec/modules/ixBidAdapter_spec.js +293 -2
  161. package/test/spec/modules/konduitWrapper_spec.js +0 -1
  162. package/test/spec/modules/limelightDigitalBidAdapter_spec.js +10 -7
  163. package/test/spec/modules/livewrappedBidAdapter_spec.js +31 -0
  164. package/test/spec/modules/lotamePanoramaIdSystem_spec.js +227 -0
  165. package/test/spec/modules/luponmediaBidAdapter_spec.js +412 -0
  166. package/test/spec/modules/mediasquareBidAdapter_spec.js +4 -4
  167. package/test/spec/modules/merkleIdSystem_spec.js +18 -0
  168. package/test/spec/modules/missenaBidAdapter_spec.js +134 -0
  169. package/test/spec/modules/nativoBidAdapter_spec.js +35 -18
  170. package/test/spec/modules/nextMillenniumBidAdapter_spec.js +26 -1
  171. package/test/spec/modules/oguryBidAdapter_spec.js +13 -11
  172. package/test/spec/modules/openxBidAdapter_spec.js +5 -0
  173. package/test/spec/modules/prebidServerBidAdapter_spec.js +62 -2
  174. package/test/spec/modules/pubgeniusBidAdapter_spec.js +3 -3
  175. package/test/spec/modules/pubmaticBidAdapter_spec.js +1 -1
  176. package/test/spec/modules/pubxaiAnalyticsAdapter_spec.js +11 -0
  177. package/test/spec/modules/realTimeDataModule_spec.js +135 -49
  178. package/test/spec/modules/relaidoBidAdapter_spec.js +71 -63
  179. package/test/spec/modules/richaudienceBidAdapter_spec.js +2 -2
  180. package/test/spec/modules/rubiconBidAdapter_spec.js +65 -9
  181. package/test/spec/modules/seedtagBidAdapter_spec.js +3 -0
  182. package/test/spec/modules/sharedIdSystem_spec.js +52 -6
  183. package/test/spec/modules/smaatoBidAdapter_spec.js +61 -0
  184. package/test/spec/modules/smartxBidAdapter_spec.js +9 -0
  185. package/test/spec/modules/sspBCBidAdapter_spec.js +33 -3
  186. package/test/spec/modules/tappxBidAdapter_spec.js +4 -0
  187. package/test/spec/modules/targetVideoBidAdapter_spec.js +96 -0
  188. package/test/spec/modules/trustxBidAdapter_spec.js +42 -0
  189. package/test/spec/modules/userId_spec.js +51 -0
  190. package/test/spec/modules/vidoomyBidAdapter_spec.js +32 -13
  191. package/test/spec/modules/visxBidAdapter_spec.js +121 -5
  192. package/test/spec/modules/weboramaRtdProvider_spec.js +408 -214
  193. package/test/spec/modules/yahoosspBidAdapter_spec.js +28 -1
  194. package/test/spec/modules/yieldlabBidAdapter_spec.js +81 -0
  195. package/test/spec/modules/yieldoneBidAdapter_spec.js +299 -53
  196. package/test/spec/modules/zeta_global_sspBidAdapter_spec.js +33 -1
  197. package/test/spec/unit/core/adapterManager_spec.js +24 -6
  198. package/test/spec/unit/core/targeting_spec.js +116 -0
  199. package/test/spec/utils_spec.js +38 -0
  200. package/test/test_deps.js +3 -0
  201. package/test/test_index.js +1 -3
@@ -197,15 +197,69 @@ describe('GPT pre-auction module', () => {
197
197
  code: 'slotCode3',
198
198
  }];
199
199
 
200
+ // first two adUnits directly pass in pbadslot => gpid is same
200
201
  const expectedAdUnits = [{
201
202
  code: 'adUnit1',
202
- ortb2Imp: { ext: { data: { pbadslot: '12345' } } }
203
- }, {
203
+ ortb2Imp: {
204
+ ext: {
205
+ data: {
206
+ pbadslot: '12345'
207
+ },
208
+ gpid: '12345'
209
+ }
210
+ }
211
+ },
212
+ // second adunit
213
+ {
204
214
  code: 'slotCode1',
205
- ortb2Imp: { ext: { data: { pbadslot: '67890', adserver: { name: 'gam', adslot: 'slotCode1' } } } }
215
+ ortb2Imp: {
216
+ ext: {
217
+ data: {
218
+ pbadslot: '67890',
219
+ adserver: {
220
+ name: 'gam',
221
+ adslot: 'slotCode1'
222
+ }
223
+ },
224
+ gpid: '67890'
225
+ }
226
+ }
206
227
  }, {
207
228
  code: 'slotCode3',
208
- ortb2Imp: { ext: { data: { pbadslot: 'slotCode3', adserver: { name: 'gam', adslot: 'slotCode3' } } } }
229
+ ortb2Imp: {
230
+ ext: {
231
+ data: {
232
+ pbadslot: 'slotCode3',
233
+ adserver: {
234
+ name: 'gam',
235
+ adslot: 'slotCode3'
236
+ }
237
+ },
238
+ gpid: 'slotCode3'
239
+ }
240
+ }
241
+ }];
242
+
243
+ window.googletag.pubads().setSlots(testSlots);
244
+ runMakeBidRequests(testAdUnits);
245
+ expect(returnedAdUnits).to.deep.equal(expectedAdUnits);
246
+ });
247
+
248
+ it('should not apply gpid if pbadslot was set by adUnitCode', () => {
249
+ const testAdUnits = [{
250
+ code: 'noMatchCode',
251
+ }];
252
+
253
+ // first two adUnits directly pass in pbadslot => gpid is same
254
+ const expectedAdUnits = [{
255
+ code: 'noMatchCode',
256
+ ortb2Imp: {
257
+ ext: {
258
+ data: {
259
+ pbadslot: 'noMatchCode'
260
+ },
261
+ }
262
+ }
209
263
  }];
210
264
 
211
265
  window.googletag.pubads().setSlots(testSlots);
@@ -152,6 +152,12 @@ describe('gumgumAdapter', function () {
152
152
  const zoneParam = { 'zone': '123a' };
153
153
  const pubIdParam = { 'pubId': 123 };
154
154
 
155
+ it('should set aun if the adUnitCode is available', function () {
156
+ const request = { ...bidRequests[0] };
157
+ const bidRequest = spec.buildRequests([request])[0];
158
+ expect(bidRequest.data.aun).to.equal(bidRequests[0].adUnitCode);
159
+ });
160
+
155
161
  it('should set pubId param if found', function () {
156
162
  const request = { ...bidRequests[0], params: pubIdParam };
157
163
  const bidRequest = spec.buildRequests([request])[0];
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  imRtdSubmodule,
3
3
  storage,
4
+ getBidderFunction,
4
5
  getCustomBidderFunction,
5
6
  setRealTimeData,
6
7
  getRealTimeData,
@@ -47,6 +48,30 @@ describe('imRtdProvider', function () {
47
48
  })
48
49
  })
49
50
 
51
+ describe('getBidderFunction', function () {
52
+ const assumedBidder = [
53
+ 'ix',
54
+ 'pubmatic'
55
+ ];
56
+ assumedBidder.forEach(bidderName => {
57
+ it(`should return bidderFunction with assumed bidder: ${bidderName}`, function () {
58
+ expect(getBidderFunction(bidderName)).to.exist.and.to.be.a('function');
59
+ });
60
+
61
+ it(`should return bid with correct key data: ${bidderName}`, function () {
62
+ const bid = {bidder: bidderName};
63
+ expect(getBidderFunction(bidderName)(bid, {'im_segments': ['12345', '67890']})).to.equal(bid);
64
+ });
65
+ it(`should return bid without data: ${bidderName}`, function () {
66
+ const bid = {bidder: bidderName};
67
+ expect(getBidderFunction(bidderName)(bid, '')).to.equal(bid);
68
+ });
69
+ });
70
+ it(`should return null with unexpected bidder`, function () {
71
+ expect(getBidderFunction('test')).to.equal(null);
72
+ });
73
+ })
74
+
50
75
  describe('getCustomBidderFunction', function () {
51
76
  it('should return config function', function () {
52
77
  const config = {
@@ -92,7 +92,8 @@ describe('Improve Digital Adapter Tests', function () {
92
92
  gdprConsent: {
93
93
  consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
94
94
  vendorData: {},
95
- gdprApplies: true
95
+ gdprApplies: true,
96
+ addtlConsent: '1~1.35.41.101',
96
97
  },
97
98
  };
98
99
 
@@ -278,6 +279,7 @@ describe('Improve Digital Adapter Tests', function () {
278
279
  const request = spec.buildRequests([bidRequest], bidderRequestGdpr)[0];
279
280
  const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
280
281
  expect(params.bid_request.gdpr).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==');
282
+ expect(params.bid_request.user.ext.consented_providers_settings.consented_providers).to.exist.and.to.deep.equal([1, 35, 41, 101]);
281
283
  });
282
284
 
283
285
  it('should add CCPA consent string', function () {
@@ -0,0 +1,141 @@
1
+ import {config as _config, config} from 'src/config.js';
2
+ import { expect } from 'chai';
3
+ import events from 'src/events.js';
4
+ import * as prebidGlobal from 'src/prebidGlobal.js';
5
+ import { intersectionSubmodule } from 'modules/intersectionRtdProvider.js';
6
+ import * as utils from 'src/utils.js';
7
+ import {getGlobal} from 'src/prebidGlobal.js';
8
+ import 'src/prebid.js';
9
+
10
+ describe('Intersection RTD Provider', function () {
11
+ let sandbox;
12
+ let placeholder;
13
+ const pbjs = getGlobal();
14
+ const adUnit = {
15
+ code: 'ad-slot-1',
16
+ mediaTypes: {
17
+ banner: {
18
+ sizes: [ [300, 250] ]
19
+ }
20
+ },
21
+ bids: [
22
+ {
23
+ bidder: 'fake'
24
+ }
25
+ ]
26
+ };
27
+ const providerConfig = {name: 'intersection', waitForIt: true};
28
+ const rtdConfig = {realTimeData: {auctionDelay: 200, dataProviders: [providerConfig]}}
29
+ describe('IntersectionObserver not supported', function() {
30
+ beforeEach(function() {
31
+ sandbox = sinon.sandbox.create();
32
+ });
33
+ afterEach(function() {
34
+ sandbox.restore();
35
+ sandbox = undefined;
36
+ });
37
+ it('init should return false', function () {
38
+ sandbox.stub(window, 'IntersectionObserver').value(undefined);
39
+ expect(intersectionSubmodule.init({})).is.false;
40
+ });
41
+ });
42
+ describe('IntersectionObserver supported', function() {
43
+ beforeEach(function() {
44
+ sandbox = sinon.sandbox.create();
45
+ placeholder = createDiv();
46
+ append();
47
+ const __config = {};
48
+ sandbox.stub(_config, 'getConfig').callsFake(function (path) {
49
+ return utils.deepAccess(__config, path);
50
+ });
51
+ sandbox.stub(_config, 'setConfig').callsFake(function (obj) {
52
+ utils.mergeDeep(__config, obj);
53
+ });
54
+ });
55
+ afterEach(function() {
56
+ sandbox.restore();
57
+ remove();
58
+ sandbox = undefined;
59
+ placeholder = undefined;
60
+ pbjs.removeAdUnit();
61
+ });
62
+ it('init should return true', function () {
63
+ expect(intersectionSubmodule.init({})).is.true;
64
+ });
65
+ it('should set intersection. (request with "adUnitCodes")', function(done) {
66
+ pbjs.addAdUnits([utils.deepClone(adUnit)]);
67
+ config.setConfig(rtdConfig);
68
+ const onDone = sandbox.stub();
69
+ const requestBidObject = {adUnitCodes: [adUnit.code]};
70
+ intersectionSubmodule.init({});
71
+ intersectionSubmodule.getBidRequestData(
72
+ requestBidObject,
73
+ onDone,
74
+ providerConfig
75
+ );
76
+ setTimeout(function() {
77
+ expect(pbjs.adUnits[0].bids[0]).to.have.property('intersection');
78
+ done();
79
+ }, 200);
80
+ });
81
+ it('should set intersection. (request with "adUnits")', function(done) {
82
+ config.setConfig(rtdConfig);
83
+ const onDone = sandbox.stub();
84
+ const requestBidObject = {adUnits: [utils.deepClone(adUnit)]};
85
+ intersectionSubmodule.init();
86
+ intersectionSubmodule.getBidRequestData(
87
+ requestBidObject,
88
+ onDone,
89
+ providerConfig
90
+ );
91
+ setTimeout(function() {
92
+ expect(requestBidObject.adUnits[0].bids[0]).to.have.property('intersection');
93
+ done();
94
+ }, 200);
95
+ });
96
+ it('should set intersection. (request all)', function(done) {
97
+ pbjs.addAdUnits([utils.deepClone(adUnit)]);
98
+ config.setConfig(rtdConfig);
99
+ const onDone = sandbox.stub();
100
+ const requestBidObject = {};
101
+ intersectionSubmodule.init({});
102
+ intersectionSubmodule.getBidRequestData(
103
+ requestBidObject,
104
+ onDone,
105
+ providerConfig
106
+ );
107
+ setTimeout(function() {
108
+ expect(pbjs.adUnits[0].bids[0]).to.have.property('intersection');
109
+ done();
110
+ }, 200);
111
+ });
112
+ it('should call done due timeout', function(done) {
113
+ config.setConfig(rtdConfig);
114
+ remove();
115
+ const onDone = sandbox.stub();
116
+ const requestBidObject = {adUnits: [utils.deepClone(adUnit)]};
117
+ intersectionSubmodule.init({});
118
+ intersectionSubmodule.getBidRequestData(
119
+ requestBidObject,
120
+ onDone,
121
+ {...providerConfig, test: 1}
122
+ );
123
+ setTimeout(function() {
124
+ sinon.assert.calledOnce(onDone);
125
+ expect(requestBidObject.adUnits[0].bids[0]).to.not.have.property('intersection');
126
+ done();
127
+ }, 300);
128
+ });
129
+ });
130
+ function createDiv() {
131
+ const div = document.createElement('div');
132
+ div.id = adUnit.code;
133
+ return div;
134
+ }
135
+ function append() {
136
+ placeholder && document.body.appendChild(placeholder);
137
+ }
138
+ function remove() {
139
+ placeholder && placeholder.parentElement && placeholder.parentElement.removeChild(placeholder);
140
+ }
141
+ });
@@ -15,7 +15,7 @@ describe('invibesBidAdapter:', function () {
15
15
  params: {
16
16
  placementId: PLACEMENT_ID
17
17
  },
18
- adUnitCode: 'test-div',
18
+ adUnitCode: 'test-div1',
19
19
  auctionId: 'a1',
20
20
  sizes: [
21
21
  [300, 250],
@@ -30,7 +30,7 @@ describe('invibesBidAdapter:', function () {
30
30
  params: {
31
31
  placementId: 'abcde'
32
32
  },
33
- adUnitCode: 'test-div',
33
+ adUnitCode: 'test-div2',
34
34
  auctionId: 'a2',
35
35
  sizes: [
36
36
  [300, 250],
@@ -48,7 +48,7 @@ describe('invibesBidAdapter:', function () {
48
48
  params: {
49
49
  placementId: PLACEMENT_ID
50
50
  },
51
- adUnitCode: 'test-div',
51
+ adUnitCode: 'test-div1',
52
52
  auctionId: 'a1',
53
53
  sizes: [
54
54
  [300, 250],
@@ -67,7 +67,7 @@ describe('invibesBidAdapter:', function () {
67
67
  params: {
68
68
  placementId: 'abcde'
69
69
  },
70
- adUnitCode: 'test-div',
70
+ adUnitCode: 'test-div2',
71
71
  auctionId: 'a2',
72
72
  sizes: [
73
73
  [300, 250],
@@ -158,6 +158,125 @@ describe('invibesBidAdapter:', function () {
158
158
  expect(request.method).to.equal('GET');
159
159
  });
160
160
 
161
+ it('sends bid request to custom endpoint via GET', function () {
162
+ const request = spec.buildRequests([{
163
+ bidId: 'b1',
164
+ bidder: BIDDER_CODE,
165
+ params: {
166
+ placementId: 'placement',
167
+ customEndpoint: 'sub.domain.com/Bid/VideoAdContent'
168
+ },
169
+ adUnitCode: 'test-div1'
170
+ }]);
171
+ expect(request.url).to.equal('sub.domain.com/Bid/VideoAdContent');
172
+ expect(request.method).to.equal('GET');
173
+ });
174
+
175
+ it('sends bid request to default endpoint when no placement', function () {
176
+ const request = spec.buildRequests([{
177
+ bidId: 'b1',
178
+ bidder: BIDDER_CODE,
179
+ params: {
180
+ },
181
+ adUnitCode: 'test-div1'
182
+ }]);
183
+ expect(request.url).to.equal(ENDPOINT);
184
+ expect(request.method).to.equal('GET');
185
+ });
186
+
187
+ it('sends bid request to default endpoint when null placement', function () {
188
+ const request = spec.buildRequests([{
189
+ bidId: 'b1',
190
+ bidder: BIDDER_CODE,
191
+ params: {
192
+ placementId: null
193
+ },
194
+ adUnitCode: 'test-div1'
195
+ }]);
196
+ expect(request.url).to.equal(ENDPOINT);
197
+ expect(request.method).to.equal('GET');
198
+ });
199
+
200
+ it('sends bid request to default endpoint 1 via GET', function () {
201
+ const request = spec.buildRequests([{
202
+ bidId: 'b1',
203
+ bidder: BIDDER_CODE,
204
+ params: {
205
+ placementId: 'placement'
206
+ },
207
+ adUnitCode: 'test-div1'
208
+ }]);
209
+ expect(request.url).to.equal('https://bid.videostep.com/Bid/VideoAdContent');
210
+ expect(request.method).to.equal('GET');
211
+ });
212
+
213
+ it('sends bid request to network id endpoint 1 via GET', function () {
214
+ const request = spec.buildRequests([{
215
+ bidId: 'b1',
216
+ bidder: BIDDER_CODE,
217
+ params: {
218
+ placementId: 'placement',
219
+ domainId: 1001
220
+ },
221
+ adUnitCode: 'test-div1'
222
+ }]);
223
+ expect(request.url).to.equal('https://bid.videostep.com/Bid/VideoAdContent');
224
+ expect(request.method).to.equal('GET');
225
+ });
226
+
227
+ it('sends bid request to network id endpoint 2 via GET', function () {
228
+ const request = spec.buildRequests([{
229
+ bidId: 'b1',
230
+ bidder: BIDDER_CODE,
231
+ params: {
232
+ placementId: 'placement',
233
+ domainId: 1002
234
+ },
235
+ adUnitCode: 'test-div1'
236
+ }]);
237
+ expect(request.url).to.equal('https://bid2.videostep.com/Bid/VideoAdContent');
238
+ expect(request.method).to.equal('GET');
239
+ });
240
+
241
+ it('sends bid request to network id by placement 1 via GET', function () {
242
+ const request = spec.buildRequests([{
243
+ bidId: 'b1',
244
+ bidder: BIDDER_CODE,
245
+ params: {
246
+ placementId: 'infeed_ivbs1'
247
+ },
248
+ adUnitCode: 'test-div1'
249
+ }]);
250
+ expect(request.url).to.equal('https://bid.videostep.com/Bid/VideoAdContent');
251
+ expect(request.method).to.equal('GET');
252
+ });
253
+
254
+ it('sends bid request to network id by placement 2 via GET', function () {
255
+ const request = spec.buildRequests([{
256
+ bidId: 'b1',
257
+ bidder: BIDDER_CODE,
258
+ params: {
259
+ placementId: 'infeed_ivbs2'
260
+ },
261
+ adUnitCode: 'test-div1'
262
+ }]);
263
+ expect(request.url).to.equal('https://bid2.videostep.com/Bid/VideoAdContent');
264
+ expect(request.method).to.equal('GET');
265
+ });
266
+
267
+ it('sends bid request to network id by placement 10 via GET', function () {
268
+ const request = spec.buildRequests([{
269
+ bidId: 'b1',
270
+ bidder: BIDDER_CODE,
271
+ params: {
272
+ placementId: 'infeed_ivbs10'
273
+ },
274
+ adUnitCode: 'test-div1'
275
+ }]);
276
+ expect(request.url).to.equal('https://bid10.videostep.com/Bid/VideoAdContent');
277
+ expect(request.method).to.equal('GET');
278
+ });
279
+
161
280
  it('sends cookies with the bid request', function () {
162
281
  const request = spec.buildRequests(bidRequests);
163
282
  expect(request.options.withCredentials).to.equal(true);
@@ -223,6 +342,12 @@ describe('invibesBidAdapter:', function () {
223
342
  expect(JSON.parse(request.data.bidParamsJson).placementIds).to.contain(bidRequests[1].params.placementId);
224
343
  });
225
344
 
345
+ it('sends all adUnitCodes', function () {
346
+ const request = spec.buildRequests(bidRequests);
347
+ expect(JSON.parse(request.data.bidParamsJson).adUnitCodes).to.contain(bidRequests[0].adUnitCode);
348
+ expect(JSON.parse(request.data.bidParamsJson).adUnitCodes).to.contain(bidRequests[1].adUnitCode);
349
+ });
350
+
226
351
  it('sends all Placement Ids and userId', function () {
227
352
  const request = spec.buildRequests(bidRequestsWithUserId);
228
353
  expect(JSON.parse(request.data.bidParamsJson).userId).to.exist;
@@ -823,6 +948,20 @@ describe('invibesBidAdapter:', function () {
823
948
  }
824
949
  };
825
950
 
951
+ let responseWithAdUnit = {
952
+ Ads: [{
953
+ BidPrice: 0.5,
954
+ VideoExposedId: 123
955
+ }],
956
+ BidModel: {
957
+ BidVersion: 1,
958
+ PlacementId: '12345_test-div1',
959
+ AuctionStartTime: Date.now(),
960
+ CreativeHtml: '<!-- Creative -->'
961
+ },
962
+ UseAdUnitCode: true
963
+ };
964
+
826
965
  var buildResponse = function(placementId, cid, blcids, creativeId) {
827
966
  return {
828
967
  MultipositionEnabled: true,
@@ -911,6 +1050,11 @@ describe('invibesBidAdapter:', function () {
911
1050
  let secondResult = spec.interpretResponse({body: response}, {bidRequests});
912
1051
  expect(secondResult).to.be.empty;
913
1052
  });
1053
+
1054
+ it('bids using the adUnitCode', function () {
1055
+ let result = spec.interpretResponse({body: responseWithAdUnit}, {bidRequests});
1056
+ expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0]));
1057
+ });
914
1058
  });
915
1059
 
916
1060
  context('when the response has meta', function () {
@@ -0,0 +1,195 @@
1
+ import {expect} from 'chai';
2
+ import {spec} from 'modules/ipromBidAdapter.js';
3
+
4
+ describe('iPROM Adapter', function () {
5
+ let bidRequests;
6
+ let bidderRequest;
7
+
8
+ beforeEach(function () {
9
+ bidRequests = [
10
+ {
11
+ bidder: 'iprom',
12
+ params: {
13
+ id: '1234',
14
+ dimension: '300x250',
15
+ },
16
+ adUnitCode: '/19966331/header-bid-tag-1',
17
+ mediaTypes: {
18
+ banner: {
19
+ sizes: [[300, 250], [300, 600]],
20
+ }
21
+ },
22
+ bidId: '29a72b151f7bd3',
23
+ auctionId: 'e36abb27-g3b1-1ad6-8a4c-701c8919d3hh',
24
+ bidderRequestId: '2z76da40m1b3cb8',
25
+ transactionId: 'j51lhf58-1ad6-g3b1-3j6s-912c9493g0gu'
26
+ }
27
+ ];
28
+
29
+ bidderRequest = {
30
+ timeout: 3000,
31
+ refererInfo: {
32
+ referer: 'https://adserver.si/index.html',
33
+ reachedTop: true,
34
+ numIframes: 1,
35
+ stack: [
36
+ 'https://adserver.si/index.html',
37
+ 'https://adserver.si/iframe1.html',
38
+ ]
39
+ }
40
+ }
41
+ });
42
+
43
+ describe('validating bids', function () {
44
+ it('should accept valid bid', function () {
45
+ let validBid = {
46
+ bidder: 'iprom',
47
+ params: {
48
+ id: '1234',
49
+ dimension: '300x250',
50
+ },
51
+ };
52
+
53
+ const isValid = spec.isBidRequestValid(validBid);
54
+
55
+ expect(isValid).to.equal(true);
56
+ });
57
+
58
+ it('should reject bid if missing dimension and id', function () {
59
+ let invalidBid = {
60
+ bidder: 'iprom',
61
+ params: {}
62
+ };
63
+
64
+ const isValid = spec.isBidRequestValid(invalidBid);
65
+
66
+ expect(isValid).to.equal(false);
67
+ });
68
+
69
+ it('should reject bid if missing dimension', function () {
70
+ let invalidBid = {
71
+ bidder: 'iprom',
72
+ params: {
73
+ id: '1234',
74
+ }
75
+ };
76
+
77
+ const isValid = spec.isBidRequestValid(invalidBid);
78
+
79
+ expect(isValid).to.equal(false);
80
+ });
81
+
82
+ it('should reject bid if dimension is not a string', function () {
83
+ let invalidBid = {
84
+ bidder: 'iprom',
85
+ params: {
86
+ id: '1234',
87
+ dimension: 404,
88
+ }
89
+ };
90
+
91
+ const isValid = spec.isBidRequestValid(invalidBid);
92
+
93
+ expect(isValid).to.equal(false);
94
+ });
95
+
96
+ it('should reject bid if missing id', function () {
97
+ let invalidBid = {
98
+ bidder: 'iprom',
99
+ params: {
100
+ dimension: '300x250',
101
+ }
102
+ };
103
+
104
+ const isValid = spec.isBidRequestValid(invalidBid);
105
+
106
+ expect(isValid).to.equal(false);
107
+ });
108
+
109
+ it('should reject bid if id is not a string', function () {
110
+ let invalidBid = {
111
+ bidder: 'iprom',
112
+ params: {
113
+ id: 1234,
114
+ dimension: '300x250',
115
+ }
116
+ };
117
+
118
+ const isValid = spec.isBidRequestValid(invalidBid);
119
+
120
+ expect(isValid).to.equal(false);
121
+ });
122
+ });
123
+
124
+ describe('building requests', function () {
125
+ it('should go to correct endpoint', function () {
126
+ const request = spec.buildRequests(bidRequests, bidderRequest);
127
+
128
+ expect(request.method).to.exist;
129
+ expect(request.method).to.equal('POST');
130
+ expect(request.url).to.exist;
131
+ expect(request.url).to.equal('https://core.iprom.net/programmatic');
132
+ });
133
+
134
+ it('should add referer info', function () {
135
+ const request = spec.buildRequests(bidRequests, bidderRequest);
136
+ const requestparse = JSON.parse(request.data);
137
+
138
+ expect(requestparse.referer).to.exist;
139
+ expect(requestparse.referer.referer).to.equal('https://adserver.si/index.html');
140
+ });
141
+
142
+ it('should add adapter version', function () {
143
+ const request = spec.buildRequests(bidRequests, bidderRequest);
144
+ const requestparse = JSON.parse(request.data);
145
+
146
+ expect(requestparse.version).to.exist;
147
+ });
148
+
149
+ it('should contain id and dimension', function () {
150
+ const request = spec.buildRequests(bidRequests, bidderRequest);
151
+ const requestparse = JSON.parse(request.data);
152
+
153
+ expect(requestparse.bids[0].params.id).to.equal('1234');
154
+ expect(requestparse.bids[0].params.dimension).to.equal('300x250');
155
+ });
156
+ });
157
+
158
+ describe('handling responses', function () {
159
+ it('should return complete bid response', function () {
160
+ const serverResponse = {
161
+ body: [{
162
+ requestId: '29a72b151f7bd3',
163
+ cpm: 0.5,
164
+ width: '300',
165
+ height: '250',
166
+ creativeId: 1234,
167
+ ad: '<html><head><title>Iprom Header bidding example</title></head><body><img src="https://iprom.si/files/2015/08/iprom-logo.svg"></body></html>',
168
+ aDomains: ['https://example.com'],
169
+ }
170
+ ]};
171
+
172
+ const request = spec.buildRequests(bidRequests, bidderRequest);
173
+ const bids = spec.interpretResponse(serverResponse, request);
174
+
175
+ expect(bids).to.be.lengthOf(1);
176
+ expect(bids[0].requestId).to.equal('29a72b151f7bd3');
177
+ expect(bids[0].cpm).to.equal(0.5);
178
+ expect(bids[0].width).to.equal('300');
179
+ expect(bids[0].height).to.equal('250');
180
+ expect(bids[0].ad).to.have.length.above(1);
181
+ expect(bids[0].meta.advertiserDomains).to.deep.equal(['https://example.com']);
182
+ });
183
+
184
+ it('should return empty bid response', function () {
185
+ const emptyServerResponse = {
186
+ body: []
187
+ };
188
+
189
+ const request = spec.buildRequests(bidRequests, bidderRequest);
190
+ const bids = spec.interpretResponse(emptyServerResponse, request);
191
+
192
+ expect(bids).to.be.lengthOf(0);
193
+ });
194
+ });
195
+ });