mirror of
https://github.com/servo/servo.git
synced 2025-09-10 15:08:21 +01:00
Update web-platform-tests to revision e8bfc205e36ad699601212cd50083870bad9a75d
This commit is contained in:
parent
65dd6d4340
commit
ccdb0a3458
1428 changed files with 118036 additions and 9786 deletions
|
@ -9,6 +9,8 @@
|
|||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="/common/dummy.xml"></iframe>
|
||||
<iframe src="/common/dummy.xhtml"></iframe>
|
||||
<script>
|
||||
function toASCIIUppercase(str) {
|
||||
var diff = "a".charCodeAt(0) - "A".charCodeAt(0);
|
||||
|
@ -22,64 +24,134 @@ function toASCIIUppercase(str) {
|
|||
}
|
||||
return res;
|
||||
}
|
||||
test(function() {
|
||||
var HTMLNS = "http://www.w3.org/1999/xhtml",
|
||||
valid = [
|
||||
//[input, localName],
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
["foo", "foo"],
|
||||
["f1oo", "f1oo"],
|
||||
["foo1", "foo1"],
|
||||
["f\u0300oo", "f\u0300oo"],
|
||||
["foo\u0300", "foo\u0300"],
|
||||
[":foo", ":foo"],
|
||||
["f:oo", "f:oo"],
|
||||
["foo:", "foo:"],
|
||||
["xml", "xml"],
|
||||
["xmlns", "xmlns"],
|
||||
["xmlfoo", "xmlfoo"],
|
||||
["xml:foo", "xml:foo"],
|
||||
["xmlns:foo", "xmlns:foo"],
|
||||
["xmlfoo:bar", "xmlfoo:bar"],
|
||||
["svg", "svg"],
|
||||
["math", "math"],
|
||||
["FOO", "foo"],
|
||||
["mar\u212a", "mar\u212a"],
|
||||
["\u0130nput", "\u0130nput"],
|
||||
["\u0131nput", "\u0131nput"]
|
||||
],
|
||||
invalid = [
|
||||
"",
|
||||
"1foo",
|
||||
"\u0300foo",
|
||||
"}foo",
|
||||
"f}oo",
|
||||
"foo}",
|
||||
"\ufffffoo",
|
||||
"f\uffffoo",
|
||||
"foo\uffff",
|
||||
"<foo",
|
||||
"foo>",
|
||||
"<foo>",
|
||||
"f<oo"
|
||||
]
|
||||
function toASCIILowercase(str) {
|
||||
var diff = "a".charCodeAt(0) - "A".charCodeAt(0);
|
||||
var res = "";
|
||||
for (var i = 0; i < str.length; ++i) {
|
||||
if ("A" <= str[i] && str[i] <= "Z") {
|
||||
res += String.fromCharCode(str.charCodeAt(i) + diff);
|
||||
} else {
|
||||
res += str[i];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
var HTMLNS = "http://www.w3.org/1999/xhtml",
|
||||
valid = [
|
||||
undefined,
|
||||
null,
|
||||
"foo",
|
||||
"f1oo",
|
||||
"foo1",
|
||||
"f\u0BC6",
|
||||
"foo\u0BC6",
|
||||
":",
|
||||
":foo",
|
||||
"f:oo",
|
||||
"foo:",
|
||||
"f:o:o",
|
||||
"f::oo",
|
||||
"f::oo:",
|
||||
"foo:0",
|
||||
"foo:_",
|
||||
// combining char after :, invalid QName but valid Name
|
||||
"foo:\u0BC6",
|
||||
"foo:foo\u0BC6",
|
||||
"foo\u0BC6:foo",
|
||||
"xml",
|
||||
"xmlns",
|
||||
"xmlfoo",
|
||||
"xml:foo",
|
||||
"xmlns:foo",
|
||||
"xmlfoo:bar",
|
||||
"svg",
|
||||
"math",
|
||||
"FOO",
|
||||
// Test that non-ASCII chars don't get uppercased/lowercased
|
||||
"mar\u212a",
|
||||
"\u0130nput",
|
||||
"\u0131nput",
|
||||
],
|
||||
invalid = [
|
||||
"",
|
||||
"1foo",
|
||||
"1:foo",
|
||||
"fo o",
|
||||
"\u0BC6foo",
|
||||
"}foo",
|
||||
"f}oo",
|
||||
"foo}",
|
||||
"\ufffffoo",
|
||||
"f\uffffoo",
|
||||
"foo\uffff",
|
||||
"<foo",
|
||||
"foo>",
|
||||
"<foo>",
|
||||
"f<oo",
|
||||
"-foo",
|
||||
".foo",
|
||||
"\u0BC6",
|
||||
]
|
||||
|
||||
valid.forEach(function(t) {
|
||||
test(function() {
|
||||
var elt = document.createElement(t[0])
|
||||
assert_true(elt instanceof Element)
|
||||
assert_true(elt instanceof Node)
|
||||
assert_equals(elt.localName, t[1])
|
||||
assert_equals(elt.tagName, toASCIIUppercase(t[1]))
|
||||
assert_equals(elt.prefix, null)
|
||||
assert_equals(elt.namespaceURI, HTMLNS)
|
||||
}, "createElement(" + format_value(t[0]) + ")");
|
||||
var xmlIframe = document.querySelector('[src="/common/dummy.xml"]');
|
||||
var xhtmlIframe = document.querySelector('[src="/common/dummy.xhtml"]');
|
||||
|
||||
function getWin(desc) {
|
||||
if (desc == "HTML document") {
|
||||
return window;
|
||||
}
|
||||
if (desc == "XML document") {
|
||||
assert_equals(xmlIframe.contentDocument.documentElement.textContent,
|
||||
"Dummy XML document", "XML document didn't load");
|
||||
return xmlIframe.contentWindow;
|
||||
}
|
||||
if (desc == "XHTML document") {
|
||||
assert_equals(xhtmlIframe.contentDocument.documentElement.textContent,
|
||||
"Dummy XHTML document", "XHTML document didn't load");
|
||||
return xhtmlIframe.contentWindow;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
valid.forEach(function(t) {
|
||||
["HTML document", "XML document", "XHTML document"].forEach(function(desc) {
|
||||
async_test(function(testObj) {
|
||||
window.addEventListener("load", function() {
|
||||
testObj.step(function() {
|
||||
var win = getWin(desc);
|
||||
var doc = win.document;
|
||||
var elt = doc.createElement(t)
|
||||
assert_true(elt instanceof win.Element, "instanceof Element")
|
||||
assert_true(elt instanceof win.Node, "instanceof Node")
|
||||
assert_equals(elt.localName,
|
||||
desc == "HTML document" ? toASCIILowercase(String(t))
|
||||
: String(t),
|
||||
"localName")
|
||||
assert_equals(elt.tagName,
|
||||
desc == "HTML document" ? toASCIIUppercase(String(t))
|
||||
: String(t),
|
||||
"tagName")
|
||||
assert_equals(elt.prefix, null, "prefix")
|
||||
assert_equals(elt.namespaceURI,
|
||||
desc == "XML document" ? null : HTMLNS, "namespaceURI")
|
||||
});
|
||||
testObj.done();
|
||||
});
|
||||
}, "createElement(" + format_value(t) + ") in " + desc);
|
||||
});
|
||||
invalid.forEach(function(arg) {
|
||||
test(function() {
|
||||
assert_throws("INVALID_CHARACTER_ERR", function() { document.createElement(arg) })
|
||||
}, "createElement(" + format_value(arg) + ")");
|
||||
});
|
||||
invalid.forEach(function(arg) {
|
||||
["HTML document", "XML document", "XHTML document"].forEach(function(desc) {
|
||||
async_test(function(testObj) {
|
||||
window.addEventListener("load", function() {
|
||||
testObj.step(function() {
|
||||
var doc = getWin(desc).document;
|
||||
assert_throws("InvalidCharacterError",
|
||||
function() { doc.createElement(arg) })
|
||||
});
|
||||
testObj.done();
|
||||
});
|
||||
}, "createElement(" + format_value(arg) + ") in " + desc);
|
||||
});
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue