prebid.js 6.7.0 → 6.8.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 (38) hide show
  1. package/integrationExamples/gpt/x-domain/creative.html +53 -26
  2. package/modules/adagioBidAdapter.js +0 -8
  3. package/modules/adagioBidAdapter.md +1 -1
  4. package/modules/appnexusBidAdapter.js +11 -0
  5. package/modules/brandmetricsRtdProvider.js +168 -0
  6. package/modules/brandmetricsRtdProvider.md +40 -0
  7. package/modules/criteoBidAdapter.js +9 -0
  8. package/modules/currency.js +26 -1
  9. package/modules/displayioBidAdapter.js +157 -0
  10. package/modules/displayioBidAdapter.md +148 -0
  11. package/modules/e_volutionBidAdapter.js +158 -0
  12. package/modules/gumgumBidAdapter.js +52 -38
  13. package/modules/interactiveOffersBidAdapter.js +9 -6
  14. package/modules/sovrnBidAdapter.js +93 -18
  15. package/modules/sovrnBidAdapter.md +80 -2
  16. package/modules/undertoneBidAdapter.js +17 -1
  17. package/modules/yahoosspBidAdapter.js +2 -0
  18. package/package.json +1 -1
  19. package/src/adRendering.js +38 -0
  20. package/src/auction.js +44 -9
  21. package/src/prebid.js +3 -19
  22. package/src/secureCreatives.js +111 -42
  23. package/src/utils.js +13 -3
  24. package/test/helpers/syncPromise.js +71 -0
  25. package/test/spec/auctionmanager_spec.js +148 -16
  26. package/test/spec/modules/adagioBidAdapter_spec.js +0 -10
  27. package/test/spec/modules/appnexusBidAdapter_spec.js +27 -0
  28. package/test/spec/modules/brandmetricsRtdProvider_spec.js +191 -0
  29. package/test/spec/modules/criteoBidAdapter_spec.js +21 -0
  30. package/test/spec/modules/currency_spec.js +21 -6
  31. package/test/spec/modules/displayioBidAdapter_spec.js +239 -0
  32. package/test/spec/modules/e_volutionBidAdapter_spec.js +242 -0
  33. package/test/spec/modules/gumgumBidAdapter_spec.js +46 -0
  34. package/test/spec/modules/sovrnBidAdapter_spec.js +413 -333
  35. package/test/spec/modules/undertoneBidAdapter_spec.js +55 -2
  36. package/test/spec/modules/yahoosspBidAdapter_spec.js +10 -0
  37. package/test/spec/unit/pbjs_api_spec.js +17 -1
  38. package/test/spec/unit/secureCreatives_spec.js +85 -0
@@ -1,5 +1,7 @@
1
- import { expect } from 'chai';
2
- import { spec } from 'modules/undertoneBidAdapter.js';
1
+ import {expect} from 'chai';
2
+ import {spec} from 'modules/undertoneBidAdapter.js';
3
+ import {BANNER, VIDEO} from '../../../src/mediaTypes';
4
+ import {deepClone} from '../../../src/utils';
3
5
 
4
6
  const URL = 'https://hb.undertone.com/hb';
5
7
  const BIDDER_CODE = 'undertone';
@@ -276,6 +278,57 @@ describe('Undertone Adapter', () => {
276
278
  sandbox.restore();
277
279
  });
278
280
 
