From 681d2caca7cab9380fc0d4aadfcc46224db210f0 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 6 Nov 2020 19:19:18 +0530 Subject: [PATCH 01/11] minimal patch for iOS firefox --- www/common/boot2.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/www/common/boot2.js b/www/common/boot2.js index 30f776a25..87bba4a43 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -37,6 +37,42 @@ 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 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(); From 760356c4ffc56a3c622e4a4ac4b7a73f74132a83 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 6 Nov 2020 19:28:36 +0530 Subject: [PATCH 02/11] patch loading.js --- customize.dist/loading.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/customize.dist/loading.js b/customize.dist/loading.js index edb66ef0a..1db126fa5 100644 --- a/customize.dist/loading.js +++ b/customize.dist/loading.js @@ -312,15 +312,24 @@ button.primary:hover{ return bar; }; + var hideSpinner = function () { + try { + document.querySelector('.cp-loading-spinner-container').style.display = 'none'; + document.querySelector('.cp-loading-spinner-container').setAttribute('style', 'display:none;'); + } catch (err) { return; } + }; + 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 { - 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); + hideSpinner(); + var list = document.querySelector('.cp-loading-progress-list'); + list && (list.innerHTML = makeList(data)); + var container = document.querySelector('.cp-loading-progress-container'); + container && (container.innerHTML = makeBar(data)); } catch (e) { if (!hasErrored) { console.error(e); } } @@ -329,6 +338,7 @@ button.primary:hover{ window.CryptPad_loadingError = function (err) { if (!built) { return; } + console.error(err); hasErrored = true; var err2; if (err === 'Script error.') { @@ -339,10 +349,12 @@ button.primary:hover{ var node = document.querySelector('.cp-loading-progress'); if (!node) { return; } if (node.parentNode) { node.parentNode.removeChild(node); } - document.querySelector('.cp-loading-spinner-container').setAttribute('style', 'display:none;'); + hideSpinner(); 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; From 46703d627b36144972e201e0f27d857e61a10d94 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 6 Nov 2020 19:30:57 +0530 Subject: [PATCH 03/11] . --- www/common/cryptpad-common.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index ca65ce77b..c4be384b8 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -2056,6 +2056,8 @@ define([ }; var userHash; + console.error("pewpew"); + //console.error('pewpew'); Nthen(function (waitFor) { if (AppConfig.beforeLogin) { @@ -2108,6 +2110,7 @@ define([ // FIXME Backward compatibility if (sessionStorage.newPadFileData) { + /* common.fromFileData = JSON.parse(sessionStorage.newPadFileData); var _parsed1 = Hash.parsePadUrl(common.fromFileData.href); var _parsed2 = Hash.parsePadUrl(window.location.href); @@ -2115,6 +2118,7 @@ define([ if (_parsed1.type !== _parsed2.type) { delete common.fromFileData; } } delete sessionStorage.newPadFileData; + */ } if (sessionStorage.newPadPath) { @@ -2134,11 +2138,12 @@ define([ var postMsg, worker; var noWorker = AppConfig.disableWorkers || false; var noSharedWorker = false; - if (localStorage.CryptPad_noWorkers) { + if (localStorage.CryptPad_noWorkers || true) { noWorker = localStorage.CryptPad_noWorkers === '1'; - console.error('WebWorker/SharedWorker state forced to ' + !noWorker); + //console.error('WebWorker/SharedWorker state forced to ' + !noWorker); } Nthen(function (waitFor2) { + return; if (Worker) { var w = waitFor2(); try { @@ -2161,6 +2166,7 @@ define([ w(); } } + return; if (typeof(SharedWorker) !== "undefined") { try { new SharedWorker(''); @@ -2170,6 +2176,18 @@ define([ } } }).nThen(function (waitFor2) { + // Use the async store in the main thread if workers are not available + require(['/common/outer/noworker.js'], waitFor2(function (NoWorker) { + NoWorker.onMessage(function (data) { + msgEv.fire({data: data}); + }); + postMsg = function (d) { setTimeout(function () { NoWorker.query(d); }); }; + NoWorker.create(); + })); + return; + + + if (!noWorker && !noSharedWorker && typeof(SharedWorker) !== "undefined") { worker = new SharedWorker('/common/outer/sharedworker.js?' + urlArgs); worker.onerror = function (e) { @@ -2337,6 +2355,8 @@ define([ } if (parsedNew.hashData) { oldHref = newHref; } }; + + /* // Listen for login/logout in other tabs window.addEventListener('storage', function (e) { if (e.key !== Constants.userHashKey) { return; } @@ -2347,7 +2367,7 @@ define([ } else if (o && !n) { LocalStore.logout(); } - }); + });*/ LocalStore.onLogout(function () { console.log('onLogout: disconnect'); postMessage("DISCONNECT"); @@ -2367,6 +2387,7 @@ define([ common.mergeAnonDrive(waitFor()); } }).nThen(function (waitFor) { + return; if (AppConfig.afterLogin) { AppConfig.afterLogin(common, waitFor()); } From b155f7b2911aefdddd327b81152978d42babdebc Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 17 Nov 2020 16:09:47 +0530 Subject: [PATCH 04/11] increase child-process timeout and improve error handling --- lib/workers/db-worker.js | 4 ++-- lib/workers/index.js | 4 +++- www/common/common-util.js | 13 +++++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/workers/db-worker.js b/lib/workers/db-worker.js index 42c75fdca..0b4c4d03d 100644 --- a/lib/workers/db-worker.js +++ b/lib/workers/db-worker.js @@ -568,7 +568,7 @@ process.on('message', function (data) { const cb = function (err, value) { process.send({ - error: err, + error: Util.serializeError(err), txid: data.txid, pid: data.pid, value: value, @@ -577,7 +577,7 @@ process.on('message', function (data) { if (!ready) { return void init(data.config, function (err) { - if (err) { return void cb(err); } + if (err) { return void cb(Util.serializeError(err)); } ready = true; cb(); }); diff --git a/lib/workers/index.js b/lib/workers/index.js index 6e9f57e88..522339812 100644 --- a/lib/workers/index.js +++ b/lib/workers/index.js @@ -9,6 +9,7 @@ const PID = process.pid; const DB_PATH = 'lib/workers/db-worker'; const MAX_JOBS = 16; +const DEFAULT_QUERY_TIMEOUT = 60000 * 15; // increased from three to fifteen minutes because queries for very large files were taking as long as seven minutes Workers.initialize = function (Env, config, _cb) { var cb = Util.once(Util.mkAsync(_cb)); @@ -113,6 +114,7 @@ Workers.initialize = function (Env, config, _cb) { const txid = guid(); var cb = Util.once(Util.mkAsync(Util.both(_cb, function (err /*, value */) { if (err !== 'TIMEOUT') { return; } + Log.debug("WORKER_TIMEOUT_CAUSE", msg); // in the event of a timeout the user will receive an error // but the state used to resend a query in the event of a worker crash // won't be cleared. This also leaks a slot that could be used to keep @@ -132,7 +134,7 @@ Workers.initialize = function (Env, config, _cb) { state.tasks[txid] = msg; // default to timing out affter 180s if no explicit timeout is passed - var timeout = typeof(opt.timeout) !== 'undefined'? opt.timeout: 180000; + var timeout = typeof(opt.timeout) !== 'undefined'? opt.timeout: DEFAULT_QUERY_TIMEOUT; response.expect(txid, cb, timeout); state.worker.send(msg); }; diff --git a/www/common/common-util.js b/www/common/common-util.js index 41797e7c8..dfc6e12d7 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -30,6 +30,15 @@ return JSON.parse(JSON.stringify(o)); }; + Util.serializeError = function (err) { + if (!(err instanceof Error)) { return err; } + var ser = {}; + Object.getOwnPropertyNames(err).forEach(function (key) { + ser[key] = err[key]; + }); + return ser; + }; + Util.tryParse = function (s) { try { return JSON.parse(s); } catch (e) { return;} }; @@ -113,13 +122,13 @@ var handle = function (id, args) { var fn = pending[id]; if (typeof(fn) !== 'function') { - errorHandler("MISSING_CALLBACK", { + return void errorHandler("MISSING_CALLBACK", { id: id, args: args, }); } try { - pending[id].apply(null, Array.isArray(args)? args : [args]); + fn.apply(null, Array.isArray(args)? args : [args]); } catch (err) { errorHandler('HANDLER_ERROR', { error: err, From 0e0c0fd6556d082d265456959e80ee9077fa790b Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 17 Nov 2020 17:45:02 +0530 Subject: [PATCH 05/11] guard against typeError for unsupported notification APIs --- www/common/notify.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/common/notify.js b/www/common/notify.js index a3c8cd2b8..81dee662d 100644 --- a/www/common/notify.js +++ b/www/common/notify.js @@ -16,6 +16,8 @@ define(['/api/config'], function (ApiConfig) { var getPermission = Module.getPermission = function (f) { f = f || function () {}; + // "Notification.requestPermission is not a function" on Firefox 68.11.0esr + if (!Notification || typeof(Notification.requestPermission) !== 'function') { return void f(false); } Notification.requestPermission(function (permission) { if (permission === "granted") { f(true); } else { f(false); } From ebc394c4b31f81866162f662e8487d4c14554c24 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 17 Nov 2020 18:09:34 +0530 Subject: [PATCH 06/11] expose defaultStorageLimit via /api/config --- server.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server.js b/server.js index 60247f47a..eb2787475 100644 --- a/server.js +++ b/server.js @@ -202,6 +202,7 @@ var serveConfig = (function () { adminKeys: Env.admins, inactiveTime: Env.inactiveTime, supportMailbox: Env.supportMailbox, + defaultStorageLimit: Env.defaultStorageLimit, maxUploadSize: Env.maxUploadSize, premiumUploadSize: Env.premiumUploadSize, }, null, '\t'), From c9ce6da49628166a05518a076c0c459623aeeaec Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 17 Nov 2020 19:05:05 +0530 Subject: [PATCH 07/11] . --- www/common/cryptpad-common.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index c4be384b8..cb312892b 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -2056,8 +2056,6 @@ define([ }; var userHash; - console.error("pewpew"); - //console.error('pewpew'); Nthen(function (waitFor) { if (AppConfig.beforeLogin) { @@ -2355,8 +2353,6 @@ define([ } if (parsedNew.hashData) { oldHref = newHref; } }; - - /* // Listen for login/logout in other tabs window.addEventListener('storage', function (e) { if (e.key !== Constants.userHashKey) { return; } @@ -2367,7 +2363,7 @@ define([ } else if (o && !n) { LocalStore.logout(); } - });*/ + }); LocalStore.onLogout(function () { console.log('onLogout: disconnect'); postMessage("DISCONNECT"); @@ -2387,7 +2383,6 @@ define([ common.mergeAnonDrive(waitFor()); } }).nThen(function (waitFor) { - return; if (AppConfig.afterLogin) { AppConfig.afterLogin(common, waitFor()); } From b37fd224b0381d4f5ab9f3a61b3302130c058d26 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 17 Nov 2020 19:19:55 +0530 Subject: [PATCH 08/11] continue bisecting --- www/common/cryptpad-common.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index cb312892b..2d7440087 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -2056,6 +2056,7 @@ define([ }; var userHash; + console.error('without this error statement Firefox on iOS throws a script error...'); Nthen(function (waitFor) { if (AppConfig.beforeLogin) { @@ -2108,7 +2109,6 @@ define([ // FIXME Backward compatibility if (sessionStorage.newPadFileData) { - /* common.fromFileData = JSON.parse(sessionStorage.newPadFileData); var _parsed1 = Hash.parsePadUrl(common.fromFileData.href); var _parsed2 = Hash.parsePadUrl(window.location.href); @@ -2116,7 +2116,6 @@ define([ if (_parsed1.type !== _parsed2.type) { delete common.fromFileData; } } delete sessionStorage.newPadFileData; - */ } if (sessionStorage.newPadPath) { @@ -2136,12 +2135,11 @@ define([ var postMsg, worker; var noWorker = AppConfig.disableWorkers || false; var noSharedWorker = false; - if (localStorage.CryptPad_noWorkers || true) { + if (localStorage.CryptPad_noWorkers) { noWorker = localStorage.CryptPad_noWorkers === '1'; - //console.error('WebWorker/SharedWorker state forced to ' + !noWorker); + console.error('WebWorker/SharedWorker state forced to ' + !noWorker); } Nthen(function (waitFor2) { - return; if (Worker) { var w = waitFor2(); try { @@ -2164,7 +2162,6 @@ define([ w(); } } - return; if (typeof(SharedWorker) !== "undefined") { try { new SharedWorker(''); @@ -2174,18 +2171,6 @@ define([ } } }).nThen(function (waitFor2) { - // Use the async store in the main thread if workers are not available - require(['/common/outer/noworker.js'], waitFor2(function (NoWorker) { - NoWorker.onMessage(function (data) { - msgEv.fire({data: data}); - }); - postMsg = function (d) { setTimeout(function () { NoWorker.query(d); }); }; - NoWorker.create(); - })); - return; - - - if (!noWorker && !noSharedWorker && typeof(SharedWorker) !== "undefined") { worker = new SharedWorker('/common/outer/sharedworker.js?' + urlArgs); worker.onerror = function (e) { From 30e1c448d39a6c294f0911d26d5d5d59d5c388d9 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 17 Nov 2020 19:35:09 +0530 Subject: [PATCH 09/11] cleanup and lint compliance --- customize.dist/loading.js | 15 ++++++++++----- www/common/boot2.js | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/customize.dist/loading.js b/customize.dist/loading.js index 1db126fa5..e3f5c24f7 100644 --- a/customize.dist/loading.js +++ b/customize.dist/loading.js @@ -315,10 +315,17 @@ button.primary:hover{ var hideSpinner = function () { try { document.querySelector('.cp-loading-spinner-container').style.display = 'none'; - document.querySelector('.cp-loading-spinner-container').setAttribute('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; } @@ -326,10 +333,8 @@ button.primary:hover{ if (c < current) { return console.error(data); } try { hideSpinner(); - var list = document.querySelector('.cp-loading-progress-list'); - list && (list.innerHTML = makeList(data)); - var container = document.querySelector('.cp-loading-progress-container'); - container && (container.innerHTML = makeBar(data)); + getList().innerHTML = makeList(data); + getProgressBar().innerHTML = makeBar(data); } catch (e) { if (!hasErrored) { console.error(e); } } diff --git a/www/common/boot2.js b/www/common/boot2.js index 87bba4a43..0d879b32f 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -61,7 +61,7 @@ define([ if (window.Proxy) { var c = console; - window.console = new Proxy(c, { + window.console = new window.Proxy(c, { get: function (o, k) { if (k !== 'error') { return o[k]; } return function () { From 713516f7517ff135ebc53ee64166db78124eaf9b Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 17 Nov 2020 19:52:37 +0530 Subject: [PATCH 10/11] 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()); } From 700ea4c282fecd92781fcd5c659e53c054e9dc2d Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 17 Nov 2020 20:25:12 +0530 Subject: [PATCH 11/11] minimal patch and an ominous warning comment --- www/common/cryptpad-common.js | 42 +++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 2aaa50796..9a9807e7e 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -2057,26 +2057,34 @@ define([ var userHash; - 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); + (function iOSFirefoxFix () { +/* + For some bizarre reason Firefox on iOS throws an error during the + loading process unless we call this function. Drawing these elements + to the DOM presumably causes the JS engine to wait just a little bit longer + until some APIs we need are ready. This occurs despite all this code being + run after the usual dom-ready events. This fix was discovered while trying + to log the error messages to the DOM because it's extremely difficult + to debug Firefox iOS in the usual ways. In summary, computers are terrible. +*/ + try { var style = document.createElement('style'); - style.type = 'text/css'; - style.appendChild(document.createTextNode(css)); + style.type = 'text/css'; + style.appendChild(document.createTextNode('#cp-logger { display: none; }')); document.head.appendChild(style); - return logger; - }; - var logToDom = function () { + + var logger = document.createElement('div'); + logger.setAttribute('id', 'cp-logger'); + document.body.appendChild(logger); + var pre = document.createElement('pre'); - pre.innerText = 'x'; - getLogElement(); - getLogElement().appendChild(pre); - }; - logToDom(); - }).nThen(function (waitFor) { + pre.innerText = 'x'; + pre.style.display = 'none'; + logger.appendChild(pre); + } catch (err) { console.error(err); } + }()); + + Nthen(function (waitFor) { if (AppConfig.beforeLogin) { AppConfig.beforeLogin(LocalStore.isLoggedIn(), waitFor()); }