Revision: 6057 Author: [email protected] Date: Tue Sep 1 08:25:59 2009 Log: Safari 4.0 treats CDATA and Text nodes seperately, but it still merges them when Node#normalize() is called, breaking XMLTest. This method fixes the test and adds a comment to Node#normalize() explaining this behavior.
Patch by: jlabanca Review by: jgw (desk) http://code.google.com/p/google-web-toolkit/source/detail?r=6057 Modified: /trunk/user/src/com/google/gwt/xml/client/Node.java /trunk/user/test/com/google/gwt/xml/client/XMLTest.java ======================================= --- /trunk/user/src/com/google/gwt/xml/client/Node.java Tue Jan 29 15:05:28 2008 +++ /trunk/user/src/com/google/gwt/xml/client/Node.java Tue Sep 1 08:25:59 2009 @@ -215,7 +215,8 @@ /** * This method may collapse adjacent text nodes into one text node, depending - * on the implementation. + * on the implementation. Safari 4.0 and Chrome will also merge CDATA nodes + * into text nodes, even though they support CDATA nodes as distinct nodes. */ void normalize(); ======================================= --- /trunk/user/test/com/google/gwt/xml/client/XMLTest.java Thu Jul 30 13:47:31 2009 +++ /trunk/user/test/com/google/gwt/xml/client/XMLTest.java Tue Sep 1 08:25:59 2009 @@ -124,13 +124,16 @@ top.getFirstChild().getFirstChild().appendChild(deep2); top.appendChild(d.createTextNode("0123456789")); - top.appendChild(d.createCDATASection("abcdefghij")); + top.appendChild(d.createTextNode("abcdefghij")); + top.appendChild(d.createElement("e4")); + top.appendChild(d.createCDATASection("klmnopqrst")); return d; } /** * Returns the module name for GWT unit test running. */ + @Override public String getModuleName() { return "com.google.gwt.xml.XML"; } @@ -169,18 +172,18 @@ createProcessingInstruction, createTextNode}); for (int i = 0; i < canHaveChildren.size(); i++) { - Node parent = (Node) canHaveChildren.get(i); + Node parent = canHaveChildren.get(i); Node cloneParent = parent.cloneNode(false); if (canBeChildren.contains(parent)) { d.appendChild(cloneParent); } for (int j = 0; j < canBeChildren.size(); j++) { - Node child = (Node) canBeChildren.get(j); + Node child = canBeChildren.get(j); cloneParent.appendChild(child.cloneNode(false)); } for (int j = 0; j < canBeChildren.size(); j++) { Node clonedChild = cloneParent.getChildNodes().item(j); - Node hopefullySameChild = (Node) canBeChildren.get(j); + Node hopefullySameChild = canBeChildren.get(j); assertEquals(hopefullySameChild.cloneNode(false).toString(), clonedChild.toString()); } @@ -441,22 +444,17 @@ assertEquals("t data", t.getData(), "01234"); assertEquals("LeftT data", rightT.getData(), "56789"); CDATASection cd = (CDATASection) d.getDocumentElement().getChildNodes().item( - 5); + 7); Text rightCD = cd.splitText(5); assertEquals("cd and leftCd parent equality", cd.getParentNode(), rightCD.getParentNode()); assertEquals("leftCD.getPreviousSibling", rightCD.getPreviousSibling(), cd); assertEquals("cd length", cd.getData().length(), 5); assertEquals("leftCD.length", rightCD.getData().length(), 5); - assertEquals("cd data", cd.getData(), "abcde"); - assertEquals("leftCD data", rightCD.getData(), "fghij"); + assertEquals("cd data", cd.getData(), "klmno"); + assertEquals("leftCD data", rightCD.getData(), "pqrst"); d.getDocumentElement().normalize(); - if (XMLParser.supportsCDATASection()) { - assertEquals("normalized t", d.getDocumentElement().getChildNodes().item( - 3).toString(), "0123456789"); - } else { - assertEquals("normalized t", d.getDocumentElement().getChildNodes().item( - 3).toString(), "0123456789abcdefghij"); - } + assertEquals("normalized t", d.getDocumentElement().getChildNodes().item( + 3).toString(), "0123456789abcdefghij"); } } --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