281
+ describe('getFloor', function () {
282
+ it('should send 0 floor when getFloor is undefined', function() {
283
+ const request = spec.buildRequests(videoBidReq, bidderReq);
284
+ const bidReq = JSON.parse(request.data)['x-ut-hb-params'][0];
285
+ expect(bidReq.mediaType).to.deep.equal(VIDEO);
286
+ expect(bidReq.bidfloor).to.deep.equal(0);
287
+ });
288
+ it('should send mocked floor when defined on video media-type', function() {
289
+ const clonedVideoBidReqArr = deepClone(videoBidReq);
290
+ const mockedFloorResponse = {
291
+ currency: 'USD',
292
+ floor: 2.3
293
+ };
294
+ clonedVideoBidReqArr[1].getFloor = () => mockedFloorResponse;
295
+
296
+ const request = spec.buildRequests(clonedVideoBidReqArr, bidderReq);
297
+ const bidReq1 = JSON.parse(request.data)['x-ut-hb-params'][0];
298
+ const bidReq2 = JSON.parse(request.data)['x-ut-hb-params'][1];
299
+ expect(bidReq1.mediaType).to.deep.equal(VIDEO);
300
+ expect(bidReq1.bidfloor).to.deep.equal(0);
301
+
302
+ expect(bidReq2.mediaType).to.deep.equal(VIDEO);
303
+ expect(bidReq2.bidfloor).to.deep.equal(mockedFloorResponse.floor);
304
+ });
305
+ it('should send mocked floor on banner media-type', function() {
306
+ const clonedValidBidReqArr = [deepClone(validBidReq)];
307
+ const mockedFloorResponse = {
308
+ currency: 'USD',
309
+ floor: 2.3
310
+ };
311
+ clonedValidBidReqArr[0].getFloor = () => mockedFloorResponse;
312
+
313
+ const request = spec.buildRequests(clonedValidBidReqArr, bidderReq);
314
+ const bidReq = JSON.parse(request.data)['x-ut-hb-params'][0];
315
+ expect(bidReq.mediaType).to.deep.equal(BANNER);
316
+ expect(bidReq.bidfloor).to.deep.equal(mockedFloorResponse.floor);
317
+ });
318
+ it('should send 0 floor on invalid currency', function() {
319
+ const clonedValidBidReqArr = [deepClone(validBidReq)];
320
+ const mockedFloorResponse = {
321
+ currency: 'EUR',
322
+ floor: 2.3
323
+ };
324
+ clonedValidBidReqArr[0].getFloor = () => mockedFloorResponse;
325
+
326
+ const request = spec.buildRequests(clonedValidBidReqArr, bidderReq);
327
+ const bidReq = JSON.parse(request.data)['x-ut-hb-params'][0];
328
+ expect(bidReq.mediaType).to.deep.equal(BANNER);
329
+ expect(bidReq.bidfloor).to.deep.equal(0);
330
+ });
331
+ });
279
332
  describe('supply chain', function () {
280
333
  it('should send supply chain if found on first bid', function () {
281
334
  const request = spec.buildRequests(supplyChainedBidReqs, bidderReq);
@@ -177,6 +177,16 @@ describe('YahooSSP Bid Adapter:', () => {
177
177
  expect(obj).to.be.an('object');
178
178
  });
179
179
 
180
+ describe('Validate basic properties', () => {
181
+ it('should define the correct bidder code', () => {
182
+ expect(spec.code).to.equal('yahoossp')
183
+ });
184
+
185
+ it('should define the correct vendor ID', () => {
186
+ expect(spec.gvlid).to.equal(25)
187
+ });
188
+ });
189
+
180
190
  describe('getUserSyncs()', () => {
181
191
  const IMAGE_PIXEL_URL = 'http://image-pixel.com/foo/bar?1234&baz=true';
182
192
  const IFRAME_ONE_URL = 'http://image-iframe.com/foo/bar?1234&baz=true';
@@ -16,6 +16,7 @@ import * as auctionModule from 'src/auction.js';
16
16
  import { registerBidder } from 'src/adapters/bidderFactory.js';
17
17
  import { _sendAdToCreative } from 'src/secureCreatives.js';
18
18
  import find from 'core-js-pure/features/array/find.js';
19
+ import {synchronizePromise} from '../../helpers/syncPromise.js';
19
20
 
20
21
  var assert = require('chai').assert;
21
22
  var expect = require('chai').expect;
@@ -190,13 +191,16 @@ window.apntag = {
190
191
  }
191
192
 
192
193
  describe('Unit: Prebid Module', function () {
193
- let bidExpiryStub;
194
+ let bidExpiryStub, promiseSandbox;
194
195
  beforeEach(function () {
196
+ promiseSandbox = sinon.createSandbox();
197
+ synchronizePromise(promiseSandbox);
195
198
  bidExpiryStub = sinon.stub(filters, 'isBidNotExpired').callsFake(() => true);
196
199
  configObj.setConfig({ useBidCache: true });
197
200
  });
198
201
 
199
202
  afterEach(function() {
203
+ promiseSandbox.restore();
200
204
  $$PREBID_GLOBAL$$.adUnits = [];
201
205
  bidExpiryStub.restore();
202
206
  configObj.setConfig({ useBidCache: false });
@@ -1854,11 +1858,23 @@ describe('Unit: Prebid Module', function () {
1854
1858
  pos: 2
1855
1859
  }
1856
1860
  }
1861
+ },
1862
+ {
1863
+ code: 'test6',
1864
+ bids: [],
1865
+ sizes: [300, 250],
1866
+ mediaTypes: {
1867
+ banner: {
1868
+ sizes: [300, 250],
1869
+ pos: 0
1870
+ }
1871
+ }
1857
1872
  }];
1858
1873
  $$PREBID_GLOBAL$$.requestBids({
1859
1874
  adUnits: adUnit
1860
1875
  });
1861
1876
  expect(auctionArgs.adUnits[0].mediaTypes.banner.pos).to.equal(2);
1877
+ expect(auctionArgs.adUnits[1].mediaTypes.banner.pos).to.equal(0);
1862
1878
  });
1863
1879
  });
1864
1880
 
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  _sendAdToCreative, receiveMessage
3
3
  } from 'src/secureCreatives.js';
4
+ import * as secureCreatives from 'src/secureCreatives.js';
4
5
  import * as utils from 'src/utils.js';
5
6
  import {getAdUnits, getBidRequests, getBidResponses} from 'test/fixtures/fixtures.js';
6
7
  import {auctionManager} from 'src/auctionManager.js';
@@ -9,6 +10,7 @@ import * as native from 'src/native.js';
9
10
  import {fireNativeTrackers, getAllAssetsMessage} from 'src/native.js';
10
11
  import events from 'src/events.js';
11
12
  import { config as configObj } from 'src/config.js';
13
+ import 'src/prebid.js';
12
14
 
13
15
  import { expect } from 'chai';
14
16
 
@@ -237,6 +239,38 @@ describe('secureCreatives', () => {
237
239
 
238
240
  configObj.setConfig({'auctionOptions': {}});
239
241
  });
242
+
243
+ it('should emit AD_RENDER_FAILED if requested missing adId', () => {
244
+ const ev = {
245
+ data: JSON.stringify({
246
+ message: 'Prebid Request',
247
+ adId: 'missing'
248
+ })
249
+ };
250
+ receiveMessage(ev);
251
+ sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.AD_RENDER_FAILED, sinon.match({
252
+ reason: CONSTANTS.AD_RENDER_FAILED_REASON.CANNOT_FIND_AD,
253
+ adId: 'missing'
254
+ }));
255
+ });
256
+
257
+ it('should emit AD_RENDER_FAILED if creative can\'t be sent to rendering frame', () => {
258
+ pushBidResponseToAuction({});
259
+ const ev = {
260
+ source: {
261
+ postMessage: sinon.stub().callsFake(() => { throw new Error(); })
262
+ },
263
+ data: JSON.stringify({
264
+ message: 'Prebid Request',
265
+ adId: bidId
266
+ })
267
+ }
268
+ receiveMessage(ev)
269
+ sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.AD_RENDER_FAILED, sinon.match({
270
+ reason: CONSTANTS.AD_RENDER_FAILED_REASON.EXCEPTION,
271
+ adId: bidId
272
+ }));
273
+ });
240
274
  });
