1
// |reftest| pref(javascript.options.xml.content,true) fails
2
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 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/. */
10
START("10.2.1 - XML.toXMLString");
12
var BUGNUMBER = 297025;
14
printBugNumber(BUGNUMBER);
25
// text 10.2.1 - Step 4
27
printStatus(inSection(n++) + ' testing text');
29
var text = 'this is text';
32
printStatus(inSection(n++) + ' testing text with pretty printing');
33
XML.prettyPrinting = true;
34
XML.prettyIndent = 10;
37
actual = xml.toXMLString();
38
TEST(n, expect, actual);
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');
45
actual = xml.toXMLString();
46
TEST(n, expect, actual);
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);
55
// EscapeElementValue - 10.2.1 Step 4.a.ii
57
printStatus(inSection(n++) + ' testing text EscapeElementValue');
58
var alpha = 'abcdefghijklmnopqrstuvwxyz';
59
xml = <a>{"< > &"}{alpha}</a>;
61
expect = '< > &' + alpha
62
actual = xml.toXMLString();
63
TEST(n, expect, actual);
65
// attribute, EscapeAttributeValue - 10.2.1 Step 5
67
printStatus(inSection(n++) + ' testing attribute EscapeAttributeValue');
69
xml.@bar = '"<&\u000A\u000D\u0009' + alpha;
70
expect = '<foo bar=""<&

	' + alpha + '"/>';
71
actual = xml.toXMLString();
72
TEST(n, expect, actual);
74
// Comment - 10.2.1 Step 6
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);
84
// Processing Instruction - 10.2.1 Step 7
86
printStatus(inSection(n++) + ' testing Processing Instruction');
87
XML.ignoreProcessingInstructions = false;
89
expect = '<?pi value?>';
90
actual = xml.toXMLString();
91
TEST(n, expect, actual);
95
// From Martin and Brendan
99
printStatus(inSection(n++));
100
expect = '<link xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink"/>';
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();
112
TEST(n, expect, actual);
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();
123
TEST(n, expect, actual);