mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
190 lines
6.8 KiB
HTML
190 lines
6.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=411103
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 411103</title>
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
|
<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>
|
|
<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>
|
|
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
/** 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 },
|
|
{ args: [":"], message: "valid XML name, invalid QName" },
|
|
{ args: [":div"], message: "valid XML name, invalid QName" },
|
|
{ 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(", ");
|
|
}
|
|
|
|
function runTests(tests, methodName, document)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|