From 2310cf7899281bf7a1a6fdfe8b833cb13b61e001 Mon Sep 17 00:00:00 2001 From: Alexander Pepper Date: Mon, 5 Jul 2021 14:25:19 +0200 Subject: [PATCH 1/2] CookieConsent: Treat denied localStorage as "declined" cookie banner. Google Chrome seems to treat direct access to "localStorage" in an iframe in incognito as a "third party cookie" and blocks it (see [1]). [1] https://github.com/elastic/kibana/issues/87901#issuecomment-758457425 --- src/Components/CookieConsentContext.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Components/CookieConsentContext.js b/src/Components/CookieConsentContext.js index 5af67b94f..1496672dc 100644 --- a/src/Components/CookieConsentContext.js +++ b/src/Components/CookieConsentContext.js @@ -33,5 +33,14 @@ export function useCookieConsent() { } function getCookieConsent() { - return localStorage.getItem("CookieConsent") || "undecided"; + try { + return localStorage.getItem("CookieConsent") || "undecided"; + } catch (e) { + if (e instanceof DOMException) { + // Prevent "Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document." + return "declined"; + } + + throw e; + } } From b4c17cf2ede90bc862e81b91ea14c4558dd8a7c7 Mon Sep 17 00:00:00 2001 From: Alexander Pepper Date: Mon, 5 Jul 2021 15:10:01 +0200 Subject: [PATCH 2/2] Improve title and description of cookieConsentLink --- src/Objs/Homepage/HomepageEditingConfig.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Objs/Homepage/HomepageEditingConfig.js b/src/Objs/Homepage/HomepageEditingConfig.js index cd4ffab5d..f4170b270 100644 --- a/src/Objs/Homepage/HomepageEditingConfig.js +++ b/src/Objs/Homepage/HomepageEditingConfig.js @@ -70,9 +70,9 @@ Scrivito.provideEditingConfig("Homepage", { ], }, cookieConsentLink: { - title: "Cookie consent link", + title: "Privacy policy for cookie consent", description: - 'If you set this link, a cookie consent box will be shown on every page. The link should point to your privacy policy. The link title defaults to "Learn more »".', + 'If you set this link, a cookie consent box will be shown on every page. To preview the effect of this setting, please enable third-party cookies in your browser. The link title defaults to "Learn more »".', }, }, properties: [...defaultPageProperties, "showAsLandingPage"],