[tbb-commits] [torbutton/master] Bug 19417: Clear asmjscache

gk at torproject.org gk at torproject.org
Fri Jun 17 14:45:16 UTC 2016


commit e264e6027a78488f9813e3796d29f52df1a189ba
Author: Georg Koppen <gk at torproject.org>
Date:   Fri Jun 17 09:49:16 2016 +0000

    Bug 19417: Clear asmjscache
    
    This patch clears the asmjscache (and the IndexedDB storage) on
    New Identity and during start-up. The latter is a suboptimal workaround
    we deploy until the asmjscache is Private Browsing Mode aware.
    InedxedDB storage is not so urgent as IndexedDB is not working in
    Private Browsing Mode anyway.
---
 src/chrome/content/torbutton.js | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index e0e541b..f69fd8a 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -578,6 +578,23 @@ function torbutton_init() {
       torbutton_update_security_slider();
     }
 
+    // XXX: Get rid of the cached asmjs (or IndexedDB) files on disk in case we
+    // don't allow things saved to disk. This is an ad-hoc fix to work around
+    // #19417. Once this is properly solved we should remove this code again.
+    if (m_tb_prefs.getBoolPref("extensions.torbutton.block_disk")) {
+      let orig_quota_test = m_tb_prefs.getBoolPref("dom.quotaManager.testing");
+      try {
+        // This works only by setting the pref to `true` otherwise we get an
+        // exception and nothing is happening.
+        m_tb_prefs.setBoolPref("dom.quotaManager.testing", true);
+        Cc["@mozilla.org/dom/quota-manager-service;1"]
+          .getService(Ci.nsIQuotaManagerService).clear();
+      } catch(e) {
+      } finally {
+        m_tb_prefs.setBoolPref("dom.quotaManager.testing", orig_quota_test);
+      }
+    }
+
     // set panel style from preferences
     torbutton_set_panel_style();
 
@@ -1677,6 +1694,7 @@ function torbutton_new_identity() {
  *      h. last open location url
  *      i. clear content prefs
  *      j. permissions
+ *      k. IndexedDB and asmjscache storage
  *   3. Sends tor the NEWNYM signal to get a new circuit
  *   4. Opens a new window with the default homepage
  *   5. Closes this window
@@ -1824,6 +1842,21 @@ function torbutton_do_new_identity() {
       window.alert("Torbutton: Unexpected error during cache clearing: "+e);
   }
 
+  torbutton_log(3, "New Identity: Clearing storage");
+
+  let orig_quota_test = m_tb_prefs.getBoolPref("dom.quotaManager.testing");
+  try {
+      // This works only by setting the pref to `true` otherwise we get an
+      // exception and nothing is happening.
+      m_tb_prefs.setBoolPref("dom.quotaManager.testing", true);
+      Cc["@mozilla.org/dom/quota-manager-service;1"]
+          .getService(Ci.nsIQuotaManagerService).clear();
+  } catch(e) {
+      torbutton_log(5, "Exception on storage clearing: "+e);
+  } finally {
+      m_tb_prefs.setBoolPref("dom.quotaManager.testing", orig_quota_test);
+  }
+
   torbutton_log(3, "New Identity: Clearing Cookies and DOM Storage");
 
   if (m_tb_prefs.getBoolPref('extensions.torbutton.cookie_protections')) {



More information about the tbb-commits mailing list