aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-09-13 11:00:36 +0200
committerMs2ger <ms2ger@gmail.com>2014-09-13 21:01:54 +0200
commitd0e095a3e5fee47d65cd5cf08cc9644223c2b64b (patch)
treecf4f3e631a7c08883af275c89001365348cd4eab
parent25f263b7516e7accc569b5a045ff9bf23c56f8a7 (diff)
downloadservo-d0e095a3e5fee47d65cd5cf08cc9644223c2b64b.tar.gz
servo-d0e095a3e5fee47d65cd5cf08cc9644223c2b64b.zip
Stop messing with the case of the attribute name in AttributeHandlers::get_attribute.
This fixes a bug where GetAttributeNS would incorrectly match lower-case attributes when called with an upper-case argument.
-rw-r--r--components/script/dom/element.rs17
-rw-r--r--tests/wpt/metadata/dom/nodes/attributes.html.ini12
-rw-r--r--tests/wpt/metadata/dom/nodes/case.html.ini96
3 files changed, 9 insertions, 116 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 30b2601f04e..2150e67f0eb 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -252,7 +252,10 @@ impl<'a> ElementHelpers for JSRef<'a, Element> {
}
pub trait AttributeHandlers {
- fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>>;
+ /// Returns the attribute with given namespace and case-sensitive local
+ /// name, if any.
+ fn get_attribute(&self, namespace: Namespace, local_name: &str)
+ -> Option<Temporary<Attr>>;
fn set_attribute_from_parser(&self, local_name: Atom,
value: DOMString, namespace: Namespace,
prefix: Option<DOMString>);
@@ -282,13 +285,9 @@ pub trait AttributeHandlers {
}
impl<'a> AttributeHandlers for JSRef<'a, Element> {
- fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>> {
- let element: &Element = self.deref();
- let local_name = match self.html_element_in_html_document() {
- true => Atom::from_slice(name.to_ascii_lower().as_slice()),
- false => Atom::from_slice(name)
- };
- element.attrs.borrow().iter().map(|attr| attr.root()).find(|attr| {
+ fn get_attribute(&self, namespace: Namespace, local_name: &str) -> Option<Temporary<Attr>> {
+ let local_name = Atom::from_slice(local_name);
+ self.attrs.borrow().iter().map(|attr| attr.root()).find(|attr| {
*attr.local_name() == local_name && attr.namespace == namespace
}).map(|x| Temporary::from_rooted(&*x))
}
@@ -423,6 +422,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
}
fn get_url_attribute(&self, name: &str) -> DOMString {
+ assert!(name == name.to_ascii_lower().as_slice());
// XXX Resolve URL.
self.get_string_attribute(name)
}
@@ -431,6 +431,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
}
fn get_string_attribute(&self, name: &str) -> DOMString {
+ assert!(name == name.to_ascii_lower().as_slice());
match self.get_attribute(Null, name) {
Some(x) => {
let x = x.root();
diff --git a/tests/wpt/metadata/dom/nodes/attributes.html.ini b/tests/wpt/metadata/dom/nodes/attributes.html.ini
index a75799b73ad..2939786c8a4 100644
--- a/tests/wpt/metadata/dom/nodes/attributes.html.ini
+++ b/tests/wpt/metadata/dom/nodes/attributes.html.ini
@@ -1,11 +1,5 @@
[attributes.html]
type: testharness
- [setAttribute should lowercase its name argument (upper case attribute)]
- expected: FAIL
-
- [setAttribute should lowercase its name argument (mixed case attribute)]
- expected: FAIL
-
[setAttribute should set the attribute with the given qualified name]
expected: FAIL
@@ -15,12 +9,6 @@
[First set attribute is returned by getAttribute]
expected: FAIL
- [Only lowercase attributes are returned on HTML elements (upper case attribute)]
- expected: FAIL
-
- [Only lowercase attributes are returned on HTML elements (mixed case attribute)]
- expected: FAIL
-
[First set attribute is returned with mapped attribute set later]
expected: FAIL
diff --git a/tests/wpt/metadata/dom/nodes/case.html.ini b/tests/wpt/metadata/dom/nodes/case.html.ini
index 8933dbb57e1..6682b11052a 100644
--- a/tests/wpt/metadata/dom/nodes/case.html.ini
+++ b/tests/wpt/metadata/dom/nodes/case.html.ini
@@ -6,15 +6,9 @@
[createElementNS http://www.w3.org/1999/xhtml,abc,Abc]
expected: FAIL
- [getAttributeNS http://www.w3.org/1999/xhtml,abc,Abc]
- expected: FAIL
-
[createElementNS http://www.w3.org/1999/xhtml,abc,ABC]
expected: FAIL
- [getAttributeNS http://www.w3.org/1999/xhtml,abc,ABC]
- expected: FAIL
-
[createElementNS http://www.w3.org/1999/xhtml,abc,\xc3\xa4]
expected: FAIL
@@ -27,15 +21,9 @@
[createElementNS http://www.w3.org/1999/xhtml,Abc,Abc]
expected: FAIL
- [getAttributeNS http://www.w3.org/1999/xhtml,Abc,Abc]
- expected: FAIL
-
[createElementNS http://www.w3.org/1999/xhtml,Abc,ABC]
expected: FAIL
- [getAttributeNS http://www.w3.org/1999/xhtml,Abc,ABC]
- expected: FAIL
-
[createElementNS http://www.w3.org/1999/xhtml,Abc,\xc3\xa4]
expected: FAIL
@@ -48,15 +36,9 @@
[createElementNS http://www.w3.org/1999/xhtml,ABC,Abc]
expected: FAIL
- [getAttributeNS http://www.w3.org/1999/xhtml,ABC,Abc]
- expected: FAIL
-
[createElementNS http://www.w3.org/1999/xhtml,ABC,ABC]
expected: FAIL
- [getAttributeNS http://www.w3.org/1999/xhtml,ABC,ABC]
- expected: FAIL
-
[createElementNS http://www.w3.org/1999/xhtml,ABC,\xc3\xa4]
expected: FAIL
@@ -69,15 +51,9 @@
[createElementNS http://www.w3.org/1999/xhtml,\xc3\xa4,Abc]
expected: FAIL
- [getAttributeNS http://www.w3.org/1999/xhtml,\xc3\xa4,Abc]
- expected: FAIL
-
[createElementNS http://www.w3.org/1999/xhtml,\xc3\xa4,ABC]
expected: FAIL
- [getAttributeNS http://www.w3.org/1999/xhtml,\xc3\xa4,ABC]
- expected: FAIL
-
[createElementNS http://www.w3.org/1999/xhtml,\xc3\xa4,\xc3\xa4]
expected: FAIL
@@ -90,84 +66,12 @@
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,Abc]
expected: FAIL
- [getAttributeNS http://www.w3.org/1999/xhtml,\xc3\x84,Abc]
- expected: FAIL
-
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,ABC]
expected: FAIL
- [getAttributeNS http://www.w3.org/1999/xhtml,\xc3\x84,ABC]
- expected: FAIL
-
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,\xc3\xa4]
expected: FAIL
[createElementNS http://www.w3.org/1999/xhtml,\xc3\x84,\xc3\x84]
expected: FAIL
- [getAttributeNS http://www.w3.org/2000/svg,abc,Abc]
- expected: FAIL
-
- [getAttributeNS http://www.w3.org/2000/svg,abc,ABC]
- expected: FAIL
-
- [getAttributeNS http://www.w3.org/2000/svg,Abc,Abc]
- expected: FAIL
-
- [getAttributeNS http://www.w3.org/2000/svg,Abc,ABC]
- expected: FAIL
-
- [getAttributeNS http://www.w3.org/2000/svg,ABC,Abc]
- expected: FAIL
-
- [getAttributeNS http://www.w3.org/2000/svg,ABC,ABC]
- expected: FAIL
-
- [getAttributeNS http://www.w3.org/2000/svg,\xc3\xa4,Abc]
- expected: FAIL
-
- [getAttributeNS http://www.w3.org/2000/svg,\xc3\xa4,ABC]
- expected: FAIL
-
- [getAttributeNS http://www.w3.org/2000/svg,\xc3\x84,Abc]
- expected: FAIL
-
- [getAttributeNS http://www.w3.org/2000/svg,\xc3\x84,ABC]
- expected: FAIL
-
- [getAttributeNS http://FOO,abc,Abc]
- expected: FAIL
-
- [getAttributeNS http://FOO,abc,ABC]
- expected: FAIL
-
- [getAttributeNS http://FOO,Abc,Abc]
- expected: FAIL
-
- [getAttributeNS http://FOO,Abc,ABC]
- expected: FAIL
-
- [getAttributeNS http://FOO,ABC,Abc]
- expected: FAIL
-
- [getAttributeNS http://FOO,ABC,ABC]
- expected: FAIL
-
- [getAttributeNS http://FOO,\xc3\xa4,Abc]
- expected: FAIL
-
- [getAttributeNS http://FOO,\xc3\xa4,ABC]
- expected: FAIL
-
- [getAttributeNS http://FOO,\xc3\x84,Abc]
- expected: FAIL
-
- [getAttributeNS http://FOO,\xc3\x84,ABC]
- expected: FAIL
-
- [getAttributeNS Abc]
- expected: FAIL
-
- [getAttributeNS ABC]
- expected: FAIL
-