~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/tests/e4x/TypeConversion/10.2.1.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) fails
 
2
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
3
/*
 
4
 *
 
5
 * This Source Code Form is subject to the terms of the Mozilla Public
 
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
8
 
 
9
 
 
10
START("10.2.1 - XML.toXMLString");
 
11
 
 
12
var BUGNUMBER = 297025;
 
13
 
 
14
printBugNumber(BUGNUMBER);
 
15
 
 
16
var n = 1;
 
17
var actual;
 
18
var expect;
 
19
 
 
20
 
 
21
// Semantics
 
22
 
 
23
var xml;
 
24
 
 
25
// text 10.2.1 - Step 4
 
26
 
 
27
printStatus(inSection(n++) + ' testing text');
 
28
 
 
29
var text = 'this is text';
 
30
 
 
31
 
 
32
printStatus(inSection(n++) + ' testing text with pretty printing');
 
33
XML.prettyPrinting = true;
 
34
XML.prettyIndent   = 10;
 
35
xml = new XML(text);
 
36
expect = text;
 
37
actual = xml.toXMLString();
 
38
TEST(n, expect, actual);
 
39
 
 
40
printStatus(inSection(n++) + ' testing text with whitespace with pretty printing');
 
41
XML.prettyPrinting = true;
 
42
XML.prettyIndent   = 10;
 
43
xml = new XML(' \t\r\n' + text + ' \t\r\n');
 
44
expect = text;
 
45
actual = xml.toXMLString();
 
46
TEST(n, expect, actual);
 
47
 
 
48
printStatus(inSection(n++) + ' testing text with whitespace without pretty printing');
 
49
XML.prettyPrinting = false;
 
50
xml = new XML(' \t\r\n' + text + ' \t\r\n');
 
51
expect = ' \t\r\n' + text + ' \t\r\n';
 
52
actual = xml.toXMLString();
 
53
TEST(n, expect, actual);
 
54
 
 
55
// EscapeElementValue - 10.2.1 Step 4.a.ii
 
56
 
 
57
printStatus(inSection(n++) + ' testing text EscapeElementValue');
 
58
var alpha = 'abcdefghijklmnopqrstuvwxyz';
 
59
xml = <a>{"< > &"}{alpha}</a>;
 
60
xml = xml.text();
 
61
expect = '&lt; &gt; &amp;' + alpha
 
62
actual = xml.toXMLString();
 
63
TEST(n, expect, actual);
 
64
 
 
65
// attribute, EscapeAttributeValue - 10.2.1 Step 5
 
66
 
 
67
printStatus(inSection(n++) + ' testing attribute EscapeAttributeValue');
 
68
xml = <foo/>;
 
69
xml.@bar = '"<&\u000A\u000D\u0009' + alpha;
 
70
expect = '<foo bar="&quot;&lt;&amp;&#xA;&#xD;&#x9;' + alpha + '"/>';
 
71
actual = xml.toXMLString();
 
72
TEST(n, expect, actual);
 
73
 
 
74
// Comment - 10.2.1 Step 6
 
75
 
 
76
printStatus(inSection(n++) + ' testing Comment');
 
77
XML.ignoreComments = false;
 
78
xml = <!-- Comment -->;
 
79
expect = '<!-- Comment -->';
 
80
actual = xml.toXMLString();
 
81
TEST(n, expect, actual);
 
82
 
 
83
 
 
84
// Processing Instruction - 10.2.1 Step 7
 
85
 
 
86
printStatus(inSection(n++) + ' testing Processing Instruction');
 
87
XML.ignoreProcessingInstructions = false;
 
88
xml = <?pi value?>;
 
89
expect = '<?pi value?>';
 
90
actual = xml.toXMLString();
 
91
TEST(n, expect, actual);
 
92
 
 
93
// 10.2.1 Step 8+
 
94
 
 
95
// From Martin and Brendan
 
96
var link;
 
97
var xlinkNamespace;
 
98
 
 
99
printStatus(inSection(n++));
 
100
expect = '<link xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink"/>';
 
101
 
 
102
link = <link type="simple" />;
 
103
xlinkNamespace = new Namespace('xlink', 'http://www.w3.org/1999/xlink');
 
104
link.addNamespace(xlinkNamespace);
 
105
printStatus('In scope namespace: ' + link.inScopeNamespaces());
 
106
printStatus('XML markup: ' + link.toXMLString());
 
107
link.@type.setName(new QName(xlinkNamespace, 'type'));
 
108
printStatus('name(): ' + link.@*::*[0].name());
 
109
actual = link.toXMLString();
 
110
printStatus(actual);
 
111
 
 
112
TEST(n, expect, actual);
 
113
 
 
114
printStatus(inSection(n++));
 
115
link = <link type="simple" />;
 
116
xlinkNamespace = new Namespace('xlink', 'http://www.w3.org/1999/xlink');
 
117
printStatus('XML markup: ' + link.toXMLString());
 
118
link.@type.setNamespace(xlinkNamespace);
 
119
printStatus('name(): ' + link.@*::*[0].name());
 
120
actual = link.toXMLString();
 
121
printStatus(actual);
 
122
 
 
123
TEST(n, expect, actual);
 
124
 
 
125
END();