1
// |reftest| pref(javascript.options.xml.content,true)
2
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */
8
//-----------------------------------------------------------------------------
9
var BUGNUMBER = "350629";
10
var summary = ".toXMLString can include invalid generated prefixes";
13
printBugNumber(BUGNUMBER);
22
function extractPrefix(el, attrName, attrVal)
24
var str = el.toXMLString();
25
var regex = new RegExp(' (.+?):' + attrName + '="' + attrVal + '"');
26
return str.match(regex)[1];
29
function assertValidPrefix(p, msg)
32
0 == p.search(/xml/i))
40
// last component is invalid prefix
42
n = new Namespace("http://foo/bar.xml");
44
p = extractPrefix(el, "fiz", "eit");
45
assertValidPrefix(p, "namespace " + n.uri + " generated invalid prefix " + p);
47
// last component is invalid prefix (different case)
49
n = new Namespace("http://foo/bar.XML");
51
p = extractPrefix(el, "fiz", "eit");
52
assertValidPrefix(p, "namespace " + n.uri + " generated invalid prefix " + p);
54
// last component is invalid prefix (but not "xml"/"xmlns")
56
n = new Namespace("http://foo/bar.xmln");
58
p = extractPrefix(el, "baz", "quux");
59
assertValidPrefix(p, "namespace " + n.uri + " generated invalid prefix " + p);
62
// generated prefix with no valid prefix component in namespace URI
64
n = new Namespace("xml:///");
65
el.@n::bike = "cycle";
66
p = extractPrefix(el, "bike", "cycle");
67
assertValidPrefix(p, "namespace " + n.uri + " generated invalid prefix " + p);
70
// generated prefix with no valid prefix component in namespace URI w/further
72
el = <aaaaa:foo xmlns:aaaaa="http://baz/"/>;
73
n = new Namespace("xml:///");
74
el.@n::bike = "cycle";
75
p = extractPrefix(el, "bike", "cycle");
76
assertValidPrefix(p, "namespace " + n.uri + " generated invalid prefix " + p);
80
// XXX this almost certainly shouldn't work, so if it fails at some time it
81
// might not be a bug! it's only here because it *is* currently a
82
// possible failure point for prefix generation
84
n = new Namespace(".:/.././.:/:");
86
p = extractPrefix(el, "biz", "17");
87
assertValidPrefix(p, "namespace " + n.uri + " generated invalid prefix " + p);
97
TEST(1, expect, actual);