prebid.js 6.4.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.
- package/integrationExamples/gpt/amp/creative.html +11 -33
- package/integrationExamples/gpt/x-domain/creative.html +53 -26
- package/modules/.submodules.json +2 -1
- package/modules/adagioBidAdapter.js +0 -8
- package/modules/adagioBidAdapter.md +1 -1
- package/modules/adbookpspBidAdapter.js +27 -10
- package/modules/adhashBidAdapter.js +3 -3
- package/modules/adkernelBidAdapter.js +2 -1
- package/modules/admanBidAdapter.js +10 -4
- package/modules/adomikAnalyticsAdapter.js +23 -11
- package/modules/adqueryIdSystem.js +103 -0
- package/modules/adqueryIdSystem.md +35 -0
- package/modules/adyoulikeBidAdapter.js +13 -9
- package/modules/appnexusBidAdapter.js +11 -0
- package/modules/bliinkBidAdapter.js +3 -2
- package/modules/brandmetricsRtdProvider.js +168 -0
- package/modules/brandmetricsRtdProvider.md +40 -0
- package/modules/colossussspBidAdapter.js +12 -8
- package/modules/colossussspBidAdapter.md +15 -1
- package/modules/compassBidAdapter.js +10 -3
- package/modules/consentManagement.js +7 -1
- package/modules/consumableBidAdapter.md +1 -1
- package/modules/criteoBidAdapter.js +10 -1
- package/modules/criteoIdSystem.js +29 -7
- package/modules/currency.js +26 -1
- package/modules/displayioBidAdapter.js +157 -0
- package/modules/displayioBidAdapter.md +148 -0
- package/modules/docereeBidAdapter.js +10 -1
- package/modules/docereeBidAdapter.md +2 -0
- package/modules/e_volutionBidAdapter.js +158 -0
- package/modules/glimpseBidAdapter.js +66 -44
- package/modules/gnetBidAdapter.js +3 -3
- package/modules/gnetBidAdapter.md +4 -4
- package/modules/gptPreAuction.js +55 -7
- package/modules/gumgumBidAdapter.js +56 -42
- package/modules/idImportLibrary.js +45 -8
- package/modules/idImportLibrary.md +4 -0
- package/modules/improvedigitalBidAdapter.js +24 -2
- package/modules/interactiveOffersBidAdapter.js +9 -6
- package/modules/ixBidAdapter.js +29 -12
- package/modules/jwplayerRtdProvider.js +71 -6
- package/modules/jwplayerRtdProvider.md +27 -11
- package/modules/kargoBidAdapter.js +2 -2
- package/modules/limelightDigitalBidAdapter.js +2 -1
- package/modules/livewrappedAnalyticsAdapter.js +3 -1
- package/modules/loglyliftBidAdapter.js +79 -0
- package/modules/loglyliftBidAdapter.md +55 -0
- package/modules/nextMillenniumBidAdapter.js +3 -1
- package/modules/oguryBidAdapter.js +9 -2
- package/modules/onetagBidAdapter.js +4 -2
- package/modules/optimeraRtdProvider.js +8 -1
- package/modules/ozoneBidAdapter.js +21 -64
- package/modules/pilotxBidAdapter.js +147 -0
- package/modules/pilotxBidAdapter.md +50 -0
- package/modules/proxistoreBidAdapter.js +0 -2
- package/modules/pubmaticAnalyticsAdapter.js +16 -0
- package/modules/richaudienceBidAdapter.js +3 -2
- package/modules/riseBidAdapter.js +1 -1
- package/modules/rtbhouseBidAdapter.js +14 -4
- package/modules/rtdModule/index.js +14 -15
- package/modules/rubiconAnalyticsAdapter.js +3 -2
- package/modules/seedingAllianceBidAdapter.js +3 -3
- package/modules/sharethroughBidAdapter.js +12 -17
- package/modules/showheroes-bsBidAdapter.js +13 -2
- package/modules/sovrnBidAdapter.js +93 -18
- package/modules/sovrnBidAdapter.md +80 -2
- package/modules/synacormediaBidAdapter.js +31 -10
- package/modules/tappxBidAdapter.js +8 -5
- package/modules/teadsBidAdapter.js +1 -2
- package/modules/undertoneBidAdapter.js +17 -1
- package/modules/userId/eids.js +7 -1
- package/modules/userId/userId.md +8 -0
- package/modules/viewability.js +177 -0
- package/modules/viewability.md +87 -0
- package/modules/welectBidAdapter.js +106 -0
- package/modules/yahoosspBidAdapter.js +2 -0
- package/modules/yieldmoBidAdapter.js +23 -5
- package/modules/zeta_global_sspAnalyticsAdapter.js +97 -0
- package/modules/zeta_global_sspAnalyticsAdapter.md +24 -0
- package/package.json +1 -1
- package/src/adRendering.js +38 -0
- package/src/auction.js +44 -9
- package/src/config.js +27 -3
- package/src/hook.js +5 -1
- package/src/prebid.js +21 -21
- package/src/secureCreatives.js +114 -44
- package/src/utils.js +25 -4
- package/test/helpers/syncPromise.js +71 -0
- package/test/spec/auctionmanager_spec.js +148 -16
- package/test/spec/config_spec.js +279 -0
- package/test/spec/modules/adagioBidAdapter_spec.js +0 -10
- package/test/spec/modules/adbookpspBidAdapter_spec.js +17 -3
- package/test/spec/modules/adhashBidAdapter_spec.js +2 -2
- package/test/spec/modules/admanBidAdapter_spec.js +2 -2
- package/test/spec/modules/adomikAnalyticsAdapter_spec.js +3 -1
- package/test/spec/modules/adqueryIdSystem_spec.js +74 -0
- package/test/spec/modules/adyoulikeBidAdapter_spec.js +49 -0
- package/test/spec/modules/appnexusBidAdapter_spec.js +27 -0
- package/test/spec/modules/bliinkBidAdapter_spec.js +2 -0
- package/test/spec/modules/brandmetricsRtdProvider_spec.js +191 -0
- package/test/spec/modules/colossussspBidAdapter_spec.js +5 -2
- package/test/spec/modules/compassBidAdapter_spec.js +1 -0
- package/test/spec/modules/consentManagement_spec.js +20 -0
- package/test/spec/modules/criteoBidAdapter_spec.js +21 -0
- package/test/spec/modules/criteoIdSystem_spec.js +6 -3
- package/test/spec/modules/currency_spec.js +21 -6
- package/test/spec/modules/displayioBidAdapter_spec.js +239 -0
- package/test/spec/modules/docereeBidAdapter_spec.js +9 -1
- package/test/spec/modules/e_volutionBidAdapter_spec.js +242 -0
- package/test/spec/modules/eids_spec.js +15 -0
- package/test/spec/modules/glimpseBidAdapter_spec.js +0 -18
- package/test/spec/modules/gnetBidAdapter_spec.js +6 -6
- package/test/spec/modules/gptPreAuction_spec.js +177 -2
- package/test/spec/modules/gumgumBidAdapter_spec.js +46 -0
- package/test/spec/modules/idImportLibrary_spec.js +197 -10
- package/test/spec/modules/improvedigitalBidAdapter_spec.js +42 -0
- package/test/spec/modules/ixBidAdapter_spec.js +104 -62
- package/test/spec/modules/jwplayerRtdProvider_spec.js +195 -2
- package/test/spec/modules/kargoBidAdapter_spec.js +1 -1
- package/test/spec/modules/limelightDigitalBidAdapter_spec.js +75 -17
- package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +22 -0
- package/test/spec/modules/loglyliftBidAdapter_spec.js +172 -0
- package/test/spec/modules/nextMillenniumBidAdapter_spec.js +1 -1
- package/test/spec/modules/oguryBidAdapter_spec.js +10 -2
- package/test/spec/modules/optimeraRtdProvider_spec.js +14 -1
- package/test/spec/modules/ozoneBidAdapter_spec.js +43 -31
- package/test/spec/modules/pilotxBidAdapter_spec.js +244 -0
- package/test/spec/modules/pubmaticAnalyticsAdapter_spec.js +13 -1
- package/test/spec/modules/realTimeDataModule_spec.js +67 -5
- package/test/spec/modules/richaudienceBidAdapter_spec.js +40 -0
- package/test/spec/modules/riseBidAdapter_spec.js +1 -1
- package/test/spec/modules/rtbhouseBidAdapter_spec.js +20 -0
- package/test/spec/modules/rubiconAnalyticsAdapter_spec.js +30 -0
- package/test/spec/modules/sharethroughBidAdapter_spec.js +91 -6
- package/test/spec/modules/showheroes-bsBidAdapter_spec.js +2 -0
- package/test/spec/modules/sovrnBidAdapter_spec.js +413 -333
- package/test/spec/modules/synacormediaBidAdapter_spec.js +70 -0
- package/test/spec/modules/tappxBidAdapter_spec.js +0 -19
- package/test/spec/modules/teadsBidAdapter_spec.js +14 -59
- package/test/spec/modules/undertoneBidAdapter_spec.js +55 -2
- package/test/spec/modules/userId_spec.js +68 -19
- package/test/spec/modules/viewability_spec.js +280 -0
- package/test/spec/modules/welectBidAdapter_spec.js +211 -0
- package/test/spec/modules/yahoosspBidAdapter_spec.js +10 -0
- package/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js +427 -0
- package/test/spec/unit/pbjs_api_spec.js +20 -2
- package/test/spec/unit/secureCreatives_spec.js +85 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import * as sinon from 'sinon';
|
|
3
|
+
import * as utils from 'src/utils.js';
|
|
4
|
+
import * as viewability from 'modules/viewability.js';
|
|
5
|
+
|
|
6
|
+
describe('viewability test', () => {
|
|
7
|
+
describe('start measurement', () => {
|
|
8
|
+
let sandbox;
|
|
9
|
+
let intersectionObserverStub;
|
|
10
|
+
let setTimeoutStub;
|
|
11
|
+
let observeCalled;
|
|
12
|
+
let unobserveCalled;
|
|
13
|
+
let ti = 1;
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
observeCalled = false;
|
|
16
|
+
unobserveCalled = false;
|
|
17
|
+
sandbox = sinon.sandbox.create();
|
|
18
|
+
|
|
19
|
+
let fakeIntersectionObserver = (stateChange, options) => {
|
|
20
|
+
return {
|
|
21
|
+
observe: (element) => {
|
|
22
|
+
observeCalled = true;
|
|
23
|
+
stateChange([{ isIntersecting: true }]);
|
|
24
|
+
},
|
|
25
|
+
unobserve: (element) => {
|
|
26
|
+
unobserveCalled = true;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
intersectionObserverStub = sandbox.stub(window, 'IntersectionObserver').callsFake(fakeIntersectionObserver);
|
|
32
|
+
setTimeoutStub = sandbox.stub(window, 'setTimeout').callsFake((callback, timeout) => {
|
|
33
|
+
callback();
|
|
34
|
+
return ti++;
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
sandbox.restore();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should trigger appropriate callbacks', () => {
|
|
43
|
+
viewability.startMeasurement('0', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
44
|
+
|
|
45
|
+
sinon.assert.called(intersectionObserverStub);
|
|
46
|
+
sinon.assert.called(setTimeoutStub);
|
|
47
|
+
expect(observeCalled).to.equal(true);
|
|
48
|
+
expect(unobserveCalled).to.equal(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should trigger img tracker', () => {
|
|
52
|
+
let triggerPixelSpy = sandbox.spy(utils, ['triggerPixel']);
|
|
53
|
+
viewability.startMeasurement('1', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
54
|
+
expect(triggerPixelSpy.callCount).to.equal(1);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should trigger js tracker', () => {
|
|
58
|
+
let insertHtmlIntoIframeSpy = sandbox.spy(utils, ['insertHtmlIntoIframe']);
|
|
59
|
+
viewability.startMeasurement('2', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
60
|
+
expect(insertHtmlIntoIframeSpy.callCount).to.equal(1);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should trigger callback tracker', () => {
|
|
64
|
+
let callbackFired = false;
|
|
65
|
+
viewability.startMeasurement('3', {}, { method: 'callback', value: () => { callbackFired = true; } }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
66
|
+
expect(callbackFired).to.equal(true);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should check for vid uniqueness', () => {
|
|
70
|
+
let logWarnSpy = sandbox.spy(utils, 'logWarn');
|
|
71
|
+
viewability.startMeasurement('4', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
72
|
+
expect(logWarnSpy.callCount).to.equal(0);
|
|
73
|
+
|
|
74
|
+
viewability.startMeasurement('4', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
75
|
+
expect(logWarnSpy.callCount).to.equal(1);
|
|
76
|
+
expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: must provide an unregistered vid`, '4')).to.equal(true);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should check for valid criteria', () => {
|
|
80
|
+
let logWarnSpy = sandbox.spy(utils, 'logWarn');
|
|
81
|
+
viewability.startMeasurement('5', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { timeInView: 1000 });
|
|
82
|
+
expect(logWarnSpy.callCount).to.equal(1);
|
|
83
|
+
expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: missing criteria`, { timeInView: 1000 })).to.equal(true);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should check for valid tracker', () => {
|
|
87
|
+
let logWarnSpy = sandbox.spy(utils, 'logWarn');
|
|
88
|
+
viewability.startMeasurement('6', {}, { method: 'callback', value: 'string' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
89
|
+
expect(logWarnSpy.callCount).to.equal(1);
|
|
90
|
+
expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: invalid tracker`, { method: 'callback', value: 'string' })).to.equal(true);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should check if element provided', () => {
|
|
94
|
+
let logWarnSpy = sandbox.spy(utils, 'logWarn');
|
|
95
|
+
viewability.startMeasurement('7', undefined, { method: 'js', value: 'http://my.tracker/123.js' }, { timeInView: 1000 });
|
|
96
|
+
expect(logWarnSpy.callCount).to.equal(1);
|
|
97
|
+
expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: no html element provided`)).to.equal(true);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('stop measurement', () => {
|
|
102
|
+
let sandbox;
|
|
103
|
+
let intersectionObserverStub;
|
|
104
|
+
let setTimeoutStub;
|
|
105
|
+
let clearTimeoutStub;
|
|
106
|
+
let observeCalled;
|
|
107
|
+
let unobserveCalled;
|
|
108
|
+
let stateChangeBackup;
|
|
109
|
+
let ti = 1;
|
|
110
|
+
beforeEach(() => {
|
|
111
|
+
observeCalled = false;
|
|
112
|
+
unobserveCalled = false;
|
|
113
|
+
sandbox = sinon.sandbox.create();
|
|
114
|
+
|
|
115
|
+
let fakeIntersectionObserver = (stateChange, options) => {
|
|
116
|
+
return {
|
|
117
|
+
observe: (element) => {
|
|
118
|
+
stateChangeBackup = stateChange;
|
|
119
|
+
observeCalled = true;
|
|
120
|
+
stateChange([{ isIntersecting: true }]);
|
|
121
|
+
},
|
|
122
|
+
unobserve: (element) => {
|
|
123
|
+
unobserveCalled = true;
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
intersectionObserverStub = sandbox.stub(window, 'IntersectionObserver').callsFake(fakeIntersectionObserver);
|
|
129
|
+
setTimeoutStub = sandbox.stub(window, 'setTimeout').callsFake((callback, timeout) => {
|
|
130
|
+
// skipping the callback
|
|
131
|
+
return ti++;
|
|
132
|
+
});
|
|
133
|
+
clearTimeoutStub = sandbox.stub(window, 'clearTimeout').callsFake((timeoutId) => { });
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
afterEach(() => {
|
|
137
|
+
sandbox.restore();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should clear the timeout', () => {
|
|
141
|
+
viewability.startMeasurement('10', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
142
|
+
stateChangeBackup([{ isIntersecting: false }]);
|
|
143
|
+
sinon.assert.called(intersectionObserverStub);
|
|
144
|
+
sinon.assert.called(setTimeoutStub);
|
|
145
|
+
sinon.assert.called(clearTimeoutStub);
|
|
146
|
+
expect(observeCalled).to.equal(true);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should unobserve', () => {
|
|
150
|
+
viewability.startMeasurement('11', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
151
|
+
sinon.assert.called(intersectionObserverStub);
|
|
152
|
+
sinon.assert.called(setTimeoutStub);
|
|
153
|
+
expect(observeCalled).to.equal(true);
|
|
154
|
+
expect(unobserveCalled).to.equal(false);
|
|
155
|
+
|
|
156
|
+
viewability.stopMeasurement('11');
|
|
157
|
+
expect(unobserveCalled).to.equal(true);
|
|
158
|
+
sinon.assert.called(clearTimeoutStub);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('should check for vid existence', () => {
|
|
162
|
+
let logWarnSpy = sandbox.spy(utils, 'logWarn');
|
|
163
|
+
viewability.stopMeasurement('100');
|
|
164
|
+
expect(logWarnSpy.callCount).to.equal(1);
|
|
165
|
+
expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: must provide a registered vid`, '100')).to.equal(true);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('handle creative messages', () => {
|
|
170
|
+
let sandbox;
|
|
171
|
+
let intersectionObserverStub;
|
|
172
|
+
let setTimeoutStub;
|
|
173
|
+
let observeCalled;
|
|
174
|
+
let unobserveCalled;
|
|
175
|
+
let ti = 1;
|
|
176
|
+
let getElementsByTagStub;
|
|
177
|
+
let getElementByIdStub;
|
|
178
|
+
|
|
179
|
+
let fakeContentWindow = {};
|
|
180
|
+
beforeEach(() => {
|
|
181
|
+
observeCalled = false;
|
|
182
|
+
unobserveCalled = false;
|
|
183
|
+
sandbox = sinon.sandbox.create();
|
|
184
|
+
|
|
185
|
+
let fakeIntersectionObserver = (stateChange, options) => {
|
|
186
|
+
return {
|
|
187
|
+
observe: (element) => {
|
|
188
|
+
observeCalled = true;
|
|
189
|
+
stateChange([{ isIntersecting: true }]);
|
|
190
|
+
},
|
|
191
|
+
unobserve: (element) => {
|
|
192
|
+
unobserveCalled = true;
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
intersectionObserverStub = sandbox.stub(window, 'IntersectionObserver').callsFake(fakeIntersectionObserver);
|
|
198
|
+
setTimeoutStub = sandbox.stub(window, 'setTimeout').callsFake((callback, timeout) => {
|
|
199
|
+
callback();
|
|
200
|
+
return ti++;
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
getElementsByTagStub = sandbox.stub(document, 'getElementsByTagName').callsFake((tagName) => {
|
|
204
|
+
return [{
|
|
205
|
+
contentWindow: fakeContentWindow,
|
|
206
|
+
}];
|
|
207
|
+
});
|
|
208
|
+
getElementByIdStub = sandbox.stub(document, 'getElementById').callsFake((id) => {
|
|
209
|
+
return {};
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
afterEach(() => {
|
|
214
|
+
sandbox.restore();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('should find element by contentWindow', () => {
|
|
218
|
+
let viewabilityRecord = {
|
|
219
|
+
vid: 1000,
|
|
220
|
+
tracker: {
|
|
221
|
+
value: 'http://my.tracker/123',
|
|
222
|
+
method: 'img',
|
|
223
|
+
},
|
|
224
|
+
criteria: { inViewThreshold: 0.5, timeInView: 1000 },
|
|
225
|
+
message: 'Prebid Viewability',
|
|
226
|
+
action: 'startMeasurement',
|
|
227
|
+
};
|
|
228
|
+
let data = JSON.stringify(viewabilityRecord);
|
|
229
|
+
|
|
230
|
+
viewability.receiveMessage({
|
|
231
|
+
data: data,
|
|
232
|
+
source: fakeContentWindow,
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
sinon.assert.called(getElementsByTagStub);
|
|
236
|
+
sinon.assert.called(intersectionObserverStub);
|
|
237
|
+
sinon.assert.called(setTimeoutStub);
|
|
238
|
+
expect(observeCalled).to.equal(true);
|
|
239
|
+
expect(unobserveCalled).to.equal(true);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('should find element by id', () => {
|
|
243
|
+
let viewabilityRecord = {
|
|
244
|
+
vid: 1001,
|
|
245
|
+
tracker: {
|
|
246
|
+
value: 'http://my.tracker/123',
|
|
247
|
+
method: 'img',
|
|
248
|
+
},
|
|
249
|
+
criteria: { inViewThreshold: 0.5, timeInView: 1000 },
|
|
250
|
+
message: 'Prebid Viewability',
|
|
251
|
+
action: 'startMeasurement',
|
|
252
|
+
elementId: '1',
|
|
253
|
+
};
|
|
254
|
+
let data = JSON.stringify(viewabilityRecord);
|
|
255
|
+
viewability.receiveMessage({
|
|
256
|
+
data: data,
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
sinon.assert.called(getElementByIdStub);
|
|
260
|
+
sinon.assert.called(intersectionObserverStub);
|
|
261
|
+
sinon.assert.called(setTimeoutStub);
|
|
262
|
+
expect(observeCalled).to.equal(true);
|
|
263
|
+
expect(unobserveCalled).to.equal(true);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('should stop measurement', () => {
|
|
267
|
+
let viewabilityRecord = {
|
|
268
|
+
vid: 1001,
|
|
269
|
+
message: 'Prebid Viewability',
|
|
270
|
+
action: 'stopMeasurement',
|
|
271
|
+
};
|
|
272
|
+
let data = JSON.stringify(viewabilityRecord);
|
|
273
|
+
viewability.receiveMessage({
|
|
274
|
+
data: data,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
expect(unobserveCalled).to.equal(true);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
});
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { spec as adapter } from 'modules/welectBidAdapter.js';
|
|
3
|
+
|
|
4
|
+
describe('WelectAdapter', function () {
|
|
5
|
+
describe('Check methods existance', function () {
|
|
6
|
+
it('exists and is a function', function () {
|
|
7
|
+
expect(adapter.isBidRequestValid).to.exist.and.to.be.a('function');
|
|
8
|
+
});
|
|
9
|
+
it('exists and is a function', function () {
|
|
10
|
+
expect(adapter.buildRequests).to.exist.and.to.be.a('function');
|
|
11
|
+
});
|
|
12
|
+
it('exists and is a function', function () {
|
|
13
|
+
expect(adapter.interpretResponse).to.exist.and.to.be.a('function');
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('Check method isBidRequestValid return', function () {
|
|
18
|
+
let bid = {
|
|
19
|
+
bidder: 'welect',
|
|
20
|
+
params: {
|
|
21
|
+
placementId: 'exampleAlias',
|
|
22
|
+
domain: 'www.welect.de'
|
|
23
|
+
},
|
|
24
|
+
sizes: [[640, 360]],
|
|
25
|
+
mediaTypes: {
|
|
26
|
+
video: {
|
|
27
|
+
context: 'instream'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
let bid2 = {
|
|
32
|
+
bidder: 'welect',
|
|
33
|
+
params: {
|
|
34
|
+
domain: 'www.welect.de'
|
|
35
|
+
},
|
|
36
|
+
mediaTypes: {
|
|
37
|
+
video: {
|
|
38
|
+
context: 'instream',
|
|
39
|
+
playerSize: [640, 360]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
it('should be true', function () {
|
|
45
|
+
expect(adapter.isBidRequestValid(bid)).to.be.true;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should be false because the placementId is missing', function () {
|
|
49
|
+
expect(adapter.isBidRequestValid(bid2)).to.be.false;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('Check buildRequests method', function () {
|
|
54
|
+
// Bids to be formatted
|
|
55
|
+
let bid1 = {
|
|
56
|
+
bidder: 'welect',
|
|
57
|
+
params: {
|
|
58
|
+
placementId: 'exampleAlias'
|
|
59
|
+
},
|
|
60
|
+
sizes: [[640, 360]],
|
|
61
|
+
mediaTypes: {
|
|
62
|
+
video: {
|
|
63
|
+
context: 'instream'
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
bidId: 'abdc'
|
|
67
|
+
};
|
|
68
|
+
let bid2 = {
|
|
69
|
+
bidder: 'welect',
|
|
70
|
+
params: {
|
|
71
|
+
placementId: 'exampleAlias',
|
|
72
|
+
domain: 'www.welect2.de'
|
|
73
|
+
},
|
|
74
|
+
sizes: [[640, 360]],
|
|
75
|
+
mediaTypes: {
|
|
76
|
+
video: {
|
|
77
|
+
context: 'instream'
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
bidId: 'abdc',
|
|
81
|
+
gdprConsent: {
|
|
82
|
+
gdprApplies: 1,
|
|
83
|
+
gdprConsent: 'some_string'
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
let data1 = {
|
|
88
|
+
bid_id: 'abdc',
|
|
89
|
+
width: 640,
|
|
90
|
+
height: 360
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let data2 = {
|
|
94
|
+
bid_id: 'abdc',
|
|
95
|
+
width: 640,
|
|
96
|
+
height: 360,
|
|
97
|
+
gdpr_consent: {
|
|
98
|
+
gdprApplies: 1,
|
|
99
|
+
tcString: 'some_string'
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Formatted requets
|
|
104
|
+
let request1 = {
|
|
105
|
+
method: 'POST',
|
|
106
|
+
url: 'https://www.welect.de/api/v2/preflight/exampleAlias',
|
|
107
|
+
data: data1,
|
|
108
|
+
options: {
|
|
109
|
+
contentType: 'application/json',
|
|
110
|
+
withCredentials: false,
|
|
111
|
+
crossOrigin: true,
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
let request2 = {
|
|
116
|
+
method: 'POST',
|
|
117
|
+
url: 'https://www.welect2.de/api/v2/preflight/exampleAlias',
|
|
118
|
+
data: data2,
|
|
119
|
+
options: {
|
|
120
|
+
contentType: 'application/json',
|
|
121
|
+
withCredentials: false,
|
|
122
|
+
crossOrigin: true,
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
it('defaults to www.welect.de, without gdpr object', function () {
|
|
127
|
+
expect(adapter.buildRequests([bid1])).to.deep.equal([request1]);
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('must return the right formatted requests, with gdpr object', function () {
|
|
131
|
+
expect(adapter.buildRequests([bid2])).to.deep.equal([request2]);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('Check interpretResponse method return', function () {
|
|
136
|
+
// invalid server response
|
|
137
|
+
let unavailableResponse = {
|
|
138
|
+
body: {
|
|
139
|
+
available: false
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
let availableResponse = {
|
|
144
|
+
body: {
|
|
145
|
+
available: true,
|
|
146
|
+
bidResponse: {
|
|
147
|
+
ad: {
|
|
148
|
+
video: 'some vast url'
|
|
149
|
+
},
|
|
150
|
+
meta: {
|
|
151
|
+
advertiserDomains: [],
|
|
152
|
+
},
|
|
153
|
+
cpm: 17,
|
|
154
|
+
creativeId: 'svmpreview',
|
|
155
|
+
currency: 'EUR',
|
|
156
|
+
netRevenue: true,
|
|
157
|
+
requestId: 'some bid id',
|
|
158
|
+
ttl: 120,
|
|
159
|
+
vastUrl: 'some vast url',
|
|
160
|
+
height: 640,
|
|
161
|
+
width: 320
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// bid Request
|
|
166
|
+
let bid = {
|
|
167
|
+
data: {
|
|
168
|
+
bid_id: 'some bid id',
|
|
169
|
+
width: 640,
|
|
170
|
+
height: 320,
|
|
171
|
+
gdpr_consent: {
|
|
172
|
+
gdprApplies: 1,
|
|
173
|
+
tcString: 'some_string'
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
method: 'POST',
|
|
177
|
+
url: 'https://www.welect.de/api/v2/preflight/exampleAlias',
|
|
178
|
+
options: {
|
|
179
|
+
contentType: 'application/json',
|
|
180
|
+
withCredentials: false,
|
|
181
|
+
crossOrigin: true,
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
// Formatted reponse
|
|
185
|
+
let result = {
|
|
186
|
+
ad: {
|
|
187
|
+
video: 'some vast url'
|
|
188
|
+
},
|
|
189
|
+
meta: {
|
|
190
|
+
advertiserDomains: []
|
|
191
|
+
},
|
|
192
|
+
cpm: 17,
|
|
193
|
+
creativeId: 'svmpreview',
|
|
194
|
+
currency: 'EUR',
|
|
195
|
+
height: 640,
|
|
196
|
+
netRevenue: true,
|
|
197
|
+
requestId: 'some bid id',
|
|
198
|
+
ttl: 120,
|
|
199
|
+
vastUrl: 'some vast url',
|
|
200
|
+
width: 320
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
it('if response reflects unavailability, should be empty', function () {
|
|
204
|
+
expect(adapter.interpretResponse(unavailableResponse, bid)).to.deep.equal([]);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('if response reflects availability, should equal result', function () {
|
|
208
|
+
expect(adapter.interpretResponse(availableResponse, bid)).to.deep.equal([result])
|
|
209
|
+
})
|
|
210
|
+
});
|
|
211
|
+
});
|
|
@@ -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';
|