prebid.js 6.5.0 → 6.9.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 (139) hide show
  1. package/.eslintrc.js +8 -1
  2. package/integrationExamples/gpt/amp/creative.html +11 -33
  3. package/integrationExamples/gpt/weboramaRtdProvider_example.html +154 -115
  4. package/integrationExamples/gpt/x-domain/creative.html +63 -29
  5. package/modules/.submodules.json +2 -1
  6. package/modules/adagioBidAdapter.js +0 -8
  7. package/modules/adagioBidAdapter.md +1 -1
  8. package/modules/adbookpspBidAdapter.js +27 -10
  9. package/modules/adhashBidAdapter.js +3 -3
  10. package/modules/adkernelBidAdapter.js +2 -1
  11. package/modules/admanBidAdapter.js +10 -4
  12. package/modules/adomikAnalyticsAdapter.js +23 -11
  13. package/modules/adqueryIdSystem.js +103 -0
  14. package/modules/adqueryIdSystem.md +35 -0
  15. package/modules/appnexusBidAdapter.js +14 -2
  16. package/modules/asealBidAdapter.js +58 -0
  17. package/modules/asealBidAdapter.md +52 -0
  18. package/modules/bliinkBidAdapter.js +2 -1
  19. package/modules/brandmetricsRtdProvider.js +168 -0
  20. package/modules/brandmetricsRtdProvider.md +40 -0
  21. package/modules/colossussspBidAdapter.js +12 -8
  22. package/modules/colossussspBidAdapter.md +15 -1
  23. package/modules/compassBidAdapter.js +10 -3
  24. package/modules/consumableBidAdapter.md +1 -1
  25. package/modules/conversantBidAdapter.js +7 -0
  26. package/modules/criteoBidAdapter.js +10 -1
  27. package/modules/criteoIdSystem.js +29 -7
  28. package/modules/currency.js +26 -1
  29. package/modules/displayioBidAdapter.js +157 -0
  30. package/modules/displayioBidAdapter.md +148 -0
  31. package/modules/e_volutionBidAdapter.js +158 -0
  32. package/modules/glimpseBidAdapter.js +66 -44
  33. package/modules/gnetBidAdapter.js +3 -3
  34. package/modules/gnetBidAdapter.md +4 -4
  35. package/modules/gumgumBidAdapter.js +56 -42
  36. package/modules/idImportLibrary.js +45 -8
  37. package/modules/idImportLibrary.md +4 -0
  38. package/modules/improvedigitalBidAdapter.js +29 -2
  39. package/modules/interactiveOffersBidAdapter.js +9 -6
  40. package/modules/jwplayerRtdProvider.js +71 -6
  41. package/modules/jwplayerRtdProvider.md +27 -11
  42. package/modules/kargoBidAdapter.js +2 -2
  43. package/modules/lunamediahbBidAdapter.js +32 -4
  44. package/modules/nextMillenniumBidAdapter.js +3 -1
  45. package/modules/oguryBidAdapter.js +14 -14
  46. package/modules/onetagBidAdapter.js +4 -2
  47. package/modules/pilotxBidAdapter.js +147 -0
  48. package/modules/pilotxBidAdapter.md +50 -0
  49. package/modules/priceFloors.js +2 -1
  50. package/modules/proxistoreBidAdapter.js +0 -2
  51. package/modules/pubmaticAnalyticsAdapter.js +16 -0
  52. package/modules/richaudienceBidAdapter.js +10 -4
  53. package/modules/riseBidAdapter.js +18 -7
  54. package/modules/rtbhouseBidAdapter.js +14 -4
  55. package/modules/rtdModule/index.js +14 -15
  56. package/modules/rubiconAnalyticsAdapter.js +8 -2
  57. package/modules/seedingAllianceBidAdapter.js +3 -3
  58. package/modules/sharethroughBidAdapter.js +12 -17
  59. package/modules/showheroes-bsBidAdapter.js +13 -2
  60. package/modules/sortableAnalyticsAdapter.js +5 -4
  61. package/modules/sovrnBidAdapter.js +93 -18
  62. package/modules/sovrnBidAdapter.md +80 -2
  63. package/modules/synacormediaBidAdapter.js +31 -10
  64. package/modules/tappxBidAdapter.js +8 -5
  65. package/modules/teadsBidAdapter.js +1 -2
  66. package/modules/undertoneBidAdapter.js +17 -1
  67. package/modules/userId/eids.js +7 -1
  68. package/modules/userId/userId.md +8 -0
  69. package/modules/viewability.js +177 -0
  70. package/modules/viewability.md +87 -0
  71. package/modules/weboramaRtdProvider.js +264 -34
  72. package/modules/weboramaRtdProvider.md +110 -40
  73. package/modules/welectBidAdapter.js +106 -0
  74. package/modules/yahoosspBidAdapter.js +2 -0
  75. package/package.json +2 -1
  76. package/src/adRendering.js +38 -0
  77. package/src/adloader.js +2 -1
  78. package/src/auction.js +103 -73
  79. package/src/bidderSettings.js +69 -0
  80. package/src/hook.js +5 -1
  81. package/src/prebid.js +19 -21
  82. package/src/secureCreatives.js +131 -47
  83. package/src/targeting.js +3 -2
  84. package/src/utils.js +13 -10
  85. package/test/helpers/syncPromise.js +71 -0
  86. package/test/spec/auctionmanager_spec.js +179 -15
  87. package/test/spec/modules/adagioBidAdapter_spec.js +0 -10
  88. package/test/spec/modules/adbookpspBidAdapter_spec.js +17 -3
  89. package/test/spec/modules/adhashBidAdapter_spec.js +2 -2
  90. package/test/spec/modules/admanBidAdapter_spec.js +2 -2
  91. package/test/spec/modules/adomikAnalyticsAdapter_spec.js +3 -1
  92. package/test/spec/modules/adqueryIdSystem_spec.js +74 -0
  93. package/test/spec/modules/appnexusBidAdapter_spec.js +27 -0
  94. package/test/spec/modules/asealBidAdapter_spec.js +144 -0
  95. package/test/spec/modules/bliinkBidAdapter_spec.js +2 -0
  96. package/test/spec/modules/brandmetricsRtdProvider_spec.js +191 -0
  97. package/test/spec/modules/colossussspBidAdapter_spec.js +5 -2
  98. package/test/spec/modules/compassBidAdapter_spec.js +1 -0
  99. package/test/spec/modules/conversantBidAdapter_spec.js +54 -2
  100. package/test/spec/modules/criteoBidAdapter_spec.js +21 -0
  101. package/test/spec/modules/criteoIdSystem_spec.js +6 -3
  102. package/test/spec/modules/currency_spec.js +21 -6
  103. package/test/spec/modules/displayioBidAdapter_spec.js +239 -0
  104. package/test/spec/modules/e_volutionBidAdapter_spec.js +242 -0
  105. package/test/spec/modules/eids_spec.js +15 -0
  106. package/test/spec/modules/glimpseBidAdapter_spec.js +0 -18
  107. package/test/spec/modules/gnetBidAdapter_spec.js +6 -6
  108. package/test/spec/modules/gumgumBidAdapter_spec.js +46 -0
  109. package/test/spec/modules/idImportLibrary_spec.js +197 -10
  110. package/test/spec/modules/improvedigitalBidAdapter_spec.js +61 -0
  111. package/test/spec/modules/jwplayerRtdProvider_spec.js +195 -2
  112. package/test/spec/modules/kargoBidAdapter_spec.js +1 -1
  113. package/test/spec/modules/loglyliftBidAdapter_spec.js +1 -1
  114. package/test/spec/modules/lunamediahbBidAdapter_spec.js +27 -1
  115. package/test/spec/modules/nextMillenniumBidAdapter_spec.js +1 -1
  116. package/test/spec/modules/oguryBidAdapter_spec.js +69 -3
  117. package/test/spec/modules/pilotxBidAdapter_spec.js +244 -0
  118. package/test/spec/modules/pubmaticAnalyticsAdapter_spec.js +13 -1
  119. package/test/spec/modules/realTimeDataModule_spec.js +67 -5
  120. package/test/spec/modules/richaudienceBidAdapter_spec.js +40 -0
  121. package/test/spec/modules/riseBidAdapter_spec.js +31 -5
  122. package/test/spec/modules/rtbhouseBidAdapter_spec.js +20 -0
  123. package/test/spec/modules/rubiconAnalyticsAdapter_spec.js +61 -1
  124. package/test/spec/modules/sharethroughBidAdapter_spec.js +91 -6
  125. package/test/spec/modules/showheroes-bsBidAdapter_spec.js +2 -0
  126. package/test/spec/modules/sortableAnalyticsAdapter_spec.js +2 -3
  127. package/test/spec/modules/sovrnBidAdapter_spec.js +413 -333
  128. package/test/spec/modules/synacormediaBidAdapter_spec.js +70 -0
  129. package/test/spec/modules/tappxBidAdapter_spec.js +0 -19
  130. package/test/spec/modules/teadsBidAdapter_spec.js +14 -59
  131. package/test/spec/modules/undertoneBidAdapter_spec.js +55 -2
  132. package/test/spec/modules/userId_spec.js +68 -19
  133. package/test/spec/modules/viewability_spec.js +280 -0
  134. package/test/spec/modules/weboramaRtdProvider_spec.js +536 -20
  135. package/test/spec/modules/welectBidAdapter_spec.js +211 -0
  136. package/test/spec/modules/yahoosspBidAdapter_spec.js +10 -0
  137. package/test/spec/unit/core/bidderSettings_spec.js +123 -0
  138. package/test/spec/unit/pbjs_api_spec.js +21 -8
  139. package/test/spec/unit/secureCreatives_spec.js +143 -24
