prebid.js 7.22.0 → 7.23.1

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 (273) hide show
  1. package/dist/33acrossBidAdapter.js +1 -1
  2. package/dist/aaxBlockmeterRtdProvider.js +1 -0
  3. package/dist/adagioBidAdapter.js +1 -1
  4. package/dist/adbookpspBidAdapter.js +1 -1
  5. package/dist/adgenerationBidAdapter.js +1 -1
  6. package/dist/adrelevantisBidAdapter.js +1 -1
  7. package/dist/adtrgtmeBidAdapter.js +1 -1
  8. package/dist/adxcgBidAdapter.js +1 -1
  9. package/dist/ajaBidAdapter.js +1 -1
  10. package/dist/amxBidAdapter.js +1 -1
  11. package/dist/amxIdSystem.js +1 -1
  12. package/dist/analyticsAdapter.js +1 -1
  13. package/dist/appierAnalyticsAdapter.js +1 -1
  14. package/dist/appnexusBidAdapter.js +1 -1
  15. package/dist/asoBidAdapter.js +1 -1
  16. package/dist/axonixBidAdapter.js +1 -1
  17. package/dist/bidViewability.js +1 -1
  18. package/dist/bidViewabilityIO.js +1 -1
  19. package/dist/bidglassBidAdapter.js +1 -1
  20. package/dist/big-richmediaBidAdapter.js +1 -1
  21. package/dist/bridgewellBidAdapter.js +1 -1
  22. package/dist/brightMountainMediaBidAdapter.js +1 -1
  23. package/dist/browsiRtdProvider.js +1 -1
  24. package/dist/carodaBidAdapter.js +1 -1
  25. package/dist/chtnwBidAdapter.js +1 -0
  26. package/dist/cleanioRtdProvider.js +1 -1
  27. package/dist/concertBidAdapter.js +1 -1
  28. package/dist/connectadBidAdapter.js +1 -1
  29. package/dist/consentManagement.js +1 -1
  30. package/dist/consentManagementUsp.js +1 -1
  31. package/dist/consumableBidAdapter.js +1 -1
  32. package/dist/conversantBidAdapter.js +1 -1
  33. package/dist/craftBidAdapter.js +1 -1
  34. package/dist/criteoBidAdapter.js +1 -1
  35. package/dist/currency.js +1 -1
  36. package/dist/dependencies.json +19 -0
  37. package/dist/dfpAdServerVideo.js +1 -1
  38. package/dist/dgkeywordRtdProvider.js +1 -1
  39. package/dist/dspxBidAdapter.js +1 -1
  40. package/dist/eplanningBidAdapter.js +1 -1
  41. package/dist/finativeBidAdapter.js +1 -1
  42. package/dist/gdprEnforcement.js +1 -1
  43. package/dist/glimpseBidAdapter.js +1 -1
  44. package/dist/gmosspBidAdapter.js +1 -1
  45. package/dist/goldbachBidAdapter.js +1 -1
  46. package/dist/googleAnalyticsAdapter.js +1 -1
  47. package/dist/gridBidAdapter.js +1 -1
  48. package/dist/gridNMBidAdapter.js +1 -1
  49. package/dist/gumgumBidAdapter.js +1 -1
  50. package/dist/h12mediaBidAdapter.js +1 -1
  51. package/dist/id5AnalyticsAdapter.js +1 -1
  52. package/dist/id5IdSystem.js +1 -1
  53. package/dist/improvedigitalBidAdapter.js +1 -1
  54. package/dist/inmarBidAdapter.js +1 -1
  55. package/dist/insticatorBidAdapter.js +1 -1
  56. package/dist/instreamTracking.js +1 -1
  57. package/dist/ixBidAdapter.js +1 -1
  58. package/dist/justpremiumBidAdapter.js +1 -1
  59. package/dist/jwplayerVideoProvider.js +1 -0
  60. package/dist/kargoBidAdapter.js +1 -1
  61. package/dist/konduitAnalyticsAdapter.js +1 -1
  62. package/dist/kueezBidAdapter.js +1 -1
  63. package/dist/lassoBidAdapter.js +1 -1
  64. package/dist/lifestreetBidAdapter.js +1 -1
  65. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  66. package/dist/logicadBidAdapter.js +1 -1
  67. package/dist/loglyliftBidAdapter.js +1 -1
  68. package/dist/magniteAnalyticsAdapter.js +1 -1
  69. package/dist/malltvAnalyticsAdapter.js +1 -1
  70. package/dist/marsmediaBidAdapter.js +1 -1
  71. package/dist/mediafuseBidAdapter.js +1 -1
  72. package/dist/mediasquareBidAdapter.js +1 -1
  73. package/dist/mgidBidAdapter.js +1 -1
  74. package/dist/minutemediaBidAdapter.js +1 -1
  75. package/dist/multibid.js +1 -1
  76. package/dist/not-for-prod/prebid.js +141 -132
  77. package/dist/oguryBidAdapter.js +1 -1
  78. package/dist/onetagBidAdapter.js +1 -1
  79. package/dist/ooloAnalyticsAdapter.js +1 -1
  80. package/dist/openxOrtbBidAdapter.js +1 -1
  81. package/dist/ortbConverter.js +1 -0
  82. package/dist/outbrainBidAdapter.js +1 -1
  83. package/dist/oxxionRtdProvider.js +1 -0
  84. package/dist/parrableIdSystem.js +1 -1
  85. package/dist/pbsExtensions.js +1 -0
  86. package/dist/pixfutureBidAdapter.js +1 -1
  87. package/dist/prebid-core.js +1 -1
  88. package/dist/prebidServerBidAdapter.js +1 -1
  89. package/dist/priceFloors.js +1 -1
  90. package/dist/pubCommonId.js +1 -1
  91. package/dist/publinkIdSystem.js +1 -1
  92. package/dist/pubmaticBidAdapter.js +1 -1
  93. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  94. package/dist/pxyzBidAdapter.js +1 -1
  95. package/dist/quantcastBidAdapter.js +1 -1
  96. package/dist/readpeakBidAdapter.js +1 -1
  97. package/dist/relaidoBidAdapter.js +1 -1
  98. package/dist/rhythmoneBidAdapter.js +1 -1
  99. package/dist/riseBidAdapter.js +1 -1
  100. package/dist/rtdModule.js +1 -1
  101. package/dist/rubiconAnalyticsAdapter.js +1 -1
  102. package/dist/rubiconBidAdapter.js +1 -1
  103. package/dist/schain.js +1 -1
  104. package/dist/seedingAllianceBidAdapter.js +1 -1
  105. package/dist/seedtagBidAdapter.js +1 -1
  106. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  107. package/dist/sharethroughBidAdapter.js +1 -1
  108. package/dist/shinezBidAdapter.js +1 -1
  109. package/dist/smaatoBidAdapter.js +1 -1
  110. package/dist/smartadserverBidAdapter.js +1 -1
  111. package/dist/smartxBidAdapter.js +1 -1
  112. package/dist/smilewantedBidAdapter.js +1 -1
  113. package/dist/sonobiBidAdapter.js +1 -1
  114. package/dist/sovrnAnalyticsAdapter.js +1 -1
  115. package/dist/sovrnBidAdapter.js +1 -1
  116. package/dist/spotxBidAdapter.js +1 -1
  117. package/dist/sspBCBidAdapter.js +1 -1
  118. package/dist/sublimeBidAdapter.js +1 -1
  119. package/dist/synacormediaBidAdapter.js +1 -1
  120. package/dist/targetVideoBidAdapter.js +1 -1
  121. package/dist/teadsBidAdapter.js +1 -1
  122. package/dist/teadsIdSystem.js +1 -1
  123. package/dist/trionBidAdapter.js +1 -1
  124. package/dist/tripleliftBidAdapter.js +1 -1
  125. package/dist/ttdBidAdapter.js +1 -1
  126. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  127. package/dist/underdogmediaBidAdapter.js +1 -1
  128. package/dist/undertoneBidAdapter.js +1 -1
  129. package/dist/userId.js +1 -1
  130. package/dist/vidazooBidAdapter.js +1 -1
  131. package/dist/video.js +1 -0
  132. package/dist/videoModule.js +1 -0
  133. package/dist/videobyteBidAdapter.js +1 -1
  134. package/dist/videojsVideoProvider.js +1 -0
  135. package/dist/visxBidAdapter.js +1 -1
  136. package/dist/vuukleBidAdapter.js +1 -1
  137. package/dist/widespaceBidAdapter.js +1 -1
  138. package/dist/winrBidAdapter.js +1 -1
  139. package/dist/yahoosspBidAdapter.js +1 -1
  140. package/dist/yieldmoBidAdapter.js +1 -1
  141. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  142. package/integrationExamples/videoModule/jwplayer/bidMarkedAsUsed.html +98 -0
  143. package/integrationExamples/videoModule/jwplayer/bidRequestScheduling.html +89 -0
  144. package/integrationExamples/videoModule/jwplayer/eventListeners.html +244 -0
  145. package/integrationExamples/videoModule/jwplayer/gamAdServerMediation.html +122 -0
  146. package/integrationExamples/videoModule/jwplayer/mediaMetadata.html +80 -0
  147. package/integrationExamples/videoModule/jwplayer/playlist.html +122 -0
  148. package/integrationExamples/videoModule/videojs/bidMarkedAsUsed.html +126 -0
  149. package/integrationExamples/videoModule/videojs/bidRequestScheduling.html +132 -0
  150. package/integrationExamples/videoModule/videojs/eventListeners.html +238 -0
  151. package/integrationExamples/videoModule/videojs/gamAdServerMediation.html +138 -0
  152. package/integrationExamples/videoModule/videojs/mediaMetadata.html +103 -0
  153. package/integrationExamples/videoModule/videojs/playlist.html +151 -0
  154. package/libraries/ortbConverter/README.md +378 -0
  155. package/libraries/ortbConverter/converter.js +135 -0
  156. package/libraries/ortbConverter/lib/composer.js +43 -0
  157. package/libraries/ortbConverter/lib/mergeProcessors.js +9 -0
  158. package/libraries/ortbConverter/lib/sizes.js +14 -0
  159. package/libraries/ortbConverter/processors/banner.js +40 -0
  160. package/libraries/ortbConverter/processors/default.js +167 -0
  161. package/libraries/ortbConverter/processors/mediaType.js +21 -0
  162. package/libraries/ortbConverter/processors/native.js +37 -0
  163. package/libraries/ortbConverter/processors/video.js +66 -0
  164. package/libraries/pbsExtensions/pbsExtensions.js +12 -0
  165. package/libraries/pbsExtensions/processors/aliases.js +17 -0
  166. package/libraries/pbsExtensions/processors/mediaType.js +23 -0
  167. package/libraries/pbsExtensions/processors/params.js +22 -0
  168. package/libraries/pbsExtensions/processors/pbs.js +99 -0
  169. package/libraries/pbsExtensions/processors/requestExtPrebid.js +30 -0
  170. package/libraries/pbsExtensions/processors/video.js +23 -0
  171. package/libraries/video/constants/enums.js +5 -0
  172. package/libraries/video/constants/events.js +97 -0
  173. package/libraries/video/constants/ortb.js +169 -0
  174. package/libraries/video/constants/vendorCodes.js +6 -0
  175. package/libraries/video/shared/eventHandler.js +18 -0
  176. package/libraries/video/shared/parentModule.js +82 -0
  177. package/libraries/video/shared/state.js +47 -0
  178. package/libraries/video/shared/vastXmlBuilder.js +77 -0
  179. package/libraries/video/shared/vastXmlEditor.js +115 -0
  180. package/modules/.submodules.json +6 -1
  181. package/modules/aaxBlockmeterRtdProvider.js +59 -0
  182. package/modules/aaxBlockmeterRtdProvider.md +48 -0
  183. package/modules/appnexusBidAdapter.js +38 -1
  184. package/modules/chtnwBidAdapter.js +110 -0
  185. package/modules/chtnwBidAdapter.md +31 -0
  186. package/modules/concertBidAdapter.js +44 -2
  187. package/modules/consentManagement.js +22 -1
  188. package/modules/consentManagementUsp.js +29 -7
  189. package/modules/criteoBidAdapter.js +25 -5
  190. package/modules/currency.js +9 -0
  191. package/modules/dgkeywordRtdProvider.js +3 -3
  192. package/modules/gridNMBidAdapter.js +10 -14
  193. package/modules/improvedigitalBidAdapter.js +191 -470
  194. package/modules/ixBidAdapter.js +24 -64
  195. package/modules/jwplayerVideoProvider.js +929 -0
  196. package/modules/jwplayerVideoProvider.md +25 -0
  197. package/modules/kargoBidAdapter.js +1 -1
  198. package/modules/multibid/index.js +12 -0
  199. package/modules/openxOrtbBidAdapter.js +120 -275
  200. package/modules/oxxionRtdProvider.js +119 -0
  201. package/modules/oxxionRtdProvider.md +48 -0
  202. package/modules/prebidServerBidAdapter/index.js +19 -716
  203. package/modules/prebidServerBidAdapter/ortbConverter.js +274 -0
  204. package/modules/priceFloors.js +73 -1
  205. package/modules/rtdModule/index.js +22 -1
  206. package/modules/schain.js +24 -1
  207. package/modules/spotxBidAdapter.js +16 -15
  208. package/modules/synacormediaBidAdapter.js +1 -1
  209. package/modules/teadsIdSystem.js +5 -0
  210. package/modules/userId/index.js +64 -6
  211. package/modules/videoModule/addingSubmodule.md +521 -0
  212. package/modules/videoModule/coreVideo.js +234 -0
  213. package/modules/videoModule/gamAdServerSubmodule.js +27 -0
  214. package/modules/videoModule/index.js +244 -0
  215. package/modules/videoModule/videoImpressionVerifier.js +206 -0
  216. package/modules/videojsVideoProvider.js +854 -0
  217. package/modules/videojsVideoProvider.md +17 -0
  218. package/package.json +5 -1
  219. package/src/adapterManager.js +56 -7
  220. package/src/adloader.js +2 -1
  221. package/src/auction.js +5 -0
  222. package/src/events.js +5 -1
  223. package/src/pbjsORTB.js +35 -0
  224. package/src/prebid.js +137 -112
  225. package/src/targeting.js +10 -2
  226. package/src/utils/currency.js +16 -0
  227. package/src/utils.js +21 -0
  228. package/test/spec/auctionmanager_spec.js +6 -0
  229. package/test/spec/modules/aaxBlockmeter_spec.js +58 -0
  230. package/test/spec/modules/chtnwBidAdapter_spec.js +105 -0
  231. package/test/spec/modules/concertBidAdapter_spec.js +56 -0
  232. package/test/spec/modules/consentManagementUsp_spec.js +64 -18
  233. package/test/spec/modules/criteoBidAdapter_spec.js +28 -0
  234. package/test/spec/modules/dgkeywordRtdProvider_spec.js +3 -3
  235. package/test/spec/modules/improvedigitalBidAdapter_spec.js +231 -211
  236. package/test/spec/modules/ixBidAdapter_spec.js +230 -371
  237. package/test/spec/modules/openxOrtbBidAdapter_spec.js +77 -49
  238. package/test/spec/modules/oxxionRtdProvider_spec.js +142 -0
  239. package/test/spec/modules/prebidServerBidAdapter_spec.js +139 -137
  240. package/test/spec/modules/realTimeDataModule_spec.js +65 -0
  241. package/test/spec/modules/userId_spec.js +67 -1
  242. package/test/spec/modules/videoModule/coreVideo_spec.js +98 -0
  243. package/test/spec/modules/videoModule/pbVideo_spec.js +362 -0
  244. package/test/spec/modules/videoModule/shared/parentModule_spec.js +73 -0
  245. package/test/spec/modules/videoModule/shared/state_spec.js +26 -0
  246. package/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js +103 -0
  247. package/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js +209 -0
  248. package/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js +846 -0
  249. package/test/spec/modules/videoModule/submodules/videojsVideoProvider_spec.js +391 -0
  250. package/test/spec/modules/videoModule/videoImpressionVerifier_spec.js +112 -0
  251. package/test/spec/ortbConverter/banner_spec.js +203 -0
  252. package/test/spec/ortbConverter/composer_spec.js +69 -0
  253. package/test/spec/ortbConverter/converter_spec.js +283 -0
  254. package/test/spec/ortbConverter/currency_spec.js +40 -0
  255. package/test/spec/ortbConverter/default_processors_spec.js +61 -0
  256. package/test/spec/ortbConverter/gdpr_spec.js +38 -0
  257. package/test/spec/ortbConverter/mediaTypes_spec.js +67 -0
  258. package/test/spec/ortbConverter/mergeProcessors_spec.js +59 -0
  259. package/test/spec/ortbConverter/multibid_spec.js +35 -0
  260. package/test/spec/ortbConverter/native_spec.js +95 -0
  261. package/test/spec/ortbConverter/pbjsORTB_spec.js +67 -0
  262. package/test/spec/ortbConverter/pbsExtensions/aliases_spec.js +57 -0
  263. package/test/spec/ortbConverter/pbsExtensions/params_spec.js +96 -0
  264. package/test/spec/ortbConverter/pbsExtensions/video_spec.js +52 -0
  265. package/test/spec/ortbConverter/priceFloors_spec.js +143 -0
  266. package/test/spec/ortbConverter/schain_spec.js +33 -0
  267. package/test/spec/ortbConverter/userId_spec.js +21 -0
  268. package/test/spec/ortbConverter/usp_spec.js +15 -0
  269. package/test/spec/ortbConverter/video_spec.js +189 -0
  270. package/test/spec/unit/core/adapterManager_spec.js +102 -0
  271. package/test/spec/unit/core/targeting_spec.js +34 -0
  272. package/test/spec/unit/pbjs_api_spec.js +124 -45
  273. package/test/spec/utils_spec.js +45 -1
