Skip to content

Commit 113dd19

Browse files
committed
add gdpr check before device write tests to ensure purpose1 gets respected using existing utils method
1 parent 41551c5 commit 113dd19

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/storageManager.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {hasDeviceAccess, checkCookieSupport, logError, logInfo, isPlainObject, d
33
import {includes} from './polyfill.js';
44
import {bidderSettings as defaultBidderSettings} from './bidderSettings.js';
55
import {gdprDataHandler} from './adapterManager.js';
6+
import {hasPurpose1Consent} from '../src/utils/gpdr.js';
67

78
const moduleTypeWhiteList = ['core', 'prebid-module'];
89

@@ -121,7 +122,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} =
121122
*/
122123
const localStorageIsEnabled = function (done) {
123124
const consentData = gdprDataHandler.getConsentData();
124-
if (!consentData || !hasPurposeOneConsent(consentData)) {
125+
if (!consentData || !hasPurpose1Consent(consentData)) {
125126
return false;
126127
}
127128
let cb = function (result) {
@@ -153,7 +154,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} =
153154
*/
154155
const cookiesAreEnabled = function (done) {
155156
let consentData = gdprDataHandler.getConsentData();
156-
if (!consentData || !hasPurposeOneConsent(consentData)) {
157+
if (!consentData || !hasPurpose1Consent(consentData)) {
157158
return false;
158159
}
159160
let cb = function (result) {
@@ -176,19 +177,6 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} =
176177
}
177178
}
178179

179-
/**
180-
* @param {string} consentData
181-
*/
182-
const hasPurposeOneConsent = function(consentData) {
183-
let result = true;
184-
if (consentData && consentData.gdprConsent) {
185-
if (consentData.gdprConsent.gdprApplies && consentData.gdprConsent.apiVersion === 2) {
186-
result = !!(deepAccess(consentData.gdprConsent, 'vendorData.purpose.consents.1') === true);
187-
}
188-
}
189-
return result;
190-
}
191-
192180
/**
193181
* @param {string} key
194182
* @param {string} value

test/spec/userSync_spec.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ describe('user sync', function () {
2121
const thisConfig = Object.assign({}, defaultUserSyncConfig, configOverrides);
2222
return newUserSync({
2323
config: thisConfig,
24-
browserSupportsCookies: !disableBrowserCookies,
24+
browserSupportsCookies: function() {
25+
return !disableBrowserCookies
26+
},
2527
})
2628
}
2729
let clock;
@@ -379,7 +381,9 @@ describe('user sync', function () {
379381
it('should still allow default image syncs if setConfig only defined iframe', function () {
380382
const userSync = newUserSync({
381383
config: config.getConfig('userSync'),
382-
browserSupportsCookies: true
384+
browserSupportsCookies: function() {
385+
return true
386+
}
383387
});
384388

385389
config.setConfig({
@@ -404,7 +408,9 @@ describe('user sync', function () {
404408
it('should not fire image pixel for a bidder if iframe pixel is fired for same bidder', function() {
405409
const userSync = newUserSync({
406410
config: config.getConfig('userSync'),
407-
browserSupportsCookies: true
411+
browserSupportsCookies: function() {
412+
return true
413+
}
408414
});
409415

410416
config.setConfig({
@@ -431,7 +437,9 @@ describe('user sync', function () {
431437
it('should override default image syncs if setConfig used image filter', function () {
432438
const userSync = newUserSync({
433439
config: config.getConfig('userSync'),
434-
browserSupportsCookies: true
440+
browserSupportsCookies: function() {
441+
return true
442+
}
435443
});
436444

437445
config.setConfig({
@@ -456,7 +464,9 @@ describe('user sync', function () {
456464
it('should override default image syncs if setConfig used all filter', function() {
457465
const userSync = newUserSync({
458466
config: config.getConfig('userSync'),
459-
browserSupportsCookies: true
467+
browserSupportsCookies: function() {
468+
return true
469+
}
460470
});
461471

462472
config.setConfig({

0 commit comments

Comments
 (0)