2008-03-20 18:23:49 -07:00
|
|
|
<!DOCTYPE html>
|
2008-02-11 20:14:57 -08:00
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=411103
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 411103</title>
|
2009-05-06 13:46:04 -07:00
|
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
2008-02-11 20:14:57 -08:00
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=411103">Mozilla Bug 411103</a>
|
|
|
|
<p id="display"></p>
|
2008-03-20 18:23:49 -07:00
|
|
|
<div id="content" style="display: none"></div>
|
|
|
|
|
|
|
|
<!-- XML's createElement and createElementNS aren't HTML's, of course -->
|
|
|
|
<iframe src="data:application/xml,%3Cfoo%3EXML%3C/foo%3E" name="xmlWindow"></iframe>
|
|
|
|
|
|
|
|
<!-- for good measure... -->
|
|
|
|
<iframe src="data:application/xhtml+xml,%3Chtml%20xmlns=%22http://www.w3.org/1999/xhtml%22%3E%3Cbody%3E%3Cp%3EXHTML%3C/p%3E%3C/body%3E%3C/html%3E"
|
|
|
|
name="xhtmlWindow"></iframe>
|
|
|
|
|
2008-02-11 20:14:57 -08:00
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
2008-03-20 18:23:49 -07:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2008-02-11 20:14:57 -08:00
|
|
|
/** Test for Bug 411103 **/
|
|
|
|
var allNSTests =
|
|
|
|
[
|
|
|
|
{ args: [undefined, undefined] },
|
|
|
|
{ args: [null, undefined] },
|
|
|
|
{ args: [undefined, null], code: 5 },
|
|
|
|
{ args: [null, null], code: 5 },
|
|
|
|
{ args: [null, ""], code: 5 },
|
|
|
|
{ args: ["", null], code: 5 },
|
|
|
|
{ args: ["", ""], code: 5 },
|
|
|
|
{ args: [null, "<div>"], code: 5 },
|
|
|
|
{ args: [null, "0div"], code: 5 },
|
|
|
|
{ args: [null, "di v"], code: 5 },
|
|
|
|
{ args: [null, "di<v"], code: 5 },
|
|
|
|
{ args: [null, "-div"], code: 5 },
|
|
|
|
{ args: [null, ".div"], code: 5 },
|
|
|
|
{ args: ["http://example.com/", "<div>"], code: 5 },
|
|
|
|
{ args: ["http://example.com/", "0div"], code: 5 },
|
|
|
|
{ args: ["http://example.com/", "di<v"], code: 5 },
|
|
|
|
{ args: ["http://example.com/", "-div"], code: 5 },
|
|
|
|
{ args: ["http://example.com/", ".div"], code: 5 },
|
|
|
|
{ args: [null, ":div"], code: 14 },
|
|
|
|
{ args: [null, "div:"], code: 14 },
|
|
|
|
{ args: ["http://example.com/", ":div"], code: 14 },
|
|
|
|
{ args: ["http://example.com/", "div:"], code: 14 },
|
|
|
|
{ args: [null, "d:iv"], code: 14 },
|
|
|
|
{ args: [null, "a:b:c"], code: 14, message: "valid XML name, invalid QName" },
|
|
|
|
{ args: ["http://example.com/", "a:b:c"], code: 14, message: "valid XML name, invalid QName" },
|
|
|
|
{ args: [null, "a::c"], code: 14, message: "valid XML name, invalid QName" },
|
|
|
|
{ args: ["http://example.com/", "a::c"], code: 14, message: "valid XML name, invalid QName" },
|
|
|
|
{ args: ["http://example.com/", "a:0"], code: 5, message: "valid XML name, not a valid QName" },
|
|
|
|
{ args: ["http://example.com/", "0:a"], code: 5, message: "0 at start makes it not a valid XML name" },
|
|
|
|
{ args: ["http://example.com/", "a:_"] },
|
|
|
|
{ args: ["http://example.com/", "a:\u0BC6"], code: 14,
|
|
|
|
message: "non-ASCII character after colon is CombiningChar, which is " +
|
|
|
|
"NCNameChar but not (Letter | \"_\") so invalid at start of " +
|
|
|
|
"NCName (but still a valid XML name, hence not 5)" },
|
|
|
|
{ args: ["http://example.com/", "\u0BC6:a"], code: 14,
|
|
|
|
message: "non-ASCII character after colon is CombiningChar, which is " +
|
|
|
|
"NCNameChar but not (Letter | \"_\") so invalid at start of " +
|
|
|
|
"NCName (Gecko chooses to throw 14 here, but either is valid " +
|
|
|
|
"as this is both an invalid XML name and an invalid QName)" },
|
|
|
|
{ args: ["http://example.com/", "a:a\u0BC6"] },
|
|
|
|
{ args: ["http://example.com/", "a\u0BC6:a"] },
|
|
|
|
{ args: ["http://example.com/", "xml:test"], code: 14, message: "binding xml prefix wrong" },
|
|
|
|
{ args: ["http://example.com/", "xmlns:test"], code: 14, message: "binding xmlns prefix wrong" },
|
|
|
|
{ args: ["http://www.w3.org/2000/xmlns/", "x:test"], code: 14, message: "binding namespace namespace to wrong prefix" },
|
|
|
|
{ args: ["http://www.w3.org/2000/xmlns/", "xmlns:test"] },
|
|
|
|
{ args: ["http://www.w3.org/XML/1998/namespace", "xml:test"] },
|
|
|
|
{ args: ["http://www.w3.org/XML/1998/namespace", "x:test"] },
|
|
|
|
];
|
|
|
|
|
|
|
|
var allNoNSTests =
|
|
|
|
[
|
|
|
|
{ args: [undefined] },
|
|
|
|
{ args: [null], code: 5 },
|
|
|
|
{ args: [""], code: 5 },
|
|
|
|
{ args: ["<div>"], code: 5 },
|
|
|
|
{ args: ["0div"], code: 5 },
|
|
|
|
{ args: ["di v"], code: 5 },
|
|
|
|
{ args: ["di<v"], code: 5 },
|
|
|
|
{ args: ["-div"], code: 5 },
|
|
|
|
{ args: [".div"], code: 5 },
|
2008-02-15 15:22:55 -08:00
|
|
|
{ args: [":"], message: "valid XML name, invalid QName" },
|
|
|
|
{ args: [":div"], message: "valid XML name, invalid QName" },
|
2008-02-11 20:14:57 -08:00
|
|
|
{ args: ["div:"], message: "valid XML name, invalid QName" },
|
|
|
|
{ args: ["d:iv"] },
|
|
|
|
{ args: ["a:b:c"], message: "valid XML name, invalid QName" },
|
|
|
|
{ args: ["a::c"], message: "valid XML name, invalid QName" },
|
|
|
|
{ args: ["a::c:"], message: "valid XML name, invalid QName" },
|
|
|
|
{ args: ["a:0"], message: "valid XML name, not a valid QName" },
|
|
|
|
{ args: ["0:a"], code: 5, message: "0 at start makes it not a valid XML name" },
|
|
|
|
{ args: ["a:_"] },
|
|
|
|
{ args: ["a:\u0BC6"],
|
|
|
|
message: "non-ASCII character after colon is CombiningChar, which is " +
|
|
|
|
"valid in pre-namespace XML" },
|
|
|
|
{ args: ["\u0BC6:a"], code: 5, message: "not a valid start character" },
|
|
|
|
{ args: ["a:a\u0BC6"] },
|
|
|
|
{ args: ["a\u0BC6:a"] },
|
|
|
|
{ args: ["xml:test"] },
|
|
|
|
{ args: ["xmlns:test"] },
|
|
|
|
{ args: ["x:test"] },
|
|
|
|
{ args: ["xmlns:test"] },
|
|
|
|
];
|
|
|
|
|
|
|
|
function sourceify(v)
|
|
|
|
{
|
|
|
|
switch (typeof v)
|
|
|
|
{
|
|
|
|
case "undefined":
|
|
|
|
return v;
|
|
|
|
|
|
|
|
case "string":
|
|
|
|
return '"' + v.replace('"', '\\"') + '"';
|
|
|
|
|
|
|
|
default:
|
|
|
|
return String(v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function sourceifyArgs(args)
|
|
|
|
{
|
|
|
|
var copy = new Array(args.length);
|
|
|
|
for (var i = 0, sz = args.length; i < sz; i++)
|
|
|
|
copy[i] = sourceify(args[i]);
|
|
|
|
|
|
|
|
return copy.join(", ");
|
|
|
|
}
|
|
|
|
|
2008-03-20 18:23:49 -07:00
|
|
|
function runTests(tests, methodName, document)
|
2008-02-11 20:14:57 -08:00
|
|
|
{
|
|
|
|
for (var i = 0, sz = tests.length; i < sz; i++)
|
|
|
|
{
|
|
|
|
var test = tests[i];
|
|
|
|
|
|
|
|
var argStr = sourceifyArgs(test.args);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
document[methodName].apply(document, test.args);
|
|
|
|
var msg = "expected no exception for " +
|
|
|
|
"document." + methodName + "(" + argStr + ")";
|
|
|
|
if ("message" in test)
|
|
|
|
msg += "; " + test.message;
|
|
|
|
ok(!("code" in test), msg);
|
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
msg = "exception code for document." + methodName + "(" + argStr + ")";
|
|
|
|
if ("message" in test)
|
|
|
|
msg += "; " + test.message;
|
|
|
|
is(e.code, test.code || "no exception", msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-20 18:23:49 -07:00
|
|
|
|
|
|
|
function run()
|
|
|
|
{
|
|
|
|
// HTML document
|
|
|
|
runTests(allNSTests, "createElementNS", document);
|
|
|
|
runTests(allNoNSTests, "createElement", document);
|
|
|
|
|
|
|
|
// XML document
|
|
|
|
var xmlDocument = window.frames.xmlWindow.document;
|
|
|
|
runTests(allNSTests, "createElementNS", xmlDocument);
|
|
|
|
runTests(allNoNSTests, "createElement", xmlDocument);
|
|
|
|
|
|
|
|
// XHTML document, for good measure
|
|
|
|
var xhtmlDocument = window.frames.xhtmlWindow.document;
|
|
|
|
runTests(allNSTests, "createElementNS", xhtmlDocument);
|
|
|
|
runTests(allNoNSTests, "createElement", xhtmlDocument);
|
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener("load", run, false);
|
2008-02-11 20:14:57 -08:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|