From f396a0df96ef09f21b4e4386cac22fbe1b967c6f Mon Sep 17 00:00:00 2001 From: "Marshall T. Rose" Date: Wed, 3 May 2017 18:08:18 -0700 Subject: [PATCH 1/3] =?UTF-8?q?If=20you=20look=20at=20https://github.com/b?= =?UTF-8?q?rave/browser-laptop/commit/40abc0c780050eb0b8dd42c15=20065d1c78?= =?UTF-8?q?4268b47#diff-8a9bac13ef6264feb2b6da7c18d86b3cL733=20and=20https?= =?UTF-8?q?://github.com/brave/browser-laptop/commit/40abc0c780050eb0b8dd4?= =?UTF-8?q?2c15=20065d1c784268b47#diff-8a9bac13ef6264feb2b6da7c18d86b3cL74?= =?UTF-8?q?6=20you=E2=80=99ll=20see=20that=20the=20old=20code=20had=20a=20?= =?UTF-8?q?catch=20to=20deal=20with=20clean-up=20errors.=20The=20new=20cod?= =?UTF-8?q?e=20doesn=E2=80=99t.=20This=20fixes=20that=20in=20filtering.js?= =?UTF-8?q?=20=E2=80=A6=20whether=20or=20not=20there=20should=20be=20a=20c?= =?UTF-8?q?atch=20is=20a=20different=20issue.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, in tabs.js, I consistently get a crash when starting up my test browser, this fixes that. --- app/browser/tabs.js | 2 +- app/filtering.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/browser/tabs.js b/app/browser/tabs.js index 2ba7b9d61b..cbf42ff942 100644 --- a/app/browser/tabs.js +++ b/app/browser/tabs.js @@ -199,7 +199,7 @@ const updateAboutDetails = (tab, tabValue) => { trackedBlockersCount, adblockCount, httpsUpgradedCount, - newTabDetail: newTabDetail.toJS() + newTabDetail: newTabDetail && newTabDetail.toJS() }) } else if (location === 'about:autofill') { const defaultSession = session.defaultSession diff --git a/app/filtering.js b/app/filtering.js index 00ed780b2f..523a6f0787 100644 --- a/app/filtering.js +++ b/app/filtering.js @@ -735,23 +735,23 @@ module.exports.isResourceEnabled = (resourceName, url, isPrivate) => { * Clears all storage data. * This includes: appcache, cookies, filesystem, indexdb, local storage, * shadercache, websql, and serviceworkers. - * @return a promise that always resolves (called on app shutdon so must always) */ +var clear = (ses, f) => { return () => { try { ses[f]() } catch (ex) {} } } + module.exports.clearStorageData = () => { for (let partition in registeredSessions) { let ses = registeredSessions[partition] - setImmediate(ses.clearStorageData.bind(ses)) + setImmediate(clear(ses, 'clearStorageData').bind(ses)) } } /** - * Clears all session cache. - * @return a promise that always resolves (called on app shutdon so must always) + * Clears all session caches. */ module.exports.clearCache = () => { for (let partition in registeredSessions) { let ses = registeredSessions[partition] - setImmediate(ses.clearCache.bind(ses)) + setImmediate(clear(ses, 'clearCache').bind(ses)) } } From 3ec9e6103ff2a1b0c062ff3598361db56dc9afd2 Mon Sep 17 00:00:00 2001 From: "Marshall T. Rose" Date: Wed, 3 May 2017 20:28:34 -0700 Subject: [PATCH 2/3] Better fix from @bridiver --- app/filtering.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/filtering.js b/app/filtering.js index 523a6f0787..343736120f 100644 --- a/app/filtering.js +++ b/app/filtering.js @@ -736,12 +736,12 @@ module.exports.isResourceEnabled = (resourceName, url, isPrivate) => { * This includes: appcache, cookies, filesystem, indexdb, local storage, * shadercache, websql, and serviceworkers. */ -var clear = (ses, f) => { return () => { try { ses[f]() } catch (ex) {} } } - module.exports.clearStorageData = () => { for (let partition in registeredSessions) { let ses = registeredSessions[partition] - setImmediate(clear(ses, 'clearStorageData').bind(ses)) + setImmediate(() => { + ses.clearStorageData(() => {}) + }) } } @@ -751,7 +751,9 @@ module.exports.clearStorageData = () => { module.exports.clearCache = () => { for (let partition in registeredSessions) { let ses = registeredSessions[partition] - setImmediate(clear(ses, 'clearCache').bind(ses)) + setImmediate(() => { + ses.clearCache(() => {}) + }) } } From 0e316500f47a28115f6bd27ef425427eb2fdd7d5 Mon Sep 17 00:00:00 2001 From: "Marshall T. Rose" Date: Wed, 3 May 2017 20:30:22 -0700 Subject: [PATCH 3/3] Don't forget the .bind() --- app/filtering.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/filtering.js b/app/filtering.js index 343736120f..17f418d24f 100644 --- a/app/filtering.js +++ b/app/filtering.js @@ -740,7 +740,7 @@ module.exports.clearStorageData = () => { for (let partition in registeredSessions) { let ses = registeredSessions[partition] setImmediate(() => { - ses.clearStorageData(() => {}) + ses.clearStorageData.bind(ses)(() => {}) }) } } @@ -752,7 +752,7 @@ module.exports.clearCache = () => { for (let partition in registeredSessions) { let ses = registeredSessions[partition] setImmediate(() => { - ses.clearCache(() => {}) + ses.clearCache.bind(ses)(() => {}) }) } }