bool ObjectWrapper::Key::hasOwn(JSContext* cx, JS::HandleObject o) { bool has; switch (_type) { case Type::Field: if (JS_AlreadyHasOwnProperty(cx, o, _field, &has)) return has; break; case Type::Index: if (JS_AlreadyHasOwnElement(cx, o, _idx, &has)) return has; break; case Type::Id: { JS::RootedId id(cx, _id); if (JS_AlreadyHasOwnPropertyById(cx, o, id, &has)) return has; break; } case Type::InternedString: { InternedStringId id(cx, _internedString); if (JS_AlreadyHasOwnPropertyById(cx, o, id, &has)) return has; break; } } throwCurrentJSException(cx, ErrorCodes::InternalError, "Failed to hasOwn value on a JSObject"); }
js::DOMProxyShadowsResult DOMProxyShadows(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id) { JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy)); JS::Value v = js::GetProxyExtra(proxy, JSPROXYSLOT_EXPANDO); bool isOverrideBuiltins = !v.isObject() && !v.isUndefined(); if (expando) { bool hasOwn; if (!JS_AlreadyHasOwnPropertyById(cx, expando, id, &hasOwn)) return js::ShadowCheckFailed; if (hasOwn) { return isOverrideBuiltins ? js::ShadowsViaIndirectExpando : js::ShadowsViaDirectExpando; } } if (!isOverrideBuiltins) { // Our expando, if any, didn't shadow, so we're not shadowing at all. return js::DoesntShadow; } bool hasOwn; if (!GetProxyHandler(proxy)->hasOwn(cx, proxy, id, &hasOwn)) return js::ShadowCheckFailed; return hasOwn ? js::Shadows : js::DoesntShadowUnique; }
js::DOMProxyShadowsResult DOMProxyShadows(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id) { JS::Value v = js::GetProxyExtra(proxy, JSPROXYSLOT_EXPANDO); if (v.isObject()) { bool hasOwn; if (!JS_AlreadyHasOwnPropertyById(cx, &v.toObject(), id, &hasOwn)) return js::ShadowCheckFailed; return hasOwn ? js::Shadows : js::DoesntShadow; } if (v.isUndefined()) { return js::DoesntShadow; } bool hasOwn; if (!GetProxyHandler(proxy)->hasOwn(cx, proxy, id, &hasOwn)) return js::ShadowCheckFailed; return hasOwn ? js::Shadows : js::DoesntShadowUnique; }