Bug 894448 part 1. Move IsChromeOrXBL to xpcpublic.h. r=bholley

This commit is contained in:
Boris Zbarsky 2013-07-25 19:41:46 -07:00
parent 94845105be
commit bd1400ee1f
6 changed files with 24 additions and 19 deletions

View File

@ -1122,12 +1122,6 @@ public:
return NS_OK;
}
/**
* Control if GetUserData and SetUserData methods will be exposed to
* unprivileged content.
*/
static bool IsChromeOrXBL(JSContext* aCx, JSObject* /* unused */);
void LookupPrefix(const nsAString& aNamespace, nsAString& aResult);
bool IsDefaultNamespace(const nsAString& aNamespaceURI)
{

View File

@ -735,15 +735,6 @@ nsINode::GetUserData(JSContext* aCx, const nsAString& aKey, ErrorResult& aError)
return result;
}
//static
bool
nsINode::IsChromeOrXBL(JSContext* aCx, JSObject* /* unused */)
{
JSCompartment* compartment = js::GetContextCompartment(aCx);
return xpc::AccessCheck::isChrome(compartment) ||
xpc::IsXBLScope(compartment);
}
uint16_t
nsINode::CompareDocumentPosition(nsINode& aOtherNode) const
{

View File

@ -1470,8 +1470,7 @@ class MethodDefiner(PropertyDefiner):
"length": 1,
"flags": "0",
"condition":
MemberCondition(None,
"nsINode::IsChromeOrXBL") })
MemberCondition(None, "IsChromeOrXBL") })
if not static:
stringifier = descriptor.operations['Stringifier']

View File

@ -96,9 +96,9 @@ interface Node : EventTarget {
readonly attribute DOMString? localName;
boolean hasAttributes();
[Throws, Func="nsINode::IsChromeOrXBL"]
[Throws, Func="IsChromeOrXBL"]
any setUserData(DOMString key, any data, UserDataHandler? handler);
[Throws, Func="nsINode::IsChromeOrXBL"]
[Throws, Func="IsChromeOrXBL"]
any getUserData(DOMString key);
[ChromeOnly]
readonly attribute Principal nodePrincipal;

View File

@ -1707,3 +1707,18 @@ JS_EXPORT_API(void) DumpCompleteHeap()
}
} // extern "C"
namespace mozilla {
namespace dom {
bool
IsChromeOrXBL(JSContext* cx, JSObject* /* unused */)
{
JSCompartment* compartment = js::GetContextCompartment(cx);
return AccessCheck::isChrome(compartment) ||
IsXBLScope(compartment);
}
} // namespace dom
} // namespace mozilla

View File

@ -478,6 +478,12 @@ DefineStaticJSVals(JSContext *cx);
void
Register(nsScriptNameSpaceManager* aNameSpaceManager);
/**
* A test for whether WebIDL methods that should only be visible to
* chrome or XBL scopes should be exposed.
*/
bool IsChromeOrXBL(JSContext* cx, JSObject* /* unused */);
} // namespace dom
} // namespace mozilla