OLD | NEW |
1 <!-- | 1 <!-- |
2 - The contents of this file are subject to the Mozilla Public | 2 - The contents of this file are subject to the Mozilla Public |
3 - License Version 1.1 (the "License"); you may not use this file | 3 - License Version 1.1 (the "License"); you may not use this file |
4 - except in compliance with the License. You may obtain a copy of | 4 - except in compliance with the License. You may obtain a copy of |
5 - the License at http://www.mozilla.org/MPL/ | 5 - the License at http://www.mozilla.org/MPL/ |
6 - | 6 - |
7 - Software distributed under the License is distributed on an "AS | 7 - Software distributed under the License is distributed on an "AS |
8 - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | 8 - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
9 - implied. See the License for the specific language governing | 9 - implied. See the License for the specific language governing |
10 - rights and limitations under the License. | 10 - rights and limitations under the License. |
11 - | 11 - |
12 - The Original Code is Mozilla Test Cases. | 12 - The Original Code is Mozilla Test Cases. |
13 - | 13 - |
14 - The Initial Developer of the Original Code is Netscape Communications | 14 - The Initial Developer of the Original Code is Netscape Communications |
15 - Corp. Portions created by Netscape Communications Corp. are | 15 - Corp. Portions created by Netscape Communications Corp. are |
16 - Copyright (C) 2001 Netscape Communications Corp. All | 16 - Copyright (C) 2001 Netscape Communications Corp. All |
17 - Rights Reserved. | 17 - Rights Reserved. |
18 - | 18 - |
19 - Contributor(s): | 19 - Contributor(s): |
20 --> | 20 --> |
21 <html> | 21 <html> |
22 <head> | 22 <head> |
23 <title>DOMParser/XMLSerializer test</title> | 23 <title>DOMParser/XMLSerializer test</title> |
24 <style type="text/css"> | 24 <style type="text/css"> |
25 .box { | 25 .box { |
26 display: box; | 26 display: box; |
27 border: 1px solid black; | 27 border: 1px solid black; |
28 margin-bottom: 0.5em; | 28 margin-bottom: 0.5em; |
29 } | 29 } |
30 pre { | 30 pre { |
31 margin-left: 2em; | 31 margin-left: 2em; |
32 } | 32 } |
33 </style> | 33 </style> |
34 <script type="text/javascript"> | 34 <script type="text/javascript"> |
35 | 35 |
36 if (window.testRunner) | 36 if (window.testRunner) |
37 testRunner.dumpAsText(); | 37 testRunner.dumpAsText(); |
38 | 38 |
39 function execute() | 39 function execute() |
40 { | 40 { |
41 var parser = new DOMParser(); | 41 var parser = new DOMParser(); |
42 var str = | 42 var str = |
43 '<?xml version="1.0"?>\n<!DOCTYPE doc [\n<!ATTLIST d id ID #IMPLIED>\n]>\n<d
oc>\n <foo xmlns="foobar">One</foo> <x:bar xmlns:x="barfoo">Two</x:bar>\n <d i
d="id3">Three</d>\n<f id="&<>">Four&<></f><empty/><empty></e
mpty></doc>\n'; | 43 '<?xml version="1.0"?>\n<!DOCTYPE doc [\n<!ATTLIST d id ID #IMPLIED>\n]>\n<d
oc>\n <foo xmlns="foobar">One</foo> <x:bar xmlns:x="barfoo">Two</x:bar>\n <d i
d="id3">Three</d>\n<f id="&<>>">Four&<></f><empty/><empty></
empty></doc>\n'; |
44 var doc = parser.parseFromString(str,"text/xml"); | 44 var doc = parser.parseFromString(str,"text/xml"); |
45 | 45 |
46 document.getElementById("id1").firstChild.nodeValue = str; | 46 document.getElementById("id1").firstChild.nodeValue = str; |
47 document.getElementById("id2").firstChild.nodeValue = doc; | 47 document.getElementById("id2").firstChild.nodeValue = doc; |
48 var ser = new XMLSerializer(); | 48 var ser = new XMLSerializer(); |
49 document.getElementById("id3").firstChild.nodeValue = ser.serializeToString(do
c); | 49 document.getElementById("id3").firstChild.nodeValue = ser.serializeToString(do
c); |
50 } | 50 } |
51 | 51 |
52 </script> | 52 </script> |
53 </head> | 53 </head> |
54 <body onload="execute();"> | 54 <body onload="execute();"> |
55 <h1>DOMParser/XMLSerializer test</h1> | 55 <h1>DOMParser/XMLSerializer test</h1> |
56 | 56 |
57 <div>The "text to parse" and "document object serialized" boxes should show the
same text, and it should be an XML document, not "@@No result@@". | 57 <div>The "text to parse" and "document object serialized" boxes should show the
same text, and it should be an XML document, not "@@No result@@". |
58 </div> | 58 </div> |
59 | 59 |
60 <div class="box"><h2>text to parse</h2> | 60 <div class="box"><h2>text to parse</h2> |
61 <pre id="id1">@@No result@@</pre> | 61 <pre id="id1">@@No result@@</pre> |
62 </div> | 62 </div> |
63 <br> | 63 <br> |
64 <div class="box"><h2>document object</h2> | 64 <div class="box"><h2>document object</h2> |
65 <pre id="id2">@@No result@@</pre> | 65 <pre id="id2">@@No result@@</pre> |
66 </div> | 66 </div> |
67 <br> | 67 <br> |
68 <div class="box"><h2>document object serialized</h2> | 68 <div class="box"><h2>document object serialized</h2> |
69 <pre id="id3">@@No result@@</pre> | 69 <pre id="id3">@@No result@@</pre> |
70 </div> | 70 </div> |
71 | 71 |
72 </body> | 72 </body> |
73 </html> | 73 </html> |
OLD | NEW |