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
16 * The Original Code is Rhino code, released
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.
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 ***** */
44 START("13.4.3 - XML Properties");
47 TEST(1, true, XML.ignoreComments);
48 TEST(2, true, XML.ignoreProcessingInstructions);
49 TEST(3, true, XML.ignoreWhitespace);
50 TEST(4, true, XML.prettyPrinting);
51 TEST(5, 2, XML.prettyIndent);
54 x = <alpha><!-- comment --><bravo>one</bravo></alpha>;
56 correct = <alpha><bravo>one</bravo></alpha>;
60 XML.ignoreComments = false;
62 x = <alpha><!-- comment --><bravo>one</bravo></alpha>;
66 " <!-- comment -->\n" +
67 " <bravo>one</bravo>\n" +
70 TEST_XML(7, correct, x);
73 // ignoreProcessingInstructions
78 <?foo version="1.0" encoding="utf-8"?>
90 XML.ignoreProcessingInstructions = false;
95 <?foo version="1.0" encoding="utf-8"?>
102 " <?foo version=\"1.0\" encoding=\"utf-8\"?>\n" +
103 " <bravo>one</bravo>\n" +
106 TEST_XML(9, correct, x);
110 x = new XML("<alpha> \t\r\n\r\n<bravo> \t\r\n\r\none</bravo> \t\r\n\r\n</alpha>");
114 " <bravo>one</bravo>\n" +
117 TEST_XML(10, correct, x);
119 XML.ignoreWhitespace = false;
120 XML.prettyPrinting = false;
122 correct = "<alpha> \n\n<bravo> \n\none</bravo> \n\n</alpha>";
123 x = new XML(correct);
125 TEST_XML(11, correct, x);
141 correct = "<alpha>\n" +
143 " <bravo>two</bravo>\n" +
147 " <echo>four</echo>\n" +
151 TEST(12, correct, x.toString());
152 TEST(13, correct, x.toXMLString());
154 XML.prettyPrinting = false;
156 correct = "<alpha>one<bravo>two</bravo><charlie/><delta>three<echo>four</echo></delta></alpha>";
157 TEST(14, correct, x.toString());
158 TEST(15, correct, x.toXMLString());
161 XML.prettyPrinting = true;
162 XML.prettyIndent = 3;
164 correct = "<alpha>\n" +
166 " <bravo>two</bravo>\n" +
170 " <echo>four</echo>\n" +
174 TEST(16, correct, x.toString());
175 TEST(17, correct, x.toXMLString());
177 XML.prettyIndent = 0;
179 correct = "<alpha>\n" +
181 "<bravo>two</bravo>\n" +
185 "<echo>four</echo>\n" +
189 TEST(18, correct, x.toString());
190 TEST(19, correct, x.toXMLString());
195 TEST(20, true, o.ignoreComments);
196 TEST(21, true, o.ignoreProcessingInstructions);
197 TEST(22, true, o.ignoreWhitespace);
198 TEST(23, true, o.prettyPrinting);
199 TEST(24, 2, o.prettyIndent);
203 o.ignoreComments = false;
204 o.ignoreProcessingInstructions = false;
205 o.ignoreWhitespace = false;
206 o.prettyPrinting = false;
211 TEST(25, false, o.ignoreComments);
212 TEST(26, false, o.ignoreProcessingInstructions);
213 TEST(27, false, o.ignoreWhitespace);
214 TEST(28, false, o.prettyPrinting);
215 TEST(29, 7, o.prettyIndent);
220 TEST(30, true, o.ignoreComments);
221 TEST(31, true, o.ignoreProcessingInstructions);
222 TEST(32, true, o.ignoreWhitespace);
223 TEST(33, true, o.prettyPrinting);
224 TEST(34, 2, o.prettyIndent);
226 correct = new XML('');
229 XML.ignoreComments = true;
230 x = <!-- comment -->;
231 TEST(35, correct, x);
233 // ignoreProcessingInstructions
234 XML.ignoreProcessingInstructions = true;
236 TEST(36, correct, x);