prebid.js 6.3.0 → 6.7.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 (157) hide show
  1. package/.circleci/config.yml +1 -1
  2. package/gulpfile.js +87 -74
  3. package/integrationExamples/gpt/amp/creative.html +11 -33
  4. package/karma.conf.maker.js +1 -1
  5. package/modules/.submodules.json +2 -1
  6. package/modules/adbookpspBidAdapter.js +27 -10
  7. package/modules/adhashBidAdapter.js +3 -3
  8. package/modules/adkernelBidAdapter.js +148 -62
  9. package/modules/adlooxAdServerVideo.js +2 -2
  10. package/modules/adlooxAnalyticsAdapter.js +4 -4
  11. package/modules/admanBidAdapter.js +10 -4
  12. package/modules/adomikAnalyticsAdapter.js +27 -9
  13. package/modules/adqueryIdSystem.js +103 -0
  14. package/modules/adqueryIdSystem.md +35 -0
  15. package/modules/adyoulikeBidAdapter.js +13 -9
  16. package/modules/aniviewBidAdapter.js +1 -1
  17. package/modules/beopBidAdapter.js +1 -1
  18. package/modules/bidViewability.js +3 -3
  19. package/modules/bidViewabilityIO.js +3 -3
  20. package/modules/bliinkBidAdapter.js +3 -2
  21. package/modules/colossussspBidAdapter.js +12 -8
  22. package/modules/colossussspBidAdapter.md +15 -1
  23. package/modules/compassBidAdapter.js +208 -0
  24. package/modules/compassBidAdapter.md +79 -0
  25. package/modules/consentManagement.js +7 -1
  26. package/modules/consumableBidAdapter.md +1 -1
  27. package/modules/criteoBidAdapter.js +1 -1
  28. package/modules/criteoIdSystem.js +29 -7
  29. package/modules/currency.js +2 -2
  30. package/modules/dailyhuntBidAdapter.js +435 -0
  31. package/modules/dailyhuntBidAdapter.md +4 -0
  32. package/modules/docereeBidAdapter.js +10 -1
  33. package/modules/docereeBidAdapter.md +2 -0
  34. package/modules/engageyaBidAdapter.js +1 -1
  35. package/modules/feedadBidAdapter.js +2 -2
  36. package/modules/feedadBidAdapter.md +4 -2
  37. package/modules/glimpseBidAdapter.js +66 -44
  38. package/modules/gnetBidAdapter.js +3 -3
  39. package/modules/gnetBidAdapter.md +4 -4
  40. package/modules/gptPreAuction.js +55 -7
  41. package/modules/gridBidAdapter.js +4 -3
  42. package/modules/gumgumBidAdapter.js +4 -4
  43. package/modules/idImportLibrary.js +45 -8
  44. package/modules/idImportLibrary.md +4 -0
  45. package/modules/improvedigitalBidAdapter.js +42 -4
  46. package/modules/instreamTracking.js +4 -4
  47. package/modules/invibesBidAdapter.js +49 -5
  48. package/modules/invibesBidAdapter.md +2 -1
  49. package/modules/ixBidAdapter.js +53 -18
  50. package/modules/jwplayerRtdProvider.js +71 -6
  51. package/modules/jwplayerRtdProvider.md +27 -11
  52. package/modules/kargoBidAdapter.js +2 -2
  53. package/modules/limelightDigitalBidAdapter.js +2 -1
  54. package/modules/livewrappedAnalyticsAdapter.js +3 -1
  55. package/modules/livewrappedBidAdapter.js +8 -2
  56. package/modules/loglyliftBidAdapter.js +79 -0
  57. package/modules/loglyliftBidAdapter.md +55 -0
  58. package/modules/nextMillenniumBidAdapter.js +11 -7
  59. package/modules/oguryBidAdapter.js +9 -2
  60. package/modules/onetagBidAdapter.js +4 -2
  61. package/modules/optimeraRtdProvider.js +8 -1
  62. package/modules/ozoneBidAdapter.js +21 -64
  63. package/modules/pilotxBidAdapter.js +147 -0
  64. package/modules/pilotxBidAdapter.md +50 -0
  65. package/modules/proxistoreBidAdapter.js +0 -2
  66. package/modules/pubgeniusBidAdapter.js +1 -1
  67. package/modules/pubmaticAnalyticsAdapter.js +16 -0
  68. package/modules/pubxaiAnalyticsAdapter.js +17 -0
  69. package/modules/richaudienceBidAdapter.js +3 -2
  70. package/modules/riseBidAdapter.js +1 -1
  71. package/modules/rtbhouseBidAdapter.js +14 -4
  72. package/modules/rtdModule/index.js +14 -15
  73. package/modules/rubiconAnalyticsAdapter.js +3 -2
  74. package/modules/rubiconBidAdapter.js +21 -11
  75. package/modules/seedingAllianceBidAdapter.js +3 -3
  76. package/modules/sharethroughBidAdapter.js +12 -17
  77. package/modules/showheroes-bsBidAdapter.js +13 -2
  78. package/modules/synacormediaBidAdapter.js +31 -10
  79. package/modules/tappxBidAdapter.js +8 -5
  80. package/modules/teadsBidAdapter.js +1 -2
  81. package/modules/telariaBidAdapter.js +2 -2
  82. package/modules/trustxBidAdapter.js +8 -16
  83. package/modules/userId/eids.js +7 -1
  84. package/modules/userId/userId.md +8 -0
  85. package/modules/viewability.js +177 -0
  86. package/modules/viewability.md +87 -0
  87. package/modules/welectBidAdapter.js +106 -0
  88. package/modules/yieldmoBidAdapter.js +23 -5
  89. package/modules/zeta_global_sspAnalyticsAdapter.js +97 -0
  90. package/modules/zeta_global_sspAnalyticsAdapter.md +24 -0
  91. package/package.json +1 -1
  92. package/src/auction.js +2 -2
  93. package/src/config.js +27 -3
  94. package/src/hook.js +5 -1
  95. package/src/prebid.js +20 -4
  96. package/src/secureCreatives.js +3 -2
  97. package/src/utils.js +12 -1
  98. package/test/helpers/prebidGlobal.js +1 -0
  99. package/test/spec/config_spec.js +279 -0
  100. package/test/spec/modules/adbookpspBidAdapter_spec.js +17 -3
  101. package/test/spec/modules/adhashBidAdapter_spec.js +2 -2
  102. package/test/spec/modules/adlooxAnalyticsAdapter_spec.js +6 -6
  103. package/test/spec/modules/admanBidAdapter_spec.js +2 -2
  104. package/test/spec/modules/adomikAnalyticsAdapter_spec.js +9 -1
  105. package/test/spec/modules/adqueryIdSystem_spec.js +74 -0
  106. package/test/spec/modules/adyoulikeBidAdapter_spec.js +49 -0
  107. package/test/spec/modules/beopBidAdapter_spec.js +1 -1
  108. package/test/spec/modules/bidViewabilityIO_spec.js +2 -2
  109. package/test/spec/modules/bidViewability_spec.js +4 -4
  110. package/test/spec/modules/bliinkBidAdapter_spec.js +2 -0
  111. package/test/spec/modules/colossussspBidAdapter_spec.js +5 -2
  112. package/test/spec/modules/compassBidAdapter_spec.js +398 -0
  113. package/test/spec/modules/consentManagement_spec.js +20 -0
  114. package/test/spec/modules/criteoIdSystem_spec.js +6 -3
  115. package/test/spec/modules/dailyhuntBidAdapter_spec.js +404 -0
  116. package/test/spec/modules/docereeBidAdapter_spec.js +9 -1
  117. package/test/spec/modules/eids_spec.js +15 -0
  118. package/test/spec/modules/feedadBidAdapter_spec.js +15 -0
  119. package/test/spec/modules/glimpseBidAdapter_spec.js +0 -18
  120. package/test/spec/modules/gnetBidAdapter_spec.js +6 -6
  121. package/test/spec/modules/gptPreAuction_spec.js +177 -2
  122. package/test/spec/modules/idImportLibrary_spec.js +197 -10
  123. package/test/spec/modules/improvedigitalBidAdapter_spec.js +45 -1
  124. package/test/spec/modules/invibesBidAdapter_spec.js +119 -0
  125. package/test/spec/modules/ixBidAdapter_spec.js +112 -62
  126. package/test/spec/modules/jwplayerRtdProvider_spec.js +195 -2
  127. package/test/spec/modules/kargoBidAdapter_spec.js +1 -1
  128. package/test/spec/modules/limelightDigitalBidAdapter_spec.js +75 -17
  129. package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +22 -0
  130. package/test/spec/modules/livewrappedBidAdapter_spec.js +31 -0
  131. package/test/spec/modules/loglyliftBidAdapter_spec.js +172 -0
  132. package/test/spec/modules/nextMillenniumBidAdapter_spec.js +9 -2
  133. package/test/spec/modules/oguryBidAdapter_spec.js +10 -2
  134. package/test/spec/modules/optimeraRtdProvider_spec.js +14 -1
  135. package/test/spec/modules/ozoneBidAdapter_spec.js +43 -31
  136. package/test/spec/modules/pilotxBidAdapter_spec.js +244 -0
  137. package/test/spec/modules/pubgeniusBidAdapter_spec.js +3 -3
  138. package/test/spec/modules/pubmaticAnalyticsAdapter_spec.js +13 -1
  139. package/test/spec/modules/pubxaiAnalyticsAdapter_spec.js +11 -0
  140. package/test/spec/modules/realTimeDataModule_spec.js +67 -5
  141. package/test/spec/modules/richaudienceBidAdapter_spec.js +40 -0
  142. package/test/spec/modules/riseBidAdapter_spec.js +1 -1
  143. package/test/spec/modules/rtbhouseBidAdapter_spec.js +20 -0
  144. package/test/spec/modules/rubiconAnalyticsAdapter_spec.js +30 -0
  145. package/test/spec/modules/rubiconBidAdapter_spec.js +48 -9
  146. package/test/spec/modules/sharethroughBidAdapter_spec.js +91 -6
  147. package/test/spec/modules/showheroes-bsBidAdapter_spec.js +2 -0
  148. package/test/spec/modules/synacormediaBidAdapter_spec.js +70 -0
  149. package/test/spec/modules/tappxBidAdapter_spec.js +0 -19
  150. package/test/spec/modules/teadsBidAdapter_spec.js +14 -59
  151. package/test/spec/modules/userId_spec.js +68 -19
  152. package/test/spec/modules/viewability_spec.js +280 -0
  153. package/test/spec/modules/welectBidAdapter_spec.js +211 -0
  154. package/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js +427 -0
  155. package/test/spec/unit/pbjs_api_spec.js +3 -1
  156. package/test/test_deps.js +3 -0
  157. package/test/test_index.js +1 -3
