|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> |
|
2 <html> |
|
3 <head> |
|
4 <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
6 <title>http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode22</title> |
|
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="text/javascript" src="DOMTestCase.js"></script> |
|
10 <script type="text/javascript" src="exclusions.js"></script> |
|
11 <script type="text/javascript"> |
|
12 // expose test function names |
|
13 function exposeTestFunctionNames() |
|
14 { |
|
15 return ['documentimportnode22']; |
|
16 } |
|
17 |
|
18 var docsLoaded = -1000000; |
|
19 var builder = null; |
|
20 |
|
21 // |
|
22 // This function is called by the testing framework before |
|
23 // running the test suite. |
|
24 // |
|
25 // If there are no configuration exceptions, asynchronous |
|
26 // document loading is started. Otherwise, the status |
|
27 // is set to complete and the exception is immediately |
|
28 // raised when entering the body of the test. |
|
29 // |
|
30 function setUpPage() { |
|
31 setUpPageStatus = 'running'; |
|
32 try { |
|
33 // |
|
34 // creates test document builder, may throw exception |
|
35 // |
|
36 builder = createConfiguredBuilder(); |
|
37 setImplementationAttribute("namespaceAware", true); |
|
38 |
|
39 docsLoaded = 0; |
|
40 |
|
41 var docRef = null; |
|
42 if (typeof(this.doc) != 'undefined') { |
|
43 docRef = this.doc; |
|
44 } |
|
45 docsLoaded += preload(docRef, "doc", "staffNS"); |
|
46 |
|
47 if (docsLoaded == 1) { |
|
48 setUpPage = 'complete'; |
|
49 } |
|
50 } catch(ex) { |
|
51 catchInitializationError(builder, ex); |
|
52 setUpPage = 'complete'; |
|
53 } |
|
54 } |
|
55 |
|
56 // |
|
57 // This method is called on the completion of |
|
58 // each asychronous load started in setUpTests. |
|
59 // |
|
60 // When every synchronous loaded document has completed, |
|
61 // the page status is changed which allows the |
|
62 // body of the test to be executed. |
|
63 function loadComplete() { |
|
64 if (++docsLoaded == 1) { |
|
65 setUpPageStatus = 'complete'; |
|
66 runJSUnitTests(); |
|
67 markTodos(); |
|
68 SimpleTest.finish(); |
|
69 } |
|
70 } |
|
71 |
|
72 var docName = 'documentimportnode22'; |
|
73 |
|
74 |
|
75 /** |
|
76 * |
|
77 The importNode method imports a node from another document to this document. |
|
78 The returned node has no parent; (parentNode is null). The source node is not |
|
79 altered or removed from the original document but a new copy of the source node |
|
80 is created. |
|
81 |
|
82 Using the method importNode with deep=true/false, import two notaiton nodes into the |
|
83 same and different documnet objects. In each case check if valid public and systemids |
|
84 are returned if any and if none, check if a null value was returned. |
|
85 |
|
86 * @author IBM |
|
87 * @author Neil Delima |
|
88 * @see http://www.w3.org/TR/DOM-Level-2-Core/core |
|
89 * @see http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode |
|
90 */ |
|
91 function documentimportnode22() { |
|
92 var success; |
|
93 if(checkInitialization(builder, "documentimportnode22") != null) return; |
|
94 var doc; |
|
95 var docTypeNull = null; |
|
96 |
|
97 var docImp; |
|
98 var domImpl; |
|
99 var docType; |
|
100 var nodeMap; |
|
101 var notation1; |
|
102 var notation2; |
|
103 var notationImp1; |
|
104 var notationImp2; |
|
105 var notationImpNew1; |
|
106 var notationImpNew2; |
|
107 var publicId1; |
|
108 var publicId1Imp; |
|
109 var publicId1NewImp; |
|
110 var publicId2Imp; |
|
111 var publicId2NewImp; |
|
112 var systemId1Imp; |
|
113 var systemId1NewImp; |
|
114 var systemId2; |
|
115 var systemId2Imp; |
|
116 var systemId2NewImp; |
|
117 |
|
118 var docRef = null; |
|
119 if (typeof(this.doc) != 'undefined') { |
|
120 docRef = this.doc; |
|
121 } |
|
122 doc = load(docRef, "doc", "staffNS"); |
|
123 domImpl = doc.implementation; |
|
124 docType = doc.doctype; |
|
125 |
|
126 docImp = domImpl.createDocument("http://www.w3.org/DOM/Test","a:b",docTypeNull); |
|
127 nodeMap = docType.notations; |
|
128 |
|
129 assertNotNull("notationsNotNull",nodeMap); |
|
130 notation1 = nodeMap.getNamedItem("notation1"); |
|
131 notation2 = nodeMap.getNamedItem("notation2"); |
|
132 notationImp1 = doc.importNode(notation1,true); |
|
133 notationImp2 = doc.importNode(notation2,false); |
|
134 notationImpNew1 = docImp.importNode(notation1,false); |
|
135 notationImpNew2 = docImp.importNode(notation2,true); |
|
136 publicId1 = notation1.publicId; |
|
137 |
|
138 publicId1Imp = notation1.publicId; |
|
139 |
|
140 publicId1NewImp = notation1.publicId; |
|
141 |
|
142 systemId1Imp = notation1.systemId; |
|
143 |
|
144 systemId1NewImp = notation1.systemId; |
|
145 |
|
146 publicId2Imp = notation2.publicId; |
|
147 |
|
148 publicId2NewImp = notation2.publicId; |
|
149 |
|
150 systemId2 = notation2.systemId; |
|
151 |
|
152 systemId2Imp = notation2.systemId; |
|
153 |
|
154 systemId2NewImp = notation2.systemId; |
|
155 |
|
156 assertEquals("documentimportnode22_N1PID",publicId1,publicId1Imp); |
|
157 assertEquals("documentimportnode22_N1NPID",publicId1,publicId1NewImp); |
|
158 assertNull("documentimportnode22_N1SID",systemId1Imp); |
|
159 assertNull("documentimportnode22_N1NSID",systemId1NewImp); |
|
160 assertEquals("documentimportnode22_N2SID",systemId2,systemId2Imp); |
|
161 assertEquals("documentimportnode22_N2NSID",systemId2,systemId2NewImp); |
|
162 assertNull("documentimportnode22_N2PID",publicId2Imp); |
|
163 assertNull("documentimportnode22_N2NPID",publicId2Imp); |
|
164 |
|
165 } |
|
166 |
|
167 </script> |
|
168 </head> |
|
169 <body> |
|
170 <h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode22</h2> |
|
171 <p></p> |
|
172 <p> |
|
173 Copyright (c) 2001-2004 World Wide Web Consortium, |
|
174 (Massachusetts Institute of Technology, European Research Consortium |
|
175 for Informatics and Mathematics, Keio University). All |
|
176 Rights Reserved. This work is distributed under the <a href="http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231">W3C(r) Software License</a> in the |
|
177 hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
|
178 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
179 </p> |
|
180 </body> |
|
181 </html> |