@@ -0,0 +1,105 @@
1
+ import { expect } from 'chai';
2
+ import { spec } from '../../../modules/chtnwBidAdapter.js';
3
+ import * as utils from '../../../src/utils.js';
4
+
5
+ describe('ChtnwAdapter', function () {
6
+ describe('isBidRequestValid', function () {
7
+ const bid = {
8
+ code: 'adunit-code',
9
+ bidder: 'chtnw',
10
+ params: {
11
+ placementId: '38EL412LO82XR9O6'
12
+ },
13
+ sizes: [
14
+ [300, 250]
15
+ ],
16
+ };
17
+
18
+ it('should return true when required params found', function () {
19
+ const bidRequest = utils.deepClone(bid);
20
+ expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
21
+ });
22
+
23
+ it('should return false when required params are missing', function () {
24
+ const bidRequest = utils.deepClone(bid);
25
+ delete bidRequest.params;
26
+ expect(spec.isBidRequestValid(bidRequest)).to.equal(false);
27
+ });
28
+ });
29
+
30
+ describe('buildRequests', function () {
31
+ let bidRequests = [{
32
+ code: 'adunit-code',
33
+ bidder: 'chtnw',
34
+ params: {
35
+ placementId: '38EL412LO82XR9O6'
36
+ },
37
+ sizes: [
38
+ [300, 250]
39
+ ],
40
+ }];
41
+
42
+ const request = spec.buildRequests(bidRequests);
43
+
44
+ it('Returns POST method', function () {
45
+ expect(request.method).to.equal('POST');
46
+ });
47
+
48
+ it('Returns general data valid', function () {
49
+ let data = request.data;
50
+ expect(data).to.be.an('object');
51
+ expect(data).to.have.property('bids');
52
+ expect(data).to.have.property('uuid');
53
+ expect(data).to.have.property('device');
54
+ expect(data).to.have.property('site');
55
+ });
56
+ });
57
+
58
+ describe('interpretResponse', function () {
59
+ let responseBody = [{
60
+ 'requestId': 'test',
61
+ 'cpm': 0.5,
62
+ 'currency': 'USD',
63
+ 'width': 300,
64
+ 'height': 250,
65
+ 'netRevenue': true,
66
+ 'ttl': 60,
67
+ 'creativeId': 'AD',
68
+ 'ad': '<h1>AD<h1>',
69
+ 'mediaType': 'banner',
70
+ 'meta': {
71
+ 'advertiserDomains': [
72
+ 'www.example.com'
73
+ ]
74
+ }
75
+ }];
76
+
77
+ it('handles empty bid response', function () {
78
+ let response = {
79
+ body: responseBody
80
+ };
81
+ let result = spec.interpretResponse(response);
82
+ expect(result.length).to.not.equal(0);
83
+ expect(result[0].meta.advertiserDomains).to.be.an('array');
84
+ });
85
+
86
+ it('handles empty bid response', function () {
87
+ let response = {
88
+ body: []
89
+ };
90
+ let result = spec.interpretResponse(response);
91
+ expect(result.length).to.equal(0);
92
+ });
93
+ });
94
+
95
+ describe('getUserSyncs', function () {
96
+ it('should register type is image', function () {
97
+ const syncOptions = {
98
+ 'pixelEnabled': 'true'
99
+ }
100
+ let userSync = spec.getUserSyncs(syncOptions);
101
+ expect(userSync[0].type).to.equal('image');
102
+ expect(userSync[0].url).to.have.string('ssp');
103
+ });
104
+ });
105
+ });
@@ -7,11 +7,33 @@ describe('ConcertAdapter', function () {
7
7
  let bidRequests;
8
8
  let bidRequest;
9
9
  let bidResponse;
10
+ let element;
11
+ let sandbox;
10
12
 
11
13
  afterEach(function () {
12
14
  $$PREBID_GLOBAL$$.bidderSettings = {};
15
+ sandbox.restore();
13
16
  });
17
+
14
18
  beforeEach(function () {
19
+ element = {
20
+ x: 0,
21
+ y: 0,
22
+ width: 0,
23
+ height: 0,
24
+ getBoundingClientRect: () => {
25
+ return {
26
+ width: element.width,
27
+ height: element.height,
28
+
29
+ left: element.x,
30
+ top: element.y,
31
+ right: element.x + element.width,
32
+ bottom: element.y + element.height
33
+ };
34
+ }
35
+ };
36
+
15
37
  $$PREBID_GLOBAL$$.bidderSettings = {
16
38
  concert: {
17
39
  storageAllowed: true
@@ -56,6 +78,9 @@ describe('ConcertAdapter', function () {
56
78
  ]
57
79
  }
58
80
  }
81
+
82
+ sandbox = sinon.sandbox.create();
83
+ sandbox.stub(document, 'getElementById').withArgs('desktop_leaderboard_variable').returns(element)
59
84
  });
60
85
 
61
86
  describe('spec.isBidRequestValid', function() {
@@ -119,6 +144,37 @@ describe('ConcertAdapter', function () {
119
144
 
120
145
  expect(payload.meta.uid).to.equal('foo');
121
146
  });
147
+
148
+ it('should add uid2 to eids list if available', function() {
149
+ bidRequests[0].userId = { uid2: { id: 'uid123' } }
150
+
151
+ const request = spec.buildRequests(bidRequests, bidRequest);
152
+ const payload = JSON.parse(request.data);
153
+ const meta = payload.meta
154
+
155
+ expect(meta.eids.length).to.equal(1);
156
+ expect(meta.eids[0].uids[0].id).to.equal('uid123')
157
+ expect(meta.eids[0].uids[0].atype).to.equal(3)
158
+ })
159
+
160
+ it('should return empty eids list if none are available', function() {
161
+ bidRequests[0].userId = { testId: { id: 'uid123' } }
162
+ const request = spec.buildRequests(bidRequests, bidRequest);
163
+ const payload = JSON.parse(request.data);
164
+ const meta = payload.meta
165
+
166
+ expect(meta.eids.length).to.equal(0);
167
+ });
168
+
169
+ it('should return x/y offset coordiantes when element is present', function() {
170
+ Object.assign(element, { x: 100, y: 0, width: 400, height: 400 })
171
+ const request = spec.buildRequests(bidRequests, bidRequest);
172
+ const payload = JSON.parse(request.data);
173
+ const slot = payload.slots[0];
174
+
175
+ expect(slot.offsetCoordinates.x).to.equal(100)
176
+ expect(slot.offsetCoordinates.y).to.equal(0)
177
+ })
122
178
  });
123
179
 
124
180
  describe('spec.interpretResponse', function() {
@@ -8,8 +8,9 @@ import {
8
8
  } from 'modules/consentManagementUsp.js';
9
9
  import * as utils from 'src/utils.js';
10
10
  import { config } from 'src/config.js';
11
- import {uspDataHandler} from 'src/adapterManager.js';
11
+ import adapterManager, {uspDataHandler} from 'src/adapterManager.js';
12
12
  import 'src/prebid.js';
13
+ import {defer} from '../../../src/utils/promise.js';
13
14
 
14
15
  let expect = require('chai').expect;
15
16
 
@@ -23,6 +24,16 @@ function createIFrameMarker() {
23
24
  }
24
25
 
25
26
  describe('consentManagement', function () {
27
+ let sandbox;
28
+ beforeEach(() => {
29
+ sandbox = sinon.sandbox.create();
30
+ sandbox.stub(adapterManager, 'callDataDeletionRequest');
31
+ });
32
+
33
+ afterEach(() => {
34
+ sandbox.restore();
35
+ });
36
+
26
37
  it('should enable itself on requestBids using default values', (done) => {
27
38
  requestBidsHook(() => {
28
39
  expect(uspDataHandler.enabled).to.be.true;
@@ -301,8 +312,11 @@ describe('consentManagement', function () {
301
312
  describe('USPAPI workflow for iframed page', function () {
302
313
  let ifr = null;
303
314
  let stringifyResponse = false;
315
+ let mockApi, replySent;
304
316
 
305
317
  beforeEach(function () {
318
+ mockApi = sinon.stub();
319
+ replySent = defer();
306
320
  sinon.stub(utils, 'logError');
307
321
  sinon.stub(utils, 'logWarn');
308
322
  ifr = createIFrameMarker();
@@ -322,17 +336,21 @@ describe('consentManagement', function () {
322
336
 
323
337
  function uspapiMessageHandler(event) {
324
338
  if (event && event.data) {
325
- var data = event.data;
339
+ const data = event.data;
326
340
  if (data.__uspapiCall) {
327
- var callId = data.__uspapiCall.callId;
328
- var response = {
329
- __uspapiReturn: {
330
- callId,
331
- returnValue: { uspString: '1YY' },
332
- success: true
341
+ const {command, version, callId} = data.__uspapiCall;
342
+ let response = mockApi(command, version, callId);
343
+ if (response) {
344
+ response = {
345
+ __uspapiReturn: {
346
+ callId,
347
+ returnValue: response,
348
+ success: true
349
+ }
333
350
  }
334
- };
335
- event.source.postMessage(stringifyResponse ? JSON.stringify(response) : response, '*');
351
+ event.source.postMessage(stringifyResponse ? JSON.stringify(response) : response, '*');
352
+ replySent.resolve();
353
+ }
336
354
  }
337
355
  }
338
356
  }
@@ -345,6 +363,11 @@ describe('consentManagement', function () {
345
363
  function testIFramedPage(testName, messageFormatString) {
346
364
  it(`should return the consent string from a postmessage + addEventListener response - ${testName}`, (done) => {
347
365
  stringifyResponse = messageFormatString;
366
+ mockApi.callsFake((cmd) => {
367
+ if (cmd === 'getUSPData') {
368
+ return { uspString: '1YY' }
369
+ }
370
+ })
348
371
  setConsentConfig(goodConfig);
349
372
  requestBidsHook(() => {
350
373
  let consent = uspDataHandler.getConsentData();
@@ -355,6 +378,20 @@ describe('consentManagement', function () {
355
378
  }, {});
356
379
  });
357
380
  }
381
+
382
+ it('fires deletion request on registerDeletion', (done) => {
383
+ mockApi.callsFake((cmd) => {
384
+ return cmd === 'registerDeletion'
385
+ })
386
+ sinon.assert.notCalled(adapterManager.callDataDeletionRequest);
387
+ setConsentConfig(goodConfig);
388
+ replySent.promise.then(() => {
389
+ setTimeout(() => { // defer again to give time for the message to get through
390
+ sinon.assert.calledOnce(adapterManager.callDataDeletionRequest);
391
+ done()
392
+ }, 200)
393
+ })
394
+ });
358
395
  });
359
396
 
360
397
  describe('test without iframe locater', function() {
@@ -400,23 +437,19 @@ describe('consentManagement', function () {
400
437
  });
401
438
 
402
439
  describe('USPAPI workflow for normal pages:', function () {
403
- let uspapiStub = sinon.stub();
404
440
  let ifr = null;
405
441
 
406
442
  beforeEach(function () {
407
443
  didHookReturn = false;
408
444
  ifr = createIFrameMarker();
409
- sinon.stub(utils, 'logError');
410
- sinon.stub(utils, 'logWarn');
445
+ sandbox.stub(utils, 'logError');
446
+ sandbox.stub(utils, 'logWarn');
411
447
  window.__uspapi = function() {};
412
448
  });
413
449
 
414
450
  afterEach(function () {
415
451
  config.resetConfig();
416
452
  $$PREBID_GLOBAL$$.requestBids.removeAll();
417
- uspapiStub.restore();
418
- utils.logError.restore();
419
- utils.logWarn.restore();
420
453
  document.body.removeChild(ifr);
421
454
  delete window.__uspapi;
422
455
  resetConsentData();
@@ -427,7 +460,7 @@ describe('consentManagement', function () {
427
460
  uspString: '1NY'
428
461
  };
429
462
 
430
- uspapiStub = sinon.stub(window, '__uspapi').callsFake((...args) => {
463
+ sandbox.stub(window, '__uspapi').callsFake((...args) => {
431
464
  args[2](testConsentData, true);
432
465
  });
433
466
 
@@ -448,7 +481,7 @@ describe('consentManagement', function () {
448
481
  uspString: '1NY'
449
482
  };
450
483
 
451
- uspapiStub = sinon.stub(window, '__uspapi').callsFake((...args) => {
484
+ sandbox.stub(window, '__uspapi').callsFake((...args) => {
452
485
  args[2](testConsentData, true);
453
486
  });
454
487
 
@@ -463,6 +496,19 @@ describe('consentManagement', function () {
463
496
  expect(consentMeta.usp).to.equal(testConsentData.uspString);
464
497
  expect(consentMeta.generatedAt).to.be.above(1644367751709);
465
498
  });
499
+
500
+ it('registers deletion request event listener', () => {
501
+ let listener;
502
+ sandbox.stub(window, '__uspapi').callsFake((cmd, _, cb) => {
503
+ if (cmd === 'registerDeletion') {
504
+ listener = cb;
505
+ }
506
+ });
507
+ setConsentConfig(goodConfig);
508
+ sinon.assert.notCalled(adapterManager.callDataDeletionRequest);
509
+ listener();
510
+ sinon.assert.calledOnce(adapterManager.callDataDeletionRequest);
511
+ })
466
512
  });
467
513
  });
468
514
  });
@@ -1279,6 +1279,34 @@ describe('The Criteo bidding adapter', function () {
1279
1279
  });
1280
1280
  });
1281
1281
 
1282
+ it('should properly build a request with static floors', function () {
1283
+ const bidRequests = [
1284
+ {
1285
+ bidder: 'criteo',
1286
+ adUnitCode: 'bid-123',
1287
+ transactionId: 'transaction-123',
1288
+ mediaTypes: {
1289
+ banner: {
1290
+ sizes: [[300, 250], [728, 90]]
1291
+ }
1292
+ },
1293
+ params: {
1294
+ networkId: 456,
1295
+ bidFloor: 1,
1296
+ bidFloorCur: 'EUR'
1297
+ },
1298
+ },
1299
+ ];
1300
+ const bidderRequest = {};
1301
+ const request = spec.buildRequests(bidRequests, bidderRequest);
1302
+ expect(request.data.slots[0].ext.floors).to.deep.equal({
1303
+ 'banner': {
1304
+ '300x250': { 'currency': 'EUR', 'floor': 1 },
1305
+ '728x90': { 'currency': 'EUR', 'floor': 1 }
1306
+ }
1307
+ });
1308
+ });
1309
+
1282
1310
  it('should properly build a video request with several player sizes with floors', function () {
1283
1311
  const bidRequests = [
1284
1312
  {
@@ -383,10 +383,11 @@ describe('Digital Garage Keyword Module', function () {
383
383
  }
384
384
  let moduleConfig = cloneDeep(DEF_CONFIG);
385
385
  window.localStorage.setItem('ope_fpid', uuid);
386
+ moduleConfig.params.enableReadFpid = true;
386
387
  dgRtd.getDgKeywordsAndSet(
387
388
  pbjs,
388
389
  () => {
389
- const url = dgRtd.getProfileApiUrl(null);
390
+ const url = dgRtd.getProfileApiUrl(null, moduleConfig.params.enableReadFpid);
390
391
  expect(url.indexOf(uuid) > 0).to.equal(true);
391
392
  expect(url).to.equal(server.requests[0].url);
392
393
  done();
@@ -410,11 +411,10 @@ describe('Digital Garage Keyword Module', function () {
410
411
  }
411
412
  let moduleConfig = cloneDeep(DEF_CONFIG);
412
413
  window.localStorage.setItem('ope_fpid', uuid);
413
- moduleConfig.params.disableReadFpid = true;
414
414
  dgRtd.getDgKeywordsAndSet(
415
415
  pbjs,
416
416
  () => {
417
- const url = dgRtd.getProfileApiUrl(null, moduleConfig.params.disableReadFpid);
417
+ const url = dgRtd.getProfileApiUrl(null);
418
418
  expect(url.indexOf(uuid) > 0).to.equal(false);
419
419
  expect(url).to.equal(server.requests[0].url);
420
420
  done();