@@ -20,7 +20,9 @@ describe('GPT pre-auction module', () => {
20
20
  const testSlots = [
21
21
  makeSlot({ code: 'slotCode1', divId: 'div1' }),
22
22
  makeSlot({ code: 'slotCode2', divId: 'div2' }),
23
- makeSlot({ code: 'slotCode3', divId: 'div3' })
23
+ makeSlot({ code: 'slotCode3', divId: 'div3' }),
24
+ makeSlot({ code: 'slotCode4', divId: 'div4' }),
25
+ makeSlot({ code: 'slotCode4', divId: 'div5' })
24
26
  ];
25
27
 
26
28
  describe('appendPbAdSlot', () => {
@@ -172,7 +174,9 @@ describe('GPT pre-auction module', () => {
172
174
  expect(_currentConfig).to.deep.equal({
173
175
  enabled: true,
174
176
  customGptSlotMatching: false,
175
- customPbAdSlot: false
177
+ customPbAdSlot: false,
178
+ customPreAuction: false,
179
+ useDefaultPreAuction: false
176
180
  });
177
181
  });
178
182
  });
@@ -266,5 +270,176 @@ describe('GPT pre-auction module', () => {
266
270
  runMakeBidRequests(testAdUnits);
267
271
  expect(returnedAdUnits).to.deep.equal(expectedAdUnits);
268
272
  });
273
+
274
+ it('should use the passed customPreAuction logic', () => {
275
+ let counter = 0;
276
+ config.setConfig({
277
+ gptPreAuction: {
278
+ enabled: true,
279
+ customPreAuction: (adUnit, slotName) => {
280
+ counter += 1;
281
+ return `${adUnit.code}-${slotName || counter}`;
282
+ }
283
+ }
284
+ });
285
+ const testAdUnits = [
286
+ {
287
+ code: 'adUnit1',
288
+ ortb2Imp: { ext: { data: { pbadslot: '12345' } } }
289
+ },
290
+ {
291
+ code: 'adUnit2',
292
+ },
293
+ {
294
+ code: 'slotCode3',
295
+ },
296
+ {
297
+ code: 'div4',
298
+ }
299
+ ];
300
+
301
+ // all slots should be passed in same time and have slot-${index}
302
+ const expectedAdUnits = [{
303
+ code: 'adUnit1',
304
+ ortb2Imp: {
305
+ ext: {
306
+ // no slotname match so uses adUnit.code-counter
307
+ data: {
308
+ pbadslot: 'adUnit1-1'
309
+ },
310
+ gpid: 'adUnit1-1'
311
+ }
312
+ }
313
+ },
314
+ // second adunit
315
+ {
316
+ code: 'adUnit2',
317
+ ortb2Imp: {
318
+ ext: {
319
+ // no slotname match so uses adUnit.code-counter
320
+ data: {
321
+ pbadslot: 'adUnit2-2'
322
+ },
323
+ gpid: 'adUnit2-2'
324
+ }
325
+ }
326
+ }, {
327
+ code: 'slotCode3',
328
+ ortb2Imp: {
329
+ ext: {
330
+ // slotname found, so uses code + slotname (which is same)
331
+ data: {
332
+ pbadslot: 'slotCode3-slotCode3',
333
+ adserver: {
334
+ name: 'gam',
335
+ adslot: 'slotCode3'
336
+ }
337
+ },
338
+ gpid: 'slotCode3-slotCode3'
339
+ }
340
+ }
341
+ }, {
342
+ code: 'div4',
343
+ ortb2Imp: {
344
+ ext: {
345
+ // slotname found, so uses code + slotname
346
+ data: {
347
+ pbadslot: 'div4-slotCode4',
348
+ adserver: {
349
+ name: 'gam',
350
+ adslot: 'slotCode4'
351
+ }
352
+ },
353
+ gpid: 'div4-slotCode4'
354
+ }
355
+ }
356
+ }];
357
+
358
+ window.googletag.pubads().setSlots(testSlots);
359
+ runMakeBidRequests(testAdUnits);
360
+ expect(returnedAdUnits).to.deep.equal(expectedAdUnits);
361
+ });
362
+
363
+ it('should use useDefaultPreAuction logic', () => {
364
+ config.setConfig({
365
+ gptPreAuction: {
366
+ enabled: true,
367
+ useDefaultPreAuction: true
368
+ }
369
+ });
370
+ const testAdUnits = [
371
+ // First adUnit should use the preset pbadslot
372
+ {
373
+ code: 'adUnit1',
374
+ ortb2Imp: { ext: { data: { pbadslot: '12345' } } }
375
+ },
376
+ // Second adUnit should not match a gam slot, so no slot set
377
+ {
378
+ code: 'adUnit2',
379
+ },
380
+ // third adunit matches a single slot so uses it
381
+ {
382
+ code: 'slotCode3',
383
+ },
384
+ // fourth adunit matches multiple slots so combination
385
+ {
386
+ code: 'div4',
387
+ }
388
+ ];
389
+
390
+ const expectedAdUnits = [{
391
+ code: 'adUnit1',
392
+ ortb2Imp: {
393
+ ext: {
394
+ data: {
395
+ pbadslot: '12345'
396
+ },
397
+ gpid: '12345'
398
+ }
399
+ }
400
+ },
401
+ // second adunit
402
+ {
403
+ code: 'adUnit2',
404
+ ortb2Imp: {
405
+ ext: {
406
+ data: {
407
+ },
408
+ }
409
+ }
410
+ }, {
411
+ code: 'slotCode3',
412
+ ortb2Imp: {
413
+ ext: {
414
+ data: {
415
+ pbadslot: 'slotCode3',
416
+ adserver: {
417
+ name: 'gam',
418
+ adslot: 'slotCode3'
419
+ }
420
+ },
421
+ gpid: 'slotCode3'
422
+ }
423
+ }
424
+ }, {
425
+ code: 'div4',
426
+ ortb2Imp: {
427
+ ext: {
428
+ data: {
429
+ pbadslot: 'slotCode4#div4',
430
+ adserver: {
431
+ name: 'gam',
432
+ adslot: 'slotCode4'
433
+ }
434
+ },
435
+ gpid: 'slotCode4#div4'
436
+ }
437
+ }
438
+ }];
439
+
440
+ window.googletag.pubads().setSlots(testSlots);
441
+ runMakeBidRequests(testAdUnits);
442
+ expect(returnedAdUnits).to.deep.equal(expectedAdUnits);
443
+ });
269
444
  });
