Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / js / tests / e4x / XML / 13.4.3.js
bloba17b5af8ce3e2e92c324dec88417b802505df6ab
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is Rhino code, released
17 * May 6, 1999.
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1997-2000
22 * the Initial Developer. All Rights Reserved.
24 * Contributor(s):
25 * Igor Bukanov
26 * Ethan Hugg
27 * Milen Nankov
29 * Alternatively, the contents of this file may be used under the terms of
30 * either the GNU General Public License Version 2 or later (the "GPL"), or
31 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
32 * in which case the provisions of the GPL or the LGPL are applicable instead
33 * of those above. If you wish to allow use of your version of this file only
34 * under the terms of either the GPL or the LGPL, and not to allow others to
35 * use your version of this file under the terms of the MPL, indicate your
36 * decision by deleting the provisions above and replace them with the notice
37 * and other provisions required by the GPL or the LGPL. If you do not delete
38 * the provisions above, a recipient may use your version of this file under
39 * the terms of any one of the MPL, the GPL or the LGPL.
41 * ***** END LICENSE BLOCK ***** */
43 gTestfile = '13.4.3.js';
45 START("13.4.3 - XML Properties");
47 // Test defaults
48 TEST(1, true, XML.ignoreComments);
49 TEST(2, true, XML.ignoreProcessingInstructions);
50 TEST(3, true, XML.ignoreWhitespace);
51 TEST(4, true, XML.prettyPrinting);
52 TEST(5, 2, XML.prettyIndent);
54 // ignoreComments
55 x = <alpha><!-- comment --><bravo>one</bravo></alpha>;
57 correct = <alpha><bravo>one</bravo></alpha>;
59 TEST(6, correct, x);
61 XML.ignoreComments = false;
63 x = <alpha><!-- comment --><bravo>one</bravo></alpha>;
65 correct =
66 "<alpha>\n" +
67 " <!-- comment -->\n" +
68 " <bravo>one</bravo>\n" +
69 "</alpha>";
71 TEST_XML(7, correct, x);
74 // ignoreProcessingInstructions
75 XML.setSettings();
76 x =
78 <alpha>
79 <?foo version="1.0" encoding="utf-8"?>
80 <bravo>one</bravo>
81 </alpha>
82 </>;
84 correct =
85 <alpha>
86 <bravo>one</bravo>
87 </alpha>;
89 TEST(8, correct, x);
91 XML.ignoreProcessingInstructions = false;
93 x =
95 <alpha>
96 <?foo version="1.0" encoding="utf-8"?>
97 <bravo>one</bravo>
98 </alpha>
99 </>;
101 correct =
102 "<alpha>\n" +
103 " <?foo version=\"1.0\" encoding=\"utf-8\"?>\n" +
104 " <bravo>one</bravo>\n" +
105 "</alpha>";
107 TEST_XML(9, correct, x);
109 // ignoreWhitespace
110 XML.setSettings();
111 x = new XML("<alpha> \t\r\n\r\n<bravo> \t\r\n\r\none</bravo> \t\r\n\r\n</alpha>");
113 correct =
114 "<alpha>\n" +
115 " <bravo>one</bravo>\n" +
116 "</alpha>";
118 TEST_XML(10, correct, x);
120 XML.ignoreWhitespace = false;
121 XML.prettyPrinting = false;
123 correct = "<alpha> \n\n<bravo> \n\none</bravo> \n\n</alpha>";
124 x = new XML(correct);
126 TEST_XML(11, correct, x);
128 // prettyPrinting
129 XML.setSettings();
132 <alpha>
134 <bravo>two</bravo>
135 <charlie/>
136 <delta>
137 three
138 <echo>four</echo>
139 </delta>
140 </alpha>;
142 correct = "<alpha>\n" +
143 " one\n" +
144 " <bravo>two</bravo>\n" +
145 " <charlie/>\n" +
146 " <delta>\n" +
147 " three\n" +
148 " <echo>four</echo>\n" +
149 " </delta>\n" +
150 "</alpha>";
152 TEST(12, correct, x.toString());
153 TEST(13, correct, x.toXMLString());
155 XML.prettyPrinting = false;
157 correct = "<alpha>one<bravo>two</bravo><charlie/><delta>three<echo>four</echo></delta></alpha>";
158 TEST(14, correct, x.toString());
159 TEST(15, correct, x.toXMLString());
161 // prettyIndent
162 XML.prettyPrinting = true;
163 XML.prettyIndent = 3;
165 correct = "<alpha>\n" +
166 " one\n" +
167 " <bravo>two</bravo>\n" +
168 " <charlie/>\n" +
169 " <delta>\n" +
170 " three\n" +
171 " <echo>four</echo>\n" +
172 " </delta>\n" +
173 "</alpha>";
175 TEST(16, correct, x.toString());
176 TEST(17, correct, x.toXMLString());
178 XML.prettyIndent = 0;
180 correct = "<alpha>\n" +
181 "one\n" +
182 "<bravo>two</bravo>\n" +
183 "<charlie/>\n" +
184 "<delta>\n" +
185 "three\n" +
186 "<echo>four</echo>\n" +
187 "</delta>\n" +
188 "</alpha>";
190 TEST(18, correct, x.toString());
191 TEST(19, correct, x.toXMLString());
193 // settings()
194 XML.setSettings();
195 o = XML.settings();
196 TEST(20, true, o.ignoreComments);
197 TEST(21, true, o.ignoreProcessingInstructions);
198 TEST(22, true, o.ignoreWhitespace);
199 TEST(23, true, o.prettyPrinting);
200 TEST(24, 2, o.prettyIndent);
202 // setSettings()
203 o = XML.settings();
204 o.ignoreComments = false;
205 o.ignoreProcessingInstructions = false;
206 o.ignoreWhitespace = false;
207 o.prettyPrinting = false;
208 o.prettyIndent = 7;
210 XML.setSettings(o);
211 o = XML.settings();
212 TEST(25, false, o.ignoreComments);
213 TEST(26, false, o.ignoreProcessingInstructions);
214 TEST(27, false, o.ignoreWhitespace);
215 TEST(28, false, o.prettyPrinting);
216 TEST(29, 7, o.prettyIndent);
218 // setSettings()
219 XML.setSettings();
220 o = XML.settings();
221 TEST(30, true, o.ignoreComments);
222 TEST(31, true, o.ignoreProcessingInstructions);
223 TEST(32, true, o.ignoreWhitespace);
224 TEST(33, true, o.prettyPrinting);
225 TEST(34, 2, o.prettyIndent);
227 correct = new XML('');
229 // ignoreComments
230 XML.ignoreComments = true;
231 x = <!-- comment -->;
232 TEST(35, correct, x);
234 // ignoreProcessingInstructions
235 XML.ignoreProcessingInstructions = true;
236 x = <?pi?>;
237 TEST(36, correct, x);
239 END();