mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 616774: Make XPath expressions like "--expr" coerce into a number. r=sicking
This commit is contained in:
parent
ebb14423fe
commit
55b50797ab
@ -313,9 +313,9 @@ txExprParser::createExpr(txExprLexer& lexer, txIParseContext* aContext,
|
||||
|
||||
while (!done) {
|
||||
|
||||
MBool unary = MB_FALSE;
|
||||
PRUint16 negations = 0;
|
||||
while (lexer.peek()->mType == Token::SUBTRACTION_OP) {
|
||||
unary = !unary;
|
||||
negations++;
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
@ -324,15 +324,19 @@ txExprParser::createExpr(txExprLexer& lexer, txIParseContext* aContext,
|
||||
break;
|
||||
}
|
||||
|
||||
if (unary) {
|
||||
Expr* unaryExpr = new UnaryExpr(expr);
|
||||
if (!unaryExpr) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
if (negations > 0) {
|
||||
if (negations % 2 == 0) {
|
||||
FunctionCall* fcExpr = new txCoreFunctionCall(txCoreFunctionCall::NUMBER);
|
||||
|
||||
rv = fcExpr->addParam(expr);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
expr.forget();
|
||||
expr = unaryExpr;
|
||||
expr = fcExpr;
|
||||
}
|
||||
else {
|
||||
expr = new UnaryExpr(expr.forget());
|
||||
}
|
||||
}
|
||||
|
||||
Token* tok = lexer.nextToken();
|
||||
|
@ -55,6 +55,7 @@ _TEST_FILES = test_bug319374.xhtml \
|
||||
test_bug566629.html \
|
||||
test_bug566629.xhtml \
|
||||
test_bug603159.html \
|
||||
test_bug616774.html \
|
||||
test_bug667315.html \
|
||||
test_exslt_regex.html \
|
||||
$(NULL)
|
||||
|
28
content/xslt/tests/mochitest/test_bug616774.html
Normal file
28
content/xslt/tests/mochitest/test_bug616774.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=616774-->
|
||||
<head>
|
||||
<title>Test for Bug 616774</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/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=616774">Mozilla Bug 616774</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
42
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 616774 **/
|
||||
is(document.evaluate('- "8"', document, null, XPathResult.ANY_TYPE, null).numberValue, -8, "Negated string literal should evaluate to itself negated");
|
||||
is(document.evaluate('- - "999"', document, null, XPathResult.ANY_TYPE, null).numberValue, 999, "String literal should evaluate to itself");
|
||||
is(document.evaluate('- - id("content")', document, null, XPathResult.ANY_TYPE, null).numberValue, 42, "DOM element should evaluate to itself coerced to a number");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user