summaryrefslogtreecommitdiff
path: root/common/content/base.js
diff options
context:
space:
mode:
Diffstat (limited to 'common/content/base.js')
-rw-r--r--common/content/base.js46
1 files changed, 25 insertions, 21 deletions
diff --git a/common/content/base.js b/common/content/base.js
index b13a1bf1..848f22d6 100644
--- a/common/content/base.js
+++ b/common/content/base.js
@@ -44,30 +44,34 @@ function allkeys(obj) {
}
}
-function keys(obj) {
- if (modules.services) {
- try {
- let ret = {};
- services.get("debugger").wrapValue(obj).getProperties(ret, {});
- for (let prop in values(ret.value))
- yield prop.name.stringValue;
- return;
- }
- catch (e) {}
+function debuggerProperties(obj) {
+ if (modules.services && options["jsdebugger"]) {
+ let ret = {};
+ services.get("debugger").wrapValue(obj).getProperties(ret, {});
+ return ret.value;
}
+}
+
+if (!Object.keys)
+ Object.keys = function keys(obj) [k for (k in obj) if (obj.hasOwnProperty(k))];
- if ("__iterator__" in obj) {
- var iter = obj.__iterator__;
- yield "__iterator__";
- // This is dangerous, but necessary.
- delete obj.__iterator__;
+if (!Object.getOwnPropertyNames)
+ Object.getOwnPropertyNames = function getOwnPropertyNames(obj) {
+ let res = debuggerProperties(obj);
+ if (res)
+ return [prop.name.stringValue for (prop in values(res))];
+ return Object.keys(obj);
}
- for (var k in obj)
- if (obj.hasOwnProperty(k))
- yield k;
- if (iter !== undefined)
- obj.__iterator__ = iter;
+
+function properties(obj, prototypes) {
+ let orig = obj;
+ let seen = {};
+ for (; obj; obj = prototypes && obj.__proto__)
+ for (let key in values(Object.getOwnPropertyNames(obj)))
+ if (!prototypes || !set.add(seen, key) && obj != orig)
+ yield key
}
+
function values(obj) {
for (var k in obj)
if (obj.hasOwnProperty(k))
@@ -273,7 +277,7 @@ function curry(fn, length, self, acc) {
function update(target) {
for (let i = 1; i < arguments.length; i++) {
let src = arguments[i];
- foreach(keys(src || {}), function (k) {
+ Object.getOwnPropertyNames(src || {}).forEach(function (k) {
var get = src.__lookupGetter__(k),
set = src.__lookupSetter__(k);
if (!get && !set) {