OLD | NEW |
1 | |
2 /* | 1 /* |
3 Copyright © 2001-2004 World Wide Web Consortium, | 2 Copyright © 2001-2004 World Wide Web Consortium, |
4 (Massachusetts Institute of Technology, European Research Consortium | 3 (Massachusetts Institute of Technology, European Research Consortium |
5 for Informatics and Mathematics, Keio University). All | 4 for Informatics and Mathematics, Keio University). All |
6 Rights Reserved. This work is distributed under the W3C® Software License [1] i
n the | 5 Rights Reserved. This work is distributed under the W3C® Software License [1] i
n the |
7 hope that it will be useful, but WITHOUT ANY WARRANTY; without even | 6 hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
8 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 7 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
9 | 8 |
10 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 | 9 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 |
11 */ | 10 */ |
12 | 11 |
13 | |
14 | |
15 /** | 12 /** |
16 * Gets URI that identifies the test. | 13 * Gets URI that identifies the test. |
17 * @return uri identifier of test | 14 * @return uri identifier of test |
18 */ | 15 */ |
19 function getTargetURI() { | 16 function getTargetURI() { |
20 return "http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodeinsertbefore
18"; | 17 return "http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodeinsertbefore
18"; |
21 } | 18 } |
22 | 19 |
23 var docsLoaded = -1000000; | 20 var docsLoaded = -1000000; |
24 var builder = null; | 21 var builder = null; |
(...skipping 11 matching lines...) Expand all Loading... |
36 setUpPageStatus = 'running'; | 33 setUpPageStatus = 'running'; |
37 try { | 34 try { |
38 // | 35 // |
39 // creates test document builder, may throw exception | 36 // creates test document builder, may throw exception |
40 // | 37 // |
41 builder = createConfiguredBuilder(); | 38 builder = createConfiguredBuilder(); |
42 setImplementationAttribute("namespaceAware", true); | 39 setImplementationAttribute("namespaceAware", true); |
43 setImplementationAttribute("expandEntityReferences", false); | 40 setImplementationAttribute("expandEntityReferences", false); |
44 | 41 |
45 docsLoaded = 0; | 42 docsLoaded = 0; |
46 | 43 |
47 var docRef = null; | 44 var docRef = null; |
48 if (typeof(this.doc) != 'undefined') { | 45 if (typeof(this.doc) != 'undefined') { |
49 docRef = this.doc; | 46 docRef = this.doc; |
50 } | 47 } |
51 docsLoaded += preload(docRef, "doc", "hc_staff"); | 48 docsLoaded += preload(docRef, "doc", "hc_staff"); |
52 | 49 |
53 if (docsLoaded == 1) { | 50 if (docsLoaded == 1) { |
54 setUpPageStatus = 'complete'; | 51 setUpPageStatus = 'complete'; |
55 } | 52 } |
56 } catch(ex) { | 53 } catch(ex) { |
57 » catchInitializationError(builder, ex); | 54 catchInitializationError(builder, ex); |
58 setUpPageStatus = 'complete'; | 55 setUpPageStatus = 'complete'; |
59 } | 56 } |
60 } | 57 } |
61 | 58 |
62 | |
63 | |
64 // | 59 // |
65 // This method is called on the completion of | 60 // This method is called on the completion of |
66 // each asychronous load started in setUpTests. | 61 // each asychronous load started in setUpTests. |
67 // | 62 // |
68 // When every synchronous loaded document has completed, | 63 // When every synchronous loaded document has completed, |
69 // the page status is changed which allows the | 64 // the page status is changed which allows the |
70 // body of the test to be executed. | 65 // body of the test to be executed. |
71 function loadComplete() { | 66 function loadComplete() { |
72 if (++docsLoaded == 1) { | 67 if (++docsLoaded == 1) { |
73 setUpPageStatus = 'complete'; | 68 setUpPageStatus = 'complete'; |
74 } | 69 } |
75 } | 70 } |
76 | 71 |
| 72 /** |
| 73 * |
| 74 The method insertBefore inserts the node newChild before the existing child
node refChild. |
| 75 If refChild is null, insert newChild at the end of the list of children. |
77 | 76 |
78 /** | 77 Using insertBefore on an Element node attempt to insert new Comment/PI and C
DATA nodes |
79 * | 78 before each other and verify the names of the newly inserted nodes. |
80 » The method insertBefore inserts the node newChild before the existing ch
ild node refChild. | |
81 » If refChild is null, insert newChild at the end of the list of children. | |
82 » | |
83 » Using insertBefore on an Element node attempt to insert new Comment/PI a
nd CDATA nodes | |
84 » before each other and verify the names of the newly inserted nodes. | |
85 | 79 |
86 * @author IBM | 80 * @author IBM |
87 * @author Neil Delima | 81 * @author Neil Delima |
88 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ID-952280727 | 82 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ID-952280727 |
89 */ | 83 */ |
90 function nodeinsertbefore18() { | 84 function nodeinsertbefore18() { |
91 var success; | 85 var success; |
92 if(checkInitialization(builder, "nodeinsertbefore18") != null) return; | 86 if(checkInitialization(builder, "nodeinsertbefore18") != null) return; |
93 var doc; | 87 var doc; |
94 var element; | 88 var element; |
95 var newElem; | 89 var newElem; |
96 var newComment; | 90 var newComment; |
97 var newPI; | 91 var newPI; |
98 var newCDATA; | 92 var newCDATA; |
99 var insertedNode; | 93 var insertedNode; |
100 var data; | 94 var data; |
101 var target; | 95 var target; |
102 var appendedChild; | 96 var appendedChild; |
103 var inserted; | 97 var inserted; |
104 | 98 |
105 var docRef = null; | 99 var docRef = null; |
106 if (typeof(this.doc) != 'undefined') { | 100 if (typeof(this.doc) != 'undefined') { |
107 docRef = this.doc; | 101 docRef = this.doc; |
108 } | 102 } |
109 doc = load(docRef, "doc", "hc_staff"); | 103 doc = load(docRef, "doc", "hc_staff"); |
110 element = doc.createElement("element"); | 104 element = doc.createElement("element"); |
111 newElem = doc.createElementNS("http://www.w3.org/DOM","dom3:elem"); | 105 newElem = doc.createElementNS("http://www.w3.org/DOM","dom3:elem"); |
112 newComment = doc.createComment("Comment"); | 106 newComment = doc.createComment("Comment"); |
113 newCDATA = doc.createCDATASection("CDATASection"); | 107 newCDATA = doc.createCDATASection("CDATASection"); |
114 newPI = doc.createProcessingInstruction("target","data"); | 108 newPI = doc.createProcessingInstruction("target","data"); |
115 appendedChild = element.appendChild(newElem); | 109 appendedChild = element.appendChild(newElem); |
116 appendedChild = element.appendChild(newComment); | 110 appendedChild = element.appendChild(newComment); |
117 appendedChild = element.appendChild(newPI); | 111 appendedChild = element.appendChild(newPI); |
118 appendedChild = element.appendChild(newCDATA); | 112 appendedChild = element.appendChild(newCDATA); |
119 inserted = element.insertBefore(newComment,newElem); | 113 inserted = element.insertBefore(newComment,newElem); |
120 insertedNode = element.firstChild; | 114 insertedNode = element.firstChild; |
121 | 115 |
122 data = insertedNode.data; | 116 data = insertedNode.data; |
123 | 117 |
124 assertEquals("nodeinsertbefore18","Comment",data); | 118 assertEquals("nodeinsertbefore18","Comment",data); |
125 | 119 |
126 } | 120 } |
127 | 121 |
128 | |
129 | |
130 | |
131 function runTest() { | 122 function runTest() { |
132 nodeinsertbefore18(); | 123 nodeinsertbefore18(); |
133 } | 124 } |
OLD | NEW |