Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion styles/all/template/js/consentmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
}

function buildGoogleConsentModeState() {
const consentState = Object.create(null);
const consentState = {};

if (!googleConsentMode.enabled) {
return consentState;
Expand Down
8 changes: 7 additions & 1 deletion tests/javascript/consentmanager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ function setupConsentManager(options) {
if (settings.withGtag) {
window.gtagCalls = gtagCalls;
window.gtag = function() {
const consentState = arguments[2];
if (consentState && typeof consentState.hasOwnProperty !== 'function') {
throw new TypeError('Google Consent Mode requires a plain state object.');
}
gtagCalls.push(Array.prototype.slice.call(arguments));
};
}
Expand Down Expand Up @@ -412,7 +416,7 @@ test('marks the consent cookie secure only on HTTPS', () => {
});

test('updates Google consent mode before activating newly consented marketing scripts', () => {
const { window, gtagCalls } = setupConsentManager({
const { window, document, gtagCalls } = setupConsentManager({
withGtag: true,
extraMarkup: `
<script type="text/plain" data-consent-category="marketing">
Expand All @@ -421,8 +425,10 @@ test('updates Google consent mode before activating newly consented marketing sc
`
});

window.consentManager.openSettings();
click(window, '[data-consent-action="accept-all"]');

expect(document.getElementById('consent-manager-modal').hidden).toBe(true);
expect(gtagCalls[0]).toEqual([
'consent',
'update',
Expand Down
Loading