@@ -12,7 +12,13 @@ const bidRequests = [
12
12
params : {
13
13
pkey : 'aaaa1111'
14
14
} ,
15
- userId : { tdid : 'fake-tdid' }
15
+ userId : {
16
+ tdid : 'fake-tdid' ,
17
+ pubcid : 'fake-pubcid'
18
+ } ,
19
+ crumbs : {
20
+ pubcid : 'fake-pubcid-in-crumbs-obj'
21
+ }
16
22
} ,
17
23
{
18
24
bidder : 'sharethrough' ,
@@ -33,8 +39,8 @@ const bidRequests = [
33
39
pkey : 'cccc3333' ,
34
40
iframe : true ,
35
41
iframeSize : [ 500 , 500 ]
36
- } ,
37
- } ,
42
+ }
43
+ }
38
44
] ;
39
45
40
46
const prebidRequests = [
@@ -98,7 +104,7 @@ const prebidRequests = [
98
104
skipIframeBusting : false ,
99
105
sizes : [ [ 300 , 250 ] , [ 300 , 300 ] , [ 250 , 250 ] , [ 600 , 50 ] ]
100
106
}
101
- } ,
107
+ }
102
108
] ;
103
109
104
110
const bidderResponse = {
@@ -121,12 +127,12 @@ const bidderResponse = {
121
127
} ;
122
128
123
129
const setUserAgent = ( uaString ) => {
124
- window . navigator [ '__defineGetter__' ] ( 'userAgent' , function ( ) {
130
+ window . navigator [ '__defineGetter__' ] ( 'userAgent' , function ( ) {
125
131
return uaString ;
126
132
} ) ;
127
133
} ;
128
134
129
- describe ( 'sharethrough internal spec' , function ( ) {
135
+ describe ( 'sharethrough internal spec' , function ( ) {
130
136
let windowSpy , windowTopSpy ;
131
137
132
138
beforeEach ( function ( ) {
@@ -141,7 +147,7 @@ describe('sharethrough internal spec', function () {
141
147
window . top . STR = undefined ;
142
148
} ) ;
143
149
144
- describe ( 'we cannot access top level document' , function ( ) {
150
+ describe ( 'we cannot access top level document' , function ( ) {
145
151
beforeEach ( function ( ) {
146
152
window . lockedInFrame = true ;
147
153
} ) ;
@@ -150,27 +156,27 @@ describe('sharethrough internal spec', function () {
150
156
window . lockedInFrame = false ;
151
157
} ) ;
152
158
153
- it ( 'appends sfp.js to the safeframe' , function ( ) {
159
+ it ( 'appends sfp.js to the safeframe' , function ( ) {
154
160
sharethroughInternal . handleIframe ( ) ;
155
161
expect ( windowSpy . calledOnce ) . to . be . true ;
156
162
} ) ;
157
163
158
- it ( 'does not append anything if sfp.js is already loaded in the safeframe' , function ( ) {
164
+ it ( 'does not append anything if sfp.js is already loaded in the safeframe' , function ( ) {
159
165
window . STR = { Tag : true } ;
160
166
sharethroughInternal . handleIframe ( ) ;
161
167
expect ( windowSpy . notCalled ) . to . be . true ;
162
168
expect ( windowTopSpy . notCalled ) . to . be . true ;
163
169
} ) ;
164
170
} ) ;
165
171
166
- describe ( 'we are able to bust out of the iframe' , function ( ) {
167
- it ( 'appends sfp.js to window.top' , function ( ) {
172
+ describe ( 'we are able to bust out of the iframe' , function ( ) {
173
+ it ( 'appends sfp.js to window.top' , function ( ) {
168
174
sharethroughInternal . handleIframe ( ) ;
169
175
expect ( windowSpy . calledOnce ) . to . be . true ;
170
176
expect ( windowTopSpy . calledOnce ) . to . be . true ;
171
177
} ) ;
172
178
173
- it ( 'only appends sfp-set-targeting.js if sfp.js is already loaded on the page' , function ( ) {
179
+ it ( 'only appends sfp-set-targeting.js if sfp.js is already loaded on the page' , function ( ) {
174
180
window . top . STR = { Tag : true } ;
175
181
sharethroughInternal . handleIframe ( ) ;
176
182
expect ( windowSpy . calledOnce ) . to . be . true ;
@@ -179,15 +185,15 @@ describe('sharethrough internal spec', function () {
179
185
} ) ;
180
186
} ) ;
181
187
182
- describe ( 'sharethrough adapter spec' , function ( ) {
183
- describe ( '.code' , function ( ) {
184
- it ( 'should return a bidder code of sharethrough' , function ( ) {
188
+ describe ( 'sharethrough adapter spec' , function ( ) {
189
+ describe ( '.code' , function ( ) {
190
+ it ( 'should return a bidder code of sharethrough' , function ( ) {
185
191
expect ( spec . code ) . to . eql ( 'sharethrough' ) ;
186
192
} ) ;
187
193
} ) ;
188
194
189
- describe ( '.isBidRequestValid' , function ( ) {
190
- it ( 'should return false if req has no pkey' , function ( ) {
195
+ describe ( '.isBidRequestValid' , function ( ) {
196
+ it ( 'should return false if req has no pkey' , function ( ) {
191
197
const invalidBidRequest = {
192
198
bidder : 'sharethrough' ,
193
199
params : {
@@ -197,7 +203,7 @@ describe('sharethrough adapter spec', function () {
197
203
expect ( spec . isBidRequestValid ( invalidBidRequest ) ) . to . eql ( false ) ;
198
204
} ) ;
199
205
200
- it ( 'should return false if req has wrong bidder code' , function ( ) {
206
+ it ( 'should return false if req has wrong bidder code' , function ( ) {
201
207
const invalidBidRequest = {
202
208
bidder : 'notSharethrough' ,
203
209
params : {
@@ -207,22 +213,22 @@ describe('sharethrough adapter spec', function () {
207
213
expect ( spec . isBidRequestValid ( invalidBidRequest ) ) . to . eql ( false ) ;
208
214
} ) ;
209
215
210
- it ( 'should return true if req is correct' , function ( ) {
216
+ it ( 'should return true if req is correct' , function ( ) {
211
217
expect ( spec . isBidRequestValid ( bidRequests [ 0 ] ) ) . to . eq ( true ) ;
212
218
expect ( spec . isBidRequestValid ( bidRequests [ 1 ] ) ) . to . eq ( true ) ;
213
- } )
219
+ } ) ;
214
220
} ) ;
215
221
216
- describe ( '.buildRequests' , function ( ) {
217
- it ( 'should return an array of requests' , function ( ) {
222
+ describe ( '.buildRequests' , function ( ) {
223
+ it ( 'should return an array of requests' , function ( ) {
218
224
const builtBidRequests = spec . buildRequests ( bidRequests ) ;
219
225
220
226
expect ( builtBidRequests [ 0 ] . url ) . to . eq ( 'https://btlr.sharethrough.com/WYu2BXv1/v1' ) ;
221
227
expect ( builtBidRequests [ 1 ] . url ) . to . eq ( 'https://btlr.sharethrough.com/WYu2BXv1/v1' ) ;
222
228
expect ( builtBidRequests [ 0 ] . method ) . to . eq ( 'GET' ) ;
223
229
} ) ;
224
230
225
- it ( 'should set the instant_play_capable parameter correctly based on browser userAgent string' , function ( ) {
231
+ it ( 'should set the instant_play_capable parameter correctly based on browser userAgent string' , function ( ) {
226
232
setUserAgent ( 'Android Chrome/60' ) ;
227
233
let builtBidRequests = spec . buildRequests ( bidRequests ) ;
228
234
expect ( builtBidRequests [ 0 ] . data . instant_play_capable ) . to . be . true ;
@@ -252,51 +258,64 @@ describe('sharethrough adapter spec', function () {
252
258
const stub = sinon . stub ( sharethroughInternal , 'getProtocol' ) . returns ( 'http:' ) ;
253
259
const bidRequest = spec . buildRequests ( bidRequests , null ) [ 0 ] ;
254
260
expect ( bidRequest . data . secure ) . to . be . false ;
255
- stub . restore ( )
261
+ stub . restore ( ) ;
256
262
} ) ;
257
263
258
264
it ( 'should set the secure parameter to true when the protocol is https' , function ( ) {
259
265
const stub = sinon . stub ( sharethroughInternal , 'getProtocol' ) . returns ( 'https:' ) ;
260
266
const bidRequest = spec . buildRequests ( bidRequests , null ) [ 0 ] ;
261
267
expect ( bidRequest . data . secure ) . to . be . true ;
262
- stub . restore ( )
268
+ stub . restore ( ) ;
263
269
} ) ;
264
270
265
271
it ( 'should set the secure parameter to true when the protocol is neither http or https' , function ( ) {
266
272
const stub = sinon . stub ( sharethroughInternal , 'getProtocol' ) . returns ( 'about:' ) ;
267
273
const bidRequest = spec . buildRequests ( bidRequests , null ) [ 0 ] ;
268
274
expect ( bidRequest . data . secure ) . to . be . true ;
269
- stub . restore ( )
275
+ stub . restore ( ) ;
270
276
} ) ;
271
277
272
- it ( 'should add ccpa parameter if uspConsent is present' , function ( ) {
278
+ it ( 'should add ccpa parameter if uspConsent is present' , function ( ) {
273
279
const uspConsent = '1YNN' ;
274
280
const bidderRequest = { uspConsent : uspConsent } ;
275
281
const bidRequest = spec . buildRequests ( bidRequests , bidderRequest ) [ 0 ] ;
276
282
expect ( bidRequest . data . us_privacy ) . to . eq ( uspConsent ) ;
277
283
} ) ;
278
284
279
- it ( 'should add consent parameters if gdprConsent is present' , function ( ) {
285
+ it ( 'should add consent parameters if gdprConsent is present' , function ( ) {
280
286
const gdprConsent = { consentString : 'consent_string123' , gdprApplies : true } ;
281
287
const bidderRequest = { gdprConsent : gdprConsent } ;
282
288
const bidRequest = spec . buildRequests ( bidRequests , bidderRequest ) [ 0 ] ;
283
289
expect ( bidRequest . data . consent_required ) . to . eq ( true ) ;
284
290
expect ( bidRequest . data . consent_string ) . to . eq ( 'consent_string123' ) ;
285
291
} ) ;
286
292
287
- it ( 'should handle gdprConsent is present but values are undefined case' , function ( ) {
293
+ it ( 'should handle gdprConsent is present but values are undefined case' , function ( ) {
288
294
const gdprConsent = { consent_string : undefined , gdprApplies : undefined } ;
289
295
const bidderRequest = { gdprConsent : gdprConsent } ;
290
296
const bidRequest = spec . buildRequests ( bidRequests , bidderRequest ) [ 0 ] ;
291
- expect ( bidRequest . data ) . to . not . include . any . keys ( 'consent_string' )
297
+ expect ( bidRequest . data ) . to . not . include . any . keys ( 'consent_string' ) ;
292
298
} ) ;
293
299
294
- it ( 'should add the ttduid parameter if a bid request contains a value for Unified ID from The Trade Desk' , function ( ) {
300
+ it ( 'should add the ttduid parameter if a bid request contains a value for Unified ID from The Trade Desk' , function ( ) {
295
301
const bidRequest = spec . buildRequests ( bidRequests ) [ 0 ] ;
296
302
expect ( bidRequest . data . ttduid ) . to . eq ( 'fake-tdid' ) ;
297
303
} ) ;
298
304
299
- it ( 'should add Sharethrough specific parameters' , function ( ) {
305
+ it ( 'should add the pubcid parameter if a bid request contains a value for the Publisher Common ID Module in the' +
306
+ ' userId object of the bidrequest' , function ( ) {
307
+ const bidRequest = spec . buildRequests ( bidRequests ) [ 0 ] ;
308
+ expect ( bidRequest . data . pubcid ) . to . eq ( 'fake-pubcid' ) ;
309
+ } ) ;
310
+
311
+ it ( 'should add the pubcid parameter if a bid request contains a value for the Publisher Common ID Module in the' +
312
+ ' crumbs object of the bidrequest' , function ( ) {
313
+ const bidRequest = spec . buildRequests ( bidRequests ) [ 0 ] ;
314
+ delete bidRequest . userId ;
315
+ expect ( bidRequest . data . pubcid ) . to . eq ( 'fake-pubcid' ) ;
316
+ } ) ;
317
+
318
+ it ( 'should add Sharethrough specific parameters' , function ( ) {
300
319
const builtBidRequests = spec . buildRequests ( bidRequests ) ;
301
320
expect ( builtBidRequests [ 0 ] ) . to . deep . include ( {
302
321
strData : {
@@ -346,8 +365,8 @@ describe('sharethrough adapter spec', function () {
346
365
} ) ;
347
366
} ) ;
348
367
349
- describe ( '.interpretResponse' , function ( ) {
350
- it ( 'returns a correctly parsed out response' , function ( ) {
368
+ describe ( '.interpretResponse' , function ( ) {
369
+ it ( 'returns a correctly parsed out response' , function ( ) {
351
370
expect ( spec . interpretResponse ( bidderResponse , prebidRequests [ 0 ] ) [ 0 ] ) . to . include (
352
371
{
353
372
width : 1 ,
@@ -357,11 +376,11 @@ describe('sharethrough adapter spec', function () {
357
376
dealId : 'aDealId' ,
358
377
currency : 'USD' ,
359
378
netRevenue : true ,
360
- ttl : 360 ,
379
+ ttl : 360
361
380
} ) ;
362
381
} ) ;
363
382
364
- it ( 'returns a correctly parsed out response with largest size when strData.skipIframeBusting is true' , function ( ) {
383
+ it ( 'returns a correctly parsed out response with largest size when strData.skipIframeBusting is true' , function ( ) {
365
384
expect ( spec . interpretResponse ( bidderResponse , prebidRequests [ 1 ] ) [ 0 ] ) . to . include (
366
385
{
367
386
width : 300 ,
@@ -371,11 +390,11 @@ describe('sharethrough adapter spec', function () {
371
390
dealId : 'aDealId' ,
372
391
currency : 'USD' ,
373
392
netRevenue : true ,
374
- ttl : 360 ,
393
+ ttl : 360
375
394
} ) ;
376
395
} ) ;
377
396
378
- it ( 'returns a correctly parsed out response with explicitly defined size when strData.skipIframeBusting is true and strData.iframeSize is provided' , function ( ) {
397
+ it ( 'returns a correctly parsed out response with explicitly defined size when strData.skipIframeBusting is true and strData.iframeSize is provided' , function ( ) {
379
398
expect ( spec . interpretResponse ( bidderResponse , prebidRequests [ 2 ] ) [ 0 ] ) . to . include (
380
399
{
381
400
width : 500 ,
@@ -385,11 +404,11 @@ describe('sharethrough adapter spec', function () {
385
404
dealId : 'aDealId' ,
386
405
currency : 'USD' ,
387
406
netRevenue : true ,
388
- ttl : 360 ,
407
+ ttl : 360
389
408
} ) ;
390
409
} ) ;
391
410
392
- it ( 'returns a correctly parsed out response with explicitly defined size when strData.skipIframeBusting is false and strData.sizes contains [0, 0] only' , function ( ) {
411
+ it ( 'returns a correctly parsed out response with explicitly defined size when strData.skipIframeBusting is false and strData.sizes contains [0, 0] only' , function ( ) {
393
412
expect ( spec . interpretResponse ( bidderResponse , prebidRequests [ 3 ] ) [ 0 ] ) . to . include (
394
413
{
395
414
width : 0 ,
@@ -399,11 +418,11 @@ describe('sharethrough adapter spec', function () {
399
418
dealId : 'aDealId' ,
400
419
currency : 'USD' ,
401
420
netRevenue : true ,
402
- ttl : 360 ,
421
+ ttl : 360
403
422
} ) ;
404
423
} ) ;
405
424
406
- it ( 'returns a correctly parsed out response with explicitly defined size when strData.skipIframeBusting is false and strData.sizes contains multiple sizes' , function ( ) {
425
+ it ( 'returns a correctly parsed out response with explicitly defined size when strData.skipIframeBusting is false and strData.sizes contains multiple sizes' , function ( ) {
407
426
expect ( spec . interpretResponse ( bidderResponse , prebidRequests [ 4 ] ) [ 0 ] ) . to . include (
408
427
{
409
428
width : 300 ,
@@ -413,26 +432,26 @@ describe('sharethrough adapter spec', function () {
413
432
dealId : 'aDealId' ,
414
433
currency : 'USD' ,
415
434
netRevenue : true ,
416
- ttl : 360 ,
435
+ ttl : 360
417
436
} ) ;
418
437
} ) ;
419
438
420
- it ( 'returns a blank array if there are no creatives' , function ( ) {
439
+ it ( 'returns a blank array if there are no creatives' , function ( ) {
421
440
const bidResponse = { body : { creatives : [ ] } } ;
422
441
expect ( spec . interpretResponse ( bidResponse , prebidRequests [ 0 ] ) ) . to . be . an ( 'array' ) . that . is . empty ;
423
442
} ) ;
424
443
425
- it ( 'returns a blank array if body object is empty' , function ( ) {
444
+ it ( 'returns a blank array if body object is empty' , function ( ) {
426
445
const bidResponse = { body : { } } ;
427
446
expect ( spec . interpretResponse ( bidResponse , prebidRequests [ 0 ] ) ) . to . be . an ( 'array' ) . that . is . empty ;
428
447
} ) ;
429
448
430
- it ( 'returns a blank array if body is null' , function ( ) {
449
+ it ( 'returns a blank array if body is null' , function ( ) {
431
450
const bidResponse = { body : null } ;
432
451
expect ( spec . interpretResponse ( bidResponse , prebidRequests [ 0 ] ) ) . to . be . an ( 'array' ) . that . is . empty ;
433
452
} ) ;
434
453
435
- it ( 'correctly generates ad markup when skipIframeBusting is false' , function ( ) {
454
+ it ( 'correctly generates ad markup when skipIframeBusting is false' , function ( ) {
436
455
const adMarkup = spec . interpretResponse ( bidderResponse , prebidRequests [ 0 ] ) [ 0 ] . ad ;
437
456
let resp = null ;
438
457
@@ -447,7 +466,7 @@ describe('sharethrough adapter spec', function () {
447
466
expect ( adMarkup ) . to . match ( / h a n d l e I f r a m e / ) ;
448
467
} ) ;
449
468
450
- it ( 'correctly generates ad markup when skipIframeBusting is true' , function ( ) {
469
+ it ( 'correctly generates ad markup when skipIframeBusting is true' , function ( ) {
451
470
const adMarkup = spec . interpretResponse ( bidderResponse , prebidRequests [ 1 ] ) [ 0 ] . ad ;
452
471
let resp = null ;
453
472
@@ -461,11 +480,11 @@ describe('sharethrough adapter spec', function () {
461
480
} ) ;
462
481
} ) ;
463
482
464
- describe ( '.getUserSyncs' , function ( ) {
483
+ describe ( '.getUserSyncs' , function ( ) {
465
484
const cookieSyncs = [ 'cookieUrl1' , 'cookieUrl2' , 'cookieUrl3' ] ;
466
485
const serverResponses = [ { body : { cookieSyncUrls : cookieSyncs } } ] ;
467
486
468
- it ( 'returns an array of correctly formatted user syncs' , function ( ) {
487
+ it ( 'returns an array of correctly formatted user syncs' , function ( ) {
469
488
const syncArray = spec . getUserSyncs ( { pixelEnabled : true } , serverResponses , null , 'fake-privacy-signal' ) ;
470
489
expect ( syncArray ) . to . deep . equal ( [
471
490
{ type : 'image' , url : 'cookieUrl1&us_privacy=fake-privacy-signal' } ,
@@ -474,22 +493,22 @@ describe('sharethrough adapter spec', function () {
474
493
) ;
475
494
} ) ;
476
495
477
- it ( 'returns an empty array if serverResponses is empty' , function ( ) {
496
+ it ( 'returns an empty array if serverResponses is empty' , function ( ) {
478
497
const syncArray = spec . getUserSyncs ( { pixelEnabled : true } , [ ] ) ;
479
498
expect ( syncArray ) . to . be . an ( 'array' ) . that . is . empty ;
480
499
} ) ;
481
500
482
- it ( 'returns an empty array if the body is null' , function ( ) {
501
+ it ( 'returns an empty array if the body is null' , function ( ) {
483
502
const syncArray = spec . getUserSyncs ( { pixelEnabled : true } , [ { body : null } ] ) ;
484
503
expect ( syncArray ) . to . be . an ( 'array' ) . that . is . empty ;
485
504
} ) ;
486
505
487
- it ( 'returns an empty array if the body.cookieSyncUrls is missing' , function ( ) {
506
+ it ( 'returns an empty array if the body.cookieSyncUrls is missing' , function ( ) {
488
507
const syncArray = spec . getUserSyncs ( { pixelEnabled : true } , [ { body : { creatives : [ 'creative' ] } } ] ) ;
489
508
expect ( syncArray ) . to . be . an ( 'array' ) . that . is . empty ;
490
509
} ) ;
491
510
492
- it ( 'returns an empty array if pixels are not enabled' , function ( ) {
511
+ it ( 'returns an empty array if pixels are not enabled' , function ( ) {
493
512
const syncArray = spec . getUserSyncs ( { pixelEnabled : false } , serverResponses ) ;
494
513
expect ( syncArray ) . to . be . an ( 'array' ) . that . is . empty ;
495
514
} ) ;
0 commit comments