~ubuntu-branches/ubuntu/trusty/mozjs17/trusty

« back to all changes in this revision

Viewing changes to js/src/tests/e4x/XML/13.4.2.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// |reftest| pref(javascript.options.xml.content,true)
 
2
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 
3
 *
 
4
 * This Source Code Form is subject to the terms of the Mozilla Public
 
5
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 
6
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
7
 
 
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();