prebid.js 9.6.0 → 9.7.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/.github/PULL_REQUEST_TEMPLATE.md +1 -1
- package/.github/release-drafter.yml +4 -0
- package/README.md +4 -4
- package/dist/33acrossAnalyticsAdapter.js +1 -1
- package/dist/33acrossBidAdapter.js +1 -1
- package/dist/33acrossIdSystem.js +1 -1
- package/dist/BTBidAdapter.js +1 -1
- package/dist/adagioAnalyticsAdapter.js +1 -1
- package/dist/adagioBidAdapter.js +1 -1
- package/dist/adagioUtils.js +1 -1
- package/dist/addefendBidAdapter.js +1 -1
- package/dist/adgenerationBidAdapter.js +1 -1
- package/dist/adlooxRtdProvider.js +1 -1
- package/dist/adqueryBidAdapter.js +1 -1
- package/dist/adrelevantisBidAdapter.js +1 -1
- package/dist/adstirBidAdapter.js +1 -1
- package/dist/adtrgtmeBidAdapter.js +1 -1
- package/dist/adxcgAnalyticsAdapter.js +1 -1
- package/dist/adxcgBidAdapter.js +1 -1
- package/dist/adyoulikeBidAdapter.js +1 -1
- package/dist/agmaAnalyticsAdapter.js +1 -1
- package/dist/ajaBidAdapter.js +1 -1
- package/dist/amxBidAdapter.js +1 -1
- package/dist/amxIdSystem.js +1 -1
- package/dist/appierAnalyticsAdapter.js +1 -1
- package/dist/appnexusBidAdapter.js +1 -1
- package/dist/asoBidAdapter.js +1 -1
- package/dist/axonixBidAdapter.js +1 -1
- package/dist/bidglassBidAdapter.js +1 -1
- package/dist/big-richmediaBidAdapter.js +1 -1
- package/dist/bridBidAdapter.js +1 -1
- package/dist/bridgewellBidAdapter.js +1 -1
- package/dist/brightMountainMediaBidAdapter.js +1 -1
- package/dist/carodaBidAdapter.js +1 -1
- package/dist/chtnwBidAdapter.js +1 -1
- package/dist/chunk-core.js +1 -1
- package/dist/cleanmedianetBidAdapter.js +1 -1
- package/dist/concertBidAdapter.js +1 -1
- package/dist/connectadBidAdapter.js +1 -1
- package/dist/connectionInfo.js +1 -0
- package/dist/consumableBidAdapter.js +1 -1
- package/dist/conversantAnalyticsAdapter.js +1 -1
- package/dist/conversantBidAdapter.js +1 -1
- package/dist/craftBidAdapter.js +1 -1
- package/dist/criteoBidAdapter.js +1 -1
- package/dist/cwireBidAdapter.js +1 -1
- package/dist/dailymotionBidAdapter.js +1 -1
- package/dist/dependencies.json +5 -1
- package/dist/docereeAdManagerBidAdapter.js +1 -1
- package/dist/dspxBidAdapter.js +1 -1
- package/dist/dxkultureBidAdapter.js +1 -1
- package/dist/eplanningBidAdapter.js +1 -1
- package/dist/euidIdSystem.js +1 -1
- package/dist/exadsBidAdapter.js +1 -1
- package/dist/feedadBidAdapter.js +1 -1
- package/dist/finativeBidAdapter.js +1 -1
- package/dist/freewheel-sspBidAdapter.js +1 -1
- package/dist/gamoshiBidAdapter.js +1 -1
- package/dist/gmosspBidAdapter.js +1 -1
- package/dist/goldbachBidAdapter.js +1 -1
- package/dist/greenbidsAnalyticsAdapter.js +1 -1
- package/dist/greenbidsRtdProvider.js +1 -1
- package/dist/gridBidAdapter.js +1 -1
- package/dist/gumgumBidAdapter.js +1 -1
- package/dist/h12mediaBidAdapter.js +1 -1
- package/dist/hypelabBidAdapter.js +1 -1
- package/dist/id5AnalyticsAdapter.js +1 -1
- package/dist/id5IdSystem.js +1 -1
- package/dist/idImportLibrary.js +1 -1
- package/dist/imdsBidAdapter.js +1 -1
- package/dist/improvedigitalBidAdapter.js +1 -1
- package/dist/insticatorBidAdapter.js +1 -1
- package/dist/intentIqAnalyticsAdapter.js +1 -1
- package/dist/ixBidAdapter.js +1 -1
- package/dist/jixieBidAdapter.js +1 -1
- package/dist/justpremiumBidAdapter.js +1 -1
- package/dist/kargoBidAdapter.js +1 -1
- package/dist/kimberliteBidAdapter.js +1 -1
- package/dist/konduitAnalyticsAdapter.js +1 -1
- package/dist/kueezBidAdapter.js +1 -1
- package/dist/lassoBidAdapter.js +1 -1
- package/dist/lifestreetBidAdapter.js +1 -1
- package/dist/liveIntentIdSystem.js +1 -1
- package/dist/logicadBidAdapter.js +1 -1
- package/dist/loglyliftBidAdapter.js +1 -1
- package/dist/luceadBidAdapter.js +1 -1
- package/dist/mabidderBidAdapter.js +1 -1
- package/dist/magniteAnalyticsAdapter.js +1 -1
- package/dist/malltvAnalyticsAdapter.js +1 -1
- package/dist/marsmediaBidAdapter.js +1 -1
- package/dist/mediafuseBidAdapter.js +1 -1
- package/dist/medianetAnalyticsAdapter.js +1 -1
- package/dist/medianetBidAdapter.js +1 -1
- package/dist/mediasquareBidAdapter.js +1 -1
- package/dist/mgidBidAdapter.js +1 -1
- package/dist/missenaBidAdapter.js +1 -1
- package/dist/mobianRtdProvider.js +1 -1
- package/dist/nexx360BidAdapter.js +1 -1
- package/dist/nobidAnalyticsAdapter.js +1 -1
- package/dist/nobidBidAdapter.js +1 -1
- package/dist/not-for-prod/prebid.js +161 -158
- package/dist/oguryBidAdapter.js +1 -1
- package/dist/onetagBidAdapter.js +1 -1
- package/dist/ooloAnalyticsAdapter.js +1 -1
- package/dist/openxBidAdapter.js +1 -1
- package/dist/optidigitalBidAdapter.js +1 -1
- package/dist/orbidderBidAdapter.js +1 -1
- package/dist/ortbConverter.js +1 -1
- package/dist/outbrainBidAdapter.js +1 -1
- package/dist/ownadxBidAdapter.js +1 -0
- package/dist/pixfutureBidAdapter.js +1 -1
- package/dist/prismaBidAdapter.js +1 -1
- package/dist/publinkIdSystem.js +1 -1
- package/dist/pubmaticAnalyticsAdapter.js +1 -1
- package/dist/pubmaticBidAdapter.js +1 -1
- package/dist/pubwiseAnalyticsAdapter.js +1 -1
- package/dist/pubxaiAnalyticsAdapter.js +1 -1
- package/dist/pxyzBidAdapter.js +1 -1
- package/dist/quantcastBidAdapter.js +1 -1
- package/dist/readpeakBidAdapter.js +1 -1
- package/dist/relaidoBidAdapter.js +1 -1
- package/dist/retailspotBidAdapter.js +1 -1
- package/dist/rhythmoneBidAdapter.js +1 -1
- package/dist/riseUtils.js +1 -1
- package/dist/rubiconBidAdapter.js +1 -1
- package/dist/seedingAllianceBidAdapter.js +1 -1
- package/dist/seedtagBidAdapter.js +1 -1
- package/dist/sharethroughAnalyticsAdapter.js +1 -1
- package/dist/sharethroughBidAdapter.js +1 -1
- package/dist/smaatoBidAdapter.js +1 -1
- package/dist/smartadserverBidAdapter.js +1 -1
- package/dist/smartxBidAdapter.js +1 -1
- package/dist/smilewantedBidAdapter.js +1 -1
- package/dist/snigelBidAdapter.js +1 -1
- package/dist/sonobiBidAdapter.js +1 -1
- package/dist/sovrnBidAdapter.js +1 -1
- package/dist/sspBCBidAdapter.js +1 -1
- package/dist/stvBidAdapter.js +1 -1
- package/dist/sublimeBidAdapter.js +1 -1
- package/dist/taboolaBidAdapter.js +1 -1
- package/dist/tappxBidAdapter.js +1 -1
- package/dist/targetVideoBidAdapter.js +1 -1
- package/dist/teadsBidAdapter.js +1 -1
- package/dist/terceptAnalyticsAdapter.js +1 -1
- package/dist/themoneytizerBidAdapter.js +1 -1
- package/dist/trionBidAdapter.js +1 -1
- package/dist/tripleliftBidAdapter.js +1 -1
- package/dist/ttdBidAdapter.js +1 -1
- package/dist/ucfunnelAnalyticsAdapter.js +1 -1
- package/dist/uid2IdSystem.js +1 -1
- package/dist/underdogmediaBidAdapter.js +1 -1
- package/dist/undertoneBidAdapter.js +1 -1
- package/dist/unrulyBidAdapter.js +1 -1
- package/dist/viantOrtbBidAdapter.js +1 -1
- package/dist/vidazooUtils.js +1 -1
- package/dist/videobyteBidAdapter.js +1 -1
- package/dist/visxBidAdapter.js +1 -1
- package/dist/vuukleBidAdapter.js +1 -1
- package/dist/widespaceBidAdapter.js +1 -1
- package/dist/winrBidAdapter.js +1 -1
- package/dist/wurflRtdProvider.js +1 -0
- package/dist/yahooAdsBidAdapter.js +1 -1
- package/dist/yieldmoBidAdapter.js +1 -1
- package/dist/yieldoneAnalyticsAdapter.js +1 -1
- package/integrationExamples/gpt/wurflRtdProvider_example.html +106 -0
- package/libraries/connectionInfo/connectionUtils.js +33 -0
- package/libraries/ortbConverter/processors/video.js +2 -24
- package/libraries/riseUtils/index.js +2 -1
- package/libraries/vidazooUtils/bidderUtils.js +16 -0
- package/modules/.submodules.json +3 -1
- package/modules/51DegreesRtdProvider.md +11 -7
- package/modules/adagioBidAdapter.js +10 -50
- package/modules/appnexusBidAdapter.js +1 -1
- package/modules/cleanmedianetBidAdapter.js +1 -1
- package/modules/dailymotionBidAdapter.js +19 -0
- package/modules/docereeAdManagerBidAdapter.js +9 -12
- package/modules/gamoshiBidAdapter.js +1 -1
- package/modules/greenbidsAnalyticsAdapter.js +7 -4
- package/modules/greenbidsRtdProvider.js +15 -5
- package/modules/id5IdSystem.js +14 -93
- package/modules/idImportLibrary.js +14 -6
- package/modules/mobianRtdProvider.js +28 -14
- package/modules/ownadxBidAdapter.js +99 -0
- package/modules/prismaBidAdapter.js +1 -27
- package/modules/pubmaticBidAdapter.js +2 -1
- package/modules/sharethroughBidAdapter.js +5 -0
- package/modules/ttdBidAdapter.js +14 -32
- package/modules/viantOrtbBidAdapter.js +1 -1
- package/modules/wurflRtdProvider.js +213 -0
- package/modules/wurflRtdProvider.md +67 -0
- package/package.json +1 -1
- package/src/adloader.js +1 -0
- package/src/prebid.js +2 -1
- package/src/video.js +78 -1
- package/test/spec/modules/adagioBidAdapter_spec.js +0 -1
- package/test/spec/modules/appnexusBidAdapter_spec.js +0 -33
- package/test/spec/modules/cleanmedianetBidAdapter_spec.js +1 -1
- package/test/spec/modules/dailymotionBidAdapter_spec.js +50 -0
- package/test/spec/modules/docereeAdManagerBidAdapter_spec.js +1 -0
- package/test/spec/modules/gamoshiBidAdapter_spec.js +1 -1
- package/test/spec/modules/id5IdSystem_spec.js +25 -98
- package/test/spec/modules/idImportLibrary_spec.js +14 -0
- package/test/spec/modules/mobianRtdProvider_spec.js +46 -43
- package/test/spec/modules/ownadxBidAdapter_spec.js +103 -0
- package/test/spec/modules/pubmaticBidAdapter_spec.js +18 -0
- package/test/spec/modules/sharethroughBidAdapter_spec.js +35 -0
- package/test/spec/modules/ttdBidAdapter_spec.js +10 -1
- package/test/spec/modules/viantOrtbBidAdapter_spec.js +1 -1
- package/test/spec/modules/vidazooBidAdapter_spec.js +12 -4
- package/test/spec/modules/wurflRtdProvider_spec.js +324 -0
- package/test/spec/video_spec.js +103 -1
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bidderData,
|
|
3
|
+
enrichBidderRequest,
|
|
4
|
+
lowEntropyData,
|
|
5
|
+
wurflSubmodule,
|
|
6
|
+
} from 'modules/wurflRtdProvider';
|
|
7
|
+
import * as ajaxModule from 'src/ajax';
|
|
8
|
+
import { loadExternalScriptStub } from 'test/mocks/adloaderStub.js';
|
|
9
|
+
|
|
10
|
+
describe('wurflRtdProvider', function () {
|
|
11
|
+
describe('wurflSubmodule', function () {
|
|
12
|
+
const altHost = 'http://example.local/wurfl.js';
|
|
13
|
+
const wurfl_pbjs = {
|
|
14
|
+
low_entropy_caps: ['complete_device_name', 'form_factor', 'is_mobile'],
|
|
15
|
+
caps: [
|
|
16
|
+
'advertised_browser',
|
|
17
|
+
'advertised_browser_version',
|
|
18
|
+
'advertised_device_os',
|
|
19
|
+
'advertised_device_os_version',
|
|
20
|
+
'brand_name',
|
|
21
|
+
'complete_device_name',
|
|
22
|
+
'form_factor',
|
|
23
|
+
'is_app_webview',
|
|
24
|
+
'is_full_desktop',
|
|
25
|
+
'is_mobile',
|
|
26
|
+
'is_robot',
|
|
27
|
+
'is_smartphone',
|
|
28
|
+
'is_smarttv',
|
|
29
|
+
'is_tablet',
|
|
30
|
+
'manufacturer_name',
|
|
31
|
+
'marketing_name'
|
|
32
|
+
],
|
|
33
|
+
authorized_bidders: {
|
|
34
|
+
'bidder1': [0, 1, 2, 3, 4, 5, 6, 7, 10, 13, 15],
|
|
35
|
+
'bidder2': [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const WURFL = {
|
|
40
|
+
advertised_browser: 'Chrome',
|
|
41
|
+
advertised_browser_version: '125.0.6422.76',
|
|
42
|
+
advertised_device_os: 'Linux',
|
|
43
|
+
advertised_device_os_version: '6.5.0',
|
|
44
|
+
brand_name: 'Google',
|
|
45
|
+
complete_device_name: 'Google Chrome',
|
|
46
|
+
form_factor: 'Desktop',
|
|
47
|
+
is_app_webview: !1,
|
|
48
|
+
is_full_desktop: !0,
|
|
49
|
+
is_mobile: !1,
|
|
50
|
+
is_robot: !1,
|
|
51
|
+
is_smartphone: !1,
|
|
52
|
+
is_smarttv: !1,
|
|
53
|
+
is_tablet: !1,
|
|
54
|
+
manufacturer_name: '',
|
|
55
|
+
marketing_name: '',
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// expected analytics values
|
|
59
|
+
const expectedStatsURL = 'https://prebid.wurflcloud.com/v1/prebid/stats';
|
|
60
|
+
const expectedData = JSON.stringify({ bidders: ['bidder1', 'bidder2'] });
|
|
61
|
+
|
|
62
|
+
let sandbox;
|
|
63
|
+
|
|
64
|
+
beforeEach(function() {
|
|
65
|
+
sandbox = sinon.createSandbox();
|
|
66
|
+
window.WURFLPromises = {
|
|
67
|
+
init: new Promise(function(resolve, reject) { resolve({ WURFL, wurfl_pbjs }) }),
|
|
68
|
+
complete: new Promise(function(resolve, reject) { resolve({ WURFL, wurfl_pbjs }) }),
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
afterEach(() => {
|
|
73
|
+
// Restore the original functions
|
|
74
|
+
sandbox.restore();
|
|
75
|
+
window.WURFLPromises = undefined;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Bid request config
|
|
79
|
+
const reqBidsConfigObj = {
|
|
80
|
+
adUnits: [{
|
|
81
|
+
bids: [
|
|
82
|
+
{ bidder: 'bidder1' },
|
|
83
|
+
{ bidder: 'bidder2' },
|
|
84
|
+
{ bidder: 'bidder3' },
|
|
85
|
+
]
|
|
86
|
+
}],
|
|
87
|
+
ortb2Fragments: {
|
|
88
|
+
bidder: {},
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
it('initialises the WURFL RTD provider', function () {
|
|
93
|
+
expect(wurflSubmodule.init()).to.be.true;
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should enrich the bid request data', (done) => {
|
|
97
|
+
const expectedURL = new URL(altHost);
|
|
98
|
+
expectedURL.searchParams.set('debug', true);
|
|
99
|
+
expectedURL.searchParams.set('mode', 'prebid');
|
|
100
|
+
|
|
101
|
+
const callback = () => {
|
|
102
|
+
expect(reqBidsConfigObj.ortb2Fragments.bidder).to.deep.equal({
|
|
103
|
+
bidder1: {
|
|
104
|
+
device: {
|
|
105
|
+
ext: {
|
|
106
|
+
wurfl: {
|
|
107
|
+
advertised_browser: 'Chrome',
|
|
108
|
+
advertised_browser_version: '125.0.6422.76',
|
|
109
|
+
advertised_device_os: 'Linux',
|
|
110
|
+
advertised_device_os_version: '6.5.0',
|
|
111
|
+
brand_name: 'Google',
|
|
112
|
+
complete_device_name: 'Google Chrome',
|
|
113
|
+
form_factor: 'Desktop',
|
|
114
|
+
is_app_webview: !1,
|
|
115
|
+
is_robot: !1,
|
|
116
|
+
is_tablet: !1,
|
|
117
|
+
marketing_name: '',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
bidder2: {
|
|
123
|
+
device: {
|
|
124
|
+
ext: {
|
|
125
|
+
wurfl: {
|
|
126
|
+
complete_device_name: 'Google Chrome',
|
|
127
|
+
form_factor: 'Desktop',
|
|
128
|
+
is_app_webview: !1,
|
|
129
|
+
is_full_desktop: !0,
|
|
130
|
+
is_mobile: !1,
|
|
131
|
+
is_robot: !1,
|
|
132
|
+
is_smartphone: !1,
|
|
133
|
+
is_smarttv: !1,
|
|
134
|
+
is_tablet: !1,
|
|
135
|
+
manufacturer_name: '',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
bidder3: {
|
|
141
|
+
device: {
|
|
142
|
+
ext: {
|
|
143
|
+
wurfl: {
|
|
144
|
+
complete_device_name: 'Google Chrome',
|
|
145
|
+
form_factor: 'Desktop',
|
|
146
|
+
is_mobile: !1,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
done();
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const config = {
|
|
156
|
+
params: {
|
|
157
|
+
altHost: altHost,
|
|
158
|
+
debug: true,
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const userConsent = {};
|
|
162
|
+
|
|
163
|
+
wurflSubmodule.getBidRequestData(reqBidsConfigObj, callback, config, userConsent);
|
|
164
|
+
expect(loadExternalScriptStub.calledOnce).to.be.true;
|
|
165
|
+
const loadExternalScriptCall = loadExternalScriptStub.getCall(0);
|
|
166
|
+
expect(loadExternalScriptCall.args[0]).to.equal(expectedURL.toString());
|
|
167
|
+
expect(loadExternalScriptCall.args[1]).to.equal('wurfl');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('onAuctionEndEvent: should send analytics data using navigator.sendBeacon, if available', () => {
|
|
171
|
+
const auctionDetails = {};
|
|
172
|
+
const config = {};
|
|
173
|
+
const userConsent = {};
|
|
174
|
+
|
|
175
|
+
const sendBeaconStub = sandbox.stub(navigator, 'sendBeacon');
|
|
176
|
+
|
|
177
|
+
// Call the function
|
|
178
|
+
wurflSubmodule.onAuctionEndEvent(auctionDetails, config, userConsent);
|
|
179
|
+
|
|
180
|
+
// Assertions
|
|
181
|
+
expect(sendBeaconStub.calledOnce).to.be.true;
|
|
182
|
+
expect(sendBeaconStub.calledWithExactly(expectedStatsURL, expectedData)).to.be.true;
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('onAuctionEndEvent: should send analytics data using fetch as fallback, if navigator.sendBeacon is not available', () => {
|
|
186
|
+
const auctionDetails = {};
|
|
187
|
+
const config = {};
|
|
188
|
+
const userConsent = {};
|
|
189
|
+
|
|
190
|
+
const sendBeaconStub = sandbox.stub(navigator, 'sendBeacon').value(undefined);
|
|
191
|
+
const windowFetchStub = sandbox.stub(window, 'fetch');
|
|
192
|
+
const fetchAjaxStub = sandbox.stub(ajaxModule, 'fetch');
|
|
193
|
+
|
|
194
|
+
// Call the function
|
|
195
|
+
wurflSubmodule.onAuctionEndEvent(auctionDetails, config, userConsent);
|
|
196
|
+
|
|
197
|
+
// Assertions
|
|
198
|
+
expect(sendBeaconStub.called).to.be.false;
|
|
199
|
+
|
|
200
|
+
expect(fetchAjaxStub.calledOnce).to.be.true;
|
|
201
|
+
const fetchAjaxCall = fetchAjaxStub.getCall(0);
|
|
202
|
+
expect(fetchAjaxCall.args[0]).to.equal(expectedStatsURL);
|
|
203
|
+
expect(fetchAjaxCall.args[1].method).to.equal('POST');
|
|
204
|
+
expect(fetchAjaxCall.args[1].body).to.equal(expectedData);
|
|
205
|
+
expect(fetchAjaxCall.args[1].mode).to.equal('no-cors');
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
describe('bidderData', () => {
|
|
210
|
+
it('should return the WURFL data for a bidder', () => {
|
|
211
|
+
const wjsData = {
|
|
212
|
+
capability1: 'value1',
|
|
213
|
+
capability2: 'value2',
|
|
214
|
+
capability3: 'value3',
|
|
215
|
+
};
|
|
216
|
+
const caps = ['capability1', 'capability2', 'capability3'];
|
|
217
|
+
const filter = [0, 2];
|
|
218
|
+
|
|
219
|
+
const result = bidderData(wjsData, caps, filter);
|
|
220
|
+
|
|
221
|
+
expect(result).to.deep.equal({
|
|
222
|
+
capability1: 'value1',
|
|
223
|
+
capability3: 'value3',
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('should return an empty object if the filter is empty', () => {
|
|
228
|
+
const wjsData = {
|
|
229
|
+
capability1: 'value1',
|
|
230
|
+
capability2: 'value2',
|
|
231
|
+
capability3: 'value3',
|
|
232
|
+
};
|
|
233
|
+
const caps = ['capability1', 'capability3'];
|
|
234
|
+
const filter = [];
|
|
235
|
+
|
|
236
|
+
const result = bidderData(wjsData, caps, filter);
|
|
237
|
+
|
|
238
|
+
expect(result).to.deep.equal({});
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
describe('lowEntropyData', () => {
|
|
243
|
+
it('should return the correct low entropy data for Apple devices', () => {
|
|
244
|
+
const wjsData = {
|
|
245
|
+
complete_device_name: 'Apple iPhone X',
|
|
246
|
+
form_factor: 'Smartphone',
|
|
247
|
+
is_mobile: !0,
|
|
248
|
+
};
|
|
249
|
+
const lowEntropyCaps = ['complete_device_name', 'form_factor', 'is_mobile'];
|
|
250
|
+
const expectedData = {
|
|
251
|
+
complete_device_name: 'Apple iPhone',
|
|
252
|
+
form_factor: 'Smartphone',
|
|
253
|
+
is_mobile: !0,
|
|
254
|
+
};
|
|
255
|
+
const result = lowEntropyData(wjsData, lowEntropyCaps);
|
|
256
|
+
expect(result).to.deep.equal(expectedData);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('should return the correct low entropy data for Android devices', () => {
|
|
260
|
+
const wjsData = {
|
|
261
|
+
complete_device_name: 'Samsung SM-G981B (Galaxy S20 5G)',
|
|
262
|
+
form_factor: 'Smartphone',
|
|
263
|
+
is_mobile: !0,
|
|
264
|
+
};
|
|
265
|
+
const lowEntropyCaps = ['complete_device_name', 'form_factor', 'is_mobile'];
|
|
266
|
+
const expectedData = {
|
|
267
|
+
complete_device_name: 'Samsung SM-G981B (Galaxy S20 5G)',
|
|
268
|
+
form_factor: 'Smartphone',
|
|
269
|
+
is_mobile: !0,
|
|
270
|
+
};
|
|
271
|
+
const result = lowEntropyData(wjsData, lowEntropyCaps);
|
|
272
|
+
expect(result).to.deep.equal(expectedData);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it('should return an empty object if the lowEntropyCaps array is empty', () => {
|
|
276
|
+
const wjsData = {
|
|
277
|
+
complete_device_name: 'Samsung SM-G981B (Galaxy S20 5G)',
|
|
278
|
+
form_factor: 'Smartphone',
|
|
279
|
+
is_mobile: !0,
|
|
280
|
+
};
|
|
281
|
+
const lowEntropyCaps = [];
|
|
282
|
+
const expectedData = {};
|
|
283
|
+
const result = lowEntropyData(wjsData, lowEntropyCaps);
|
|
284
|
+
expect(result).to.deep.equal(expectedData);
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
describe('enrichBidderRequest', () => {
|
|
289
|
+
it('should enrich the bidder request with WURFL data', () => {
|
|
290
|
+
const reqBidsConfigObj = {
|
|
291
|
+
ortb2Fragments: {
|
|
292
|
+
bidder: {
|
|
293
|
+
exampleBidder: {
|
|
294
|
+
device: {
|
|
295
|
+
ua: 'user-agent',
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
const bidderCode = 'exampleBidder';
|
|
302
|
+
const wjsData = {
|
|
303
|
+
capability1: 'value1',
|
|
304
|
+
capability2: 'value2'
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
enrichBidderRequest(reqBidsConfigObj, bidderCode, wjsData);
|
|
308
|
+
|
|
309
|
+
expect(reqBidsConfigObj.ortb2Fragments.bidder).to.deep.equal({
|
|
310
|
+
exampleBidder: {
|
|
311
|
+
device: {
|
|
312
|
+
ua: 'user-agent',
|
|
313
|
+
ext: {
|
|
314
|
+
wurfl: {
|
|
315
|
+
capability1: 'value1',
|
|
316
|
+
capability2: 'value2'
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
});
|
package/test/spec/video_spec.js
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import {fillVideoDefaults, isValidVideoBid} from 'src/video.js';
|
|
1
|
+
import {fillVideoDefaults, isValidVideoBid, validateOrtbVideoFields} from 'src/video.js';
|
|
2
2
|
import {hook} from '../../src/hook.js';
|
|
3
3
|
import {stubAuctionIndex} from '../helpers/indexStub.js';
|
|
4
|
+
import * as utils from '../../src/utils.js';
|
|
4
5
|
|
|
5
6
|
describe('video.js', function () {
|
|
7
|
+
let sandbox;
|
|
8
|
+
let utilsMock;
|
|
9
|
+
|
|
6
10
|
before(() => {
|
|
7
11
|
hook.ready();
|
|
8
12
|
});
|
|
9
13
|
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
sandbox = sinon.createSandbox();
|
|
16
|
+
utilsMock = sandbox.mock(utils);
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
utilsMock.restore();
|
|
21
|
+
sandbox.restore();
|
|
22
|
+
});
|
|
23
|
+
|
|
10
24
|
describe('fillVideoDefaults', () => {
|
|
11
25
|
function fillDefaults(videoMediaType = {}) {
|
|
12
26
|
const adUnit = {mediaTypes: {video: videoMediaType}};
|
|
@@ -77,6 +91,94 @@ describe('video.js', function () {
|
|
|
77
91
|
})
|
|
78
92
|
})
|
|
79
93
|
|
|
94
|
+
describe('validateOrtbVideoFields', () => {
|
|
95
|
+
it('remove incorrect ortb properties, and keep non ortb ones', () => {
|
|
96
|
+
sandbox.spy(utils, 'logWarn');
|
|
97
|
+
|
|
98
|
+
const mt = {
|
|
99
|
+
content: 'outstream',
|
|
100
|
+
|
|
101
|
+
mimes: ['video/mp4'],
|
|
102
|
+
minduration: 5,
|
|
103
|
+
maxduration: 15,
|
|
104
|
+
startdelay: 0,
|
|
105
|
+
maxseq: 0,
|
|
106
|
+
poddur: 0,
|
|
107
|
+
protocols: [7],
|
|
108
|
+
w: 600,
|
|
109
|
+
h: 480,
|
|
110
|
+
podid: 'an-id',
|
|
111
|
+
podseq: 0,
|
|
112
|
+
rqddurs: [5],
|
|
113
|
+
placement: 1,
|
|
114
|
+
plcmt: 1,
|
|
115
|
+
linearity: 1,
|
|
116
|
+
skip: 0,
|
|
117
|
+
skipmin: 3,
|
|
118
|
+
skipafter: 3,
|
|
119
|
+
sequence: 0,
|
|
120
|
+
slotinpod: 0,
|
|
121
|
+
mincpmpersec: 2.5,
|
|
122
|
+
battr: [6, 7],
|
|
123
|
+
maxextended: 0,
|
|
124
|
+
minbitrate: 800,
|
|
125
|
+
maxbitrate: 1000,
|
|
126
|
+
boxingallowed: 1,
|
|
127
|
+
playbackmethod: [1],
|
|
128
|
+
playbackend: 1,
|
|
129
|
+
delivery: [2],
|
|
130
|
+
pos: 0,
|
|
131
|
+
api: 6, // -- INVALID
|
|
132
|
+
companiontype: [1, 2, 3],
|
|
133
|
+
poddedupe: [1],
|
|
134
|
+
|
|
135
|
+
otherOne: 'test',
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const expected = {...mt};
|
|
139
|
+
delete expected.api;
|
|
140
|
+
|
|
141
|
+
const adUnit = {
|
|
142
|
+
code: 'adUnitCode',
|
|
143
|
+
mediaTypes: { video: mt }
|
|
144
|
+
};
|
|
145
|
+
validateOrtbVideoFields(adUnit);
|
|
146
|
+
|
|
147
|
+
expect(adUnit.mediaTypes.video).to.eql(expected);
|
|
148
|
+
sinon.assert.callCount(utils.logWarn, 1);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('Early return when 1st param is not a plain object', () => {
|
|
152
|
+
sandbox.spy(utils, 'logWarn');
|
|
153
|
+
|
|
154
|
+
validateOrtbVideoFields();
|
|
155
|
+
validateOrtbVideoFields([]);
|
|
156
|
+
validateOrtbVideoFields(null);
|
|
157
|
+
validateOrtbVideoFields('hello');
|
|
158
|
+
validateOrtbVideoFields(() => {});
|
|
159
|
+
|
|
160
|
+
sinon.assert.callCount(utils.logWarn, 5);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('Calls onInvalidParam when a property is invalid', () => {
|
|
164
|
+
const onInvalidParam = sandbox.spy();
|
|
165
|
+
const adUnit = {
|
|
166
|
+
code: 'adUnitCode',
|
|
167
|
+
mediaTypes: {
|
|
168
|
+
video: {
|
|
169
|
+
content: 'outstream',
|
|
170
|
+
mimes: ['video/mp4'],
|
|
171
|
+
api: 6
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
validateOrtbVideoFields(adUnit, onInvalidParam);
|
|
176
|
+
|
|
177
|
+
sinon.assert.calledOnce(onInvalidParam);
|
|
178
|
+
sinon.assert.calledWith(onInvalidParam, 'api', 6, adUnit);
|
|
179
|
+
});
|
|
180
|
+
})
|
|
181
|
+
|
|
80
182
|
describe('isValidVideoBid', () => {
|
|
81
183
|
it('validates valid instream bids', function () {
|
|
82
184
|
const bid = {
|