[or-cvs] r14357: Fix method copying for history wrapper. Seems to fix 'Clear (torbutton/trunk/src/components)

mikeperry at seul.org mikeperry at seul.org
Fri Apr 11 07:56:20 UTC 2008


Author: mikeperry
Date: 2008-04-11 03:56:20 -0400 (Fri, 11 Apr 2008)
New Revision: 14357

Modified:
   torbutton/trunk/src/components/ignore-history.js
Log:

Fix method copying for history wrapper. Seems to fix 'Clear
Private Data' issue.



Modified: torbutton/trunk/src/components/ignore-history.js
===================================================================
--- torbutton/trunk/src/components/ignore-history.js	2008-04-11 06:40:38 UTC (rev 14356)
+++ torbutton/trunk/src/components/ignore-history.js	2008-04-11 07:56:20 UTC (rev 14357)
@@ -58,12 +58,15 @@
     }
     return history;
   };
+    
+  this.copyMethods(this._history());
 }
 
 HistoryWrapper.prototype =
 {
   QueryInterface: function(iid) {
-    if (iid.equals(Components.interfaces.nsISupports)) {
+    if (iid.equals(Components.interfaces.nsIClassInfo)
+        || iid.equals(Components.interfaces.nsISupports)) {
       return this;
     }
 
@@ -72,6 +75,29 @@
     return this;
   },
 
+  // make this an nsIClassInfo object
+  flags: Components.interfaces.nsIClassInfo.DOM_OBJECT,
+
+  // method of nsIClassInfo
+  classDescription: "@mozilla.org/browser/global-history;2",
+  contractID: "@mozilla.org/browser/global-history;2",
+  classID: kMODULE_CID,
+
+  // method of nsIClassInfo
+  getInterfaces: function(count) {
+    var interfaceList = [Components.interfaces.nsIClassInfo];
+    for (var i = 0; i < this._interfaces.length; i++) {
+      interfaceList.push(Components.interfaces[this._interfaces[i]]);
+    }
+
+    count.value = interfaceList.length;
+    return interfaceList;
+  },
+
+  // method of nsIClassInfo  
+  getHelperForLanguage: function(count) { return null; },
+
+
   /*
    * Determine whether we should hide visited links
    */
@@ -104,11 +130,14 @@
           var params = [];
           params.length = wrapped[method].length;
           var x = 0;
-          var call = method + "("+params.join().replace(/(?:)/g,function(){return "p"+(++x)})+")";
+          var call;
+          if(params.length) call = "("+params.join().replace(/(?:)/g,function(){return "p"+(++x)})+")";
+          else call = "()";
           var fun = "function "+call+"{if (arguments.length < "+wrapped[method].length+") throw Components.results.NS_ERROR_XPC_NOT_ENOUGH_ARGS; return wrapped."+method+".apply(wrapped, arguments);}";
           // already in scope
           //var Components = this.Components;
           newObj[method] = eval(fun);
+          //dump("wrapped: "+method+": "+fun+"\n");
       } else {
           newObj.__defineGetter__(method, function() { return wrapped[method]; });
           newObj.__defineSetter__(method, function(val) { wrapped[method] = val; });



More information about the tor-commits mailing list