@@ -348,6 +348,21 @@ describe('eids array generation for known sub-modules', function() {
348
348
  }]
349
349
  });
350
350
  });
351
+
352
+ it('qid', function() {
353
+ const userId = {
354
+ qid: 'some-random-id-value'
355
+ };
356
+ const newEids = createEidsArray(userId);
357
+ expect(newEids.length).to.equal(1);
358
+ expect(newEids[0]).to.deep.equal({
359
+ source: 'adquery.io',
360
+ uids: [{
361
+ id: 'some-random-id-value',
362
+ atype: 1
363
+ }]
364
+ });
365
+ });
351
366
  });
352
367
  describe('Negative case', function() {
353
368
  it('eids array generation for UN-known sub-module', function() {
@@ -178,24 +178,6 @@ describe('GlimpseProtocolAdapter', () => {
178
178
  const bidRequests = [getBidRequest()]
179
179
  const bidderRequest = getBidderRequest()
180
180
 
181
- it('Adds a demo flag', () => {
182
- const request = spec.buildRequests(bidRequests, bidderRequest)
183
- const payload = JSON.parse(request.data)
184
- expect(payload.data.demo).to.be.false
185
- })
186
-
187
- it('Adds an account id', () => {
188
- const request = spec.buildRequests(bidRequests, bidderRequest)
189
- const payload = JSON.parse(request.data)
190
- expect(payload.data.account).to.equal(-1)
191
- })
192
-
193
- it('Adds a demand provider', () => {
194
- const request = spec.buildRequests(bidRequests, bidderRequest)
195
- const payload = JSON.parse(request.data)
196
- expect(payload.data.demand).to.equal('glimpse')
197
- })
198
-
199
181
  it('Adds GDPR consent', () => {
200
182
  const request = spec.buildRequests(bidRequests, bidderRequest)
201
183
  const payload = JSON.parse(request.data)
@@ -8,7 +8,7 @@ import {
8
8
  newBidder
9
9
  } from 'src/adapters/bidderFactory.js';
10
10
 
11
- const ENDPOINT = 'https://adserver.gnetproject.com/prebid.php';
11
+ const ENDPOINT = 'https://service.gnetrtb.com/api/adrequest';
12
12
 
13
13
  describe('gnetAdapter', function () {
14
14
  const adapter = newBidder(spec);
@@ -23,7 +23,7 @@ describe('gnetAdapter', function () {
23
23
  let bid = {
24
24
  bidder: 'gnet',
25
25
  params: {
26
- websiteId: '4'
26
+ websiteId: '1', adunitId: '1'
27
27
  }
28
28
  };
29
29
 
@@ -43,7 +43,7 @@ describe('gnetAdapter', function () {
43
43
  const bidRequests = [{
44
44
  bidder: 'gnet',
45
45
  params: {
46
- websiteId: '4'
46
+ websiteId: '1', adunitId: '1'
47
47
  },
48
48
  adUnitCode: '/150790500/4_ZONA_IAB_300x250_5',
49
49
  sizes: [
@@ -57,7 +57,7 @@ describe('gnetAdapter', function () {
57
57
 
58
58
  const bidderRequest = {
59
59
  refererInfo: {
60
- referer: 'https://gnetproject.com/'
60
+ referer: 'https://gnetrtb.com'
61
61
  }
62
62
  };
63
63
 
@@ -66,13 +66,13 @@ describe('gnetAdapter', function () {
66
66
  expect(requests[0].url).to.equal(ENDPOINT);
67
67
  expect(requests[0].method).to.equal('POST');
68
68
  expect(requests[0].data).to.equal(JSON.stringify({
69
- 'referer': 'https://gnetproject.com/',
69
+ 'referer': 'https://gnetrtb.com',
70
70
  'adUnitCode': '/150790500/4_ZONA_IAB_300x250_5',
71
71
  'bidId': '2a19afd5173318',
72
72
  'transactionId': '894bdff6-61ec-4bec-a5a9-f36a5bfccef5',
73
73
  'sizes': ['300x250'],
74
74
  'params': {
75
- 'websiteId': '4'
75
+ 'websiteId': '1', 'adunitId': '1'
76
76
  }
77
77
  }));
78
78
  });
@@ -544,6 +544,52 @@ describe('gumgumAdapter', function () {
544
544
  const bidRequest = spec.buildRequests(bidRequests)[0];
545
545
  expect(!!bidRequest.data.lt).to.be.true;
546
546
  });
547
+
548
+ it('should handle no gg params', function () {
549
+ const bidRequest = spec.buildRequests(bidRequests, { refererInfo: { referer: 'https://www.prebid.org/?param1=foo&param2=bar&param3=baz' } })[0];
550
+
551
+ // no params are in object
552
+ expect(bidRequest.data.hasOwnProperty('eAdBuyId')).to.be.false;
553
+ expect(bidRequest.data.hasOwnProperty('adBuyId')).to.be.false;
554
+ expect(bidRequest.data.hasOwnProperty('ggdeal')).to.be.false;
555
+ });
556
+
557
+ it('should handle encrypted ad buy id', function () {
558
+ const bidRequest = spec.buildRequests(bidRequests, { refererInfo: { referer: 'https://www.prebid.org/?param1=foo&ggad=bar&param3=baz' } })[0];
559
+
560
+ // correct params are in object
561
+ expect(bidRequest.data.hasOwnProperty('eAdBuyId')).to.be.true;
562
+ expect(bidRequest.data.hasOwnProperty('adBuyId')).to.be.false;
563
+ expect(bidRequest.data.hasOwnProperty('ggdeal')).to.be.false;
564
+
565
+ // params are stripped from pu property
566
+ expect(bidRequest.data.pu.includes('ggad')).to.be.false;
567
+ });
568
+
569
+ it('should handle unencrypted ad buy id', function () {
570
+ const bidRequest = spec.buildRequests(bidRequests, { refererInfo: { referer: 'https://www.prebid.org/?param1=foo&ggad=123&param3=baz' } })[0];
571
+
572
+ // correct params are in object
573
+ expect(bidRequest.data.hasOwnProperty('eAdBuyId')).to.be.false;
574
+ expect(bidRequest.data.hasOwnProperty('adBuyId')).to.be.true;
575
+ expect(bidRequest.data.hasOwnProperty('ggdeal')).to.be.false;
576
+
577
+ // params are stripped from pu property
578
+ expect(bidRequest.data.pu.includes('ggad')).to.be.false;
579
+ });
580
+
581
+ it('should handle multiple gg params', function () {
582
+ const bidRequest = spec.buildRequests(bidRequests, { refererInfo: { referer: 'https://www.prebid.org/?ggdeal=foo&ggad=bar&param3=baz' } })[0];
583
+
584
+ // correct params are in object
585
+ expect(bidRequest.data.hasOwnProperty('eAdBuyId')).to.be.true;
586
+ expect(bidRequest.data.hasOwnProperty('adBuyId')).to.be.false;
587
+ expect(bidRequest.data.hasOwnProperty('ggdeal')).to.be.true;
588
+
589
+ // params are stripped from pu property
590
+ expect(bidRequest.data.pu.includes('ggad')).to.be.false;
591
+ expect(bidRequest.data.pu.includes('ggdeal')).to.be.false;
592
+ });
547
593
  })
548
594
 
549
595
  describe('interpretResponse', function () {
@@ -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
  });
@@ -515,6 +515,67 @@ describe('Improve Digital Adapter Tests', function () {
515
515
  });
516
516
  getConfigStub.restore();
517
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
+ });
560
+
561
+ it('should set coppa', function() {
562
+ sinon.stub(config, 'getConfig')
563
+ .withArgs('coppa')
564
+ .returns(true);
565
+ const bidRequest = Object.assign({}, simpleBidRequest);
566
+ const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0];
567
+ const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
568
+ expect(params.bid_request.coppa).to.equal(1);
569
+
570
+ config.getConfig.restore();
571
+ });
572
+
573
+ it('should undefined coppa', function() {
574
+ const bidRequest = Object.assign({}, simpleBidRequest);
575
+ const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0];
576
+ const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length)));
577
+ expect(params.bid_request.coppa).to.equal(undefined);
578
+ });
518
579
  });
519
580
 
520
581
  const serverResponse = {