summaryrefslogtreecommitdiff
path: root/common/modules
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-06-17 18:18:34 -0400
committerKris Maglione <maglione.k@gmail.com>2011-06-17 18:18:34 -0400
commit94c9515422de9e9983a47799e3f18a57bb60b9ac (patch)
tree79369b43ef3bb44e6445116efb48d7c3812f9f40 /common/modules
parent3c15e4d29025cd6caa62693e68ce8463388b715f (diff)
downloadpentadactyl-94c9515422de9e9983a47799e3f18a57bb60b9ac.tar.gz
Clobber focusAndSelectUrlBar.
Diffstat (limited to 'common/modules')
-rw-r--r--common/modules/util.jsm35
1 files changed, 28 insertions, 7 deletions
diff --git a/common/modules/util.jsm b/common/modules/util.jsm
index d183b9c8..688a054a 100644
--- a/common/modules/util.jsm
+++ b/common/modules/util.jsm
@@ -1338,12 +1338,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
// Guard against horrible add-ons that use eval-based monkey
// patching.
+ let value = desc.value;
if (callable(desc.value)) {
- let value = desc.value;
-
- let sentinel = "(function DactylOverlay() {}())"
- value.toString = function toString() toString.toString.call(this).replace(/\}?$/, sentinel + "; $&");
- value.toSource = function toSource() toSource.toSource.call(this).replace(/\}?$/, sentinel + "; $&");
delete desc.value;
delete desc.writable;
@@ -1359,12 +1355,37 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
};
}
- Object.defineProperty(object, k, desc);
+ try {
+ Object.defineProperty(object, k, desc);
+
+ if (callable(value)) {
+ let sentinel = "(function DactylOverlay() {}())"
+ value.toString = function toString() toString.toString.call(this).replace(/\}?$/, sentinel + "; $&");
+ value.toSource = function toSource() toSource.toSource.call(this).replace(/\}?$/, sentinel + "; $&");
+ }
+ }
+ catch (e) {
+ try {
+ if (value) {
+ object[k] = value;
+ return;
+ }
+ }
+ catch (f) {}
+ util.reportError(e);
+ }
}, this);
return function unwrap() {
for each (let k in Object.getOwnPropertyNames(original))
- Object.defineProperty(object, k, Object.getOwnPropertyDescriptor(original, k));
+ if (Object.getOwnPropertyDescriptor(object, k).configurable)
+ Object.defineProperty(object, k, Object.getOwnPropertyDescriptor(original, k));
+ else {
+ try {
+ object[k] = original[k];
+ }
+ catch (e) {}
+ }
};
},