prebid.js 7.22.0 → 7.24.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 (314) 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/admaticBidAdapter.js +1 -0
  7. package/dist/adrelevantisBidAdapter.js +1 -1
  8. package/dist/adtrgtmeBidAdapter.js +1 -1
  9. package/dist/adxcgBidAdapter.js +1 -1
  10. package/dist/adyoulikeBidAdapter.js +1 -1
  11. package/dist/ajaBidAdapter.js +1 -1
  12. package/dist/amxBidAdapter.js +1 -1
  13. package/dist/amxIdSystem.js +1 -1
  14. package/dist/analyticsAdapter.js +1 -1
  15. package/dist/appierAnalyticsAdapter.js +1 -1
  16. package/dist/appnexusBidAdapter.js +1 -1
  17. package/dist/asoBidAdapter.js +1 -1
  18. package/dist/audiencerunBidAdapter.js +1 -1
  19. package/dist/axonixBidAdapter.js +1 -1
  20. package/dist/bidViewability.js +1 -1
  21. package/dist/bidViewabilityIO.js +1 -1
  22. package/dist/bidglassBidAdapter.js +1 -1
  23. package/dist/big-richmediaBidAdapter.js +1 -1
  24. package/dist/bluebillywigBidAdapter.js +1 -1
  25. package/dist/bridgewellBidAdapter.js +1 -1
  26. package/dist/brightMountainMediaBidAdapter.js +1 -1
  27. package/dist/browsiRtdProvider.js +1 -1
  28. package/dist/carodaBidAdapter.js +1 -1
  29. package/dist/chtnwBidAdapter.js +1 -0
  30. package/dist/cleanioRtdProvider.js +1 -1
  31. package/dist/concertBidAdapter.js +1 -1
  32. package/dist/connectIdSystem.js +1 -1
  33. package/dist/connectadBidAdapter.js +1 -1
  34. package/dist/consentManagement.js +1 -1
  35. package/dist/consentManagementUsp.js +1 -1
  36. package/dist/consumableBidAdapter.js +1 -1
  37. package/dist/conversantBidAdapter.js +1 -1
  38. package/dist/craftBidAdapter.js +1 -1
  39. package/dist/criteoBidAdapter.js +1 -1
  40. package/dist/currency.js +1 -1
  41. package/dist/dependencies.json +19 -0
  42. package/dist/dfpAdServerVideo.js +1 -1
  43. package/dist/dgkeywordRtdProvider.js +1 -1
  44. package/dist/dspxBidAdapter.js +1 -1
  45. package/dist/eplanningBidAdapter.js +1 -1
  46. package/dist/finativeBidAdapter.js +1 -1
  47. package/dist/gdprEnforcement.js +1 -1
  48. package/dist/glimpseBidAdapter.js +1 -1
  49. package/dist/gmosspBidAdapter.js +1 -1
  50. package/dist/goldbachBidAdapter.js +1 -1
  51. package/dist/googleAnalyticsAdapter.js +1 -1
  52. package/dist/gridBidAdapter.js +1 -1
  53. package/dist/gridNMBidAdapter.js +1 -1
  54. package/dist/growthCodeIdSystem.js +1 -1
  55. package/dist/gumgumBidAdapter.js +1 -1
  56. package/dist/h12mediaBidAdapter.js +1 -1
  57. package/dist/id5AnalyticsAdapter.js +1 -1
  58. package/dist/id5IdSystem.js +1 -1
  59. package/dist/impactifyBidAdapter.js +1 -1
  60. package/dist/improvedigitalBidAdapter.js +1 -1
  61. package/dist/inmarBidAdapter.js +1 -1
  62. package/dist/insticatorBidAdapter.js +1 -1
  63. package/dist/instreamTracking.js +1 -1
  64. package/dist/ixBidAdapter.js +1 -1
  65. package/dist/jixieBidAdapter.js +1 -1
  66. package/dist/justpremiumBidAdapter.js +1 -1
  67. package/dist/jwplayerVideoProvider.js +1 -0
  68. package/dist/kargoBidAdapter.js +1 -1
  69. package/dist/konduitAnalyticsAdapter.js +1 -1
  70. package/dist/kueezBidAdapter.js +1 -1
  71. package/dist/kueezRtbBidAdapter.js +1 -0
  72. package/dist/lassoBidAdapter.js +1 -1
  73. package/dist/lifestreetBidAdapter.js +1 -1
  74. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  75. package/dist/logicadBidAdapter.js +1 -1
  76. package/dist/loglyliftBidAdapter.js +1 -1
  77. package/dist/magniteAnalyticsAdapter.js +1 -1
  78. package/dist/malltvAnalyticsAdapter.js +1 -1
  79. package/dist/marsmediaBidAdapter.js +1 -1
  80. package/dist/mediafuseBidAdapter.js +1 -1
  81. package/dist/mediakeysBidAdapter.js +1 -1
  82. package/dist/mediasquareBidAdapter.js +1 -1
  83. package/dist/mgidBidAdapter.js +1 -1
  84. package/dist/mgidRtdProvider.js +1 -0
  85. package/dist/minutemediaBidAdapter.js +1 -1
  86. package/dist/multibid.js +1 -1
  87. package/dist/not-for-prod/prebid.js +153 -141
  88. package/dist/oguryBidAdapter.js +1 -1
  89. package/dist/onetagBidAdapter.js +1 -1
  90. package/dist/ooloAnalyticsAdapter.js +1 -1
  91. package/dist/openxOrtbBidAdapter.js +1 -1
  92. package/dist/ortbConverter.js +1 -0
  93. package/dist/outbrainBidAdapter.js +1 -1
  94. package/dist/oxxionRtdProvider.js +1 -0
  95. package/dist/parrableIdSystem.js +1 -1
  96. package/dist/pbsExtensions.js +1 -0
  97. package/dist/permutiveRtdProvider.js +1 -1
  98. package/dist/pixfutureBidAdapter.js +1 -1
  99. package/dist/prebid-core.js +1 -1
  100. package/dist/prebidServerBidAdapter.js +1 -1
  101. package/dist/priceFloors.js +1 -1
  102. package/dist/pubCommonId.js +1 -1
  103. package/dist/publinkIdSystem.js +1 -1
  104. package/dist/pubmaticBidAdapter.js +1 -1
  105. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  106. package/dist/pxyzBidAdapter.js +1 -1
  107. package/dist/quantcastBidAdapter.js +1 -1
  108. package/dist/readpeakBidAdapter.js +1 -1
  109. package/dist/relaidoBidAdapter.js +1 -1
  110. package/dist/rhythmoneBidAdapter.js +1 -1
  111. package/dist/riseBidAdapter.js +1 -1
  112. package/dist/rtdModule.js +1 -1
  113. package/dist/rubiconAnalyticsAdapter.js +1 -1
  114. package/dist/rubiconBidAdapter.js +1 -1
  115. package/dist/schain.js +1 -1
  116. package/dist/seedingAllianceBidAdapter.js +1 -1
  117. package/dist/seedtagBidAdapter.js +1 -1
  118. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  119. package/dist/sharethroughBidAdapter.js +1 -1
  120. package/dist/shinezBidAdapter.js +1 -1
  121. package/dist/smaatoBidAdapter.js +1 -1
  122. package/dist/smartadserverBidAdapter.js +1 -1
  123. package/dist/smartxBidAdapter.js +1 -1
  124. package/dist/smilewantedBidAdapter.js +1 -1
  125. package/dist/sonobiBidAdapter.js +1 -1
  126. package/dist/sovrnAnalyticsAdapter.js +1 -1
  127. package/dist/sovrnBidAdapter.js +1 -1
  128. package/dist/spotxBidAdapter.js +1 -1
  129. package/dist/sspBCBidAdapter.js +1 -1
  130. package/dist/sublimeBidAdapter.js +1 -1
  131. package/dist/synacormediaBidAdapter.js +1 -1
  132. package/dist/targetVideoBidAdapter.js +1 -1
  133. package/dist/teadsBidAdapter.js +1 -1
  134. package/dist/teadsIdSystem.js +1 -1
  135. package/dist/trionBidAdapter.js +1 -1
  136. package/dist/tripleliftBidAdapter.js +1 -1
  137. package/dist/ttdBidAdapter.js +1 -1
  138. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  139. package/dist/underdogmediaBidAdapter.js +1 -1
  140. package/dist/undertoneBidAdapter.js +1 -1
  141. package/dist/userId.js +1 -1
  142. package/dist/vidazooBidAdapter.js +1 -1
  143. package/dist/video.js +1 -0
  144. package/dist/videoModule.js +1 -0
  145. package/dist/videobyteBidAdapter.js +1 -1
  146. package/dist/videojsVideoProvider.js +1 -0
  147. package/dist/visxBidAdapter.js +1 -1
  148. package/dist/vuukleBidAdapter.js +1 -1
  149. package/dist/widespaceBidAdapter.js +1 -1
  150. package/dist/winrBidAdapter.js +1 -1
  151. package/dist/yahoosspBidAdapter.js +1 -1
  152. package/dist/yieldmoBidAdapter.js +1 -1
  153. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  154. package/integrationExamples/gpt/mgidRtdProvider_example.html +143 -0
  155. package/integrationExamples/videoModule/jwplayer/bidMarkedAsUsed.html +98 -0
  156. package/integrationExamples/videoModule/jwplayer/bidRequestScheduling.html +89 -0
  157. package/integrationExamples/videoModule/jwplayer/eventListeners.html +244 -0
  158. package/integrationExamples/videoModule/jwplayer/gamAdServerMediation.html +122 -0
  159. package/integrationExamples/videoModule/jwplayer/mediaMetadata.html +80 -0
  160. package/integrationExamples/videoModule/jwplayer/playlist.html +122 -0
  161. package/integrationExamples/videoModule/videojs/bidMarkedAsUsed.html +126 -0
  162. package/integrationExamples/videoModule/videojs/bidRequestScheduling.html +132 -0
  163. package/integrationExamples/videoModule/videojs/eventListeners.html +238 -0
  164. package/integrationExamples/videoModule/videojs/gamAdServerMediation.html +138 -0
  165. package/integrationExamples/videoModule/videojs/mediaMetadata.html +103 -0
  166. package/integrationExamples/videoModule/videojs/playlist.html +151 -0
  167. package/libraries/ortbConverter/README.md +378 -0
  168. package/libraries/ortbConverter/converter.js +135 -0
  169. package/libraries/ortbConverter/lib/composer.js +43 -0
  170. package/libraries/ortbConverter/lib/mergeProcessors.js +9 -0
  171. package/libraries/ortbConverter/lib/sizes.js +14 -0
  172. package/libraries/ortbConverter/processors/banner.js +40 -0
  173. package/libraries/ortbConverter/processors/default.js +167 -0
  174. package/libraries/ortbConverter/processors/mediaType.js +21 -0
  175. package/libraries/ortbConverter/processors/native.js +37 -0
  176. package/libraries/ortbConverter/processors/video.js +66 -0
  177. package/libraries/pbsExtensions/pbsExtensions.js +12 -0
  178. package/libraries/pbsExtensions/processors/aliases.js +17 -0
  179. package/libraries/pbsExtensions/processors/mediaType.js +23 -0
  180. package/libraries/pbsExtensions/processors/params.js +22 -0
  181. package/libraries/pbsExtensions/processors/pbs.js +99 -0
  182. package/libraries/pbsExtensions/processors/requestExtPrebid.js +30 -0
  183. package/libraries/pbsExtensions/processors/video.js +23 -0
  184. package/libraries/video/constants/enums.js +5 -0
  185. package/libraries/video/constants/events.js +97 -0
  186. package/libraries/video/constants/ortb.js +169 -0
  187. package/libraries/video/constants/vendorCodes.js +6 -0
  188. package/libraries/video/shared/eventHandler.js +18 -0
  189. package/libraries/video/shared/parentModule.js +82 -0
  190. package/libraries/video/shared/state.js +47 -0
  191. package/libraries/video/shared/vastXmlBuilder.js +77 -0
  192. package/libraries/video/shared/vastXmlEditor.js +115 -0
  193. package/modules/.submodules.json +7 -1
  194. package/modules/aaxBlockmeterRtdProvider.js +59 -0
  195. package/modules/aaxBlockmeterRtdProvider.md +48 -0
  196. package/modules/admaticBidAdapter.js +147 -0
  197. package/modules/admaticBidAdapter.md +48 -0
  198. package/modules/amxBidAdapter.js +1 -0
  199. package/modules/appnexusBidAdapter.js +38 -1
  200. package/modules/chtnwBidAdapter.js +110 -0
  201. package/modules/chtnwBidAdapter.md +31 -0
  202. package/modules/concertBidAdapter.js +44 -2
  203. package/modules/connectIdSystem.js +36 -23
  204. package/modules/connectIdSystem.md +3 -2
  205. package/modules/consentManagement.js +22 -1
  206. package/modules/consentManagementUsp.js +29 -7
  207. package/modules/criteoBidAdapter.js +25 -5
  208. package/modules/currency.js +9 -0
  209. package/modules/dgkeywordRtdProvider.js +3 -3
  210. package/modules/gridNMBidAdapter.js +10 -14
  211. package/modules/growthCodeIdSystem.js +9 -5
  212. package/modules/gumgumBidAdapter.js +4 -0
  213. package/modules/improvedigitalBidAdapter.js +191 -470
  214. package/modules/ixBidAdapter.js +54 -71
  215. package/modules/jwplayerVideoProvider.js +929 -0
  216. package/modules/jwplayerVideoProvider.md +25 -0
  217. package/modules/kargoBidAdapter.js +1 -1
  218. package/modules/kueezRtbBidAdapter.js +278 -0
  219. package/modules/kueezRtbBidAdapter.md +35 -0
  220. package/modules/magniteAnalyticsAdapter.js +6 -1
  221. package/modules/mgidRtdProvider.js +190 -0
  222. package/modules/mgidRtdProvider.md +51 -0
  223. package/modules/multibid/index.js +12 -0
  224. package/modules/openxOrtbBidAdapter.js +120 -275
  225. package/modules/oxxionRtdProvider.js +119 -0
  226. package/modules/oxxionRtdProvider.md +48 -0
  227. package/modules/permutiveRtdProvider.js +2 -1
  228. package/modules/permutiveRtdProvider.md +36 -1
  229. package/modules/prebidServerBidAdapter/index.js +19 -716
  230. package/modules/prebidServerBidAdapter/ortbConverter.js +274 -0
  231. package/modules/priceFloors.js +73 -1
  232. package/modules/pubmaticBidAdapter.js +21 -29
  233. package/modules/rtdModule/index.js +22 -1
  234. package/modules/schain.js +24 -1
  235. package/modules/spotxBidAdapter.js +16 -15
  236. package/modules/synacormediaBidAdapter.js +1 -1
  237. package/modules/teadsIdSystem.js +5 -0
  238. package/modules/tripleliftBidAdapter.js +1 -1
  239. package/modules/userId/eids.js +3 -10
  240. package/modules/userId/index.js +64 -6
  241. package/modules/videoModule/addingSubmodule.md +521 -0
  242. package/modules/videoModule/coreVideo.js +234 -0
  243. package/modules/videoModule/gamAdServerSubmodule.js +27 -0
  244. package/modules/videoModule/index.js +244 -0
  245. package/modules/videoModule/videoImpressionVerifier.js +206 -0
  246. package/modules/videojsVideoProvider.js +854 -0
  247. package/modules/videojsVideoProvider.md +17 -0
  248. package/package.json +12 -8
  249. package/src/adRendering.js +1 -1
  250. package/src/adapterManager.js +56 -7
  251. package/src/adloader.js +3 -1
  252. package/src/auction.js +6 -1
  253. package/src/events.js +5 -1
  254. package/src/pbjsORTB.js +35 -0
  255. package/src/prebid.js +137 -112
  256. package/src/targeting.js +10 -2
  257. package/src/utils/currency.js +16 -0
  258. package/src/utils.js +21 -0
  259. package/test/spec/auctionmanager_spec.js +15 -0
  260. package/test/spec/modules/aaxBlockmeter_spec.js +58 -0
  261. package/test/spec/modules/admaticBidAdapter_spec.js +46 -0
  262. package/test/spec/modules/chtnwBidAdapter_spec.js +105 -0
  263. package/test/spec/modules/concertBidAdapter_spec.js +56 -0
  264. package/test/spec/modules/connectIdSystem_spec.js +175 -5
  265. package/test/spec/modules/consentManagementUsp_spec.js +64 -18
  266. package/test/spec/modules/criteoBidAdapter_spec.js +28 -0
  267. package/test/spec/modules/dgkeywordRtdProvider_spec.js +3 -3
  268. package/test/spec/modules/eids_spec.js +10 -7
  269. package/test/spec/modules/ftrackIdSystem_spec.js +34 -22
  270. package/test/spec/modules/gumgumBidAdapter_spec.js +15 -0
  271. package/test/spec/modules/improvedigitalBidAdapter_spec.js +231 -211
  272. package/test/spec/modules/ixBidAdapter_spec.js +412 -350
  273. package/test/spec/modules/kueezRtbBidAdapter_spec.js +396 -0
  274. package/test/spec/modules/magniteAnalyticsAdapter_spec.js +26 -0
  275. package/test/spec/modules/mgidRtdProvider_spec.js +366 -0
  276. package/test/spec/modules/openxOrtbBidAdapter_spec.js +77 -49
  277. package/test/spec/modules/oxxionRtdProvider_spec.js +142 -0
  278. package/test/spec/modules/permutiveRtdProvider_spec.js +64 -5
  279. package/test/spec/modules/prebidServerBidAdapter_spec.js +139 -137
  280. package/test/spec/modules/realTimeDataModule_spec.js +65 -0
  281. package/test/spec/modules/tripleliftBidAdapter_spec.js +14 -0
  282. package/test/spec/modules/userId_spec.js +67 -1
  283. package/test/spec/modules/videoModule/coreVideo_spec.js +98 -0
  284. package/test/spec/modules/videoModule/pbVideo_spec.js +362 -0
  285. package/test/spec/modules/videoModule/shared/parentModule_spec.js +73 -0
  286. package/test/spec/modules/videoModule/shared/state_spec.js +26 -0
  287. package/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js +103 -0
  288. package/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js +209 -0
  289. package/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js +846 -0
  290. package/test/spec/modules/videoModule/submodules/videojsVideoProvider_spec.js +391 -0
  291. package/test/spec/modules/videoModule/videoImpressionVerifier_spec.js +112 -0
  292. package/test/spec/ortbConverter/banner_spec.js +203 -0
  293. package/test/spec/ortbConverter/composer_spec.js +69 -0
  294. package/test/spec/ortbConverter/converter_spec.js +283 -0
  295. package/test/spec/ortbConverter/currency_spec.js +40 -0
  296. package/test/spec/ortbConverter/default_processors_spec.js +61 -0
  297. package/test/spec/ortbConverter/gdpr_spec.js +38 -0
  298. package/test/spec/ortbConverter/mediaTypes_spec.js +67 -0
  299. package/test/spec/ortbConverter/mergeProcessors_spec.js +59 -0
  300. package/test/spec/ortbConverter/multibid_spec.js +35 -0
  301. package/test/spec/ortbConverter/native_spec.js +95 -0
  302. package/test/spec/ortbConverter/pbjsORTB_spec.js +67 -0
  303. package/test/spec/ortbConverter/pbsExtensions/aliases_spec.js +57 -0
  304. package/test/spec/ortbConverter/pbsExtensions/params_spec.js +96 -0
  305. package/test/spec/ortbConverter/pbsExtensions/video_spec.js +52 -0
  306. package/test/spec/ortbConverter/priceFloors_spec.js +143 -0
  307. package/test/spec/ortbConverter/schain_spec.js +33 -0
  308. package/test/spec/ortbConverter/userId_spec.js +21 -0
  309. package/test/spec/ortbConverter/usp_spec.js +15 -0
  310. package/test/spec/ortbConverter/video_spec.js +189 -0
  311. package/test/spec/unit/core/adapterManager_spec.js +102 -0
  312. package/test/spec/unit/core/targeting_spec.js +34 -0
  313. package/test/spec/unit/pbjs_api_spec.js +124 -45
  314. package/test/spec/utils_spec.js +45 -1
