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 ***** */
43 gTestfile
= '13.4.3.js';
45 START("13.4.3 - XML Properties");
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
);
55 x
= <alpha
><!-- comment
--><bravo
>one
</bravo></alpha>;
57 correct
= <alpha
><bravo
>one
</bravo></alpha>;
61 XML
.ignoreComments
= false;
63 x
= <alpha
><!-- comment
--><bravo
>one
</bravo></alpha>;
67 " <!-- comment -->\n" +
68 " <bravo>one</bravo>\n" +
71 TEST_XML(7, correct
, x
);
74 // ignoreProcessingInstructions
79 <?foo version
="1.0" encoding
="utf-8"?>
91 XML
.ignoreProcessingInstructions
= false;
96 <?foo version
="1.0" encoding
="utf-8"?>
103 " <?foo version=\"1.0\" encoding=\"utf-8\"?>\n" +
104 " <bravo>one</bravo>\n" +
107 TEST_XML(9, correct
, x
);
111 x
= new XML("<alpha> \t\r\n\r\n<bravo> \t\r\n\r\none</bravo> \t\r\n\r\n</alpha>");
115 " <bravo>one</bravo>\n" +
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
);
142 correct
= "<alpha>\n" +
144 " <bravo>two</bravo>\n" +
148 " <echo>four</echo>\n" +
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());
162 XML
.prettyPrinting
= true;
163 XML
.prettyIndent
= 3;
165 correct
= "<alpha>\n" +
167 " <bravo>two</bravo>\n" +
171 " <echo>four</echo>\n" +
175 TEST(16, correct
, x
.toString());
176 TEST(17, correct
, x
.toXMLString());
178 XML
.prettyIndent
= 0;
180 correct
= "<alpha>\n" +
182 "<bravo>two</bravo>\n" +
186 "<echo>four</echo>\n" +
190 TEST(18, correct
, x
.toString());
191 TEST(19, correct
, x
.toXMLString());
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
);
204 o
.ignoreComments
= false;
205 o
.ignoreProcessingInstructions
= false;
206 o
.ignoreWhitespace
= false;
207 o
.prettyPrinting
= false;
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
);
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('');
230 XML
.ignoreComments
= true;
231 x
= <!-- comment
-->;
232 TEST(35, correct
, x
);
234 // ignoreProcessingInstructions
235 XML
.ignoreProcessingInstructions
= true;
237 TEST(36, correct
, x
);