@@ -123,7 +123,8 @@ describe('The Criteo bidding adapter', function () {
123
123
getCookieStub ,
124
124
setCookieStub ,
125
125
getDataFromLocalStorageStub ,
126
- removeDataFromLocalStorageStub ;
126
+ removeDataFromLocalStorageStub ,
127
+ triggerPixelStub ;
127
128
128
129
beforeEach ( function ( ) {
129
130
getConfigStub = sinon . stub ( config , 'getConfig' ) ;
@@ -146,6 +147,8 @@ describe('The Criteo bidding adapter', function () {
146
147
setCookieStub = sinon . stub ( storage , 'setCookie' ) ;
147
148
getDataFromLocalStorageStub = sinon . stub ( storage , 'getDataFromLocalStorage' ) ;
148
149
removeDataFromLocalStorageStub = sinon . stub ( storage , 'removeDataFromLocalStorage' ) ;
150
+
151
+ triggerPixelStub = sinon . stub ( utils , 'triggerPixel' ) ;
149
152
} ) ;
150
153
151
154
afterEach ( function ( ) {
@@ -158,6 +161,7 @@ describe('The Criteo bidding adapter', function () {
158
161
setCookieStub . restore ( ) ;
159
162
getDataFromLocalStorageStub . restore ( ) ;
160
163
removeDataFromLocalStorageStub . restore ( ) ;
164
+ triggerPixelStub . restore ( ) ;
161
165
} ) ;
162
166
163
167
it ( 'should not trigger sync if publisher did not enable iframe based syncs' , function ( ) {
@@ -301,6 +305,30 @@ describe('The Criteo bidding adapter', function () {
301
305
expect ( removeDataFromLocalStorageStub . called ) . to . be . false ;
302
306
expect ( ajaxStub . called ) . to . be . false ;
303
307
} ) ;
308
+
309
+ it ( 'should trigger sync pixel from iframe response' , function ( done ) {
310
+ const userSyncs = spec . getUserSyncs ( syncOptionsIframeEnabled , undefined , undefined , undefined ) ;
311
+
312
+ const event = new MessageEvent ( 'message' , {
313
+ data : {
314
+ requestId : '123456' ,
315
+ callbacks : [
316
+ 'https://example.com/pixel1' ,
317
+ 'https://example.com/pixel2'
318
+ ]
319
+ } ,
320
+ origin : 'https://gum.criteo.com'
321
+ } ) ;
322
+
323
+ window . dispatchEvent ( event ) ;
324
+ setTimeout ( ( ) => {
325
+ expect ( triggerPixelStub . calledTwice ) . to . be . true ;
326
+ expect ( triggerPixelStub . firstCall . calledWith ( 'https://example.com/pixel1' ) ) . to . be . true ;
327
+ expect ( triggerPixelStub . secondCall . calledWith ( 'https://example.com/pixel2' ) ) . to . be . true ;
328
+
329
+ done ( ) ;
330
+ } , 0 ) ;
331
+ } ) ;
304
332
} ) ;
305
333
306
334
describe ( 'isBidRequestValid' , function ( ) {
0 commit comments