Debian Codegraph @

rhino/testsrc/tests/e4x/XML/13.4.2.js

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 gTestfile = '13.4.2.js';
8
9 START("13.4.2 - XML Constructor");
10
11 x = new XML();
12 TEST(1, "xml", typeof(x));
13 TEST(2, true, x instanceof XML);
14
15 correct =
16 <Envelope
17 xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
18 xmlns:stock="http://mycompany.com/stocks"
19 soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
20 <Body>
21 <stock:GetLastTradePrice>
22 <stock:symbol>DIS</stock:symbol>
23 </stock:GetLastTradePrice>
24 </Body>
25 </Envelope>;
26
27 x = new XML(correct);
28 TEST_XML(3, correct.toXMLString(), x);
29
30 text =
31 "<Envelope" +
32 " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
33 " xmlns:stock=\"http://mycompany.com/stocks\"" +
34 " soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" +
35 " <Body>" +
36 " <stock:GetLastTradePrice>" +
37 " <stock:symbol>DIS</stock:symbol>" +
38 " </stock:GetLastTradePrice>" +
39 " </Body>" +
40 "</Envelope>";
41
42 x = new XML(text);
43 TEST(4, correct, x);
44
45 // Make sure it's a copy
46 x =
47 <alpha>
48 <bravo>one</bravo>
49 </alpha>;
50
51 y = new XML(x);
52
53 x.bravo.prependChild(<charlie>two</charlie>);
54
55 correct =
56 <alpha>
57 <bravo>one</bravo>
58 </alpha>;
59
60 TEST(5, correct, y);
61
62 // Make text node
63 x = new XML("4");
64 TEST_XML(6, "4", x);
65
66 x = new XML(4);
67 TEST_XML(7, "4", x);
68
69 // Undefined and null should behave like ""
70 x = new XML(null);
71 TEST_XML(8, "", x);
72
73 x = new XML(undefined);
74 TEST_XML(9, "", x);
75
76 // see bug 320008
77 x = new XML("<hello a='\"' />");
78 TEST_XML(10, "<hello a=\"&quot;\"/>", x);
79
80 END();