From efdf43f1d549d372b8925305c76731ef5837f4ed Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 30 Oct 2016 13:06:23 -0400 Subject: [PATCH] FF webext does not support getBytesInUse() --- src/js/settings.js | 6 +++++- src/js/storage.js | 13 +++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/js/settings.js b/src/js/settings.js index 26aa954e3..6315eaf18 100644 --- a/src/js/settings.js +++ b/src/js/settings.js @@ -109,7 +109,11 @@ var exportToFile = function() { var onLocalDataReceived = function(details) { uDom('#localData > ul > li:nth-of-type(1)').text( - vAPI.i18n('settingsStorageUsed').replace('{{value}}', details.storageUsed.toLocaleString()) + vAPI.i18n('settingsStorageUsed') + .replace( + '{{value}}', + typeof details.storageUsed === 'number' ? details.storageUsed.toLocaleString() : '?' + ) ); var elem, dt; diff --git a/src/js/storage.js b/src/js/storage.js index edb238976..7a42cd708 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -1,7 +1,7 @@ /******************************************************************************* - uBlock - a browser extension to block requests. - Copyright (C) 2014-2015 Raymond Hill + uBlock Origin - a browser extension to block requests. + Copyright (C) 2014-2016 Raymond Hill This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -/* global YaMD5, µBlock, vAPI, punycode, publicSuffixList */ +/* global YaMD5, punycode, publicSuffixList */ 'use strict'; @@ -33,7 +33,12 @@ µBlock.storageUsed = bytesInUse; callback(bytesInUse); }; - vAPI.storage.getBytesInUse(null, getBytesInUseHandler); + // Not all platforms implement this method. + if ( vAPI.storage.getBytesInUse instanceof Function ) { + vAPI.storage.getBytesInUse(null, getBytesInUseHandler); + } else { + callback(); + } }; /******************************************************************************/