bool BaseProxyHandler::getOwnEnumerablePropertyKeys(JSContext *cx, HandleObject proxy, AutoIdVector &props) const { assertEnteredPolicy(cx, proxy, JSID_VOID, ENUMERATE); MOZ_ASSERT(props.length() == 0); if (!ownPropertyKeys(cx, proxy, props)) return false; /* Select only the enumerable properties through in-place iteration. */ RootedId id(cx); size_t i = 0; for (size_t j = 0, len = props.length(); j < len; j++) { MOZ_ASSERT(i <= j); id = props[j]; if (JSID_IS_SYMBOL(id)) continue; AutoWaivePolicy policy(cx, proxy, id, BaseProxyHandler::GET); Rooted<PropertyDescriptor> desc(cx); if (!getOwnPropertyDescriptor(cx, proxy, id, &desc)) return false; if (desc.object() && desc.isEnumerable()) props[i++].set(id); } MOZ_ASSERT(i <= props.length()); props.resize(i); return true; }
bool JSProxyHandler::enumerateOwn(JSContext *cx, JSObject *proxy, AutoIdVector &props) { JS_ASSERT(OperationInProgress(cx, proxy)); JS_ASSERT(props.length() == 0); if (!getOwnPropertyNames(cx, proxy, props)) return false; /* Select only the enumerable properties through in-place iteration. */ AutoPropertyDescriptorRooter desc(cx); size_t i = 0; for (size_t j = 0, len = props.length(); j < len; j++) { JS_ASSERT(i <= j); jsid id = props[j]; if (!getOwnPropertyDescriptor(cx, proxy, id, false, &desc)) return false; if (desc.obj && (desc.attrs & JSPROP_ENUMERATE)) props[i++] = id; } JS_ASSERT(i <= props.length()); props.resize(i); return true; }
static bool Filter(JSContext *cx, JSObject *wrapper, AutoIdVector &props) { size_t w = 0; for (size_t n = 0; n < props.length(); ++n) { jsid id = props[n]; if (Policy::check(cx, wrapper, id, Wrapper::GET)) props[w++] = id; else if (JS_IsExceptionPending(cx)) return false; } props.resize(w); return true; }
static bool Filter(JSContext *cx, JSObject *wrapper, AutoIdVector &props) { size_t w = 0; for (size_t n = 0; n < props.length(); ++n) { jsid id = props[n]; Permission perm; if (!Policy::check(cx, wrapper, id, Wrapper::GET, perm)) return false; // Error if (perm != DenyAccess) props[w++] = id; } props.resize(w); return true; }
static bool Filter(JSContext* cx, HandleObject wrapper, AutoIdVector& props) { size_t w = 0; RootedId id(cx); for (size_t n = 0; n < props.length(); ++n) { id = props[n]; if (Policy::check(cx, wrapper, id, Wrapper::GET) || Policy::check(cx, wrapper, id, Wrapper::SET)) props[w++].set(id); else if (JS_IsExceptionPending(cx)) return false; } props.resize(w); return true; }