prebid.js 6.8.0 → 6.9.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.
- package/.eslintrc.js +8 -1
- package/integrationExamples/gpt/weboramaRtdProvider_example.html +154 -115
- package/integrationExamples/gpt/x-domain/creative.html +13 -6
- package/modules/appnexusBidAdapter.js +3 -2
- package/modules/asealBidAdapter.js +58 -0
- package/modules/asealBidAdapter.md +52 -0
- package/modules/conversantBidAdapter.js +7 -0
- package/modules/improvedigitalBidAdapter.js +5 -0
- package/modules/lunamediahbBidAdapter.js +32 -4
- package/modules/oguryBidAdapter.js +6 -13
- package/modules/priceFloors.js +2 -1
- package/modules/richaudienceBidAdapter.js +7 -2
- package/modules/riseBidAdapter.js +17 -6
- package/modules/rubiconAnalyticsAdapter.js +5 -0
- package/modules/sortableAnalyticsAdapter.js +5 -4
- package/modules/weboramaRtdProvider.js +264 -34
- package/modules/weboramaRtdProvider.md +110 -40
- package/package.json +2 -1
- package/src/adloader.js +2 -1
- package/src/auction.js +59 -64
- package/src/bidderSettings.js +69 -0
- package/src/secureCreatives.js +26 -12
- package/src/targeting.js +3 -2
- package/src/utils.js +0 -7
- package/test/spec/auctionmanager_spec.js +33 -1
- package/test/spec/modules/asealBidAdapter_spec.js +144 -0
- package/test/spec/modules/conversantBidAdapter_spec.js +54 -2
- package/test/spec/modules/improvedigitalBidAdapter_spec.js +19 -0
- package/test/spec/modules/lunamediahbBidAdapter_spec.js +27 -1
- package/test/spec/modules/oguryBidAdapter_spec.js +62 -4
- package/test/spec/modules/riseBidAdapter_spec.js +30 -4
- package/test/spec/modules/rubiconAnalyticsAdapter_spec.js +31 -1
- package/test/spec/modules/sortableAnalyticsAdapter_spec.js +2 -3
- package/test/spec/modules/weboramaRtdProvider_spec.js +536 -20
- package/test/spec/unit/core/bidderSettings_spec.js +123 -0
- package/test/spec/unit/pbjs_api_spec.js +1 -6
- package/test/spec/unit/secureCreatives_spec.js +66 -32
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {bidderSettings, ScopedSettings} from '../../../../src/bidderSettings.js';
|
|
2
|
+
import {expect} from 'chai';
|
|
3
|
+
import * as prebidGlobal from '../../../../src/prebidGlobal';
|
|
4
|
+
import sinon from 'sinon';
|
|
5
|
+
|
|
6
|
+
describe('ScopedSettings', () => {
|
|
7
|
+
let data;
|
|
8
|
+
let settings;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
settings = new ScopedSettings(() => data, 'fallback');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('get', () => {
|
|
15
|
+
it('should retrieve setting from scope', () => {
|
|
16
|
+
data = {
|
|
17
|
+
scope: {key: 'value'}
|
|
18
|
+
};
|
|
19
|
+
expect(settings.get('scope', 'key')).to.equal('value');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should fallback to fallback scope', () => {
|
|
23
|
+
data = {
|
|
24
|
+
fallback: {
|
|
25
|
+
key: 'value'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
expect(settings.get('scope', 'key')).to.equal('value');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should retrieve from default scope if scope is null', () => {
|
|
32
|
+
data = {
|
|
33
|
+
fallback: {
|
|
34
|
+
key: 'value'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
expect(settings.get(null, 'key')).to.equal('value');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should not fall back if own setting has a falsy value', () => {
|
|
42
|
+
data = {
|
|
43
|
+
scope: {
|
|
44
|
+
key: false,
|
|
45
|
+
},
|
|
46
|
+
fallback: {
|
|
47
|
+
key: true
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
expect(settings.get('scope', 'key')).to.equal(false);
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('getOwn', () => {
|
|
55
|
+
it('should not fall back to default scope', () => {
|
|
56
|
+
data = {
|
|
57
|
+
fallback: {
|
|
58
|
+
key: 'value'
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
expect(settings.getOwn('missing', 'key')).to.be.undefined;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should use default if scope is null', () => {
|
|
65
|
+
data = {
|
|
66
|
+
fallback: {
|
|
67
|
+
key: 'value'
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
expect(settings.getOwn(null, 'key')).to.equal('value');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('getScopes', () => {
|
|
75
|
+
it('should return all top-level keys except the default scope', () => {
|
|
76
|
+
data = {
|
|
77
|
+
fallback: {},
|
|
78
|
+
scope1: {},
|
|
79
|
+
scope2: {},
|
|
80
|
+
};
|
|
81
|
+
expect(settings.getScopes()).to.have.members(['scope1', 'scope2']);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('settingsFor', () => {
|
|
86
|
+
it('should merge with default scope', () => {
|
|
87
|
+
data = {
|
|
88
|
+
fallback: {
|
|
89
|
+
dkey: 'value'
|
|
90
|
+
},
|
|
91
|
+
scope: {
|
|
92
|
+
skey: 'value'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
expect(settings.settingsFor('scope')).to.eql({
|
|
96
|
+
dkey: 'value',
|
|
97
|
+
skey: 'value'
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('bidderSettings', () => {
|
|
104
|
+
let sandbox;
|
|
105
|
+
beforeEach(() => {
|
|
106
|
+
sandbox = sinon.sandbox.create();
|
|
107
|
+
sandbox.stub(prebidGlobal, 'getGlobal').returns({
|
|
108
|
+
bidderSettings: {
|
|
109
|
+
scope: {
|
|
110
|
+
key: 'value'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
afterEach(() => {
|
|
117
|
+
sandbox.restore();
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('should fetch data from getGlobal().bidderSettings', () => {
|
|
121
|
+
expect(bidderSettings.get('scope', 'key')).to.equal('value');
|
|
122
|
+
})
|
|
123
|
+
});
|
|
@@ -1006,12 +1006,7 @@ describe('Unit: Prebid Module', function () {
|
|
|
1006
1006
|
adUnitCode: config.adUnitCodes[0],
|
|
1007
1007
|
};
|
|
1008
1008
|
|
|
1009
|
-
|
|
1010
|
-
source: { postMessage: sinon.stub() },
|
|
1011
|
-
origin: 'origin.sf.com'
|
|
1012
|
-
};
|
|
1013
|
-
|
|
1014
|
-
_sendAdToCreative(mockAdObject, event);
|
|
1009
|
+
_sendAdToCreative(mockAdObject, sinon.stub());
|
|
1015
1010
|
|
|
1016
1011
|
expect(slots[0].spyGetSlotElementId.called).to.equal(false);
|
|
1017
1012
|
expect(slots[1].spyGetSlotElementId.called).to.equal(true);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
_sendAdToCreative, receiveMessage
|
|
2
|
+
_sendAdToCreative, getReplier, receiveMessage
|
|
3
3
|
} from 'src/secureCreatives.js';
|
|
4
4
|
import * as secureCreatives from 'src/secureCreatives.js';
|
|
5
5
|
import * as utils from 'src/utils.js';
|
|
@@ -17,6 +17,44 @@ import { expect } from 'chai';
|
|
|
17
17
|
var CONSTANTS = require('src/constants.json');
|
|
18
18
|
|
|
19
19
|
describe('secureCreatives', () => {
|
|
20
|
+
function makeEvent(ev) {
|
|
21
|
+
return Object.assign({origin: 'mock-origin', ports: []}, ev)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe('getReplier', () => {
|
|
25
|
+
it('should use source.postMessage if no MessagePort is available', () => {
|
|
26
|
+
const ev = {
|
|
27
|
+
ports: [],
|
|
28
|
+
source: {
|
|
29
|
+
postMessage: sinon.spy()
|
|
30
|
+
},
|
|
31
|
+
origin: 'mock-origin'
|
|
32
|
+
};
|
|
33
|
+
getReplier(ev)('test');
|
|
34
|
+
sinon.assert.calledWith(ev.source.postMessage, JSON.stringify('test'));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should use MesagePort.postMessage if available', () => {
|
|
38
|
+
const ev = {
|
|
39
|
+
ports: [{
|
|
40
|
+
postMessage: sinon.spy()
|
|
41
|
+
}]
|
|
42
|
+
}
|
|
43
|
+
getReplier(ev)('test');
|
|
44
|
+
sinon.assert.calledWith(ev.ports[0].postMessage, JSON.stringify('test'));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should throw if origin is null and no MessagePort is available', () => {
|
|
48
|
+
const ev = {
|
|
49
|
+
origin: null,
|
|
50
|
+
ports: [],
|
|
51
|
+
postMessage: sinon.spy()
|
|
52
|
+
}
|
|
53
|
+
const reply = getReplier(ev);
|
|
54
|
+
expect(() => reply('test')).to.throw();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
20
58
|
describe('_sendAdToCreative', () => {
|
|
21
59
|
beforeEach(function () {
|
|
22
60
|
sinon.stub(utils, 'logError');
|
|
@@ -42,14 +80,10 @@ describe('secureCreatives', () => {
|
|
|
42
80
|
cpm: '1.00',
|
|
43
81
|
adUnitCode: 'some_dom_id'
|
|
44
82
|
};
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_sendAdToCreative(mockAdObject, event);
|
|
51
|
-
expect(JSON.parse(event.source.postMessage.args[0][0]).ad).to.equal('<script src="http://prebid.org/creative/1.00"></script>');
|
|
52
|
-
expect(JSON.parse(event.source.postMessage.args[0][0]).adUrl).to.equal('http://creative.prebid.org/1.00');
|
|
83
|
+
const reply = sinon.spy();
|
|
84
|
+
_sendAdToCreative(mockAdObject, reply);
|
|
85
|
+
expect(reply.args[0][0].ad).to.equal('<script src="http://prebid.org/creative/1.00"></script>');
|
|
86
|
+
expect(reply.args[0][0].adUrl).to.equal('http://creative.prebid.org/1.00');
|
|
53
87
|
window.googletag = oldVal;
|
|
54
88
|
window.apntag = oldapntag;
|
|
55
89
|
});
|
|
@@ -143,9 +177,9 @@ describe('secureCreatives', () => {
|
|
|
143
177
|
message: 'Prebid Request'
|
|
144
178
|
};
|
|
145
179
|
|
|
146
|
-
const ev = {
|
|
147
|
-
data: JSON.stringify(data)
|
|
148
|
-
};
|
|
180
|
+
const ev = makeEvent({
|
|
181
|
+
data: JSON.stringify(data),
|
|
182
|
+
});
|
|
149
183
|
|
|
150
184
|
receiveMessage(ev);
|
|
151
185
|
|
|
@@ -170,9 +204,9 @@ describe('secureCreatives', () => {
|
|
|
170
204
|
message: 'Prebid Request'
|
|
171
205
|
};
|
|
172
206
|
|
|
173
|
-
const ev = {
|
|
207
|
+
const ev = makeEvent({
|
|
174
208
|
data: JSON.stringify(data)
|
|
175
|
-
};
|
|
209
|
+
});
|
|
176
210
|
|
|
177
211
|
receiveMessage(ev);
|
|
178
212
|
|
|
@@ -211,9 +245,9 @@ describe('secureCreatives', () => {
|
|
|
211
245
|
message: 'Prebid Request'
|
|
212
246
|
};
|
|
213
247
|
|
|
214
|
-
const ev = {
|
|
248
|
+
const ev = makeEvent({
|
|
215
249
|
data: JSON.stringify(data)
|
|
216
|
-
};
|
|
250
|
+
});
|
|
217
251
|
|
|
218
252
|
receiveMessage(ev);
|
|
219
253
|
|
|
@@ -241,12 +275,12 @@ describe('secureCreatives', () => {
|
|
|
241
275
|
});
|
|
242
276
|
|
|
243
277
|
it('should emit AD_RENDER_FAILED if requested missing adId', () => {
|
|
244
|
-
const ev = {
|
|
278
|
+
const ev = makeEvent({
|
|
245
279
|
data: JSON.stringify({
|
|
246
280
|
message: 'Prebid Request',
|
|
247
281
|
adId: 'missing'
|
|
248
282
|
})
|
|
249
|
-
};
|
|
283
|
+
});
|
|
250
284
|
receiveMessage(ev);
|
|
251
285
|
sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.AD_RENDER_FAILED, sinon.match({
|
|
252
286
|
reason: CONSTANTS.AD_RENDER_FAILED_REASON.CANNOT_FIND_AD,
|
|
@@ -256,7 +290,7 @@ describe('secureCreatives', () => {
|
|
|
256
290
|
|
|
257
291
|
it('should emit AD_RENDER_FAILED if creative can\'t be sent to rendering frame', () => {
|
|
258
292
|
pushBidResponseToAuction({});
|
|
259
|
-
const ev = {
|
|
293
|
+
const ev = makeEvent({
|
|
260
294
|
source: {
|
|
261
295
|
postMessage: sinon.stub().callsFake(() => { throw new Error(); })
|
|
262
296
|
},
|
|
@@ -264,7 +298,7 @@ describe('secureCreatives', () => {
|
|
|
264
298
|
message: 'Prebid Request',
|
|
265
299
|
adId: bidId
|
|
266
300
|
})
|
|
267
|
-
}
|
|
301
|
+
});
|
|
268
302
|
receiveMessage(ev)
|
|
269
303
|
sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.AD_RENDER_FAILED, sinon.match({
|
|
270
304
|
reason: CONSTANTS.AD_RENDER_FAILED_REASON.EXCEPTION,
|
|
@@ -283,13 +317,13 @@ describe('secureCreatives', () => {
|
|
|
283
317
|
action: 'allAssetRequest'
|
|
284
318
|
};
|
|
285
319
|
|
|
286
|
-
const ev = {
|
|
320
|
+
const ev = makeEvent({
|
|
287
321
|
data: JSON.stringify(data),
|
|
288
322
|
source: {
|
|
289
323
|
postMessage: sinon.stub()
|
|
290
324
|
},
|
|
291
325
|
origin: 'any origin'
|
|
292
|
-
};
|
|
326
|
+
});
|
|
293
327
|
|
|
294
328
|
receiveMessage(ev);
|
|
295
329
|
|
|
@@ -312,13 +346,13 @@ describe('secureCreatives', () => {
|
|
|
312
346
|
action: 'allAssetRequest'
|
|
313
347
|
};
|
|
314
348
|
|
|
315
|
-
const ev = {
|
|
349
|
+
const ev = makeEvent({
|
|
316
350
|
data: JSON.stringify(data),
|
|
317
351
|
source: {
|
|
318
352
|
postMessage: sinon.stub()
|
|
319
353
|
},
|
|
320
354
|
origin: 'any origin'
|
|
321
|
-
};
|
|
355
|
+
});
|
|
322
356
|
|
|
323
357
|
receiveMessage(ev);
|
|
324
358
|
|
|
@@ -356,13 +390,13 @@ describe('secureCreatives', () => {
|
|
|
356
390
|
action: 'allAssetRequest'
|
|
357
391
|
};
|
|
358
392
|
|
|
359
|
-
const ev = {
|
|
393
|
+
const ev = makeEvent({
|
|
360
394
|
data: JSON.stringify(data),
|
|
361
395
|
source: {
|
|
362
396
|
postMessage: sinon.stub()
|
|
363
397
|
},
|
|
364
398
|
origin: 'any origin'
|
|
365
|
-
};
|
|
399
|
+
});
|
|
366
400
|
|
|
367
401
|
receiveMessage(ev);
|
|
368
402
|
|
|
@@ -400,13 +434,13 @@ describe('secureCreatives', () => {
|
|
|
400
434
|
action: 'click',
|
|
401
435
|
};
|
|
402
436
|
|
|
403
|
-
const ev = {
|
|
437
|
+
const ev = makeEvent({
|
|
404
438
|
data: JSON.stringify(data),
|
|
405
439
|
source: {
|
|
406
440
|
postMessage: sinon.stub()
|
|
407
441
|
},
|
|
408
442
|
origin: 'any origin'
|
|
409
|
-
};
|
|
443
|
+
});
|
|
410
444
|
|
|
411
445
|
receiveMessage(ev);
|
|
412
446
|
|
|
@@ -442,7 +476,7 @@ describe('secureCreatives', () => {
|
|
|
442
476
|
});
|
|
443
477
|
|
|
444
478
|
it(`should${shouldEmit ? ' ' : ' not '}emit AD_RENDER_FAILED`, () => {
|
|
445
|
-
const event = {
|
|
479
|
+
const event = makeEvent({
|
|
446
480
|
data: JSON.stringify({
|
|
447
481
|
message: 'Prebid Event',
|
|
448
482
|
event: CONSTANTS.EVENTS.AD_RENDER_FAILED,
|
|
@@ -452,7 +486,7 @@ describe('secureCreatives', () => {
|
|
|
452
486
|
message: 'Fail message',
|
|
453
487
|
},
|
|
454
488
|
})
|
|
455
|
-
};
|
|
489
|
+
});
|
|
456
490
|
receiveMessage(event);
|
|
457
491
|
expect(stubEmit.calledWith(CONSTANTS.EVENTS.AD_RENDER_FAILED, {
|
|
458
492
|
adId: bidId,
|
|
@@ -463,13 +497,13 @@ describe('secureCreatives', () => {
|
|
|
463
497
|
});
|
|
464
498
|
|
|
465
499
|
it(`should${shouldEmit ? ' ' : ' not '}emit AD_RENDER_SUCCEEDED`, () => {
|
|
466
|
-
const event = {
|
|
500
|
+
const event = makeEvent({
|
|
467
501
|
data: JSON.stringify({
|
|
468
502
|
message: 'Prebid Event',
|
|
469
503
|
event: CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED,
|
|
470
504
|
adId: bidId,
|
|
471
505
|
})
|
|
472
|
-
};
|
|
506
|
+
});
|
|
473
507
|
receiveMessage(event);
|
|
474
508
|
expect(stubEmit.calledWith(CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED, {
|
|
475
509
|
adId: bidId,
|