From 0cffe55f05a802a6f35c646940aaa26db699cff9 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Fri, 24 Jan 2014 16:08:25 -0800 Subject: [PATCH] Bug 957688 - Remove checkaccess junk from the XBL compilation scope. r=mrbkap I have no idea what this is supposed to be doing, given that the compilation scope doesn't run script. We should make sure this is reviewed by someone who remembers why this was written. --- dom/xbl/nsXBLDocumentInfo.cpp | 66 ++--------------------------------- 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/dom/xbl/nsXBLDocumentInfo.cpp b/dom/xbl/nsXBLDocumentInfo.cpp index b3f6acde8d4c..edf72243a83c 100644 --- a/dom/xbl/nsXBLDocumentInfo.cpp +++ b/dom/xbl/nsXBLDocumentInfo.cpp @@ -55,9 +55,6 @@ public: void Destroy(); nsIPrincipal* GetPrincipal(); - static bool doCheckAccess(JSContext *cx, JS::Handle obj, - JS::Handle id, uint32_t accessType); - void ClearGlobalObjectOwner(); static const JSClass gSharedGlobalClass; @@ -70,65 +67,6 @@ protected: bool mDestroyed; // Probably not necessary, but let's be safe. }; -bool -nsXBLDocGlobalObject::doCheckAccess(JSContext *cx, JS::Handle obj, - JS::Handle id, uint32_t accessType) -{ - nsIScriptSecurityManager *ssm = nsContentUtils::GetSecurityManager(); - if (!ssm) { - ::JS_ReportError(cx, "Unable to verify access to a global object property."); - return false; - } - - // Make sure to actually operate on our object, and not some object further - // down on the proto chain. - JS::Rooted base(cx, obj); - while (JS_GetClass(base) != &nsXBLDocGlobalObject::gSharedGlobalClass) { - if (!::JS_GetPrototype(cx, base, &base)) { - return false; - } - if (!base) { - ::JS_ReportError(cx, "Invalid access to a global object property."); - return false; - } - } - - nsresult rv = ssm->CheckPropertyAccess(cx, base, JS_GetClass(base)->name, - id, accessType); - return NS_SUCCEEDED(rv); -} - -static bool -nsXBLDocGlobalObject_getProperty(JSContext *cx, JS::Handle obj, - JS::Handle id, JS::MutableHandle vp) -{ - return nsXBLDocGlobalObject:: - doCheckAccess(cx, obj, id, nsIXPCSecurityManager::ACCESS_GET_PROPERTY); -} - -static bool -nsXBLDocGlobalObject_setProperty(JSContext *cx, JS::Handle obj, - JS::Handle id, bool strict, JS::MutableHandle vp) -{ - return nsXBLDocGlobalObject:: - doCheckAccess(cx, obj, id, nsIXPCSecurityManager::ACCESS_SET_PROPERTY); -} - -static bool -nsXBLDocGlobalObject_checkAccess(JSContext *cx, JS::Handle obj, JS::Handle id, - JSAccessMode mode, JS::MutableHandle vp) -{ - uint32_t translated; - if (mode & JSACC_WRITE) { - translated = nsIXPCSecurityManager::ACCESS_SET_PROPERTY; - } else { - translated = nsIXPCSecurityManager::ACCESS_GET_PROPERTY; - } - - return nsXBLDocGlobalObject:: - doCheckAccess(cx, obj, id, translated); -} - static void nsXBLDocGlobalObject_finalize(JSFreeOp *fop, JSObject *obj) { @@ -156,10 +94,10 @@ const JSClass nsXBLDocGlobalObject::gSharedGlobalClass = { JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_IMPLEMENTS_BARRIERS | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(0), JS_PropertyStub, JS_DeletePropertyStub, - nsXBLDocGlobalObject_getProperty, nsXBLDocGlobalObject_setProperty, + JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, nsXBLDocGlobalObject_resolve, JS_ConvertStub, nsXBLDocGlobalObject_finalize, - nsXBLDocGlobalObject_checkAccess, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr };