Title: [144726] trunk
Revision
144726
Author
[email protected]
Date
2013-03-04 22:57:55 -0800 (Mon, 04 Mar 2013)

Log Message

getAttribute does not behave correctly for mixed-case attributes on HTML elements
https://bugs.webkit.org/show_bug.cgi?id=105713

Patch by Arpita Bahuguna <[email protected]> on 2013-03-04
Reviewed by Andreas Kling.

Source/WebCore:

getAttribute() and getAttributeNode() APIs do not convert the
passed attribute name to lowercase before comparing against the
existing attributes.
The specification however states that the passed name should
be converted to ASCII lowercase before checking for the existence
of the given attribute. [www.w3.org/TR/domcore/#dom-element-getattribute]

Test: fast/dom/Element/getAttribute-case-insensitivity.html

* dom/Element.h:
(WebCore::ElementData::getAttributeItemIndex):
getAttributeItemIndex() accepts a bool param 'shouldIgnoreAttributeCase'
which specifies whether the attribute's case should be ignored
before comparison. But inspite of this param's value we still carry
out a case sensitive search.
Have modified the same to convert the passed attribute's name to
lowercase if 'shouldIgnoreAttributeCase' is true.

LayoutTests:

* fast/dom/Element/getAttribute-case-insensitivity-expected.txt: Added.
* fast/dom/Element/getAttribute-case-insensitivity.html: Added.
Layout test added for verifying that getAttribute() and getAttributeNode()
APIs convert the passed attribute name to lowercase before comparing
against the existing attributes.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (144725 => 144726)


--- trunk/LayoutTests/ChangeLog	2013-03-05 06:35:55 UTC (rev 144725)
+++ trunk/LayoutTests/ChangeLog	2013-03-05 06:57:55 UTC (rev 144726)
@@ -1,3 +1,16 @@
+2013-03-04  Arpita Bahuguna  <[email protected]>
+
+        getAttribute does not behave correctly for mixed-case attributes on HTML elements
+        https://bugs.webkit.org/show_bug.cgi?id=105713
+
+        Reviewed by Andreas Kling.
+
+        * fast/dom/Element/getAttribute-case-insensitivity-expected.txt: Added.
+        * fast/dom/Element/getAttribute-case-insensitivity.html: Added.
+        Layout test added for verifying that getAttribute() and getAttributeNode()
+        APIs convert the passed attribute name to lowercase before comparing
+        against the existing attributes.
+
 2013-03-04  Joshua Bell  <[email protected]>
 
         [V8] Add LayoutTests for SerializedScriptValue Int32/Uint32 cases

Added: trunk/LayoutTests/fast/dom/Element/getAttribute-case-insensitivity-expected.txt (0 => 144726)


--- trunk/LayoutTests/fast/dom/Element/getAttribute-case-insensitivity-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/getAttribute-case-insensitivity-expected.txt	2013-03-05 06:57:55 UTC (rev 144726)
@@ -0,0 +1,15 @@
+Test for Bugzilla bug: 105713: getAttribute does not behave correctly for mixed-case attributes on HTML testements.
+This test verifies that the getAttribute() and the getAttributeNode() APIs convert the passed attribute name to lowercase before comparing against existing attributes.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS test.getAttribute('NEWATTR') is 'PASS'
+PASS test.getAttributeNode('NEWATTR').value is 'PASS'
+PASS test.getAttributeNS(null, 'NEWATTR') is 'FAIL'
+PASS test.getAttribute('newattr') is 'PASS'
+PASS test.getAttributeNode('newattr').value is 'PASS'
+PASS test.getAttributeNS(null, 'newattr') is 'PASS'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/Element/getAttribute-case-insensitivity.html (0 => 144726)


--- trunk/LayoutTests/fast/dom/Element/getAttribute-case-insensitivity.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/getAttribute-case-insensitivity.html	2013-03-05 06:57:55 UTC (rev 144726)
@@ -0,0 +1,32 @@
+<html>
+<head>
+<script src=""
+<script>
+function runTest()
+{
+    description("This test verifies that the getAttribute() and the getAttributeNode() APIs convert the passed attribute name to lowercase before comparing against existing attributes.");
+    
+    var test = document.getElementById("test");
+    test.setAttributeNS(null, "NEWATTR", "FAIL");
+    test.setAttributeNS(null, "newattr", "PASS");
+    
+    if (window.testRunner) {
+        shouldBe("test.getAttribute('NEWATTR')", "'PASS'");
+        shouldBe("test.getAttributeNode('NEWATTR').value", "'PASS'");
+        shouldBe("test.getAttributeNS(null, 'NEWATTR')", "'FAIL'");
+        shouldBe("test.getAttribute('newattr')", "'PASS'");
+        shouldBe("test.getAttributeNode('newattr').value", "'PASS'");
+        shouldBe("test.getAttributeNS(null, 'newattr')", "'PASS'");
+    
+        isSuccessfullyParsed();
+    }
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<div>Test for Bugzilla bug:<a href="" 105713:</a>  getAttribute does not behave correctly for mixed-case attributes on HTML testements.</div>
+<div id="test"></div>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (144725 => 144726)


--- trunk/Source/WebCore/ChangeLog	2013-03-05 06:35:55 UTC (rev 144725)
+++ trunk/Source/WebCore/ChangeLog	2013-03-05 06:57:55 UTC (rev 144726)
@@ -1,3 +1,28 @@
+2013-03-04  Arpita Bahuguna  <[email protected]>
+
+        getAttribute does not behave correctly for mixed-case attributes on HTML elements
+        https://bugs.webkit.org/show_bug.cgi?id=105713
+
+        Reviewed by Andreas Kling.
+
+        getAttribute() and getAttributeNode() APIs do not convert the
+        passed attribute name to lowercase before comparing against the
+        existing attributes.
+        The specification however states that the passed name should
+        be converted to ASCII lowercase before checking for the existence
+        of the given attribute. [www.w3.org/TR/domcore/#dom-element-getattribute]
+
+        Test: fast/dom/Element/getAttribute-case-insensitivity.html
+
+        * dom/Element.h:
+        (WebCore::ElementData::getAttributeItemIndex):
+        getAttributeItemIndex() accepts a bool param 'shouldIgnoreAttributeCase'
+        which specifies whether the attribute's case should be ignored
+        before comparison. But inspite of this param's value we still carry
+        out a case sensitive search.
+        Have modified the same to convert the passed attribute's name to
+        lowercase if 'shouldIgnoreAttributeCase' is true.
+
 2013-03-04  Kunihiko Sakamoto  <[email protected]>
 
         [Chromium] Add runtime flag for font load events

Modified: trunk/Source/WebCore/dom/Element.h (144725 => 144726)


--- trunk/Source/WebCore/dom/Element.h	2013-03-05 06:35:55 UTC (rev 144725)
+++ trunk/Source/WebCore/dom/Element.h	2013-03-05 06:57:55 UTC (rev 144726)
@@ -941,7 +941,7 @@
     for (unsigned i = 0; i < len; ++i) {
         const Attribute* attribute = attributeItem(i);
         if (!attribute->name().hasPrefix()) {
-            if (name == attribute->localName())
+            if ((shouldIgnoreAttributeCase ? name.lower() : name) == attribute->localName())
                 return i;
         } else
             doSlowCheck = true;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to