diff --git a/LayoutTests/imported/w3c/web-platform-tests/domxpath/node-sets-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/domxpath/node-sets-expected.txt index 08f6c2fb9ad0..91f5430f300c 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/domxpath/node-sets-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/domxpath/node-sets-expected.txt @@ -1,3 +1,3 @@ -FAIL | operator should evaluate both sides of expressions with the same context node assert_equals: expected 2 but got 1 +PASS | operator should evaluate both sides of expressions with the same context node diff --git a/Source/WebCore/xml/XPathPredicate.cpp b/Source/WebCore/xml/XPathPredicate.cpp index b3316bee1300..8994bdb74c48 100644 --- a/Source/WebCore/xml/XPathPredicate.cpp +++ b/Source/WebCore/xml/XPathPredicate.cpp @@ -252,11 +252,16 @@ Union::Union(std::unique_ptr lhs, std::unique_ptr rhs) Value Union::evaluate() const { + EvaluationContext clonedContext(Expression::evaluationContext()); Value lhsResult = subexpression(0).evaluate(); - Value rhs = subexpression(1).evaluate(); + Value rhsResult = [&] { + SetForScope contextForScope(Expression::evaluationContext(), clonedContext); + return subexpression(1).evaluate(); + }(); + Expression::evaluationContext().hadTypeConversionError |= clonedContext.hadTypeConversionError; NodeSet& resultSet = lhsResult.modifiableNodeSet(); - const NodeSet& rhsNodes = rhs.toNodeSet(); + const NodeSet& rhsNodes = rhsResult.toNodeSet(); HashSet> nodes; for (auto& result : resultSet)