mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 605982 - mozMatchesSelector should raise a SYNTAX_ERR exception on invalid selectors. r+a=bz
This commit is contained in:
parent
9957297493
commit
b40e6cf739
@ -5601,16 +5601,16 @@ nsGenericElement::doQuerySelectorAll(nsINode* aRoot,
|
||||
|
||||
|
||||
PRBool
|
||||
nsGenericElement::MozMatchesSelector(const nsAString& aSelector)
|
||||
nsGenericElement::MozMatchesSelector(const nsAString& aSelector, nsresult* aResult)
|
||||
{
|
||||
nsAutoPtr<nsCSSSelectorList> selectorList;
|
||||
nsPresContext* presContext;
|
||||
PRBool matches = PR_FALSE;
|
||||
|
||||
if (NS_SUCCEEDED(ParseSelectorList(this, aSelector,
|
||||
getter_Transfers(selectorList),
|
||||
&presContext)))
|
||||
{
|
||||
*aResult = ParseSelectorList(this, aSelector, getter_Transfers(selectorList),
|
||||
&presContext);
|
||||
|
||||
if (NS_SUCCEEDED(*aResult)) {
|
||||
RuleProcessorData data(presContext, this, nsnull);
|
||||
matches = nsCSSRuleProcessor::SelectorListMatches(data, selectorList);
|
||||
}
|
||||
@ -5622,6 +5622,9 @@ NS_IMETHODIMP
|
||||
nsNSElementTearoff::MozMatchesSelector(const nsAString& aSelector, PRBool* aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn, "Null out param?");
|
||||
*aReturn = mContent->MozMatchesSelector(aSelector);
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv;
|
||||
*aReturn = mContent->MozMatchesSelector(aSelector, &rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -748,7 +748,7 @@ public:
|
||||
nsIDOMDOMTokenList* GetClassList(nsresult *aResult);
|
||||
void SetCapture(PRBool aRetargetToElement);
|
||||
void ReleaseCapture();
|
||||
PRBool MozMatchesSelector(const nsAString& aSelector);
|
||||
PRBool MozMatchesSelector(const nsAString& aSelector, nsresult* aResult);
|
||||
|
||||
/**
|
||||
* Get the attr info for the given namespace ID and attribute name. The
|
||||
|
@ -431,6 +431,7 @@ _TEST_FILES2 = \
|
||||
test_bug601803.html \
|
||||
file_bug601803a.html \
|
||||
file_bug601803b.html \
|
||||
test_bug605982.html \
|
||||
$(NULL)
|
||||
|
||||
# This test fails on the Mac for some reason
|
||||
|
34
content/base/test/test_bug605982.html
Normal file
34
content/base/test/test_bug605982.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=605982
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 605982</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=605982">Mozilla Bug 605982</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 605982 **/
|
||||
|
||||
var elmt = document.createElement("div");
|
||||
|
||||
var caught = false;
|
||||
try {
|
||||
elmt.mozMatchesSelector("!!");
|
||||
} catch(e) {
|
||||
ok(e.code == DOMException.SYNTAX_ERR, "Error should be SYNTAX_ERROR");
|
||||
caught = true;
|
||||
}
|
||||
ok(caught, "An exception should have been thrown");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -784,8 +784,7 @@ customMethodCalls = {
|
||||
},
|
||||
'nsIDOMNSElement_MozMatchesSelector': {
|
||||
'thisType': 'nsGenericElement',
|
||||
'code': ' PRBool result = self->MozMatchesSelector(arg0);',
|
||||
'canFail': False
|
||||
'code': ' PRBool result = self->MozMatchesSelector(arg0, &rv);',
|
||||
},
|
||||
'nsIDOM3Text_': {
|
||||
'thisType': 'nsGenericTextNode'
|
||||
|
Loading…
Reference in New Issue
Block a user