Changeset 195248 in webkit
- Timestamp:
- Jan 18, 2016 11:37:32 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 13 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r195247 r195248 1 2016-01-18 Ryosuke Niwa <rniwa@webkit.org> 2 3 createAttribute should lowercase the attribute name in a HTML document 4 https://bugs.webkit.org/show_bug.cgi?id=153112 5 6 Reviewed by Darin Adler. 7 8 Update tests, rebaseline tests, and add more test cases as needed. 9 10 createAttribute lowercases localName and getAttributeNode finds attribute ignoring cases 11 whereas createAttributeNS preserves localName's case and getAttributeNodeNS finds attribute preserving cases 12 13 * fast/dom/Element/mozilla-dom-base-tests/test_bug1075702-expected.txt: Since the test is adding "aa" as well 14 as "AA" as Attr nodes, we should be able to get both. 15 * fast/dom/Element/mozilla-dom-base-tests/test_bug1075702.xhtml: Renamed from .html file since test cases here 16 are more relevant for XHTML documents. 17 18 * fast/dom/Element/getAttribute-check-case-sensitivity-expected.txt: 19 * fast/dom/Element/script-tests/getAttribute-check-case-sensitivity.js: 20 (testGetAttributeNodeMixedCase): Change the test case to retrieve the attribute name with lowercase name 21 since createAttribute always lowercases the name in a HTML document. 22 (testAttribNodeNamePreservesCase): Use getAttributeNode instead of getAttributeNodeNS since the former does 23 case insensitive lookup as needed here. 24 (testAttribNodeNamePreservesCaseGetNode): Ditto. 25 (testAttribNodeNamePreservesCaseGetNode2): Ditto. Use createAttributeNS to create a case-preserving Attr node. 26 27 * fast/dom/Element/setAttributeNode-case-insensitivity-expected.txt: 28 * fast/dom/Element/setAttributeNode-case-insensitivity.html: Since getAttributeNode does a case-insensitive 29 lookup, we should be getting the same Attr node for both 'style' and 'STYLE'. 30 31 * fast/dom/Element/setAttributeNode-for-existing-attribute-expected.txt: Rebaselined. This is a progression 32 since we're now getting "green" when querying style.backgroundColor as expected. 33 34 * fast/dom/Element/setAttributeNode-overriding-lowercase-values-1-expected.txt: 35 * fast/dom/Element/setAttributeNode-overriding-lowercase-values-1.html: Updated test cases for new behavior. 36 37 * fast/dom/Element/setAttributeNode-overriding-lowercase-values-1-xml-expected.txt: Added. 38 * fast/dom/Element/setAttributeNode-overriding-lowercase-values-1-xml.xhtml: Added. Test behaviors in a XML 39 document. 40 1 41 2016-01-18 Brady Eidson <beidson@apple.com> 2 42 -
trunk/LayoutTests/fast/dom/Element/getAttribute-check-case-sensitivity-expected.txt
r179497 r195248 10 10 PASS testGetAttributeNodeLowerCase() is "x" 11 11 PASS testSetAttributeNodeKeepsRef() is "1" 12 PASS testAttribNodeNamePreservesCase() is " A,A"13 PASS testAttribNodeNamePreservesCaseGetNode() is " A,A"12 PASS testAttribNodeNamePreservesCase() is "a,a" 13 PASS testAttribNodeNamePreservesCaseGetNode() is "a,a" 14 14 PASS testAttribNodeNamePreservesCaseGetNode2() is "B,B" 15 15 PASS testAttribNodeNameGetMutate() is "1" 16 PASS (new XMLSerializer).serializeToString(node) is "<div xmlns=\"http://www.w3.org/1999/xhtml\" myAttrib=\"XXX\"></div>" 17 PASS node.getAttributeNodeNS('', 'myAttrib').name is "myAttrib" 18 PASS node.getAttributeNodeNS('', 'myattrib') is null 19 PASS attrib.name is "myAttrib" 16 PASS (new XMLSerializer).serializeToString(node) is "<div xmlns=\"http://www.w3.org/1999/xhtml\" myattrib=\"XXX\" myAttrib2=\"XXX\"></div>" 17 PASS node.getAttributeNodeNS('', 'myattrib') is attrib 18 PASS node.getAttributeNodeNS('', 'myAttrib') is null 19 PASS attrib.name is "myattrib" 20 PASS node.getAttributeNodeNS('', 'myAttrib2') is attrib2 21 PASS node.getAttributeNodeNS('', 'myattrib2') is null 22 PASS attrib2.name is "myAttrib2" 20 23 PASS successfullyParsed is true 21 24 -
trunk/LayoutTests/fast/dom/Element/mozilla-dom-base-tests/test_bug1075702-expected.txt
r189825 r195248 4 4 5 5 6 PASS document.documentElement.hasAttributeNS("", "aa") is false7 PASS document.documentElement.getAttributeNS("", "aa") is null6 PASS document.documentElement.hasAttributeNS("", "aa") is true 7 PASS document.documentElement.getAttributeNS("", "aa") is "lowercase" 8 8 PASS document.documentElement.hasAttributeNS("", "AA") is true 9 9 PASS document.documentElement.getAttributeNS("", "AA") is "UPPERCASE" -
trunk/LayoutTests/fast/dom/Element/mozilla-dom-base-tests/test_bug1075702.xhtml
r195247 r195248 1 <!DOCTYPE HTML>2 <html >1 <!DOCTYPE html> 2 <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> 3 3 <!-- 4 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1075702 5 5 --> 6 6 <head> 7 <meta charset="utf-8" >7 <meta charset="utf-8"/> 8 8 <script src="../../../../resources/js-test-pre.js"></script> 9 9 </head> … … 29 29 document.documentElement.setAttributeNode(a2); 30 30 31 shouldBe False('document.documentElement.hasAttributeNS("", "aa")');32 shouldBe Null('document.documentElement.getAttributeNS("", "aa")');31 shouldBeTrue('document.documentElement.hasAttributeNS("", "aa")'); 32 shouldBeEqualToString('document.documentElement.getAttributeNS("", "aa")', 'lowercase'); 33 33 shouldBeTrue('document.documentElement.hasAttributeNS("", "AA")'); 34 34 shouldBeEqualToString('document.documentElement.getAttributeNS("", "AA")', 'UPPERCASE'); -
trunk/LayoutTests/fast/dom/Element/script-tests/getAttribute-check-case-sensitivity.js
r179497 r195248 20 20 a.nodeValue = "x"; 21 21 div.setAttributeNode(a); 22 return div.getAttributeNS("", "mixed CaseAttrib");22 return div.getAttributeNS("", "mixedcaseattrib"); 23 23 } 24 24 … … 62 62 } 63 63 64 shouldBe("testAttribNodeNamePreservesCase()", '" A,A"');64 shouldBe("testAttribNodeNamePreservesCase()", '"a,a"'); 65 65 66 66 … … 75 75 body.setAttributeNode(a); 76 76 77 a = document.body.getAttributeNode NS("","A");77 a = document.body.getAttributeNode("A"); 78 78 if (!a) 79 79 return "FAIL"; … … 83 83 } 84 84 85 shouldBe("testAttribNodeNamePreservesCaseGetNode()", '" A,A"');85 shouldBe("testAttribNodeNamePreservesCaseGetNode()", '"a,a"'); 86 86 87 87 function testAttribNodeNamePreservesCaseGetNode2() … … 95 95 body.setAttributeNode(a); 96 96 97 a = document.body.getAttributeNodeNS("", " B");97 a = document.body.getAttributeNodeNS("", "b"); 98 98 if (!a) 99 99 return "FAIL"; 100 100 101 // Now create node second time -- this time case is preserved in FF! 102 a = body.ownerDocument.createAttribute("B"); 101 a = body.ownerDocument.createAttributeNS("", "B"); 103 102 a.nodeValue = "x"; 104 103 body.setAttributeNode(a); … … 136 135 node.setAttributeNode(attrib); 137 136 138 shouldBe("(new XMLSerializer).serializeToString(node)", '"<div xmlns=\\"http://www.w3.org/1999/xhtml\\" myAttrib=\\"XXX\\"></div>"'); 139 shouldBe("node.getAttributeNodeNS('', 'myAttrib').name", '"myAttrib"'); 140 shouldBe("node.getAttributeNodeNS('', 'myattrib')", 'null'); 141 shouldBe("attrib.name", '"myAttrib"'); 137 var attrib2 = document.createAttributeNS("", "myAttrib2"); 138 attrib2.nodeValue = "XXX"; 139 node.setAttributeNode(attrib2); 140 141 shouldBe("(new XMLSerializer).serializeToString(node)", '"<div xmlns=\\"http://www.w3.org/1999/xhtml\\" myattrib=\\"XXX\\" myAttrib2=\\"XXX\\"></div>"'); 142 shouldBe("node.getAttributeNodeNS('', 'myattrib')", 'attrib'); 143 shouldBeNull("node.getAttributeNodeNS('', 'myAttrib')"); 144 shouldBe("attrib.name", '"myattrib"'); 145 146 shouldBe("node.getAttributeNodeNS('', 'myAttrib2')", 'attrib2'); 147 shouldBeNull("node.getAttributeNodeNS('', 'myattrib2')"); 148 shouldBe("attrib2.name", '"myAttrib2"'); -
trunk/LayoutTests/fast/dom/Element/setAttributeNode-case-insensitivity-expected.txt
r179497 r195248 5 5 6 6 PASS test.getAttribute('style') is test.getAttribute('STYLE') 7 PASS test.getAttributeNode('style') is null7 PASS test.getAttributeNode('style') is test.getAttributeNode('STYLE') 8 8 Verifying that attributes with the same name but different namespaces are treated as unique entities. For the following test two different attribute values should be returned. 9 9 PASS test.getAttributeNodeNS('ns1', 'newattr').value is 'newattr1' -
trunk/LayoutTests/fast/dom/Element/setAttributeNode-case-insensitivity.html
r179497 r195248 17 17 test.setAttributeNode(newStyleAttr); 18 18 shouldBe("test.getAttribute('style')", "test.getAttribute('STYLE')"); 19 shouldBe("test.getAttributeNode('style')", " null");19 shouldBe("test.getAttributeNode('style')", "test.getAttributeNode('STYLE')"); 20 20 21 21 -
trunk/LayoutTests/fast/dom/Element/setAttributeNode-for-existing-attribute-expected.txt
r179497 r195248 3 3 Testcase for bug 120293: setAttributeNode() does not set the new value to an existing attribute if specified attribute is in a different case.\nThe issue can be manually verified by ascertaining that a green colored block is displayed instead of a red one. 4 4 5 background-color specified with lowercase style attribute was: red and specified with uppercase style attribute is: 5 background-color specified with lowercase style attribute was: red and specified with uppercase style attribute is: green -
trunk/LayoutTests/fast/dom/Element/setAttributeNode-overriding-lowercase-values-1-expected.txt
r189825 r195248 14 14 PASS document.documentElement.attributes.length is 1 15 15 PASS camelCaseFoobar is not oldAttributeNode 16 PASS document.documentElement.getAttribute("foobar") is null17 PASS document.documentElement.hasAttribute("foobar") is false18 PASS document.documentElement.getAttribute("FooBar") is null19 PASS document.documentElement.hasAttribute("FooBar") is false20 PASS document.documentElement.getAttributeNS("", "foobar") is null21 PASS document.documentElement.hasAttributeNS("", "foobar") is false22 PASS document.documentElement.getAttributeNS("", "FooBar") is "Rocks!"23 PASS document.documentElement.hasAttributeNS("", "FooBar") is true24 PASS oldAttributeNode2 is null16 PASS document.documentElement.getAttribute("foobar") is "Rocks!" 17 PASS document.documentElement.hasAttribute("foobar") is true 18 PASS document.documentElement.getAttribute("FooBar") is "Rocks!" 19 PASS document.documentElement.hasAttribute("FooBar") is true 20 PASS document.documentElement.getAttributeNS("", "foobar") is "Rocks!" 21 PASS document.documentElement.hasAttributeNS("", "foobar") is true 22 PASS document.documentElement.getAttributeNS("", "FooBar") is null 23 PASS document.documentElement.hasAttributeNS("", "FooBar") is false 24 PASS oldAttributeNode2 is camelCaseFoobar 25 25 PASS document.documentElement.getAttribute("foobar") is "WebKit2" 26 26 PASS document.documentElement.hasAttribute("foobar") is true … … 29 29 PASS document.documentElement.getAttributeNS("", "foobar") is "WebKit2" 30 30 PASS document.documentElement.hasAttributeNS("", "foobar") is true 31 PASS document.documentElement.getAttributeNS("", "FooBar") is "Rocks!"32 PASS document.documentElement.hasAttributeNS("", "FooBar") is true31 PASS document.documentElement.getAttributeNS("", "FooBar") is null 32 PASS document.documentElement.hasAttributeNS("", "FooBar") is false 33 33 PASS successfullyParsed is true 34 34 -
trunk/LayoutTests/fast/dom/Element/setAttributeNode-overriding-lowercase-values-1-xml.xhtml
r195247 r195248 1 1 <!DOCTYPE html> 2 <html >2 <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> 3 3 <head> 4 <meta charset="utf-8" >4 <meta charset="utf-8"/> 5 5 <script src="../../../resources/js-test-pre.js"></script> 6 6 </head> … … 13 13 document.documentElement.setAttribute('FooBar', 'WebKit'); 14 14 15 shouldBe EqualToString('document.documentElement.getAttribute("foobar")', 'WebKit');16 shouldBe True('document.documentElement.hasAttribute("foobar")');15 shouldBeNull('document.documentElement.getAttribute("foobar")'); 16 shouldBeFalse('document.documentElement.hasAttribute("foobar")'); 17 17 shouldBeEqualToString('document.documentElement.getAttribute("FooBar")', 'WebKit'); 18 18 shouldBeTrue('document.documentElement.hasAttribute("FooBar")'); 19 19 20 shouldBe EqualToString('document.documentElement.getAttributeNS("", "foobar")', 'WebKit');21 shouldBe True('document.documentElement.hasAttributeNS("", "foobar")');22 shouldBe ('document.documentElement.getAttributeNS("", "FooBar")', 'null');23 shouldBe False('document.documentElement.hasAttributeNS("", "FooBar")');20 shouldBeNull('document.documentElement.getAttributeNS("", "foobar")', 'WebKit'); 21 shouldBeFalse('document.documentElement.hasAttributeNS("", "foobar")'); 22 shouldBeEqualToString('document.documentElement.getAttributeNS("", "FooBar")', 'WebKit'); 23 shouldBeTrue('document.documentElement.hasAttributeNS("", "FooBar")'); 24 24 25 25 26 shouldBe('document.documentElement.attributes.length', ' 1');26 shouldBe('document.documentElement.attributes.length', '3'); 27 27 28 // "FooBar" should nuke the "foobar" value while itself having the "FooBar" name.28 // Should replace the value of "FooBar" by "WebKit". 29 29 var camelCaseFoobar = document.createAttribute("FooBar"); 30 30 camelCaseFoobar.value = 'Rocks!' … … 35 35 shouldBe('document.documentElement.getAttribute("foobar")', 'null'); 36 36 shouldBeFalse('document.documentElement.hasAttribute("foobar")'); 37 shouldBe ('document.documentElement.getAttribute("FooBar")', 'null');38 shouldBe False('document.documentElement.hasAttribute("FooBar")');37 shouldBeEqualToString('document.documentElement.getAttribute("FooBar")', 'Rocks!'); 38 shouldBeTrue('document.documentElement.hasAttribute("FooBar")'); 39 39 40 40 shouldBe('document.documentElement.getAttributeNS("", "foobar")', 'null'); … … 52 52 shouldBeEqualToString('document.documentElement.getAttribute("foobar")', 'WebKit2'); 53 53 shouldBeTrue('document.documentElement.hasAttribute("foobar")'); 54 shouldBeEqualToString('document.documentElement.getAttribute("FooBar")', ' WebKit2');54 shouldBeEqualToString('document.documentElement.getAttribute("FooBar")', 'Rocks!'); 55 55 shouldBeTrue('document.documentElement.hasAttribute("FooBar")'); 56 56 -
trunk/LayoutTests/fast/dom/Element/setAttributeNode-overriding-lowercase-values-1.html
r179497 r195248 26 26 shouldBe('document.documentElement.attributes.length', '1'); 27 27 28 // "FooBar" should nuke the "foobar" value while itself having the "FooBar" name.28 // "FooBar" should nuke the "foobar" value and itself having the "foobar" name. 29 29 var camelCaseFoobar = document.createAttribute("FooBar"); 30 30 camelCaseFoobar.value = 'Rocks!' … … 33 33 shouldNotBe('camelCaseFoobar', 'oldAttributeNode'); 34 34 35 shouldBe ('document.documentElement.getAttribute("foobar")', 'null');36 shouldBe False('document.documentElement.hasAttribute("foobar")');37 shouldBe ('document.documentElement.getAttribute("FooBar")', 'null');38 shouldBe False('document.documentElement.hasAttribute("FooBar")');35 shouldBeEqualToString('document.documentElement.getAttribute("foobar")', 'Rocks!'); 36 shouldBeTrue('document.documentElement.hasAttribute("foobar")'); 37 shouldBeEqualToString('document.documentElement.getAttribute("FooBar")', 'Rocks!'); 38 shouldBeTrue('document.documentElement.hasAttribute("FooBar")'); 39 39 40 shouldBe ('document.documentElement.getAttributeNS("", "foobar")', 'null');41 shouldBe False('document.documentElement.hasAttributeNS("", "foobar")');42 shouldBe EqualToString('document.documentElement.getAttributeNS("", "FooBar")', 'Rocks!');43 shouldBe True('document.documentElement.hasAttributeNS("", "FooBar")');40 shouldBeEqualToString('document.documentElement.getAttributeNS("", "foobar")', 'Rocks!'); 41 shouldBeTrue('document.documentElement.hasAttributeNS("", "foobar")'); 42 shouldBeNull('document.documentElement.getAttributeNS("", "FooBar")'); 43 shouldBeFalse('document.documentElement.hasAttributeNS("", "FooBar")'); 44 44 45 45 // "foobar" should exist alongside "FooBar". … … 48 48 var oldAttributeNode2 = document.documentElement.setAttributeNode(lowerCaseFoobar); 49 49 50 shouldBe('oldAttributeNode2', ' null');50 shouldBe('oldAttributeNode2', 'camelCaseFoobar'); 51 51 52 52 shouldBeEqualToString('document.documentElement.getAttribute("foobar")', 'WebKit2'); … … 57 57 shouldBeEqualToString('document.documentElement.getAttributeNS("", "foobar")', 'WebKit2'); 58 58 shouldBeTrue('document.documentElement.hasAttributeNS("", "foobar")'); 59 shouldBe EqualToString('document.documentElement.getAttributeNS("", "FooBar")', 'Rocks!');60 shouldBe True('document.documentElement.hasAttributeNS("", "FooBar")');59 shouldBeNull('document.documentElement.getAttributeNS("", "FooBar")'); 60 shouldBeFalse('document.documentElement.hasAttributeNS("", "FooBar")'); 61 61 </script> 62 62 <script src="../../../resources/js-test-post.js"></script> -
trunk/LayoutTests/imported/w3c/ChangeLog
r195229 r195248 1 2016-01-18 Ryosuke Niwa <rniwa@webkit.org> 2 3 createAttribute should lowercase the attribute name in a HTML document 4 https://bugs.webkit.org/show_bug.cgi?id=153112 5 6 Reviewed by Darin Adler. 7 8 Rebaseline a test now that it's passing all test cases. 9 10 * web-platform-tests/dom/nodes/Document-createAttribute-expected.txt: 11 1 12 2016-01-18 Xabier Rodriguez Calvar <calvaris@igalia.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createAttribute-expected.txt
r191379 r195248 16 16 PASS HTML document.createAttribute("title") 17 17 PASS XML document.createAttribute("title") 18 FAIL HTML document.createAttribute("TITLE") assert_equals: expected "title" but got "TITLE" 18 PASS HTML document.createAttribute("TITLE") 19 19 PASS XML document.createAttribute("TITLE") 20 20 PASS HTML document.createAttribute(null) -
trunk/Source/WebCore/ChangeLog
r195247 r195248 1 2016-01-18 Ryosuke Niwa <rniwa@webkit.org> 2 3 createAttribute should lowercase the attribute name in a HTML document 4 https://bugs.webkit.org/show_bug.cgi?id=153112 5 6 Reviewed by Darin Adler. 7 8 In a HTML document, we should always lowercase localName in document.createAttribute as specified in 9 https://dom.spec.whatwg.org/#dom-document-createattribute: 10 11 1. If localName does not match the Name production in XML, throw an InvalidCharacterError exception. 12 2. If the context object is an HTML document, let localName be converted to ASCII lowercase. 13 3. Return a new attribute whose local name is localName. 14 15 Change WebKit's behavior to match the spec as well as Firefox. document.createAttributeNS will 16 continue to preserve the case as spec'ed. 17 18 No new tests are added since the behavior change is covered by existing tests. 19 20 * dom/Document.cpp: 21 (WebCore::Document::createAttribute): 22 1 23 2016-01-18 Brady Eidson <beidson@apple.com> 2 24 -
trunk/Source/WebCore/dom/Document.cpp
r195142 r195248 4920 4920 RefPtr<Attr> Document::createAttribute(const String& name, ExceptionCode& ec) 4921 4921 { 4922 return createAttributeNS(String(), name, ec, true);4922 return createAttributeNS(String(), isHTMLDocument() ? name.convertToASCIILowercase() : name, ec, true); 4923 4923 } 4924 4924
Note: See TracChangeset
for help on using the changeset viewer.