270
445
  });
@@ -3,15 +3,20 @@ import * as idImportlibrary from 'modules/idImportLibrary.js';
3
3
 
4
4
  var expect = require('chai').expect;
5
5
 
6
- describe('currency', function () {
7
- let fakeCurrencyFileServer;
6
+ const mockMutationObserver = {
7
+ observe: () => {
8
+ return null
9
+ }
10
+ }
11
+
12
+ describe('IdImportLibrary Tests', function () {
13
+ let fakeServer;
8
14
  let sandbox;
9
15
  let clock;
10
-
11
16
  let fn = sinon.spy();
12
17
 
13
18
  beforeEach(function () {
14
- fakeCurrencyFileServer = sinon.fakeServer.create();
19
+ fakeServer = sinon.fakeServer.create();
15
20
  sinon.stub(utils, 'logInfo');
16
21
  sinon.stub(utils, 'logError');
17
22
  });
@@ -19,7 +24,7 @@ describe('currency', function () {
19
24
  afterEach(function () {
20
25
  utils.logInfo.restore();
21
26
  utils.logError.restore();
22
- fakeCurrencyFileServer.restore();
27
+ fakeServer.restore();
23
28
  idImportlibrary.setConfig({});
24
29
  });
25
30
 
@@ -34,28 +39,210 @@ describe('currency', function () {
34
39
  clock.restore();
35
40
  });
36
41
 
37
- it('results when no config available', function () {
42
+ it('results when no config is set', function () {
43
+ idImportlibrary.setConfig();
44
+ sinon.assert.called(utils.logError);
45
+ });
46
+ it('results when config is empty', function () {
38
47
  idImportlibrary.setConfig({});
39
48
  sinon.assert.called(utils.logError);
40
49
  });
41
- it('results with config available', function () {
42
- idImportlibrary.setConfig({ 'url': 'URL' });
50
+ it('results with config available with url and debounce', function () {
51
+ idImportlibrary.setConfig({ 'url': 'URL', 'debounce': 0 });
43
52
  sinon.assert.called(utils.logInfo);
44
53
  });
54
+ it('results with config debounce ', function () {
55
+ let config = { 'url': 'URL', 'debounce': 300 }
56
+ idImportlibrary.setConfig(config);
57
+ expect(config.debounce).to.be.equal(300);
58
+ });
59
+
45
60
  it('results with config default debounce ', function () {
46
61
  let config = { 'url': 'URL' }
47
62
  idImportlibrary.setConfig(config);
48
63
  expect(config.debounce).to.be.equal(250);
49
64
  });
50
65
  it('results with config default fullscan ', function () {
51
- let config = { 'url': 'URL' }
66
+ let config = { 'url': 'URL', 'debounce': 0 }
52
67
  idImportlibrary.setConfig(config);
53
68
  expect(config.fullscan).to.be.equal(false);
54
69
  });
55
70
  it('results with config fullscan ', function () {
56
- let config = { 'url': 'URL', 'fullscan': true }
71
+ let config = { 'url': 'URL', 'fullscan': true, 'debounce': 0 }
72
+ idImportlibrary.setConfig(config);
73
+ expect(config.fullscan).to.be.equal(true);
74
+ expect(config.inputscan).to.be.equal(false);
75
+ });
76
+ it('results with config inputscan ', function () {
77
+ let config = { 'inputscan': true, 'debounce': 0 }
78
+ idImportlibrary.setConfig(config);
79
+ expect(config.inputscan).to.be.equal(true);
80
+ });
81
+ });
82
+ describe('Test with email is found', function () {
83
+ let mutationObserverStub;
84
+ let userId;
85
+ let refreshUserIdSpy;
86
+ beforeEach(function() {
87
+ let sandbox = sinon.createSandbox();
88
+ refreshUserIdSpy = sinon.spy(window.$$PREBID_GLOBAL$$, 'refreshUserIds');
89
+ clock = sinon.useFakeTimers(1046952000000); // 2003-03-06T12:00:00Z
90
+ mutationObserverStub = sinon.stub(window, 'MutationObserver').returns(mockMutationObserver);
91
+ userId = sandbox.stub(window.$$PREBID_GLOBAL$$, 'getUserIds').returns({id: {'MOCKID': '1111'}});
92
+ fakeServer.respondWith('POST', 'URL', [200,
93
+ {
94
+ 'Content-Type': 'application/json',
95
+ 'Access-Control-Allow-Origin': '*'
96
+ },
97
+ ''
98
+ ]);
99
+ });
100
+ afterEach(function () {
101
+ sandbox.restore();
102
+ clock.restore();
103
+ userId.restore();
104
+ refreshUserIdSpy.restore();
105
+ mutationObserverStub.restore();
106
+ document.body.innerHTML = '';
107
+ });
108
+
109
+ it('results with config fullscan with email found in html ', function () {
110
+ document.body.innerHTML = '<body><div>test@test.com</div></body>';
111
+ let config = { 'url': 'URL', 'fullscan': true, 'debounce': 0 }
112
+ idImportlibrary.setConfig(config);
113
+ expect(config.fullscan).to.be.equal(true);
114
+ expect(config.inputscan).to.be.equal(false);
115
+ expect(refreshUserIdSpy.calledOnce).to.equal(true);
116
+ });
117
+
118
+ it('results with config fullscan with no email found in html ', function () {
119
+ document.body.innerHTML = '<body><div>test</div></body>';
120
+ let config = { 'url': 'URL', 'fullscan': true, 'debounce': 0 }
121
+ idImportlibrary.setConfig(config);
122
+ expect(config.fullscan).to.be.equal(true);
123
+ expect(config.inputscan).to.be.equal(false);
124
+ expect(refreshUserIdSpy.calledOnce).to.equal(false);
125
+ });
126
+
127
+ it('results with config formElementId without listner ', function () {
128
+ let config = { url: 'testUrl', 'formElementId': 'userid', 'debounce': 0 }
129
+ document.body.innerHTML = '<body><input type="text" id="userid" value="test@test.com"></body>';
130
+ idImportlibrary.setConfig(config);
131
+ expect(config.formElementId).to.be.equal('userid');
132
+ expect(refreshUserIdSpy.calledOnce).to.equal(true);
133
+ });
134
+
135
+ it('results with config formElementId with listner ', function () {
136
+ let config = { url: 'testUrl', 'formElementId': 'userid', 'debounce': 0 }
137
+ document.body.innerHTML = '<body><input type="text" id="userid" value=""></body>';
138
+ idImportlibrary.setConfig(config);
139
+ expect(config.formElementId).to.be.equal('userid');
140
+ expect(refreshUserIdSpy.calledOnce).to.equal(false);
141
+ });
142
+
143
+ it('results with config target without listner ', function () {
144
+ let config = { url: 'testUrl', 'target': 'userid', 'debounce': 0 }
145
+ document.body.innerHTML = '<body><div id="userid">test@test.com<div></div></body>';
146
+ idImportlibrary.setConfig(config);
147
+ expect(config.target).to.be.equal('userid');
148
+ expect(refreshUserIdSpy.calledOnce).to.equal(true);
149
+ });
150
+ it('results with config target with listner ', function () {
151
+ let config = { url: 'testUrl', 'target': 'userid', 'debounce': 0 }
152
+ document.body.innerHTML = '<body><div id="userid"><div></div></body>';
153
+ idImportlibrary.setConfig(config);
154
+
155
+ expect(config.target).to.be.equal('userid');
156
+ expect(refreshUserIdSpy.calledOnce).to.equal(false);
157
+ });
158
+
159
+ it('results with config target with listner', function () {
160
+ let config = { url: 'testUrl', 'target': 'userid', 'debounce': 0 }
161
+ idImportlibrary.setConfig(config);
162
+ document.body.innerHTML = '<body><div id="userid">test@test.com<div></div></body>';
163
+ expect(config.target).to.be.equal('userid');
164
+ expect(refreshUserIdSpy.calledOnce).to.equal(false);
165
+ });
166
+ it('results with config fullscan ', function () {
167
+ let config = { url: 'testUrl', 'fullscan': true, 'debounce': 0 }
57
168
  idImportlibrary.setConfig(config);
169
+ document.body.innerHTML = '<body><div id="userid"><div></div></body>';
58
170
  expect(config.fullscan).to.be.equal(true);
171
+ expect(refreshUserIdSpy.calledOnce).to.equal(false);
172
+ });
173
+ it('results with config inputscan with listner', function () {
174
+ let config = { url: 'testUrl', 'inputscan': true, 'debounce': 0 }
175
+ var input = document.createElement('input');
176
+ input.setAttribute('type', 'text');
177
+ document.body.appendChild(input);
178
+ idImportlibrary.setConfig(config);
179
+ expect(config.inputscan).to.be.equal(true);
180
+ input.setAttribute('value', 'text@text.com');
181
+ const inputEvent = new InputEvent('blur');
182
+ input.dispatchEvent(inputEvent);
183
+ expect(refreshUserIdSpy.calledOnce).to.equal(true);
184
+ });
185
+
186
+ it('results with config inputscan with listner and no user ids ', function () {
187
+ let config = { 'url': 'testUrl', 'inputscan': true, 'debounce': 0 }
188
+ document.body.innerHTML = '<body><input id="userid" value=""></body>';
189
+ idImportlibrary.setConfig(config);
190
+ expect(config.inputscan).to.be.equal(true);
191
+ expect(refreshUserIdSpy.calledOnce).to.equal(false);
192
+ });
193
+
194
+ it('results with config inputscan with listner ', function () {
195
+ let config = { 'url': 'testUrl', 'inputscan': true, 'debounce': 0 }
196
+ document.body.innerHTML = '<body><input id="userid" type=text value=""></body>';
197
+ idImportlibrary.setConfig(config);
198
+ expect(config.inputscan).to.be.equal(true);
199
+ expect(refreshUserIdSpy.calledOnce).to.equal(false);
200
+ });
201
+
202
+ it('results with config inputscan without listner ', function () {
203
+ let config = { 'url': 'testUrl', 'inputscan': true, 'debounce': 0 }
204
+ document.body.innerHTML = '<body><input id="userid" value="test@test.com"></body>';
205
+ idImportlibrary.setConfig(config);
206
+ expect(config.inputscan).to.be.equal(true);
207
+ expect(refreshUserIdSpy.calledOnce).to.equal(true);
208
+ });
209
+ });
210
+ describe('Tests with no user ids', function () {
211
+ let mutationObserverStub;
212
+ let userId;
213
+ let jsonSpy;
214
+ beforeEach(function() {
215
+ let sandbox = sinon.createSandbox();
216
+ clock = sinon.useFakeTimers(1046952000000); // 2003-03-06T12:00:00Z
217
+ mutationObserverStub = sinon.stub(window, 'MutationObserver');
218
+ jsonSpy = sinon.spy(JSON, 'stringify');
219
+ fakeServer.respondWith('POST', 'URL', [200,
220
+ {
221
+ 'Content-Type': 'application/json',
222
+ 'Access-Control-Allow-Origin': '*'
223
+ },
224
+ ''
225
+ ]);
226
+ });
227
+ afterEach(function () {
228
+ sandbox.restore();
229
+ clock.restore();
230
+ jsonSpy.restore();
231
+ mutationObserverStub.restore();
232
+ });
233
+ it('results with config inputscan without listner with no user ids ', function () {
234
+ let config = { 'url': 'testUrl', 'inputscan': true, 'debounce': 0 }
235
+ document.body.innerHTML = '<body><input id="userid" value="test@test.com"></body>';
236
+ idImportlibrary.setConfig(config);
237
+ expect(config.inputscan).to.be.equal(true);
238
+ expect(jsonSpy.calledOnce).to.equal(false);
239
+ });
240
+ it('results with config inputscan without listner with no user ids ', function () {
241
+ let config = { 'url': 'testUrl', 'inputscan': true, 'debounce': 0 }
242
+ document.body.innerHTML = '<body><input id="userid"></body>';
243
+ idImportlibrary.setConfig(config);
244
+ expect(config.inputscan).to.be.equal(true);
245
+ expect(jsonSpy.calledOnce).to.equal(false);
59
246
  });
60
247
  });
61
248
  });
@@ -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 () {
@@ -513,6 +515,48 @@ describe('Improve Digital Adapter Tests', function () {
513
515
  });
514
516
  getConfigStub.restore();
515
517
  });
518
+
519
+ it('should set pagecat and genre ➞ fpd:ortb2.site', function() {
520
+ config.setConfig(JSON.parse('{"ortb2":{"site":{"cat":["IAB2"],"pagecat":["IAB2-2"],"content":{"genre":"Adventure"}}}}'));
521
+ const bidRequest = Object.assign({}, simpleBidRequest);
522
+ const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0];
523
+ const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
524
+ expect(params.bid_request.pagecat).to.be.an('array');
525
+ expect(params.bid_request.pagecat).to.deep.equal(['IAB2-2']);
526
+ expect(params.bid_request.genre).to.be.a('string');
527
+ expect(params.bid_request.genre).be.equal('Adventure');
528
+ });
529
+
530
+ it('should not set pagecat and genre when malformed data provided ➞ fpd:ortb2.site', function() {
531
+ config.setConfig(JSON.parse('{"ortb2":{"site":{"pagecat":"IAB2-2","content":{"genre":["Adventure"]}}}}'));
532
+ const bidRequest = Object.assign({}, simpleBidRequest);
533
+ const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0];
534
+ const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
535
+ expect(params.bid_request.pagecat).does.not.exist;
536
+ expect(params.bid_request.genre).does.not.exist;
537
+ });
538
+
539
+ it('should use cat when pagecat not available ➞ fpd:ortb2.site', function() {
540
+ config.setConfig(JSON.parse('{"ortb2":{"site":{"cat":["IAB2"]}}}'));
541
+ const bidRequest = Object.assign({}, simpleBidRequest);
542
+ const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0];
543
+ const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
544
+ expect(params.bid_request.pagecat).to.be.an('array');
545
+ expect(params.bid_request.pagecat).to.deep.equal(['IAB2']);
546
+ });
547
+
548
+ it('should format pagecat correctly ➞ fpd:ortb2.site', function() {
549
+ config.setConfig(JSON.parse('{"ortb2":{"site":{"cat":["IAB2", ["IAB-1"], "IAB3", 123, ""]}}}'));
550
+ const bidRequest = Object.assign({}, simpleBidRequest);
551
+ const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0];
552
+ const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
553
+ expect(params.bid_request.pagecat).to.be.an('array');
554
+ expect(params.bid_request.pagecat).to.deep.equal([
555
+ 'IAB2',
556
+ 'IAB3'
557
+ ]
558
+ );
559
+ });
516
560
  });
517
561
 
518
562
  const serverResponse = {
@@ -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);