241
275
 
242
276
  describe('Prebid Native', function() {
@@ -395,5 +429,56 @@ describe('secureCreatives', () => {
395
429
  expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED);
396
430
  });
397
431
  });
432
+
433
+ describe('Prebid Event', () => {
434
+ Object.entries({
435
+ 'unrendered': [false, (bid) => { delete bid.status; }],
436
+ 'rendered': [true, (bid) => { bid.status = CONSTANTS.BID_STATUS.RENDERED }]
437
+ }).forEach(([test, [shouldEmit, prepBid]]) => {
438
+ describe(`for ${test} bids`, () => {
439
+ beforeEach(() => {
440
+ prepBid(adResponse);
441
+ pushBidResponseToAuction(adResponse);
442
+ });
443
+
444
+ it(`should${shouldEmit ? ' ' : ' not '}emit AD_RENDER_FAILED`, () => {
445
+ const event = {
446
+ data: JSON.stringify({
447
+ message: 'Prebid Event',
448
+ event: CONSTANTS.EVENTS.AD_RENDER_FAILED,
449
+ adId: bidId,
450
+ info: {
451
+ reason: 'Fail reason',
452
+ message: 'Fail message',
453
+ },
454
+ })
455
+ };
456
+ receiveMessage(event);
457
+ expect(stubEmit.calledWith(CONSTANTS.EVENTS.AD_RENDER_FAILED, {
458
+ adId: bidId,
459
+ bid: adResponse,
460
+ reason: 'Fail reason',
461
+ message: 'Fail message'
462
+ })).to.equal(shouldEmit);
463
+ });
464
+
465
+ it(`should${shouldEmit ? ' ' : ' not '}emit AD_RENDER_SUCCEEDED`, () => {
466
+ const event = {
467
+ data: JSON.stringify({
468
+ message: 'Prebid Event',
469
+ event: CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED,
470
+ adId: bidId,
471
+ })
472
+ };
473
+ receiveMessage(event);
474
+ expect(stubEmit.calledWith(CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED, {
475
+ adId: bidId,
476
+ bid: adResponse,
477
+ doc: null
478
+ })).to.equal(shouldEmit);
479
+ });
480
+ });
481
+ });
482
+ });
398
483
  });
399
484
  });