From 713516f7517ff135ebc53ee64166db78124eaf9b Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 17 Nov 2020 19:52:37 +0530 Subject: [PATCH] keep bisecting to narrow down on the Firefox iOS error --- customize.dist/loading.js | 27 +++++--------------------- www/common/boot2.js | 36 ----------------------------------- www/common/cryptpad-common.js | 22 +++++++++++++++++++-- 3 files changed, 25 insertions(+), 60 deletions(-) diff --git a/customize.dist/loading.js b/customize.dist/loading.js index e3f5c24f7..edb66ef0a 100644 --- a/customize.dist/loading.js +++ b/customize.dist/loading.js @@ -312,29 +312,15 @@ button.primary:hover{ return bar; }; - var hideSpinner = function () { - try { - document.querySelector('.cp-loading-spinner-container').style.display = 'none'; - } catch (err) { return; } - }; - - var getList = function () { - return document.querySelector('.cp-loading-progress-list') || {}; - }; - - var getProgressBar = function () { - return document.querySelector('.cp-loading-progress-container') || {}; - }; - var hasErrored = false; var updateLoadingProgress = function (data) { if (!built || !data) { return; } var c = types.indexOf(data.type); if (c < current) { return console.error(data); } try { - hideSpinner(); - getList().innerHTML = makeList(data); - getProgressBar().innerHTML = makeBar(data); + document.querySelector('.cp-loading-spinner-container').style.display = 'none'; + document.querySelector('.cp-loading-progress-list').innerHTML = makeList(data); + document.querySelector('.cp-loading-progress-container').innerHTML = makeBar(data); } catch (e) { if (!hasErrored) { console.error(e); } } @@ -343,7 +329,6 @@ button.primary:hover{ window.CryptPad_loadingError = function (err) { if (!built) { return; } - console.error(err); hasErrored = true; var err2; if (err === 'Script error.') { @@ -354,12 +339,10 @@ button.primary:hover{ var node = document.querySelector('.cp-loading-progress'); if (!node) { return; } if (node.parentNode) { node.parentNode.removeChild(node); } - hideSpinner(); + document.querySelector('.cp-loading-spinner-container').setAttribute('style', 'display:none;'); document.querySelector('#cp-loading-message').setAttribute('style', 'display:block;'); document.querySelector('#cp-loading-message').innerText = err2 || err; - } catch (e) { - console.error(e); - } + } catch (e) { console.error(e); } }; return function () { built = true; diff --git a/www/common/boot2.js b/www/common/boot2.js index 0d879b32f..30f776a25 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -37,42 +37,6 @@ define([ window.alert("CryptPad needs localStorage to work. Try changing your cookie permissions, or using a different browser"); }; - - var getLogElement = function () { - var logger = document.querySelector('#cp-logger'); - if (logger) { return logger; } - logger = document.createElement('div'); - logger.setAttribute('id', 'cp-logger'); - document.body.appendChild(logger); - var css = function(){/* #cp-logger { display: none; } */}.toString().slice(14, -3); - var style = document.createElement('style'); - style.type = 'text/css'; - style.appendChild(document.createTextNode(css)); - document.head.appendChild(style); - return logger; - }; - - - var logToDom = function () { - var pre = document.createElement('pre'); - pre.innerText = 'x'; - getLogElement().appendChild(pre); - }; - - if (window.Proxy) { - var c = console; - window.console = new window.Proxy(c, { - get: function (o, k) { - if (k !== 'error') { return o[k]; } - return function () { - var args = Array.prototype.slice.call(arguments); - c.error.apply(null, args); - logToDom(); - }; - }, - }); - } - window.onerror = function (e) { if (/requirejs\.org/.test(e)) { console.log(); diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 2d7440087..2aaa50796 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -2056,9 +2056,27 @@ define([ }; var userHash; - console.error('without this error statement Firefox on iOS throws a script error...'); - Nthen(function (waitFor) { + Nthen(function () { + var getLogElement = function () { + var logger = document.createElement('div'); + logger.setAttribute('id', 'cp-logger'); + document.body.appendChild(logger); + var css = function(){/* #cp-logger { display: none; } */}.toString().slice(14, -3); + var style = document.createElement('style'); + style.type = 'text/css'; + style.appendChild(document.createTextNode(css)); + document.head.appendChild(style); + return logger; + }; + var logToDom = function () { + var pre = document.createElement('pre'); + pre.innerText = 'x'; + getLogElement(); + getLogElement().appendChild(pre); + }; + logToDom(); + }).nThen(function (waitFor) { if (AppConfig.beforeLogin) { AppConfig.beforeLogin(LocalStore.isLoggedIn(), waitFor()); }