Bug 750556 - crash in mozilla::dom::Element::ClearStyleStateLocks; r=bz

This commit is contained in:
Heather Arthur 2012-05-09 17:23:57 +01:00
parent 8b7988e945
commit 90bc12cbe0
2 changed files with 29 additions and 16 deletions

View File

@ -398,14 +398,14 @@ NS_IMETHODIMP
inDOMUtils::AddPseudoClassLock(nsIDOMElement *aElement,
const nsAString &aPseudoClass)
{
NS_ENSURE_ARG_POINTER(aElement);
nsEventStates state = GetStatesForPseudoClass(aPseudoClass);
if (state.IsEmpty()) {
return NS_OK;
}
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(aElement);
NS_ENSURE_ARG_POINTER(element);
element->LockStyleStates(state);
return NS_OK;
@ -415,14 +415,14 @@ NS_IMETHODIMP
inDOMUtils::RemovePseudoClassLock(nsIDOMElement *aElement,
const nsAString &aPseudoClass)
{
NS_ENSURE_ARG_POINTER(aElement);
nsEventStates state = GetStatesForPseudoClass(aPseudoClass);
if (state.IsEmpty()) {
return NS_OK;
}
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(aElement);
NS_ENSURE_ARG_POINTER(element);
element->UnlockStyleStates(state);
return NS_OK;
@ -433,8 +433,6 @@ inDOMUtils::HasPseudoClassLock(nsIDOMElement *aElement,
const nsAString &aPseudoClass,
bool *_retval)
{
NS_ENSURE_ARG_POINTER(aElement);
nsEventStates state = GetStatesForPseudoClass(aPseudoClass);
if (state.IsEmpty()) {
*_retval = false;
@ -442,6 +440,8 @@ inDOMUtils::HasPseudoClassLock(nsIDOMElement *aElement,
}
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(aElement);
NS_ENSURE_ARG_POINTER(element);
nsEventStates locks = element->LockedStyleStates();
*_retval = locks.HasAllStates(state);
@ -451,9 +451,9 @@ inDOMUtils::HasPseudoClassLock(nsIDOMElement *aElement,
NS_IMETHODIMP
inDOMUtils::ClearPseudoClassLocks(nsIDOMElement *aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(aElement);
NS_ENSURE_ARG_POINTER(element);
element->ClearStyleStateLocks();
return NS_OK;

View File

@ -28,6 +28,7 @@ function RunTests() {
testVisited();
testMultiple();
testInvalid();
testNotElement();
}
function testLockEnabled() {
@ -256,7 +257,19 @@ function testInvalid() {
}
}
function testNotElement() {
var values = [null, undefined, {}];
try {
for each (value in values); {
DOMUtils.hasPseudoClassLock(value, ":hover");
DOMUtils.addPseudoClassLock(value, ":hover");
DOMUtils.removePseudoClassLock(value, ":hover");
DOMUtils.clearPseudoClassLocks(value);
}
} catch(e) {
// just make sure we don't crash on non-elements
}
}
]]>
</script>