Commit 0292ac42 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

XPath: Apply ignore-case matching to attribute names

... if attribute's owner element is an HTML element and its owner document
is an HTML document and it has no namespaceURI.

The new behavior matches to Firefox.

Bug: 179453
Change-Id: I499f809c8ad2620da2ef2c78fe6d301feec6f67b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1975494Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726562}
parent 9a232626
......@@ -192,6 +192,11 @@ static inline bool NodeMatchesBasicTest(Node* node,
return namespace_uri.IsEmpty() ||
attr->namespaceURI() == namespace_uri;
if (attr->GetDocument().IsHTMLDocument() && attr->ownerElement() &&
attr->ownerElement()->IsHTMLElement() && namespace_uri.IsNull() &&
attr->namespaceURI().IsNull())
return EqualIgnoringASCIICase(attr->localName(), name);
return attr->localName() == name &&
attr->namespaceURI() == namespace_uri;
}
......@@ -385,8 +390,15 @@ void Step::NodesInAxis(EvaluationContext& evaluation_context,
// need anyway.
if (GetNodeTest().GetKind() == NodeTest::kNameTest &&
GetNodeTest().Data() != g_star_atom) {
Attr* attr = context_element->getAttributeNodeNS(
GetNodeTest().NamespaceURI(), GetNodeTest().Data());
Attr* attr;
// We need this branch because getAttributeNodeNS() doesn't do
// ignore-case matching even for an HTML element in an HTML document.
if (GetNodeTest().NamespaceURI().IsNull()) {
attr = context_element->getAttributeNode(GetNodeTest().Data());
} else {
attr = context_element->getAttributeNodeNS(
GetNodeTest().NamespaceURI(), GetNodeTest().Data());
}
// In XPath land, namespace nodes are not accessible on the attribute
// axis.
if (attr && attr->namespaceURI() != xmlns_names::kNamespaceURI) {
......
This is a testharness.js-based test.
PASS Select html element based on attribute
FAIL Select html element based on attribute mixed case assert_array_equals: lengths differ, expected 1 got 0
PASS Select both HTML and SVG elements based on attribute
PASS Select HTML element with non-ascii attribute 1
PASS Select HTML element with non-ascii attribute 2
FAIL Select HTML element with non-ascii attribute 3 assert_array_equals: lengths differ, expected 1 got 0
PASS Select SVG element based on mixed case attribute
FAIL Select both HTML and SVG elements based on mixed case attribute assert_array_equals: lengths differ, expected 1 got 0
PASS Select SVG elements with refX attribute
PASS Select SVG elements with refX attribute incorrect case
PASS Select SVG elements with refX attribute lowercase
PASS Select SVG element with non-ascii attribute 1
PASS Select SVG element with non-ascii attribute 2
PASS xmlns attribute
PASS svg element with XLink attribute
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment