From a537f7de8be83b2657295abd48df769b7f73e556 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 28 Jun 2018 16:13:52 +0200 Subject: [PATCH 1/6] Fix infinite loading screen caused by some browser settings --- www/common/cryptpad-common.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 589ec0292..833380513 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -907,6 +907,7 @@ define([ var msgEv = Util.mkEvent(); var postMsg, worker; var noWorker = AppConfig.disableWorkers || false; + var noSharedWorker = false; if (localStorage.CryptPad_noWorkers) { noWorker = localStorage.CryptPad_noWorkers === '1'; console.error('WebWorker/SharedWorker state forced to ' + !noWorker); @@ -927,8 +928,17 @@ define([ } }; } + if (typeof(SharedWorker) !== "undefined") { + try { + new SharedWorker(''); + catch (e) { + noSharedWorker = true; + e = e; + console.log('Disabling SharedWorker because of privacy settings.'); + } + } }).nThen(function (waitFor2) { - if (!noWorker && typeof(SharedWorker) !== "undefined") { + if (!noWorker && !noSharedWorker && typeof(SharedWorker) !== "undefined") { worker = new SharedWorker('/common/outer/sharedworker.js?' + urlArgs); worker.onerror = function (e) { console.error(e.message); @@ -947,7 +957,7 @@ define([ window.addEventListener('beforeunload', function () { postMsg('CLOSE'); }); - } else if (false && !noWorker && 'serviceWorker' in navigator) { + } else if (false && !noWorker && !noSharedWorker && 'serviceWorker' in navigator) { var initializing = true; var stopWaiting = waitFor2(); // Call this function when we're ready From 34914785eb579c56607aaa9589d89ac5584e0b1b Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 28 Jun 2018 16:15:38 +0200 Subject: [PATCH 2/6] lint compliance --- www/common/cryptpad-common.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 833380513..574a696c3 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -931,9 +931,8 @@ define([ if (typeof(SharedWorker) !== "undefined") { try { new SharedWorker(''); - catch (e) { + } catch (e) { noSharedWorker = true; - e = e; console.log('Disabling SharedWorker because of privacy settings.'); } } From 071c34d4fa6d7ce56ba1e64f126c9a76d0c191bb Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 2 Jul 2018 10:50:30 +0200 Subject: [PATCH 3/6] Fix undefined secret with password-protected files (#250) --- www/common/sframe-common-outer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 8b30aa2e2..459d9bc73 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -188,13 +188,13 @@ define([ if (val) { password = val; - Cryptpad.getFileSize(window.location.href, password, function (e, size) { + Cryptpad.getFileSize(window.location.href, password, waitFor(function (e, size) { if (size !== 0) { return void todo(); } // Wrong password or deleted file? askPassword(true); - }); + })); } else { askPassword(); } From fabdbc3b6172e4d4eb9b516a2a620af1147eb9b3 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Thu, 12 Jul 2018 16:02:46 +0200 Subject: [PATCH 4/6] Add a feedback test for checking for CSS variables, so we won't use a feature which is not implemented by the vast majority of the people using CryptPad... --- www/common/cryptpad-common.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 574a696c3..69c67fdc5 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -834,6 +834,20 @@ define([ LOADING_DRIVE: common.loading.onDriveEvent.fire }; + common.hasCSSVariables = function () { + if (window.CSS && window.CSS.supports && window.CSS.supports('--a', 0)) { return true; } + // Safari lol y u always b returnin false ? + var color = 'rgb(255, 198, 0)'; + var el = document.createElement('span'); + el.style.setProperty('--color', color); + el.style.setProperty('background', 'var(--color)'); + document.body.appendChild(el); + var styles = getComputedStyle(el); + document.body.removeChild(el); + var doesSupport = (styles.backgroundColor === color); + return doesSupport; + }; + common.ready = (function () { var env = {}; var initialized = false; @@ -873,6 +887,9 @@ define([ if (typeof(ServiceWorker) === "undefined") { Feedback.send('NO_SERVICEWORKER'); } + if (!common.hasCSSVariables()) { + Feedback.send('NO_CSS_VARIABLES'); + } Feedback.reportScreenDimensions(); Feedback.reportLanguage(); From cb8888ea1aa149090d9dedbf63d84680f98be2aa Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Thu, 12 Jul 2018 16:51:48 +0200 Subject: [PATCH 5/6] Yes, so it turns out that making a small asthetic change after testing on every browser does actually break it :| --- www/common/cryptpad-common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 69c67fdc5..25f21e435 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -843,8 +843,8 @@ define([ el.style.setProperty('background', 'var(--color)'); document.body.appendChild(el); var styles = getComputedStyle(el); - document.body.removeChild(el); var doesSupport = (styles.backgroundColor === color); + document.body.removeChild(el); return doesSupport; }; From a440359bc73f810a8d1831427730bd96bb70bbb1 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Thu, 12 Jul 2018 16:59:36 +0200 Subject: [PATCH 6/6] Commit patches provided to me by someone who Seemed Trustworthy At The Time (should fix false negatives in shared-worker detection) --- www/common/cryptpad-common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 25f21e435..06f5e7ec8 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -884,7 +884,7 @@ define([ if (typeof(Worker) === "undefined") { Feedback.send('NO_WEBWORKER'); } - if (typeof(ServiceWorker) === "undefined") { + if (!('serviceWorker' in navigator)) { Feedback.send('NO_SERVICEWORKER'); } if (!common.hasCSSVariables()) {