This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 261 - hc_nodeinsertbefore relies on parser specifics (whitespace handling).
Summary: hc_nodeinsertbefore relies on parser specifics (whitespace handling).
Status: RESOLVED FIXED
Alias: None
Product: DOM TS
Classification: Unclassified
Component: DOM Level 1 (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Philippe Le Hegaret
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-30 09:22 UTC by David Faure
Modified: 2003-09-23 05:04 UTC (History)
0 users

See Also:


Attachments
standalone testcase (765 bytes, text/html)
2003-06-30 09:26 UTC, David Faure
Details

Description David Faure 2003-06-30 09:22:02 UTC
The DOM1 hc_nodeinsertbefore test relies on a specificity of the Mozilla parser: when a <p> 
tag has a newline before the first child tag, Mozilla creates a text node to hold that 
(whitespace-only) text. Internet Explorer doesn't do that, and Konqueror neither. 
 
hc_nodeinsertbefore relies on the <sup> tag being at position 7 (the 8th child) among the 
children of the <p> tag. In IE and Konq, it is at position 6, since there's no leading text node. 
 
Can the test be changed to use something safer than getting a child by its index, for instance 
getElementsByTagName or namedItem?
Comment 1 David Faure 2003-06-30 09:26:13 UTC
Created attachment 40 [details]
standalone testcase
Comment 2 Curt Arnold 2003-09-23 01:04:33 UTC
The test was an transliteration of a NIST XML test.  So it is not only Mozilla,
but any XML parser, that would pass the test as written.  

That said, asserting the preservation of a leading whitespace in a p element was
not the objective of the test.  The following patch changes the test so it
obtains the refChild child parameter using getElementsByTagname and is not
affected by the elimination of the leading whitespace node.


Index: hc_nodeinsertbefore.xml
===================================================================
RCS file:
/sources/public/2001/DOM-Test-Suite/tests/level1/core/hc_nodeinsertbefore.xml,v
retrieving revision 1.4
diff -u -r1.4 hc_nodeinsertbefore.xml
--- hc_nodeinsertbefore.xml	28 Jun 2003 19:11:05 -0000	1.4
+++ hc_nodeinsertbefore.xml	23 Sep 2003 04:42:16 -0000
@@ -19,8 +19,8 @@
     The "insertBefore(newChild,refChild)" method inserts the
     node "newChild" before the node "refChild". 
     
-    Insert a newly created Element node before the eigth
-    child of the second employee and check the "newChild"
+    Insert a newly created Element node before the second
+    sup element in the document and check the "newChild"
     and "refChild" after insertion for correct placement.
 </description>
 
@@ -28,6 +28,7 @@
 <subject
resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727"/>
 <subject resource="http://www.w3.org/Bugs/Public/show_bug.cgi?id=246"/>
 <subject resource="http://www.w3.org/Bugs/Public/show_bug.cgi?id=247"/>
+<subject resource="http://www.w3.org/Bugs/Public/show_bug.cgi?id=261"/>
 </metadata>
 <var name="doc" type="Document"/>
 <var name="elementList" type="NodeList"/>
@@ -50,10 +51,10 @@
 </var>
 <var name="nodeType" type="int"/>
 <load var="doc" href="hc_staff" willBeModified="true"/>
-<getElementsByTagName interface="Document" obj="doc" tagname='"p"'
var="elementList"/>
-<item interface="NodeList" obj="elementList" index="1" var="employeeNode"/>
-<childNodes obj="employeeNode" var="childList"/>
-<item interface="NodeList" obj="childList" index="7" var="refChild"/>
+<getElementsByTagName interface="Document" obj="doc" tagname='"sup"'
var="elementList"/>
+<item interface="NodeList" obj="elementList" index="2" var="refChild"/>
+<parentNode interface="Node" var="employeeNode" obj="refChild"/>
+<childNodes var="childList" obj="employeeNode"/> 
 <createElement obj="doc" tagName='"br"' var="newChild"/>
 <insertBefore var="insertedNode" obj="employeeNode" newChild="newChild"
refChild="refChild"/>
 <for-each collection="childList" member="child">