[or-cvs] r11739: Fix incompatibily with debuglogger due to new event mechanis (in torbutton/trunk/src: . chrome/content)

mikeperry at seul.org mikeperry at seul.org
Tue Oct 2 05:36:18 UTC 2007


Author: mikeperry
Date: 2007-10-02 01:36:18 -0400 (Tue, 02 Oct 2007)
New Revision: 11739

Modified:
   torbutton/trunk/src/CHANGELOG
   torbutton/trunk/src/chrome/content/torbutton.js
   torbutton/trunk/src/chrome/content/torbutton_util.js
Log:

Fix incompatibily with debuglogger due to new event mechanism.
Update changelog. 



Modified: torbutton/trunk/src/CHANGELOG
===================================================================
--- torbutton/trunk/src/CHANGELOG	2007-10-02 01:22:42 UTC (rev 11738)
+++ torbutton/trunk/src/CHANGELOG	2007-10-02 05:36:18 UTC (rev 11739)
@@ -1,15 +1,16 @@
 1.1.8
-  XX Oct 2007
-  * bugfix: bug 503: prevent sessionstore from writing Tor tabs to disk
-  * bugfix: bug 510: decouple cookie clearing from Clear Private Data settings
-  * bugfix: bug 474: decouple password+form saving from history writing
-  * bugfix: bug 460: rework handling of hooking based on global events+window
+  01 Oct 2007
+  * bugfix: bug 503: Prevent sessionstore from writing Tor tabs to disk
+  * bugfix: bug 510: Decouple cookie clearing from Clear Private Data settings
+  * bugfix: bug 474: Decouple password+form saving from history writing
+  * bugfix: bug 460: Rework handling of hooking based on global events+window
     lookup
-  * bugfix: cookies are now properly synced before storing into a jar
-  * misc: tightened up the alerts a bit more for the javascript hooking
-  * misc: changed defaults to be less intrusive to non-tor usage
+  * bugfix: Hooking fixes for pages with nested frames/iframes
+  * bugfix: Cookies are now properly synced before storing into a jar
+  * misc: Tightened up the alerts a bit more for the javascript hooking
+  * misc: Changed defaults to be less intrusive to non-tor usage
   * new: Added options to start in Tor and reload cookies after browser crash 
-  * new: Added ability to have both tor and non-tor jars
+  * new: Added ability to have both tor and non-tor cookie jars
 
 1.1.7
   20 Sep 2007

Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js	2007-10-02 01:22:42 UTC (rev 11738)
+++ torbutton/trunk/src/chrome/content/torbutton.js	2007-10-02 05:36:18 UTC (rev 11739)
@@ -1134,13 +1134,16 @@
 function torbutton_check_progress(aProgress) {
     // This fires when the location bar changes i.e load event is confirmed
     // or when the user switches tabs
+
+    // XXX: Warning! this can also fire when the 'debuglogger' extension
+    // updates its window. Typically for this, doc.domain is null. Do not
+    // log in this case (until we find a better way to filter those
+    // events out). Use torbutton_eclog for common-path stuff.
     if(aProgress) {
-        torbutton_log(1, "location progress");
         var doc = aProgress.DOMWindow.document;
         try {
             if(doc && doc.domain)
                 torbutton_hookdoc(aProgress.DOMWindow.window, doc);
-            else torbutton_log(2, "No DOM yet at location event");
         } catch(e) {
             torbutton_log(3, "Hit about:plugins? "+doc.location);
         }        
@@ -1163,25 +1166,25 @@
 
   onStateChange: function(aProgress, aRequest, aFlag, aStatus)
   { 
-      torbutton_log(1, 'State change()');
+      torbutton_eclog(1, 'State change()');
       return torbutton_check_progress(aProgress);
   },
 
   onLocationChange: function(aProgress, aRequest, aURI)
   {
-      torbutton_log(1, 'onLocationChange');
+      torbutton_eclog(1, 'onLocationChange: '+aURI.asciiSpec);
       return torbutton_check_progress(aProgress);
   },
 
   onProgressChange: function(aProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) 
   { 
-      torbutton_log(1, 'called progressChange'); 
+      torbutton_eclog(1, 'called progressChange'); 
       return torbutton_check_progress(aProgress);
   },
   
   onStatusChange: function(aProgress, request, stat, message) 
   { 
-      torbutton_log(1, 'called progressChange'); 
+      torbutton_eclog(1, 'called progressChange'); 
       return torbutton_check_progress(aProgress);
   },
   

Modified: torbutton/trunk/src/chrome/content/torbutton_util.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton_util.js	2007-10-02 01:22:42 UTC (rev 11738)
+++ torbutton/trunk/src/chrome/content/torbutton_util.js	2007-10-02 05:36:18 UTC (rev 11739)
@@ -13,11 +13,23 @@
                     .getService(Components.interfaces.nsIDebugLoggerManager); 
     m_tb_logger = logMngr.registerLogger("torbutton");
 } catch (exErr) {
-    m_tb_console = Components.classes["@mozilla.org/consoleservice;1"]
-                    .getService(Components.interfaces.nsIConsoleService);
     m_tb_logger = false;
 }
+m_tb_console = Components.classes["@mozilla.org/consoleservice;1"]
+.getService(Components.interfaces.nsIConsoleService);
 
+function torbutton_eclog(nLevel, sMsg) {
+    if(!m_tb_debug) return true;
+    var rDate = new Date();
+    
+    if (m_tb_console && nLevel >= m_tb_loglevel) {
+        m_tb_console.logStringMessage(rDate.getTime()+': '+sMsg);
+    } else if (nLevel >= m_tb_loglevel) {
+        dump(rDate.getTime()+': '+sMsg+"\n");
+    }
+    return true;
+}
+
 function torbutton_log(nLevel, sMsg) {
     if(!m_tb_debug) return true;
 



More information about the tor-commits mailing list