prebid-universal-creative 1.17.2 → 1.18.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/.circleci/config.yml +1 -1
- package/README.md +74 -7
- package/browsers.json +12 -12
- package/dist/amp.js +3 -3
- package/dist/banner.js +3 -3
- package/dist/creative.js +3 -3
- package/dist/load-cookie-with-consent.html +1 -1
- package/dist/load-cookie.html +1 -1
- package/dist/{2088600fa2b5f5e3c29c.max.js → main.max.js} +403 -371
- package/dist/mobile.js +3 -3
- package/dist/native-render.js +3 -3
- package/dist/native-trk.js +3 -3
- package/dist/native.js +3 -3
- package/dist/uid.js +3 -3
- package/dist/video.js +3 -3
- package/gulpfile.js +35 -11
- package/karma.conf.maker.js +22 -10
- package/package.json +15 -16
- package/src/cookieSync.js +2 -0
- package/src/cookieSyncWithConsent.js +2 -0
- package/src/mobileAndAmpRender.js +2 -2
- package/src/nativeAssetManager.js +1 -1
- package/src/nativeORTBTrackerManager.js +0 -2
- package/src/nativeTrackerManager.js +1 -1
- package/src/postscribeRender.js +63 -2
- package/src/renderingManager.js +1 -1
- package/test/spec/mobileAndAmpRender_spec.js +86 -93
- package/test/spec/nativeAssetManager_spec.js +20 -8
- package/test/spec/nativeORTBTrackerManager_spec.js +2 -2
- package/test/spec/nativeTrackerManager_spec.js +3 -8
- package/test/spec/renderingManager_spec.js +4 -24
- package/test/spec/uid_spec.js +10 -29
- package/test/test_index.js +1 -1
- package/webpack.conf.js +12 -15
|
@@ -27,11 +27,6 @@ describe('nativeTrackerManager', function () {
|
|
|
27
27
|
pubUrl: 'http://example.com'
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
let tagDataAlt = {
|
|
31
|
-
pubUrl: 'http://example.com',
|
|
32
|
-
adId: 'ad123',
|
|
33
|
-
assetsToReplace: ['image','hb_native_linkurl','body','title'],
|
|
34
|
-
};
|
|
35
30
|
|
|
36
31
|
beforeEach(function () {
|
|
37
32
|
mockWin = merge(mocks.createFakeWindow(tagData.pubUrl), renderingMocks.getWindowObject());
|
|
@@ -49,7 +44,7 @@ describe('nativeTrackerManager', function () {
|
|
|
49
44
|
value: 'ad123'
|
|
50
45
|
}
|
|
51
46
|
},
|
|
52
|
-
addEventListener: (
|
|
47
|
+
addEventListener: () => {
|
|
53
48
|
},
|
|
54
49
|
}];
|
|
55
50
|
|
|
@@ -74,7 +69,7 @@ describe('nativeTrackerManager', function () {
|
|
|
74
69
|
value: 'ad123'
|
|
75
70
|
}
|
|
76
71
|
},
|
|
77
|
-
addEventListener: ((type, listener
|
|
72
|
+
addEventListener: ((type, listener) => {
|
|
78
73
|
listener({
|
|
79
74
|
})
|
|
80
75
|
})
|
|
@@ -97,7 +92,7 @@ describe('nativeTrackerManager', function () {
|
|
|
97
92
|
|
|
98
93
|
it('should verify 2 warning messages (one for impression, one for click) was executed', function() {
|
|
99
94
|
mockWin.document.getElementsByClassName = () => [{
|
|
100
|
-
addEventListener: ((type, listener
|
|
95
|
+
addEventListener: ((type, listener) => {
|
|
101
96
|
listener({
|
|
102
97
|
})
|
|
103
98
|
})
|
|
@@ -24,7 +24,7 @@ function renderingMocks() {
|
|
|
24
24
|
renderAd: sinon.spy()
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
-
postMessage: (message
|
|
27
|
+
postMessage: (message) => {
|
|
28
28
|
this.messages[0](message);
|
|
29
29
|
},
|
|
30
30
|
top: null,
|
|
@@ -34,7 +34,7 @@ function renderingMocks() {
|
|
|
34
34
|
expand: sinon.spy()
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
addEventListener: (type, listener
|
|
37
|
+
addEventListener: (type, listener) => {
|
|
38
38
|
this.messages.push(listener);
|
|
39
39
|
},
|
|
40
40
|
innerWidth: 300,
|
|
@@ -56,39 +56,21 @@ function createMockIframe() {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
describe('renderingManager', function() {
|
|
59
|
-
let xhr;
|
|
60
|
-
let requests;
|
|
61
|
-
|
|
62
|
-
before(function() {
|
|
63
|
-
xhr = sinon.useFakeXMLHttpRequest();
|
|
64
|
-
xhr.onCreate = (request) => requests.push(request);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
beforeEach(function() {
|
|
68
|
-
requests = [];
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
after(function(){
|
|
72
|
-
xhr.restore();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
59
|
describe('cross domain creative', function() {
|
|
76
60
|
const ORIGIN = 'http://example.com';
|
|
77
61
|
let sandbox;
|
|
78
62
|
let parseStub;
|
|
79
63
|
let iframeStub;
|
|
80
|
-
let triggerPixelSpy;
|
|
81
64
|
let mockWin;
|
|
82
65
|
let ucTagData;
|
|
83
66
|
let mockIframe;
|
|
84
|
-
let eventSource;
|
|
85
67
|
|
|
86
68
|
beforeEach(function(){
|
|
87
69
|
sandbox = sinon.createSandbox();
|
|
88
70
|
mockIframe = createMockIframe();
|
|
89
71
|
parseStub = sandbox.stub(utils, 'parseUrl');
|
|
90
72
|
iframeStub = sandbox.stub(domHelper, 'getEmptyIframe').returns(mockIframe);
|
|
91
|
-
|
|
73
|
+
sandbox.stub(utils, 'triggerPixel');
|
|
92
74
|
parseStub.returns({
|
|
93
75
|
protocol: 'http',
|
|
94
76
|
host: 'example.com'
|
|
@@ -99,8 +81,6 @@ describe('renderingManager', function() {
|
|
|
99
81
|
adServerDomain: 'mypub.com',
|
|
100
82
|
pubUrl: ORIGIN,
|
|
101
83
|
};
|
|
102
|
-
eventSource = null;
|
|
103
|
-
|
|
104
84
|
renderCrossDomain(mockWin, ucTagData.adId, ucTagData.adServerDomain, ucTagData.pubUrl);
|
|
105
85
|
|
|
106
86
|
});
|
|
@@ -126,7 +106,7 @@ describe('renderingManager', function() {
|
|
|
126
106
|
};
|
|
127
107
|
mockPrebidResponse(data);
|
|
128
108
|
sinon.assert.calledWith(dynamic.runDynamicRenderer, data.adId, sinon.match(data))
|
|
129
|
-
})
|
|
109
|
+
});
|
|
130
110
|
|
|
131
111
|
it("should render cross domain creative", function () {
|
|
132
112
|
mockPrebidResponse({
|
package/test/spec/uid_spec.js
CHANGED
|
@@ -3,42 +3,27 @@ import * as commons from 'src/ssp-userids/commons';
|
|
|
3
3
|
import { expect } from 'chai';
|
|
4
4
|
|
|
5
5
|
describe('uid module', function() {
|
|
6
|
-
let
|
|
7
|
-
let requests;
|
|
6
|
+
let sandbox;
|
|
8
7
|
let saveStorageStub;
|
|
9
8
|
let getStorageStub;
|
|
10
|
-
|
|
11
|
-
before(function() {
|
|
12
|
-
xhr = sinon.useFakeXMLHttpRequest();
|
|
13
|
-
xhr.onCreate = function(xhr) {
|
|
14
|
-
requests.push(xhr);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
after(function(){
|
|
19
|
-
xhr.restore();
|
|
20
|
-
});
|
|
9
|
+
let ajaxStub;
|
|
21
10
|
|
|
22
11
|
beforeEach(function() {
|
|
23
|
-
|
|
24
|
-
saveStorageStub =
|
|
25
|
-
getStorageStub =
|
|
12
|
+
sandbox = sinon.createSandbox();
|
|
13
|
+
saveStorageStub = sandbox.stub(commons, 'setDataInLocalStorage');
|
|
14
|
+
getStorageStub = sandbox.stub(commons, 'getDataFromLocalStorage');
|
|
15
|
+
ajaxStub = sandbox.stub(commons, 'ajax');
|
|
26
16
|
});
|
|
27
17
|
|
|
28
18
|
afterEach(function() {
|
|
29
|
-
|
|
30
|
-
getStorageStub.restore();
|
|
19
|
+
sandbox.restore();
|
|
31
20
|
});
|
|
32
21
|
|
|
33
22
|
it('should save data in local storage when script is loaded', function() {
|
|
34
23
|
getStorageStub.returns(null);
|
|
35
24
|
let response = '{"buyeruids": {"appnexus":"12345"}}';
|
|
36
25
|
loadData(sinon.spy());
|
|
37
|
-
|
|
38
|
-
200,
|
|
39
|
-
{ "Content-Type": "text/plain" },
|
|
40
|
-
response
|
|
41
|
-
);
|
|
26
|
+
ajaxStub.firstCall.args[1](response);
|
|
42
27
|
expect(JSON.parse(saveStorageStub.args[0][1])).to.have.all.keys(['buyeruids', 'lastUpdated'])
|
|
43
28
|
expect(saveStorageStub.callCount).to.equal(1);
|
|
44
29
|
});
|
|
@@ -52,7 +37,7 @@ describe('uid module', function() {
|
|
|
52
37
|
"buyeruids": {"appnexus":"12345"}
|
|
53
38
|
}
|
|
54
39
|
expect(callbackSpy.calledWith(null, expectedResponse)).to.be.true;
|
|
55
|
-
expect(
|
|
40
|
+
expect(ajaxStub.callCount).to.equal(0);
|
|
56
41
|
});
|
|
57
42
|
|
|
58
43
|
it('should get buyer ids from endpoint when local storage not supported', function() {
|
|
@@ -60,11 +45,7 @@ describe('uid module', function() {
|
|
|
60
45
|
getStorageStub.returns(undefined);
|
|
61
46
|
let callbackSpy = sinon.spy();
|
|
62
47
|
getBuyerUids(callbackSpy);
|
|
63
|
-
|
|
64
|
-
200,
|
|
65
|
-
{ "Content-Type": "text/plain" },
|
|
66
|
-
response
|
|
67
|
-
);
|
|
48
|
+
ajaxStub.firstCall.args[1](response);
|
|
68
49
|
expect(callbackSpy.calledWith(null, JSON.parse(response))).to.be.true;
|
|
69
50
|
expect(saveStorageStub.callCount).to.equal(1);
|
|
70
51
|
});
|
package/test/test_index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var testsContext = require.context('.', true, /_spec$/);
|
|
2
|
-
testsContext.keys().forEach(testsContext);
|
|
2
|
+
testsContext.keys().forEach(testsContext);
|
package/webpack.conf.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var creative = require('./package.json');
|
|
2
|
-
var StringReplacePlugin = require('string-replace-webpack-plugin');
|
|
3
2
|
var path = require('path');
|
|
4
|
-
const ShakePlugin = require('webpack-common-shake').Plugin;
|
|
5
3
|
|
|
6
4
|
module.exports = {
|
|
5
|
+
mode: 'none',
|
|
6
|
+
target: ['web', 'es5'],
|
|
7
7
|
devtool: 'source-map',
|
|
8
8
|
resolve: {
|
|
9
9
|
modules: [
|
|
@@ -13,6 +13,9 @@ module.exports = {
|
|
|
13
13
|
},
|
|
14
14
|
output: {
|
|
15
15
|
},
|
|
16
|
+
optimization: {
|
|
17
|
+
usedExports: true
|
|
18
|
+
},
|
|
16
19
|
module: {
|
|
17
20
|
rules: [
|
|
18
21
|
{
|
|
@@ -22,7 +25,7 @@ module.exports = {
|
|
|
22
25
|
{
|
|
23
26
|
loader: 'babel-loader',
|
|
24
27
|
options: {
|
|
25
|
-
presets: ['@babel/preset-env']
|
|
28
|
+
presets: [['@babel/preset-env', { modules: 'commonjs' }]]
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
]
|
|
@@ -30,18 +33,12 @@ module.exports = {
|
|
|
30
33
|
{
|
|
31
34
|
test: /\.js$/,
|
|
32
35
|
include: /(src|test|testpages)/,
|
|
33
|
-
loader:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return creative.globalVarName;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
})
|
|
36
|
+
loader: 'string-replace-loader',
|
|
37
|
+
options: {
|
|
38
|
+
search: /\$\$PREBID_GLOBAL\$\$/g,
|
|
39
|
+
replace: creative.globalVarName
|
|
40
|
+
}
|
|
43
41
|
}
|
|
44
42
|
]
|
|
45
|
-
}
|
|
46
|
-
plugins: [new ShakePlugin()],
|
|
43
|
+
}
|
|
47
44
|
};
|