@@ -0,0 +1,391 @@
1
+ // Using require style imports for fine grained control of import time
2
+ import {
3
+ SETUP_COMPLETE, SETUP_FAILED
4
+ } from 'libraries/video/constants/events.js';
5
+
6
+ const {VideojsProvider, utils} = require('modules/videojsVideoProvider');
7
+
8
+ const {
9
+ PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE, AD_POSITION
10
+ } = require('libraries/video/constants/ortb.js');
11
+
12
+ const videojs = require('video.js').default;
13
+ require('videojs-playlist').default;
14
+ require('videojs-ima').default;
15
+ require('videojs-contrib-ads').default;
16
+
17
+ describe('videojsProvider', function () {
18
+ let config;
19
+ let adState;
20
+ let timeState;
21
+ let callbackStorage;
22
+
23
+ describe('init', function () {
24
+ beforeEach(() => {
25
+ config = {};
26
+ document.body.innerHTML = '';
27
+ });
28
+
29
+ it('should trigger failure when videojs is missing', function () {
30
+ const provider = VideojsProvider(config, null, adState, timeState, callbackStorage, utils);
31
+ const setupFailed = sinon.spy();
32
+ provider.onEvent(SETUP_FAILED, setupFailed, {});
33
+ provider.init();
34
+ expect(setupFailed.calledOnce).to.be.true;
35
+ const payload = setupFailed.args[0][1];
36
+ expect(payload.errorCode).to.be.equal(-1);
37
+ });
38
+
39
+ it('should trigger failure when videojs version is under min supported version', function () {
40
+ const provider = VideojsProvider(config, {...videojs, VERSION: '0.0.0'}, adState, timeState, callbackStorage, utils);
41
+ const setupFailed = sinon.spy();
42
+ provider.onEvent(SETUP_FAILED, setupFailed, {});
43
+ provider.init();
44
+ expect(setupFailed.calledOnce).to.be.true;
45
+ const payload = setupFailed.args[0][1];
46
+ expect(payload.errorCode).to.be.equal(-2);
47
+ });
48
+
49
+ it('should trigger failure when the div is not found', function () {
50
+ config.divId = 'fake-div'
51
+ const provider = VideojsProvider(config, videojs, adState, timeState, callbackStorage, utils);
52
+ const setupFailed = sinon.spy();
53
+ provider.onEvent(SETUP_FAILED, setupFailed, {});
54
+ provider.init();
55
+ expect(setupFailed.calledOnce).to.be.true;
56
+ const payload = setupFailed.args[0][1];
57
+ expect(payload.errorCode).to.be.equal(-3);
58
+ });
59
+
60
+ it('should instantiate the player when uninstantied', function () {
61
+ config.playerConfig = {testAttr: true};
62
+ config.divId = 'test-div'
63
+ const div = document.createElement('div');
64
+ div.setAttribute('id', 'test-div');
65
+ document.body.appendChild(div);
66
+
67
+ const mockVideojs = sinon.spy();
68
+ const provider = VideojsProvider(config, mockVideojs, adState, timeState, callbackStorage, utils);
69
+ provider.init();
70
+ expect(mockVideojs.calledOnce).to.be.true
71
+ });
72
+
73
+ it('should not reinstantiate the player', function () {
74
+ const div = document.createElement('div');
75
+ div.setAttribute('id', 'test-div');
76
+ document.body.appendChild(div);
77
+ const player = videojs(div, {})
78
+ config.playerConfig = {};
79
+ config.divId = 'test-div'
80
+ const provider = VideojsProvider(config, videojs, adState, timeState, callbackStorage, utils);
81
+ provider.init();
82
+ expect(videojs.getPlayer('test-div')).to.be.equal(player)
83
+ videojs.getPlayer('test-div').dispose()
84
+ });
85
+
86
+ it('should trigger setup complete when player is already insantiated', function () {
87
+ const div = document.createElement('div');
88
+ div.setAttribute('id', 'test-div');
89
+ document.body.appendChild(div);
90
+ videojs(div, {})
91
+ config.playerConfig = {};
92
+ config.divId = 'test-div'
93
+ const provider = VideojsProvider(config, videojs, adState, timeState, callbackStorage, utils);
94
+ const setupComplete = sinon.spy();
95
+ provider.onEvent(SETUP_COMPLETE, setupComplete, {});
96
+ provider.init();
97
+ expect(setupComplete.called).to.be.true;
98
+ videojs.getPlayer('test-div').dispose()
99
+ });
100
+ });
101
+
102
+ describe('getId', function () {
103
+ it('should return configured div id', function () {
104
+ const provider = VideojsProvider({ divId: 'test_id' });
105
+ expect(provider.getId()).to.be.equal('test_id');
106
+ });
107
+ });
108
+
109
+ describe('getOrtbParams', function () {
110
+ beforeEach(() => {
111
+ config = {divId: 'test'};
112
+ // initialize videojs element
113
+ document.body.innerHTML = `
114
+ <video preload id='test' width="${200}" height="${100}">
115
+ <source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
116
+ </video>`;
117
+ });
118
+
119
+ afterEach(() => {
120
+ const testPlayer = videojs('test');
121
+ if (testPlayer && !testPlayer.isDisposed()) {
122
+ testPlayer.dispose();
123
+ }
124
+ });
125
+
126
+ it('should populate oRTB Video and Content', function () {
127
+ const provider = VideojsProvider(config, videojs, adState, timeState, callbackStorage, utils);
128
+ provider.init();
129
+
130
+ const video = provider.getOrtbVideo();
131
+
132
+ expect(video.mimes).to.include(VIDEO_MIME_TYPE.MP4);
133
+ expect(video.protocols).to.deep.equal([2]);
134
+ expect(video.h).to.equal(100);
135
+ expect(video.w).to.equal(200);
136
+
137
+ expect(video.maxextended).to.equal(-1);
138
+ expect(video.boxingallowed).to.equal(1);
139
+ expect(video.playbackmethod).to.include(PLAYBACK_METHODS.CLICK_TO_PLAY);
140
+ expect(video.playbackend).to.equal(1);
141
+ expect(video.api).to.deep.equal([2]);
142
+ expect(video.placement).to.be.equal(PLACEMENT.INSTREAM);
143
+ });
144
+
145
+ it('should populate oRTB Content', function () {
146
+ const provider = VideojsProvider(config, videojs, adState, timeState, callbackStorage, utils);
147
+ provider.init();
148
+
149
+ const content = provider.getOrtbContent();
150
+ expect(content.url).to.be.equal('http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4');
151
+ expect(content).to.not.have.property('len');
152
+ });
153
+
154
+ it('should change populated oRTB params when ima present', function () {
155
+ require('videojs-contrib-ads');
156
+ require('videojs-ima');
157
+ config.playerConfig = {
158
+ params: {
159
+ vendorConfig: {
160
+ mediaid: 'vendor-id',
161
+ advertising: {
162
+ tag: ['test-tag']
163
+ }
164
+ }
165
+ }
166
+ }
167
+
168
+ let provider = VideojsProvider(config, videojs, null, null, null, utils);
169
+ provider.init();
170
+ const video = provider.getOrtbVideo();
171
+
172
+ expect(video.protocols).to.include(PROTOCOLS.VAST_2_0);
173
+ expect(video.api).to.include(API_FRAMEWORKS.VPAID_2_0);
174
+ expect(video.mimes).to.include(VPAID_MIME_TYPE);
175
+ });
176
+ //
177
+ // We can't determine what type of outstream play is occuring
178
+ // if the src is absent so we should not set placement
179
+ it('should not set placement when src is absent', function() {
180
+ document.body.innerHTML = `<video preload id='test' width="${200}" height="${100}"></video>`
181
+ const provider = VideojsProvider(config, videojs, null, null, null, utils);
182
+ provider.init();
183
+ const video = provider.getOrtbVideo();
184
+ expect(video).to.not.have.property('placement')
185
+ })
186
+ //
187
+ it('should populate position when fullscreen', function () {
188
+ const provider = VideojsProvider(config, videojs, null, null, null, utils);
189
+ provider.init();
190
+ const player = videojs.getPlayer('test')
191
+ player.isFullscreen = () => true;
192
+ const video = provider.getOrtbVideo();
193
+ expect(video.pos).to.equal(7);
194
+ });
195
+ //
196
+ it('should populate length when loaded', function () {
197
+ const provider = VideojsProvider(config, videojs, null, null, null, utils);
198
+ provider.init();
199
+ const player = videojs.getPlayer('test')
200
+ player.readyState = () => 1
201
+ player.duration = () => 100
202
+ const content = provider.getOrtbContent();
203
+ expect(content.len).to.equal(100);
204
+ });
205
+ //
206
+ it('should return the correct playback method for autoplay', function () {
207
+ const provider = VideojsProvider(config, videojs, null, null, null, utils);
208
+ provider.init();
209
+ const player = videojs.getPlayer('test')
210
+ player.autoplay(true)
211
+ const video = provider.getOrtbVideo();
212
+ expect(video.playbackmethod).to.include(PLAYBACK_METHODS.AUTOPLAY);
213
+ });
214
+ //
215
+ it('should return the correct playback method for autoplay muted', function () {
216
+ const provider = VideojsProvider(config, videojs, null, null, null, utils);
217
+ provider.init();
218
+ const player = videojs.getPlayer('test')
219
+ player.muted = () => true
220
+ player.autoplay = () => true
221
+ const video = provider.getOrtbVideo();
222
+ expect(video.playbackmethod).to.include(PLAYBACK_METHODS.AUTOPLAY_MUTED);
223
+ });
224
+ //
225
+ it('should return the correct playback method for the other autoplay muted', function () {
226
+ const provider = VideojsProvider(config, videojs, null, null, null, utils);
227
+ provider.init();
228
+ const player = videojs.getPlayer('test')
229
+ player.autoplay = () => 'muted'
230
+ const video = provider.getOrtbVideo();
231
+ expect(video.playbackmethod).to.include(PLAYBACK_METHODS.AUTOPLAY_MUTED);
232
+ });
233
+ });
234
+ });
235
+
236
+ describe('utils', function() {
237
+ describe('getSetupConfig', function() {
238
+ it('should return undefined when config is absent', function () {
239
+ expect(utils.getSetupConfig()).to.be.undefined;
240
+ });
241
+
242
+ it('should give priority to vendorConfig', function () {
243
+ const config = {
244
+ autostart: false,
245
+ mute: false,
246
+ params: {
247
+ vendorConfig: {
248
+ autostart: true,
249
+ mute: true,
250
+ other: true
251
+ }
252
+ }
253
+ };
254
+ const setupConfig = utils.getSetupConfig(config);
255
+ expect(setupConfig.autostart).to.be.true;
256
+ expect(setupConfig.mute).to.be.true;
257
+ expect(setupConfig.other).to.be.true;
258
+ });
259
+
260
+ it('should only global apply properties when absent from vendor config', function () {
261
+ const config = {
262
+ autostart: false,
263
+ params: {
264
+ vendorConfig: {
265
+ other: true
266
+ }
267
+ }
268
+ };
269
+ const setupConfig = utils.getSetupConfig(config);
270
+ expect(setupConfig.autostart).to.be.false;
271
+ expect(setupConfig.mute).to.be.undefined;
272
+ expect(setupConfig.other).to.be.true;
273
+ });
274
+ });
275
+
276
+ describe('getAdConfig', function () {
277
+ it('should return empty object when config is absent', function () {
278
+ expect(utils.getAdConfig()).to.deep.equal({});
279
+ });
280
+
281
+ it('should return adPluginConfig', function () {
282
+ const config = {
283
+ params: {
284
+ adPluginConfig: {
285
+ vpaid: true,
286
+ }
287
+ }
288
+ };
289
+
290
+ expect(utils.getAdConfig(config)).to.be.equal(config.params.adPluginConfig);
291
+ });
292
+ });
293
+
294
+ describe('getPositionCode', function() {
295
+ it('should return the correct position when video is above the fold', function () {
296
+ const code = utils.getPositionCode({
297
+ left: window.innerWidth / 10,
298
+ top: 0,
299
+ width: window.innerWidth - window.innerWidth / 10,
300
+ height: window.innerHeight,
301
+ })
302
+ expect(code).to.equal(AD_POSITION.ABOVE_THE_FOLD)
303
+ });
304
+
305
+ it('should return the correct position when video is below the fold', function () {
306
+ const code = utils.getPositionCode({
307
+ left: window.innerWidth / 10,
308
+ top: window.innerHeight,
309
+ width: window.innerWidth - window.innerWidth / 10,
310
+ height: window.innerHeight / 2,
311
+ })
312
+ expect(code).to.equal(AD_POSITION.BELOW_THE_FOLD)
313
+ });
314
+
315
+ it('should return the unkown position when the video is out of bounds', function () {
316
+ const code = utils.getPositionCode({
317
+ left: window.innerWidth / 10,
318
+ top: window.innerHeight,
319
+ width: window.innerWidth,
320
+ height: window.innerHeight,
321
+ })
322
+ expect(code).to.equal(AD_POSITION.UNKNOWN)
323
+ });
324
+ });
325
+
326
+ describe('Playlist', function () {
327
+ const emptyPlayer = {};
328
+
329
+ describe('getPlaylistCount', function () {
330
+ it('should return 1 when playlist is absent', function () {
331
+ expect(utils.getPlaylistCount(emptyPlayer)).to.be.equal(1);
332
+ });
333
+
334
+ it('should return playlist length', function () {
335
+ document.body.innerHTML = `
336
+ <video preload id='test' width="${200}" height="${100}">
337
+ <source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
338
+ </video>`;
339
+ const player = videojs('test', {});
340
+ player.playlist([{
341
+ sources: { src: 'sample.mp4' }
342
+ }, {
343
+ sources: { src: 'sample2.mp4' }
344
+ }]);
345
+ expect(utils.getPlaylistCount(player)).to.be.equal(2);
346
+ player.dispose();
347
+ });
348
+ });
349
+
350
+ describe('getCurrentPlaylistIndex', function () {
351
+ it('should return 0 when playlist is absent', function () {
352
+ expect(utils.getCurrentPlaylistIndex(emptyPlayer)).to.be.equal(0);
353
+ });
354
+ });
355
+
356
+ describe('getCurrentPlaylistItem', function () {
357
+ it('should return undefined when playlist is absent', function () {
358
+ expect(utils.getCurrentPlaylistItem(emptyPlayer)).to.be.undefined;
359
+ });
360
+ });
361
+ });
362
+
363
+ describe('Get Media', function () {
364
+ describe('parseSource', function () {
365
+ it('should return src property when source is object', function () {
366
+ expect(utils.parseSource({
367
+ src: 'test.url',
368
+ other: 'other'
369
+ })).to.be.equal('test.url');
370
+ });
371
+
372
+ it('should return source when it is a string', function () {
373
+ expect(utils.parseSource('test.url')).to.be.equal('test.url');
374
+ });
375
+
376
+ it('should return undefined when not object or string', function () {
377
+ expect(utils.parseSource(() => {})).to.be.undefined;
378
+ });
379
+ });
380
+
381
+ describe('getMediaUrl', function () {
382
+ it('should return undefined when arg is missing', function () {
383
+ expect(utils.getMediaUrl()).to.be.undefined;
384
+ });
385
+
386
+ it('should parse first index when arg is array', function () {
387
+ expect(utils.getMediaUrl(['test.url.1', 'test.url.2'])).to.be.equal('test.url.1');
388
+ });
389
+ });
390
+ });
391
+ })
@@ -0,0 +1,112 @@
1
+ import { baseImpressionVerifier, PB_PREFIX } from 'modules/videoModule/videoImpressionVerifier.js';
2
+
3
+ let trackerMock;
4
+ trackerMock = {
5
+ store: sinon.spy(),
6
+ remove: sinon.spy()
7
+ }
8
+
9
+ describe('Base Impression Verifier', function() {
10
+ describe('trackBid', function () {
11
+ it('should generate uuid', function () {
12
+ const baseVerifier = baseImpressionVerifier(trackerMock);
13
+ const uuid = baseVerifier.trackBid({});
14
+ expect(uuid.substring(0, 3)).to.equal(PB_PREFIX);
15
+ expect(uuid.length).to.be.lessThan(16);
16
+ });
17
+ });
18
+
19
+ describe('getBidIdentifiers', function () {
20
+ it('should match ad id to uuid', function () {
21
+
22
+ });
23
+ });
24
+ });
25
+
26
+ /*
27
+ const adUnitCode = 'test_ad_unit_code';
28
+ const sampleBid = {
29
+ adId: 'test_ad_id',
30
+ adUnitCode,
31
+ vastUrl: 'test_ad_url'
32
+ };
33
+ const sampleAdUnit = {
34
+ code: adUnitCode,
35
+ };
36
+
37
+ const expectedImpressionUrl = 'test_impression_url';
38
+ const expectedImpressionId = 'test_impression_id';
39
+ const expectedErrorUrl = 'test_error_url';
40
+ const expectedVastXml = 'test_xml';
41
+
42
+ it('should not modify the bid\'s adXml when the tracking config is omitted', function () {
43
+ const adUnit = Object.assign({}, sampleAdUnit, { video: { adServer: { tracking: null } } });
44
+ const pbGlobal = Object.assign({}, pbGlobalMock, { adUnits: [ adUnit ] });
45
+ pbVideoFactory(null, () => ({}), pbGlobal, pbEvents);
46
+
47
+ bidAdjustmentCb(sampleBid);
48
+ // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.called).to.be.false;
49
+ // expect(vastXmlEditorMock.buildVastWrapper.called).to.be.false;
50
+ });
51
+
52
+ it('should request a vast wrapper when only an ad url is provided', function () {
53
+ const adUnit = Object.assign({}, sampleAdUnit, { video: { adServer: { tracking: { } } } });
54
+ const pbGlobal = Object.assign({}, pbGlobalMock, { adUnits: [ adUnit ] });
55
+ pbVideoFactory(null, () => ({}), pbGlobal, pbEvents);
56
+
57
+ bidAdjustmentCb(sampleBid);
58
+ // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.called).to.be.false;
59
+ // expect(vastXmlEditorMock.buildVastWrapper.called).to.be.true;
60
+ });
61
+
62
+ it('should request the addition of tracking nodes when an ad xml is provided', function () {
63
+ const adUnit = Object.assign({}, sampleAdUnit, { video: { adServer: { tracking: { } } } });
64
+ const pbGlobal = Object.assign({}, pbGlobalMock, { adUnits: [ adUnit ] });
65
+ pbVideoFactory(null, () => ({}), pbGlobal, pbEvents);
66
+
67
+ const bid = Object.assign({}, sampleBid, { vastXml: 'test_xml' });
68
+ bidAdjustmentCb(bid);
69
+ // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.called).to.be.true;
70
+ // expect(vastXmlEditorMock.buildVastWrapper.called).to.be.false;
71
+ });
72
+
73
+ it('should pass the tracking information as args to the xml editing function', function () {
74
+ const adUnit = Object.assign({}, sampleAdUnit, { video: { adServer: { tracking: {
75
+ impression: {
76
+ url: expectedImpressionUrl,
77
+ id: expectedImpressionId
78
+ },
79
+ error: {
80
+ url: expectedErrorUrl
81
+ }
82
+ } } } });
83
+ const pbGlobal = Object.assign({}, pbGlobalMock, { adUnits: [ adUnit ] });
84
+ pbVideoFactory(null, () => ({}), pbGlobal, pbEvents);
85
+
86
+ const bid = Object.assign({}, sampleBid, { vastXml: expectedVastXml });
87
+ bidAdjustmentCb(bid);
88
+ // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.called).to.be.true;
89
+ // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.calledWith(expectedVastXml, expectedImpressionUrl, expectedImpressionId, expectedErrorUrl))
90
+ // expect(vastXmlEditorMock.buildVastWrapper.called).to.be.false;
91
+ });
92
+
93
+ it('should generate the impression id when not specified in config', function () {
94
+ const adUnit = Object.assign({}, sampleAdUnit, { video: { adServer: { tracking: {
95
+ impression: {
96
+ url: expectedImpressionUrl,
97
+ },
98
+ error: {
99
+ url: expectedErrorUrl
100
+ }
101
+ } } } });
102
+ const pbGlobal = Object.assign({}, pbGlobalMock, { adUnits: [ adUnit ] });
103
+ pbVideoFactory(null, () => ({}), pbGlobal, pbEvents);
104
+
105
+ const bid = Object.assign({}, sampleBid, { vastXml: expectedVastXml });
106
+ bidAdjustmentCb(bid);
107
+ const expectedGeneratedId = sampleBid.adId + '-impression';
108
+ // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.called).to.be.true;
109
+ // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.calledWith(expectedVastXml, expectedImpressionUrl, expectedGeneratedId, expectedErrorUrl))
110
+ // expect(vastXmlEditorMock.buildVastWrapper.called).to.be.false;
111
+ });
112
+ */
@@ -0,0 +1,203 @@
1
+ import {fillBannerImp, bannerResponseProcessor} from '../../../libraries/ortbConverter/processors/banner.js';
2
+ import {BANNER, VIDEO} from '../../../src/mediaTypes.js';
3
+ import {inIframe} from '../../../src/utils.js';
4
+
5
+ const topframe = inIframe() ? 0 : 1;
6
+
7
+ describe('pbjs -> ortb banner conversion', () => {
8
+ [
9
+ {
10
+ t: 'non-banner request',
11
+ request: {
12
+ mediaTypes: {
13
+ video: {}
14
+ }
15
+ },
16
+ imp: {}
17
+ },
18
+ {
19
+ t: 'banner with no sizes',
20
+ request: {
21
+ mediaTypes: {
22
+ banner: {
23
+ pos: 'pos',
24
+ }
25
+ }
26
+ },
27
+ imp: {
28
+ banner: {
29
+ topframe,
30
+ pos: 'pos',
31
+ }
32
+ }
33
+ },
34
+ {
35
+ t: 'single size banner',
36
+ request: {
37
+ mediaTypes: {
38
+ banner: {
39
+ sizes: [1, 2],
40
+ }
41
+ }
42
+ },
43
+ imp: {
44
+ banner: {
45
+ format: [
46
+ {w: 1, h: 2}
47
+ ],
48
+ topframe,
49
+ }
50
+ }
51
+ },
52
+ {
53
+ t: 'multi size banner',
54
+ request: {
55
+ mediaTypes: {
56
+ banner: {
57
+ sizes: [[1, 2], [3, 4]]
58
+ }
59
+ }
60
+ },
61
+ imp: {
62
+ banner: {
63
+ format: [
64
+ {w: 1, h: 2},
65
+ {w: 3, h: 4}
66
+ ],
67
+ topframe,
68
+ }
69
+ }
70
+ },
71
+ {
72
+ t: 'banner with pos param',
73
+ request: {
74
+ mediaTypes: {
75
+ banner: {
76
+ sizes: [1, 2],
77
+ pos: 'pos'
78
+ }
79
+ }
80
+ },
81
+ imp: {
82
+ banner: {
83
+ format: [
84
+ {w: 1, h: 2}
85
+ ],
86
+ pos: 'pos',
87
+ topframe,
88
+ }
89
+ },
90
+ },
91
+ {
92
+ t: 'banner with pos 0',
93
+ request: {
94
+ mediaTypes: {
95
+ banner: {
96
+ sizes: [1, 2],
97
+ pos: 0
98
+ }
99
+ }
100
+ },
101
+ imp: {
102
+ banner: {
103
+ format: [
104
+ {w: 1, h: 2}
105
+ ],
106
+ pos: 0,
107
+ topframe,
108
+ }
109
+ }
110
+ }
111
+ ].forEach(({t, request, imp}) => {
112
+ it(`can convert ${t}`, () => {
113
+ const actual = {};
114
+ fillBannerImp(actual, request, {});
115
+ expect(actual).to.eql(imp);
116
+ });
117
+ });
118
+
119
+ it('should keep ortb2Imp.banner', () => {
120
+ const imp = {
121
+ banner: {
122
+ someParam: 'someValue'
123
+ }
124
+ };
125
+ fillBannerImp(imp, {mediaTypes: {banner: {sizes: [1, 2]}}}, {});
126
+ expect(imp.banner.someParam).to.eql('someValue');
127
+ });
128
+
129
+ it('does nothing if context.mediaType is set but is not BANNER', () => {
130
+ const imp = {};
131
+ fillBannerImp(imp, {mediaTypes: {banner: {sizes: [1, 2]}}}, {mediaType: VIDEO});
132
+ expect(imp).to.eql({});
133
+ })
134
+ });
135
+
136
+ describe('ortb -> pbjs banner conversion', () => {
137
+ let createPixel, seatbid2Banner;
138
+ beforeEach(() => {
139
+ createPixel = sinon.stub().callsFake((url) => `${url}Pixel`);
140
+ seatbid2Banner = bannerResponseProcessor({createPixel});
141
+ });
142
+
143
+ [
144
+ {
145
+ t: 'non-banner request',
146
+ seatbid: {
147
+ adm: 'mockAdm',
148
+ nurl: 'mockNurl'
149
+ },
150
+ response: {
151
+ mediaType: VIDEO
152
+ },
153
+ expected: {
154
+ mediaType: VIDEO
155
+ }
156
+ },
157
+ {
158
+ t: 'response with both adm and nurl',
159
+ seatbid: {
160
+ adm: 'mockAdm',
161
+ nurl: 'mockUrl'
162
+ },
163
+ response: {
164
+ mediaType: BANNER,
165
+ },
166
+ expected: {
167
+ mediaType: BANNER,
168
+ ad: 'mockAdmmockUrlPixel'
169
+ }
170
+ },
171
+ {
172
+ t: 'response with just adm',
173
+ seatbid: {
174
+ adm: 'mockAdm'
175
+ },
176
+ response: {
177
+ mediaType: BANNER,
178
+ },
179
+ expected: {
180
+ mediaType: BANNER,
181
+ ad: 'mockAdm'
182
+ }
183
+ },
184
+ {
185
+ t: 'response with just nurl',
186
+ seatbid: {
187
+ nurl: 'mockNurl'
188
+ },
189
+ response: {
190
+ mediaType: BANNER
191
+ },
192
+ expected: {
193
+ mediaType: BANNER,
194
+ adUrl: 'mockNurl'
195
+ }
196
+ }
197
+ ].forEach(({t, seatbid, response, expected}) => {
198
+ it(`can handle ${t}`, () => {
199
+ seatbid2Banner(response, seatbid, context);
200
+ expect(response).to.eql(expected)
201
+ })
202
+ });
203
+ })