Bug 771932 - Import some more DOM4 tests; r=sicking

This commit is contained in:
Ms2ger 2012-08-04 09:43:59 +02:00
Родитель 95dd3e7358
Коммит 48b417b456
124 изменённых файлов: 4228 добавлений и 0 удалений

Просмотреть файл

@ -13,6 +13,7 @@ DIRS = \
failures/editing/selecttest \
failures/html/tests/submission/Opera/microdata \
failures/webapps/DOMCore/tests/approved \
failures/webapps/DOMCore/tests/submissions/Ms2ger \
failures/webapps/DOMCore/tests/submissions/Opera \
failures/webapps/WebStorage/tests/submissions/Infraware \
failures/webapps/WebStorage/tests/submissions/Ms2ger \

Просмотреть файл

@ -0,0 +1,44 @@
# THIS FILE IS AUTOGENERATED BY parseFailures.py - DO NOT EDIT
DEPTH = ../../../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imptests/failures/webapps/DOMCore/tests/submissions/Ms2ger
DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_FILES = \
test_DOMImplementation-createDocument.html.json \
test_Document-createElementNS.html.json \
test_Document-getElementsByTagName.html.json \
test_Element-children.html.json \
test_Event-constructors.html.json \
test_Event-defaultPrevented.html.json \
test_Event-initEvent.html.json \
test_EventTarget-dispatchEvent.html.json \
test_Node-appendChild.html.json \
test_Node-constants.html.json \
test_Node-insertBefore.html.json \
test_Node-isEqualNode.xhtml.json \
test_Node-removeChild.html.json \
test_Node-replaceChild.html.json \
test_NodeFilter-constants.html.json \
test_Range-attributes.html.json \
test_Range-commonAncestorContainer.html.json \
test_Range-comparePoint.html.json \
test_Range-detach.html.json \
test_Range-intersectsNode.html.json \
test_attributes.html.json \
test_case.html.json \
test_historical.html.json \
test_interfaces.html.json \
$(NULL)
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

Просмотреть файл

@ -0,0 +1,11 @@
{
"DOMImplementation.createDocument(namespaceURI, qualifiedName, doctype) 16": true,
"DOMImplementation.createDocument(namespaceURI, qualifiedName, doctype) 31": true,
"DOMImplementation.createDocument(namespaceURI, qualifiedName, doctype) 46": true,
"DOMImplementation.createDocument(namespaceURI, qualifiedName, doctype) 61": true,
"DOMImplementation.createDocument(namespaceURI, qualifiedName, doctype) 76": true,
"DOMImplementation.createDocument(namespaceURI, qualifiedName, doctype) 92": true,
"DOMImplementation.createDocument(namespaceURI, qualifiedName, doctype) 93": true,
"DOMImplementation.createDocument(namespaceURI, qualifiedName, doctype) 95": true,
"DOMImplementation.createDocument(namespaceURI, qualifiedName, doctype) 97": true
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"Invalid Name: \u0300foo": true
}

Просмотреть файл

@ -0,0 +1,4 @@
{
"Document.getElementsByTagName 2": true,
"Document.getElementsByTagName 3": true
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"HTMLCollection edge cases 1": true
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"Event constructors": true
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"initEvent should unset defaultPrevented.": true
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"Calling initEvent must not have an effect during dispatching.": true
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"If the event's dispatch flag is set, an InvalidStateError must be thrown.": true
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"Node.appendChild": true
}

Просмотреть файл

@ -0,0 +1,4 @@
{
"Constants for createDocumentPosition on [object DOM Constructor.prototype].": true,
"Constants for nodeType on [object DOM Constructor.prototype].": true
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"Calling insertBefore with a non-Node first argument must throw TypeError.": true,
"Calling insertBefore with a non-Node first argument on a leaf node Comment node <!--Foo--> must throw TypeError.": true,
"Calling insertBefore with a non-Node first argument on a leaf node DocumentType node must throw TypeError.": true,
"Calling insertBefore with a non-Node first argument on a leaf node ProcessingInstruction node with target \"foo\" and data \"bar\" must throw TypeError.": true,
"Calling insertBefore with a non-Node first argument on a leaf node Text node \"Foo\" must throw TypeError.": true
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"isEqualNode should return true when only the internal subsets of DocumentTypes differ.": true
}

Просмотреть файл

@ -0,0 +1,5 @@
{
"Calling removeChild on a comment with no children should throw NOT_FOUND_ERR.": true,
"Calling removeChild on a text with no children should throw NOT_FOUND_ERR.": true,
"Passing a value that is not a Node reference to removeChild should throw TypeError.": true
}

Просмотреть файл

@ -0,0 +1,4 @@
{
"If the context node is not a node that can contain children, a NotFoundError exception should be thrown": true,
"Passing null to replaceChild should throw a TypeError.": true
}

Просмотреть файл

@ -0,0 +1,4 @@
{
"Constants for acceptNode on undefined.": true,
"Constants for whatToShow on undefined.": true
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"Range attributes": true
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"Detached Range": true
}

Просмотреть файл

@ -0,0 +1,4 @@
{
"Range.comparePoint": true,
"Range.comparePoint 1": true
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"Range.detach": true
}

Просмотреть файл

@ -0,0 +1,5 @@
{
"Range.intersectsNode": true,
"Range.intersectsNode 1": true,
"Range.intersectsNode 2": true
}

Просмотреть файл

@ -0,0 +1,6 @@
{
"AttrExodus": true,
"First set attribute is returned by setAttribute": true,
"First set attribute is returned with mapped attribute set first": true,
"setAttribute should throw a NAMESPACE_ERR when qualifiedName starts with 'xmlns'": true
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"getElementsByTagName ABC": true,
"getElementsByTagName Abc": true,
"getElementsByTagName abc": true,
"getElementsByTagName \u00c4": true,
"getElementsByTagName \u00e4": true
}

Просмотреть файл

@ -0,0 +1,18 @@
{
"DocumentType member must be nuked: internalSubset": true,
"Historical DOM features must be removed: CDATASection": true,
"Historical DOM features must be removed: NamedNodeMap": true,
"Historical DOM features must be removed: UserDataHandler": true,
"Historical DOM features must be removed: createAttribute": true,
"Historical DOM features must be removed: createAttributeNS": true,
"Historical DOM features must be removed: createCDATASection": true,
"Historical DOM features must be removed: getAttributeNode": true,
"Historical DOM features must be removed: getAttributeNodeNS": true,
"Historical DOM features must be removed: inputEncoding": true,
"Historical DOM features must be removed: removeAttributeNode": true,
"Historical DOM features must be removed: setAttributeNode": true,
"Node member must be nuked: getUserData": true,
"Node member must be nuked: hasAttributes": true,
"Node member must be nuked: isSupported": true,
"Node member must be nuked: setUserData": true
}

Просмотреть файл

@ -0,0 +1,6 @@
{
"Should be able to delete CharacterData.": true,
"Should be able to delete Document.": true,
"Should be able to delete Node.": true,
"Should be able to delete NodeFilter.": true
}

Просмотреть файл

@ -1,5 +1,6 @@
DIRS += \
webapps/DOMCore/tests/approved \
webapps/DOMCore/tests/submissions/Ms2ger \
webapps/DOMCore/tests/submissions/Opera \
webapps/WebStorage/tests/submissions \
webapps/XMLHttpRequest/tests/submissions/Ms2ger \

Просмотреть файл

@ -1,5 +1,6 @@
https://dvcs.w3.org/hg/webapps|webapps
DOMCore/tests/approved
DOMCore/tests/submissions/Ms2ger
DOMCore/tests/submissions/Opera
WebStorage/tests/submissions
XMLHttpRequest/tests/submissions/Ms2ger

Просмотреть файл

@ -0,0 +1,39 @@
test(function() {
var invalid = [
["A", "?>"],
["\u00B7A", "x"],
["\u00D7A", "x"],
["A\u00D7", "x"],
["\\A", "x"],
["\f", "x"],
[0, "x"],
["0", "x"]
],
valid = [
["xml:fail", "x"],
["A\u00B7A", "x"],
["a0", "x"]
]
for (var i = 0, il = invalid.length; i < il; i++) {
test(function() {
assert_throws("INVALID_CHARACTER_ERR", function() {
document.createProcessingInstruction(invalid[i][0], invalid[i][1])
})
}, "Should throw an INVALID_CHARACTER_ERR for target " +
format_value(invalid[i][0]) + " and data " +
format_value(invalid[i][1]) + ".")
}
for (var i = 0, il = valid.length; i < il; ++i) {
test(function() {
var pi = document.createProcessingInstruction(valid[i][0], valid[i][1]);
assert_equals(pi.target, valid[i][0]);
assert_equals(pi.data, valid[i][1]);
assert_equals(pi.ownerDocument, document);
assert_true(pi instanceof ProcessingInstruction);
assert_true(pi instanceof Node);
}, "Should get a ProcessingInstruction for target " +
format_value(valid[i][0]) + " and data " +
format_value(valid[i][1]) + ".")
}
})

Просмотреть файл

@ -0,0 +1,115 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
DEPTH = ../../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imptests/webapps/DOMCore/tests/submissions/Ms2ger
DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_FILES = \
test_attributes.html \
test_case.html \
test_CharacterData-appendData.html \
test_CharacterData-deleteData.html \
test_CharacterData-insertData.html \
test_CharacterData-replaceData.html \
test_Document-adoptNode.html \
test_Document-createComment.html \
test_Document-createElement.html \
test_Document-createElementNS.html \
test_Document-createEvent.html \
test_Document-createProcessingInstruction.html \
test_Document-createProcessingInstruction-literal-1.xhtml \
test_Document-createProcessingInstruction-literal-2.xhtml \
test_Document-createProcessingInstruction.xhtml \
test_Document-getElementById.html \
test_Document-getElementsByTagName.html \
test_Document-getElementsByTagNameNS.html \
test_Document-importNode.html \
test_DOMException-constants.html \
test_DOMImplementation-createDocument.html \
test_DOMImplementation-createDocumentType.html \
test_DOMImplementation-createHTMLDocument.html \
test_DOMImplementation-hasFeature.html \
test_Element-childElementCount-dynamic-add.html \
test_Element-childElementCount-dynamic-add.svg \
test_Element-childElementCount-dynamic-add.xhtml \
test_Element-childElementCount-dynamic-remove.html \
test_Element-childElementCount-dynamic-remove.svg \
test_Element-childElementCount-dynamic-remove.xhtml \
test_Element-childElementCount.html \
test_Element-childElementCount-nochild.html \
test_Element-childElementCount-nochild.svg \
test_Element-childElementCount-nochild.xhtml \
test_Element-childElementCount.svg \
test_Element-childElementCount.xhtml \
test_Element-childElement-null.html \
test_Element-childElement-null.svg \
test_Element-childElement-null.xhtml \
test_Element-children.html \
test_Element-firstElementChild-entity.svg \
test_Element-firstElementChild-entity.xhtml \
test_Element-firstElementChild.html \
test_Element-firstElementChild-namespace.html \
test_Element-firstElementChild-namespace.svg \
test_Element-firstElementChild-namespace.xhtml \
test_Element-firstElementChild.svg \
test_Element-firstElementChild.xhtml \
test_Element-getElementsByClassName.html \
test_Element-lastElementChild.html \
test_Element-lastElementChild.svg \
test_Element-lastElementChild.xhtml \
test_Element-nextElementSibling.html \
test_Element-nextElementSibling.svg \
test_Element-nextElementSibling.xhtml \
test_Element-previousElementSibling.html \
test_Element-previousElementSibling.svg \
test_Element-previousElementSibling.xhtml \
test_Element-removeAttributeNS.html \
test_Element-siblingElement-null.html \
test_Element-siblingElement-null.svg \
test_Element-siblingElement-null.xhtml \
test_Element-tagName.html \
test_Event-constants.html \
test_Event-constructors.html \
test_Event-defaultPrevented.html \
test_Event-initEvent.html \
test_EventTarget-dispatchEvent.html \
test_historical.html \
test_interfaces.html \
test_Node-appendChild.html \
test_Node-cloneNode.html \
test_Node-constants.html \
test_Node-insertBefore.html \
test_Node-isEqualNode.xhtml \
test_Node-lookupPrefix.xhtml \
test_Node-nodeName.html \
test_Node-nodeName.xhtml \
test_Node-normalize.html \
test_Node-parentElement.html \
test_Node-parentNode.html \
test_Node-removeChild.html \
test_Node-replaceChild.html \
test_NodeFilter-constants.html \
test_Range-attributes.html \
test_Range-commonAncestorContainer.html \
test_Range-comparePoint.html \
test_Range-detach.html \
test_Range-intersectsNode.html \
attributes.js \
case.js \
creators.js \
constants.js \
Document-createProcessingInstruction.js \
productions.js \
$(NULL)
libs:: $(_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

Просмотреть файл

@ -0,0 +1,14 @@
function attr_is(attr, v, ln, ns, p, n) {
assert_equals(attr.value, v)
assert_equals(attr.localName, ln)
assert_equals(attr.namespaceURI, ns)
assert_equals(attr.prefix, p)
assert_equals(attr.name, n)
}
function attributes_are(el, l) {
for (var i = 0, il = l.length; i < il; i++) {
attr_is(el.attributes[i], l[i][1], l[i][0], (l[i].length < 3) ? null : l[i][2], null, l[i][0])
// assert_equals(el.attributes[i].ownerElement, el)
}
}

Просмотреть файл

@ -0,0 +1,178 @@
/*
* document.createElement(NS)
*
* document.getElementsByTagName(NS)
*
* Element.setAttribute(NS)
*
* Element.getAttribute(NS)
* Element.hasAttribute(NS)
* Element.getElementsByTagName(NS)
*/
var tests = [];
setup(function() {
var name_inputs = ["abc", "Abc", "ABC", "ä", "Ä"];
var namespaces = ["http://www.w3.org/1999/xhtml", "http://www.w3.org/2000/svg", "http://FOO"];
name_inputs.forEach(function(x) {
tests.push(["createElement " + x, test_create_element, [x]]);
tests.push(["setAttribute " +x, test_set_attribute, [x]]);
tests.push(["getAttribute " +x, test_get_attribute, [x]]);
tests.push(["getElementsByTagName " +x, test_get_elements_tag_name,
[outer_product(namespaces, ["a"], name_inputs),
x]]);
});
outer_product(namespaces, name_inputs, name_inputs).forEach(function(x) {
tests.push(["createElementNS " + x, test_create_element_ns, x]);
tests.push(["setAttributeNS " + x, test_set_attribute_ns, x]);
tests.push(["getAttributeNS " + x, test_get_attribute_ns, x]);
});
outer_product([null].concat(namespaces), name_inputs).forEach(function(x) {
tests.push(["getElementsByTagNameNS " + x, test_get_elements_tag_name_ns,
outer_product(namespaces, name_inputs), x]);
});
name_inputs.forEach(function(x) {
tests.push(["createElementNS " + x, test_create_element_ns, [null, null, x]]);
tests.push(["setAttributeNS " + x, test_set_attribute_ns, [null, null, x]]);
tests.push(["getAttributeNS " + x, test_get_attribute_ns, [null, null, x]]);
});
});
function outer_product() {
var rv = [];
function compute_outer_product() {
var args = Array.prototype.slice.call(arguments);
var index = args[0];
if (index < args.length) {
args[index].forEach(function(x) {
compute_outer_product.apply(this, [index+1].concat(args.slice(1, index), x, args.slice(index+1)));
});
} else {
rv.push(args.slice(1));
}
}
compute_outer_product.apply(this, [1].concat(Array.prototype.slice.call(arguments)));
return rv;
}
function expected_case(input) {
//is_html gets set by a global on the page loading the tests
if (is_html) {
return ascii_lowercase(input);
} else {
return input;
}
}
function ascii_lowercase(input) {
return input.replace(/[A-Z]/g, function(x) {
return x.toLowerCase();
});
}
function test_create_element(name) {
var node = document.createElement(name);
assert_equals(node.localName, expected_case(name));
}
function test_create_element_ns(namespace, prefix, local_name) {
var qualified_name = prefix ? prefix + ":" + local_name : local_name;
var node = document.createElementNS(namespace, qualified_name);
assert_equals(node.prefix, prefix, "prefix");
assert_equals(node.localName, local_name, "localName");
}
function test_set_attribute(name) {
var node = document.createElement("div");
node.setAttribute(name, "test");
assert_equals(node.attributes[0].localName, expected_case(name));
}
function test_set_attribute_ns(namespace, prefix, local_name) {
var qualified_name = prefix ? prefix + ":" + local_name : local_name;
var node = document.createElement("div");
node.setAttributeNS(namespace, qualified_name, "test");
var attr = node.attributes[0];
assert_equals(attr.prefix, prefix, "prefix");
assert_equals(attr.localName, local_name, "localName");
}
function test_get_attribute(name) {
var node = document.createElement("div");
node.setAttribute(name, "test");
var expected_name = expected_case(name);
assert_equals(node.getAttribute(expected_name), "test");
if (expected_name != name) {
assert_equals(node.getAttribute(expected_name), "test");
} else if (name !== ascii_lowercase(name)) {
assert_equals(node.getAttribute(ascii_lowercase(name)), null);
}
}
function test_get_attribute_ns(namespace, prefix, local_name) {
var qualified_name = prefix ? prefix + ":" + local_name : local_name;
var node = document.createElement("div");
node.setAttributeNS(namespace, qualified_name, "test");
var expected_name = local_name;
assert_equals(node.getAttributeNS(namespace, expected_name), "test");
if (local_name !== ascii_lowercase(local_name)) {
assert_equals(node.getAttributeNS(namespace, ascii_lowercase(local_name)), null);
}
}
function test_get_elements_tag_name(elements_to_create, search_string) {
var container = document.createElement("div");
elements_to_create.forEach(function(x) {
var qualified_name = x[1] ? x[1] + ":" + x[2] : x[2];
var element = document.createElementNS(x[0], qualified_name);
container.appendChild(element);
});
var expected = Array.prototype.filter.call(container.childNodes,
function(node) {
if (is_html && node.namespaceURI === "http://www.w3.org/1999/xhtml") {
return expected_case(node.localName) === expected_case(search_string);
} else {
return node.localName === expected_case(search_string);
}
});
document.documentElement.appendChild(container);
try {
assert_array_equals(document.getElementsByTagName(search_string), expected);
} catch(e) {
throw e;
} finally {
document.documentElement.removeChild(container);
}
}
function test_get_elements_tag_name_ns(elements_to_create, search_input) {
var search_uri = search_input[0];
var search_name = search_input[1];
var container = document.createElement("div");
elements_to_create.forEach(function(x) {
var qualified_name = x[1] ? x[1] + ":" + x[2] : x[2];
var element = document.createElementNS(x[0], qualified_name);
container.appendChild(element);
});
var expected = Array.prototype.filter.call(container.childNodes,
function(node) {
return node.namespaceURI === search_uri;
return node.localName === search_name;
});
document.documentElement.appendChild(container);
try {
assert_array_equals(document.getElementsByTagNameNS(search_uri, search_name), expected);
} catch(e) {
throw e;
} finally {
document.documentElement.removeChild(container);
}
}
function test_func() {
var func = arguments[0];
var rest = arguments[1];
func.apply(this, rest);
}
generate_tests(test_func, tests);

Просмотреть файл

@ -0,0 +1,10 @@
function testConstants(objects, constants, msg) {
objects.forEach(function(o) {
test(function() {
constants.forEach(function(d) {
assert_true(d[0] in o, "Object " + o + " doesn't have " + d[0])
assert_equals(o[d[0]], d[1], "Object " + o + " value for " + d[0] + " is wrong")
})
}, "Constants for " + msg + " on " + o + ".")
})
}

Просмотреть файл

@ -0,0 +1,5 @@
var creators = {
"element": "createElement",
"text": "createTextNode",
"comment": "createComment"
};

Просмотреть файл

@ -0,0 +1,3 @@
var invalid_names = ["\\", "'", '"', "0", "0:a"] // XXX
var valid_names = ["x", ":", "a:0"]
var invalid_qnames = [":a", "b:", "x:y:z"] // XXX

Просмотреть файл

@ -0,0 +1,18 @@
<!DOCTYPE html>
<title>CharacterData.appendData</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(node) {
test(function() {
assert_equals(node.data, "test")
node.appendData("test")
assert_equals(node.data, "testtest")
})
}
test(function() {
testNode(document.createTextNode("test"))
testNode(document.createComment("test"))
})
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<!DOCTYPE html>
<title>CharacterData.deleteData</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(node) {
test(function() {
assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(5, 10) })
assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(5, 0) })
node.deleteData(2, 10)
assert_equals(node.data, "te")
node.data = "test"
node.deleteData(1, 1)
assert_equals(node.data, "tst")
})
}
test(function() {
testNode(document.createTextNode("test"))
testNode(document.createComment("test"))
})
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<!DOCTYPE html>
<title>CharacterData.insertData</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(node) {
test(function() {
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "x") })
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "") })
node.insertData(2, "X")
assert_equals(node.data, "teXst")
node.data = "test"
node.insertData(4, "ing")
assert_equals(node.data, "testing")
})
}
test(function() {
testNode(document.createTextNode("test"))
testNode(document.createComment("test"))
})
</script>

Просмотреть файл

@ -0,0 +1,24 @@
<!DOCTYPE html>
<title>CharacterData.replaceData</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(node) {
test(function() {
assert_throws("INDEX_SIZE_ERR", function() { node.replaceData(5, 1, "x") })
assert_throws("INDEX_SIZE_ERR", function() { node.replaceData(5, 0, "") })
node.replaceData(2, 10, "yo")
assert_equals(node.data, "teyo")
node.data = "test"
node.replaceData(1, 1, "waddup")
assert_equals(node.data, "twaddupst")
node.replaceData(1, 1, "yup")
assert_equals(node.data, "tyupaddupst")
})
}
test(function() {
testNode(document.createTextNode("test"))
testNode(document.createComment("test"))
})
</script>

Просмотреть файл

@ -0,0 +1,41 @@
<!doctype html>
<title>DOMException constants</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var constants = [
"INDEX_SIZE_ERR",
"DOMSTRING_SIZE_ERR",
"HIERARCHY_REQUEST_ERR",
"WRONG_DOCUMENT_ERR",
"INVALID_CHARACTER_ERR",
"NO_DATA_ALLOWED_ERR",
"NO_MODIFICATION_ALLOWED_ERR",
"NOT_FOUND_ERR",
"NOT_SUPPORTED_ERR",
"INUSE_ATTRIBUTE_ERR",
"INVALID_STATE_ERR",
"SYNTAX_ERR",
"INVALID_MODIFICATION_ERR",
"NAMESPACE_ERR",
"INVALID_ACCESS_ERR",
"VALIDATION_ERR",
"TYPE_MISMATCH_ERR",
"SECURITY_ERR",
"NETWORK_ERR",
"ABORT_ERR",
"URL_MISMATCH_ERR",
"QUOTA_EXCEEDED_ERR",
"TIMEOUT_ERR",
"INVALID_NODE_TYPE_ERR",
"DATA_CLONE_ERR"
]
for (var i = 0; i < constants.length; i++) {
var name = constants[i];
if (name)
assert_equals(DOMException[name], i + 1, name)
}
})
</script>

Просмотреть файл

@ -0,0 +1,155 @@
<!doctype html>
<title>DOMImplementation.createDocument(namespaceURI, qualifiedName, doctype)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var tests = [
[null, null, null, null],
[null, "", null, null],
[null, "foo", null, null],
[null, "1foo", null, "INVALID_CHARACTER_ERR"],
[null, "f1oo", null, null],
[null, "foo1", null, null],
[null, ":foo", null, "NAMESPACE_ERR"],
[null, "f:oo", null, "NAMESPACE_ERR"],
[null, "foo:", null, "NAMESPACE_ERR"],
[null, "xml", null, null],
[null, "xmlns", null, "NAMESPACE_ERR"],
[null, "xmlfoo", null, null],
[null, "xml:foo", null, "NAMESPACE_ERR"],
[null, "xmlns:foo", null, "NAMESPACE_ERR"],
[null, "xmlfoo:bar", null, "NAMESPACE_ERR"],
["http://example.com/", null, null, null],
["http://example.com/", "", null, null],
["http://example.com/", "foo", null, null],
["http://example.com/", "1foo", null, "INVALID_CHARACTER_ERR"],
["http://example.com/", "f1oo", null, null],
["http://example.com/", "foo1", null, null],
["http://example.com/", ":foo", null, "NAMESPACE_ERR"],
["http://example.com/", "f:oo", null, null],
["http://example.com/", "foo:", null, "NAMESPACE_ERR"],
["http://example.com/", "xml", null, null],
["http://example.com/", "xmlns", null, "NAMESPACE_ERR"],
["http://example.com/", "xmlfoo", null, null],
["http://example.com/", "xml:foo", null, "NAMESPACE_ERR"],
["http://example.com/", "xmlns:foo", null, "NAMESPACE_ERR"],
["http://example.com/", "xmlfoo:bar", null, null],
["/", null, null, null],
["/", "", null, null],
["/", "foo", null, null],
["/", "1foo", null, "INVALID_CHARACTER_ERR"],
["/", "f1oo", null, null],
["/", "foo1", null, null],
["/", ":foo", null, "NAMESPACE_ERR"],
["/", "f:oo", null, null],
["/", "foo:", null, "NAMESPACE_ERR"],
["/", "xml", null, null],
["/", "xmlns", null, "NAMESPACE_ERR"],
["/", "xmlfoo", null, null],
["/", "xml:foo", null, "NAMESPACE_ERR"],
["/", "xmlns:foo", null, "NAMESPACE_ERR"],
["/", "xmlfoo:bar", null, null],
["http://www.w3.org/XML/1998/namespace", null, null, null],
["http://www.w3.org/XML/1998/namespace", "", null, null],
["http://www.w3.org/XML/1998/namespace", "foo", null, null],
["http://www.w3.org/XML/1998/namespace", "1foo", null, "INVALID_CHARACTER_ERR"],
["http://www.w3.org/XML/1998/namespace", "f1oo", null, null],
["http://www.w3.org/XML/1998/namespace", "foo1", null, null],
["http://www.w3.org/XML/1998/namespace", ":foo", null, "NAMESPACE_ERR"],
["http://www.w3.org/XML/1998/namespace", "f:oo", null, null],
["http://www.w3.org/XML/1998/namespace", "foo:", null, "NAMESPACE_ERR"],
["http://www.w3.org/XML/1998/namespace", "xml", null, null],
["http://www.w3.org/XML/1998/namespace", "xmlns", null, "NAMESPACE_ERR"],
["http://www.w3.org/XML/1998/namespace", "xmlfoo", null, null],
["http://www.w3.org/XML/1998/namespace", "xml:foo", null, null],
["http://www.w3.org/XML/1998/namespace", "xmlns:foo", null, "NAMESPACE_ERR"],
["http://www.w3.org/XML/1998/namespace", "xmlfoo:bar", null, null],
["http://www.w3.org/2000/xmlns/", null, null, null],
["http://www.w3.org/2000/xmlns/", "", null, null],
["http://www.w3.org/2000/xmlns/", "foo", null, "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "1foo", null, "INVALID_CHARACTER_ERR"],
["http://www.w3.org/2000/xmlns/", "f1oo", null, "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "foo1", null, "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", ":foo", null, "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "f:oo", null, "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "foo:", null, "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "xml", null, "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "xmlns", null, null],
["http://www.w3.org/2000/xmlns/", "xmlfoo", null, "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "xml:foo", null, "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "xmlns:foo", null, null],
["http://www.w3.org/2000/xmlns/", "xmlfoo:bar", null, "NAMESPACE_ERR"],
["foo:", null, null, null],
["foo:", "", null, null],
["foo:", "foo", null, null],
["foo:", "1foo", null, "INVALID_CHARACTER_ERR"],
["foo:", "f1oo", null, null],
["foo:", "foo1", null, null],
["foo:", ":foo", null, "NAMESPACE_ERR"],
["foo:", "f:oo", null, null],
["foo:", "foo:", null, "NAMESPACE_ERR"],
["foo:", "xml", null, null],
["foo:", "xmlns", null, "NAMESPACE_ERR"],
["foo:", "xmlfoo", null, null],
["foo:", "xml:foo", null, "NAMESPACE_ERR"],
["foo:", "xmlns:foo", null, "NAMESPACE_ERR"],
["foo:", "xmlfoo:bar", null, null],
]
try { // XXX merge?!
var tempTests = tests.concat([
[null, null, document.implementation.createDocumentType("foo", "", ""), null],
[null, null, document.doctype, "WRONG_DOCUMENT_ERR"], // This causes a horrible WebKit bug (now fixed in trunk).
[null, null, function() {
var foo = document.implementation.createDocumentType("foo", "", "");
document.implementation.createDocument(null, null, foo);
return foo;
}(), "WRONG_DOCUMENT_ERR"], // DOCTYPE already associated with a document.
[null, null, function() {
var bar = document.implementation.createDocument(null, null, null);
return bar.implementation.createDocumentType("bar", "", "");
}(), null], // DOCTYPE created by a different implementation.
[null, null, function() {
var bar = document.implementation.createDocument(null, null, null);
var magic = bar.implementation.createDocumentType("bar", "", "");
bar.implementation.createDocument(null, null, magic);
return magic;
}(), "WRONG_DOCUMENT_ERR"], // DOCTYPE created by a different implementation and already associated with a document.
[null, "foo", document.implementation.createDocumentType("foo", "", ""), null],
["foo", null, document.implementation.createDocumentType("foo", "", ""), null],
["foo", "bar", document.implementation.createDocumentType("foo", "", ""), null],
]);
tests = tempTests;
} catch (e) {
assert_unreached()
}
for (var i in tests) {
test(function() {
var test = tests[i],
namespaceURI = test[0],
qualifiedName = test[1],
doctype = test[2],
expected = test[3]
if (expected != null) {
assert_throws(expected, function() { document.implementation.createDocument(namespaceURI, qualifiedName, doctype) })
} else {
var doc = document.implementation.createDocument(namespaceURI, qualifiedName, doctype)
assert_equals(doc.nodeType, Node.DOCUMENT_NODE)
assert_equals(doc.nodeType, doc.DOCUMENT_NODE)
if(!qualifiedName) {
assert_equals(doc.documentElement, null)
}
if(!doctype) {
assert_equals(doc.doctype, null)
}
if(!qualifiedName && !doctype) {
assert_equals(doc.childNodes.length, 0)
}
}
})
}
})
</script>

Просмотреть файл

@ -0,0 +1,54 @@
<!doctype html>
<title>DOMImplementation.createDocumentType(qualifiedName, publicId, systemId)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var tests = [
["foo", "", "", null],
["1foo", "", "", "INVALID_CHARACTER_ERR"],
["foo1", "", "", null],
["f1oo", "", "", null],
["@foo", "", "", "INVALID_CHARACTER_ERR"],
["foo@", "", "", "INVALID_CHARACTER_ERR"],
["f@oo", "", "", "INVALID_CHARACTER_ERR"],
["f:oo", "", "", null],
[":foo", "", "", "NAMESPACE_ERR"],
["foo:", "", "", "NAMESPACE_ERR"],
["foo", "foo", "", null],
["foo", "", "foo", null],
["foo", "f'oo", "", null],
["foo", "", "f'oo", null],
["foo", 'f"oo', "", null],
["foo", "", 'f"oo', null],
["foo", "f'o\"o", "", null],
["foo", "", "f'o\"o", null],
["foo", "foo>", "", null],
["foo", "", "foo>", null]
]
var doc = document.implementation.createHTMLDocument("title");
var doTest = function(aDocument, aQualifiedName, aPublicId, aSystemId) {
var doctype = aDocument.implementation.createDocumentType(aQualifiedName, aPublicId, aSystemId);
assert_equals(doctype.name, aQualifiedName, "name")
assert_equals(doctype.publicId, aPublicId, "publicId")
assert_equals(doctype.systemId, aSystemId, "systemId")
assert_equals(doctype.ownerDocument, aDocument, "ownerDocument")
}
tests.forEach(function(t) {
var qualifiedName = t[0], publicId = t[1], systemId = t[2], expected = t[3]
test(function() {
if (expected) {
assert_throws(expected, function() {
document.implementation.createDocumentType(qualifiedName, publicId, systemId)
})
} else {
doTest(document, qualifiedName, publicId, systemId);
doTest(doc, qualifiedName, publicId, systemId);
}
}, "createDocumentType(" + format_value(qualifiedName) + ", " + format_value(publicId) + ", " + format_value(systemId) + ") should " +
(expected ? "throw " + expected : "work"));
});
})
</script>

Просмотреть файл

@ -0,0 +1,31 @@
<!DOCTYPE html>
<title>DOMImplementation.createHTMLDocument</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function checkDoc(title, expectedtitle, normalizedtitle) {
test(function() {
var doc = document.implementation.createHTMLDocument(title);
assert_equals(doc.doctype.name, "html")
assert_equals(doc.doctype.publicId, "")
assert_equals(doc.doctype.systemId, "")
assert_equals(doc.documentElement.localName, "html")
assert_equals(doc.documentElement.firstChild.localName, "head")
assert_equals(doc.documentElement.firstChild.childNodes.length, 1)
assert_equals(doc.documentElement.firstChild.firstChild.localName, "title")
assert_equals(doc.documentElement.firstChild.firstChild.firstChild.data,
expectedtitle)
assert_equals(doc.documentElement.lastChild.localName, "body")
assert_equals(doc.documentElement.lastChild.childNodes.length, 0)
})
}
checkDoc("", "", "")
checkDoc(null, "null", "null")
checkDoc(undefined, "undefined", "undefined")
checkDoc("foo bar baz", "foo bar baz", "foo bar baz")
checkDoc("foo\t\tbar baz", "foo\t\tbar baz", "foo bar baz")
checkDoc("foo\n\nbar baz", "foo\n\nbar baz", "foo bar baz")
checkDoc("foo\f\fbar baz", "foo\f\fbar baz", "foo bar baz")
checkDoc("foo\r\rbar baz", "foo\r\rbar baz", "foo bar baz")
</script>

Просмотреть файл

@ -0,0 +1,138 @@
<!doctype html>
<title>DOMImplementation.hasFeature(feature, version)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var tests = [
["Core", "1.0", false],
["Core", "2.0", true],
["Core", "3.0", false],
["Core", "100.0", false],
["XML", "1.0", true],
["XML", "2.0", true],
["XML", "3.0", false],
["XML", "100.0", false],
["Core", "1", false],
["Core", "2", false],
["Core", "3", false],
["Core", "100", false],
["XML", "1", false],
["XML", "2", false],
["XML", "3", false],
["XML", "100", false],
["Core", "1.1", false],
["Core", "2.1", false],
["Core", "3.1", false],
["Core", "100.1", false],
["XML", "1.1", false],
["XML", "2.1", false],
["XML", "3.1", false],
["XML", "100.1", false],
["Core", "", true],
["XML", "", true],
["core", "", true],
["xml", "", true],
["CoRe", "", true],
["XmL", "", true],
[" Core", "", false],
[" XML", "", false],
["Core ", "", false],
["XML ", "", false],
["Co re", "", false],
["XM L", "", false],
["aCore", "", false],
["aXML", "", false],
["Corea", "", false],
["XMLa", "", false],
["Coare", "", false],
["XMaL", "", false],
["Core", " ", false],
["XML", " ", false],
["Core", " 1.0", false],
["Core", " 2.0", false],
["Core", " 3.0", false],
["Core", " 100.0", false],
["XML", " 1.0", false],
["XML", " 2.0", false],
["XML", " 3.0", false],
["XML", " 100.0", false],
["Core", "1.0 ", false],
["Core", "2.0 ", false],
["Core", "3.0 ", false],
["Core", "100.0 ", false],
["XML", "1.0 ", false],
["XML", "2.0 ", false],
["XML", "3.0 ", false],
["XML", "100.0 ", false],
["Core", "1. 0", false],
["Core", "2. 0", false],
["Core", "3. 0", false],
["Core", "100. 0", false],
["XML", "1. 0", false],
["XML", "2. 0", false],
["XML", "3. 0", false],
["XML", "100. 0", false],
["Core", "a1.0", false],
["Core", "a2.0", false],
["Core", "a3.0", false],
["Core", "a100.0", false],
["XML", "a1.0", false],
["XML", "a2.0", false],
["XML", "a3.0", false],
["XML", "a100.0", false],
["Core", "1.0a", false],
["Core", "2.0a", false],
["Core", "3.0a", false],
["Core", "100.0a", false],
["XML", "1.0a", false],
["XML", "2.0a", false],
["XML", "3.0a", false],
["XML", "100.0a", false],
["Core", "1.a0", false],
["Core", "2.a0", false],
["Core", "3.a0", false],
["Core", "100.a0", false],
["XML", "1.a0", false],
["XML", "2.a0", false],
["XML", "3.a0", false],
["XML", "100.a0", false],
["Core", 1, false],
["Core", 2, false],
["Core", 3, false],
["Core", 100, false],
["XML", 1, false],
["XML", 2, false],
["XML", 3, false],
["XML", 100, false],
["Core", null, true],
["XML", null, true],
["core", null, true],
["xml", null, true],
["CoRe", null, true],
["XmL", null, true],
[" Core", null, false],
[" XML", null, false],
["Core ", null, false],
["XML ", null, false],
["Co re", null, false],
["XM L", null, false],
["aCore", null, false],
["aXML", null, false],
["Corea", null, false],
["XMLa", null, false],
["Coare", null, false],
["XMaL", null, false],
["Core", undefined, false],
["XML", undefined, false],
["This is filler text.", "", false],
[null, "", false],
[undefined, "", false],
]
for (var i in tests) {
var test = tests[i]
assert_equals(document.implementation.hasFeature(test[0], test[1]), test[2], test[0] + " " + test[1])
}
})
</script>

Просмотреть файл

@ -0,0 +1,46 @@
<!doctype html>
<html>
<head>
<title>Document.adoptNode</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<!--creates an element with local name "x<": --><x<>x</x<>
<script>
test(function() {
var y = document.getElementsByTagName("x<")[0]
assert_equals(y.parentNode, document.body)
assert_equals(y.ownerDocument, document)
document.adoptNode(y)
assert_equals(y.parentNode, null)
assert_equals(y.ownerDocument, document)
var doc = document.implementation.createDocument(null, null, null)
doc.adoptNode(y)
assert_equals(y.parentNode, null)
assert_equals(y.ownerDocument, doc)
}, "Adopting an Element called 'x<' should work.")
test(function() {
var x = document.createElement(":good:times:")
document.adoptNode(x)
var doc = document.implementation.createDocument(null, null, null)
doc.adoptNode(x)
assert_equals(x.parentNode, null)
assert_equals(x.ownerDocument, doc)
}, "Adopting an Element called ':good:times:' should work.")
test(function() {
var doctype = document.doctype;
assert_equals(doctype.parentNode, document)
assert_equals(doctype.ownerDocument, document)
document.adoptNode(doctype)
assert_equals(doctype.parentNode, null)
assert_equals(doctype.ownerDocument, document)
}, "Explicitly adopting a DocumentType should work.")
test(function() {
var doc = document.implementation.createDocument(null, null, null)
assert_throws("NOT_SUPPORTED_ERR", function() { document.adoptNode(doc) })
}, "Adopting a Document should throw.")
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE html>
<title>Document.createComment</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var c = document.createComment("a -- b");
assert_true(c instanceof Comment);
assert_true(c instanceof Node);
assert_equals(c.ownerDocument, document);
assert_equals(c.data, "a -- b");
assert_equals(c.nodeValue, "a -- b");
assert_equals(c.textContent, "a -- b");
assert_equals(c.length, 6);
assert_equals(c.nodeType, 8);
assert_equals(c.nodeName, "#comment");
assert_equals(c.hasChildNodes(), false);
assert_equals(c.childNodes.length, 0);
assert_equals(c.firstChild, null);
assert_equals(c.lastChild, null);
});
</script>

Просмотреть файл

@ -0,0 +1,59 @@
<!DOCTYPE html>
<title>Document.createElement</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var HTMLNS = "http://www.w3.org/1999/xhtml",
valid = [
//[input, localName],
[undefined, "undefined"],
["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"]
],
invalid = [
"",
"1foo",
"\u0300foo",
"}foo",
"f}oo",
"foo}",
"\ufffffoo",
"f\uffffoo",
"foo\uffff",
"<foo",
"foo>",
"<foo>",
"f<oo"
]
for (var i = 0, il = valid.length; i < il; i++) {
var test = valid[i],
elt = document.createElement(test[0])
assert_true(elt instanceof Element)
assert_equals(elt.localName, test[1])
assert_equals(elt.tagName, test[1].toUpperCase())
assert_equals(elt.prefix, null)
assert_equals(elt.namespaceURI, HTMLNS)
}
for (var i = 0, il = invalid.length; i < il; i++) {
assert_throws("INVALID_CHARACTER_ERR", function() { document.createElement(invalid[i]) })
}
})
</script>

Просмотреть файл

@ -0,0 +1,46 @@
<!DOCTYPE html>
<title>Document.createElementNS</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var invalidNames = [
"",
"1foo",
"\u0300foo",
"}foo",
"f}oo",
"foo}",
"\ufffffoo",
"f\uffffoo",
"foo\uffff",
"<foo",
"foo>",
"<foo>",
"f<oo"
],
invalidNSQNameCombinations = [
["", ":foo"],
["", "foo:"],
["", "foo:foo"],
["http://oops/", "xml:foo"],
["http://oops/", "xmlns"],
["http://oops/", "xmlns:foo"],
["http://www.w3.org/2000/xmlns/", "xml:foo"],
["http://www.w3.org/2000/xmlns/", "foo:xmlns"]
];
invalidNames.forEach(function(name) {
test(function() {
assert_throws("INVALID_CHARACTER_ERR", function() { document.createElementNS("", name) });
}, "Invalid Name: " + name)
})
invalidNSQNameCombinations.forEach(function(a) {
test(function() {
assert_throws("NAMESPACE_ERR", function() { document.createElementNS(a[0], a[1]) });
}, "Invalid namespace " + a[0] + " and QName " + a[1])
})
})
</script>

Просмотреть файл

@ -0,0 +1,32 @@
<!DOCTYPE html>
<title>Document.createEvent</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testAlias(arg, iface) {
test(function() {
if (iface in window) {
var ev = document.createEvent(arg);
assert_true(ev instanceof window[iface]);
}
}, arg + " should be an alias for " + iface + ".");
}
[
["Events", "Event"],
["HTMLEvents", "Event"],
["MouseEvents", "MouseEvent"],
["MutationEvents", "MutationEvent"],
["UIEvents", "UIEvent"]
].forEach(function(alias) {
testAlias(alias[0], alias[1]);
testAlias(alias[0].toLowerCase(), alias[1]);
testAlias(alias[0].toUpperCase(), alias[1]);
});
test(function() {
assert_throws("NOT_SUPPORTED_ERR", function() {
var evt = document.createEvent("foo");
});
}, "Should throw NOT_SUPPORTED_ERR for unrecognized arguments");
</script>

Просмотреть файл

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>&lt;?xml?> is not a ProcessingInstruction</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"/>
<script>
test(function() {
assert_equals(document.firstChild, document.documentElement)
})
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,19 @@
<?xml-stylesheet href="support/style.css" type="text/css"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Document.createProcessingInstruction</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"/>
<script>
test(function() {
var pienc = document.firstChild;
assert_true(pienc instanceof ProcessingInstruction)
assert_equals(pienc.target, "xml-stylesheet")
assert_equals(pienc.data, 'href="support/style.css" type="text/css"')
})
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,6 @@
<!DOCTYPE html>
<title>Document.createProcessingInstruction in HTML documents</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script src="Document-createProcessingInstruction.js"></script>

Просмотреть файл

@ -0,0 +1,11 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Document.createProcessingInstruction in XML documents</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"/>
<script src="Document-createProcessingInstruction.js"/>
</body>
</html>

Просмотреть файл

@ -0,0 +1,13 @@
<!DOCTYPE html>
<title>Document.getElementById with an empty string</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id="log"></div>
<div id=""></div>
<script>
test(function() {
assert_equals(document.getElementById(""), null)
// XXX needs more tests
})
</script>

Просмотреть файл

@ -0,0 +1,45 @@
<!DOCTYPE html>
<title>Document.getElementsByTagName</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id="log"></div>
<script>
test(function() {
assert_false(document.getElementsByTagName("html") instanceof NodeList, "NodeList")
assert_true(document.getElementsByTagName("html") instanceof HTMLCollection, "HTMLCollection")
assert_true(document.getElementsByTagName("html") !== document.getElementsByTagName("html") ||
document.getElementsByTagName("html") === document.getElementsByTagName("html"),
"Caching is allowed.")
})
test(function() {
var l = document.getElementsByTagName("nosuchtag")
l[5] = "foopy"
assert_equals(l[5], undefined)
assert_equals(l.item(5), null)
}, "Shouldn't be able to set unsigned properties on a HTMLCollection")
test(function() {
assert_equals(document.createElementNS("http://www.w3.org/1999/xhtml", "i").localName, "i") // Sanity
var i = document.body.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "I"))
assert_equals(i.localName, "I")
assert_equals(i.tagName, "I")
assert_equals(document.getElementsByTagName("I").length, 0)
assert_equals(document.getElementsByTagName("i").length, 0)
assert_equals(document.body.getElementsByTagName("I").length, 0)
assert_equals(document.body.getElementsByTagName("i").length, 0)
document.body.removeChild(i)
})
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "te:st"))
assert_equals(document.getElementsByTagName("st").length, 1)
assert_equals(document.getElementsByTagName("st")[0], t)
assert_equals(document.getElementsByTagName("te:st").length, 0)
document.body.removeChild(t)
})
test(function() {
var h = document.body.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "te:st"))
assert_equals(document.getElementsByTagName("st")[0], h)
assert_equals(document.getElementsByTagName("TE:ST").length, 0)
document.body.removeChild(h)
})
</script>

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE html>
<title>Document.getElementsByTagNameNS</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id="log"></div>
<script>
test(function() {
assert_false(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html") instanceof NodeList, "NodeList")
assert_true(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html") instanceof HTMLCollection, "HTMLCollection")
assert_true(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html") !==
document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html") ||
document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html") ===
document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html"), "Caching is allowed.")
})
</script>

Просмотреть файл

@ -0,0 +1,44 @@
<!DOCTYPE html>
<title>Document.importNode</title>
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var doc = document.implementation.createHTMLDocument("Title");
var div = doc.body.appendChild(doc.createElement("div"));
div.appendChild(doc.createElement("span"));
assert_equals(div.ownerDocument, doc);
assert_equals(div.firstChild.ownerDocument, doc);
var newDiv = document.importNode(div);
assert_equals(div.ownerDocument, doc);
assert_equals(div.firstChild.ownerDocument, doc);
assert_equals(newDiv.ownerDocument, document);
assert_equals(newDiv.firstChild.ownerDocument, document);
}, "No 'deep' argument.")
test(function() {
var doc = document.implementation.createHTMLDocument("Title");
var div = doc.body.appendChild(doc.createElement("div"));
div.appendChild(doc.createElement("span"));
assert_equals(div.ownerDocument, doc);
assert_equals(div.firstChild.ownerDocument, doc);
var newDiv = document.importNode(div, true);
assert_equals(div.ownerDocument, doc);
assert_equals(div.firstChild.ownerDocument, doc);
assert_equals(newDiv.ownerDocument, document);
assert_equals(newDiv.firstChild.ownerDocument, document);
}, "True 'deep' argument.")
test(function() {
var doc = document.implementation.createHTMLDocument("Title");
var div = doc.body.appendChild(doc.createElement("div"));
div.appendChild(doc.createElement("span"));
assert_equals(div.ownerDocument, doc);
assert_equals(div.firstChild.ownerDocument, doc);
var newDiv = document.importNode(div, false);
assert_equals(div.ownerDocument, doc);
assert_equals(div.firstChild.ownerDocument, doc);
assert_equals(newDiv.ownerDocument, document);
assert_equals(newDiv.firstChild, null);
}, "False 'deep' argument.")
</script>

Просмотреть файл

@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Null test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Test of firstElementChild and lastChildElement returning null</h1>
<div id="log"></div>
<p id="parentEl" style="font-weight:bold;">Test.</p>
<script>
test(function() {
var parentEl = document.getElementById("parentEl")
assert_equals(parentEl.firstElementChild, null)
assert_equals(parentEl.lastElementChild, null)
})
</script>

Просмотреть файл

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>Null test</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of firstElementChild and lastChildElement returning null</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle" font-weight="bold">Test</text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
assert_equals(parentEl.firstElementChild, null)
assert_equals(parentEl.lastElementChild, null)
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 788 B

Просмотреть файл

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Null Test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of firstElementChild and lastChildElement returning null</h1>
<div id="log"></div>
<p id="parentEl" style="font-weight:bold;">Test.</p>
<script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
assert_equals(parentEl.firstElementChild, null)
assert_equals(parentEl.lastElementChild, null)
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Dynamic Adding of Elements</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Test of Dynamic Adding of Elements</h1>
<div id="log"></div>
<p id="parentEl">The result of this test is
<span id="first_element_child" style="font-weight:bold;">logged above.</span></p>
<script>
test(function() {
var parentEl = document.getElementById("parentEl");
var newChild = document.createElement("span");
parentEl.appendChild(newChild);
assert_equals(parentEl.childElementCount, 2)
})
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>Dynamic Adding of Elements</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of Dynamic Adding of Elements</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of this test is
<tspan id="first_element_child" font-weight="bold">unknown.</tspan></text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var newChild = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
parentEl.appendChild(newChild);
assert_equals(parentEl.childElementCount, 2)
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 913 B

Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Dynamic Adding of Elements</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of Dynamic Adding of Elements</h1>
<div id="log"></div>
<p id="parentEl">The result of this test is
<span id="first_element_child" style="font-weight:bold;">logged above.</span></p>
<script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var newChild = document.createElement("span");
parentEl.appendChild(newChild);
assert_equals(parentEl.childElementCount, 2)
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Dynamic Removal of Elements</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Test of Dynamic Removal of Elements</h1>
<div id="log"></div>
<p id="parentEl">The result of this test is
<span id="first_element_child" style="font-weight:bold;">unknown.</span><span id="last_element_child"> </span></p>
<script>
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = parentEl.lastElementChild;
parentEl.removeChild(lec);
assert_equals(parentEl.childElementCount, 1)
})
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>Dynamic Removal of Elements</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of Dynamic Removal of Elements</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of this test is
<tspan id="first_element_child" font-weight="bold">unknown.</tspan><tspan id="last_element_child"> </tspan></text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = parentEl.lastElementChild;
parentEl.removeChild(lec);
assert_equals(parentEl.childElementCount, 1)
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 907 B

Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Dynamic Removal of Elements</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of Removal Adding of Elements</h1>
<div id="log"></div>
<p id="parentEl">The result of this test is
<span id="first_element_child" style="font-weight:bold;">logged above.</span><span id="last_element_child"> </span></p>
<script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = parentEl.lastElementChild;
parentEl.removeChild(lec);
assert_equals(parentEl.childElementCount, 1)
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>childElementCount without Child Element Nodes</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Test of childElementCount with No Child Element Nodes</h1>
<div id="log"></div>
<p id="parentEl" style="font-weight:bold;">Test.</p>
<script>
test(function() {
var parentEl = document.getElementById("parentEl")
assert_equals(parentEl.childElementCount, 0)
})
</script>

Просмотреть файл

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>childElementCount</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of childElementCount with No Child Element Nodes</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle" font-weight="bold">Test</text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
assert_equals(parentEl.childElementCount, 0)
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 735 B

Просмотреть файл

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>childElementCount without Child Element Nodes</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of childElementCount with No Child Element Nodes</h1>
<div id="log"></div>
<p id="parentEl" style="font-weight:bold;">Test.</p>
<script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
assert_equals(parentEl.childElementCount, 0)
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,20 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>childElementCount</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Test of childElementCount</h1>
<div id="log"></div>
<p id="parentEl">The result of <span id="first_element_child"><span>this</span> <span>test</span></span> is
<span id="middle_element_child" style="font-weight:bold;">given above.</span>
<span id="last_element_child" style="display:none;">fnord</span> </p>
<script>
test(function() {
var parentEl = document.getElementById("parentEl")
assert_true("childElementCount" in parentEl)
assert_equals(parentEl.childElementCount, 3)
})
</script>

Просмотреть файл

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>childElementCount</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of childElementCount</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of <tspan id="first_element_child"><tspan>this</tspan> <tspan>test</tspan></tspan> is
<tspan id="middle_element_child" font-weight="bold">unknown.</tspan>
<tspan id="last_element_child" style="display:none;">fnord</tspan> </text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
assert_true("childElementCount" in parentEl)
assert_equals(parentEl.childElementCount, 3)
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 970 B

Просмотреть файл

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>childElementCount</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of childElementCount</h1>
<div id="log"></div>
<p id="parentEl">The result of <span id="first_element_child"><span>this</span> <span>test</span></span> is
<span id="middle_element_child" style="font-weight:bold;">unknown.</span>
<span id="last_element_child" style="display:none;">fnord</span> </p>
<script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
assert_true("childElementCount" in parentEl)
assert_equals(parentEl.childElementCount, 3)
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,25 @@
<!DOCTYPE html>
<title>HTMLCollection edge cases</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test"><img><img id=foo><img id=foo></div>
<script>
test(function() {
var container = document.getElementById("test");
var result = container.children.item("foo");
assert_true(result instanceof Element, "Expected an Element.");
assert_false(result.hasAttribute("id"), "Expected the IDless Element.")
})
test(function() {
var container = document.getElementById("test");
var list = container.children;
var result = [];
for (var p in list) {
if (list.hasOwnProperty(p)) {
result.push(p);
}
}
assert_array_equals(result, ['0', '1', '2', 'foo']);
});
</script>

Просмотреть файл

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
[
<!ENTITY tree "<tspan id='first_element_child' font-weight='bold'>unknown.</tspan>">
]>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>Entity References</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of Entity References</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of this test is &tree;</text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
var fec = parentEl.firstElementChild;
assert_true(!!fec)
assert_equals(fec.nodeType, 1)
assert_equals(fec.getAttribute("id"), "first_element_child")
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 1015 B

Просмотреть файл

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
[
<!ENTITY tree "<span id='first_element_child' style='font-weight:bold;'>unknown.</span>">
]>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Entity References</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of Entity References</h1>
<div id="log"></div>
<p id="parentEl">The result of this test is &tree;</p>
<script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
var fec = parentEl.firstElementChild;
assert_true(!!fec)
assert_equals(fec.nodeType, 1)
assert_equals(fec.getAttribute("id"), "first_element_child")
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,21 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>firstElementChild with namespaces</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Test of firstElementChild with namespaces</h1>
<div id="log"></div>
<p id="parentEl">The result of this test is a unknown.</p>
<script>
test(function() {
var parentEl = document.getElementById("parentEl")
var el = document.createElementNS("http://ns.example.org/pickle", "pickle:dill")
el.setAttribute("id", "first_element_child")
parentEl.appendChild(el)
var fec = parentEl.firstElementChild
assert_true(!!fec)
assert_equals(fec.nodeType, 1)
assert_equals(fec.getAttribute("id"), "first_element_child")
assert_equals(fec.localName, "dill")
})
</script>

Просмотреть файл

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:pickle="http://ns.example.org/pickle"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>firstElementChild with namespaces</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of firstElementChild with namespaces</text>
<g id="parentEl">
<pickle:dill id="first_element_child"/>
</g>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var fec = parentEl.firstElementChild;
assert_true(!!fec)
assert_equals(fec.nodeType, 1)
assert_equals(fec.getAttribute("id"), "first_element_child")
assert_equals(fec.localName, "dill")
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 888 B

Просмотреть файл

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:pickle="http://ns.example.org/pickle">
<head>
<title>firstElementChild with namespaces</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of firstElementChild with namespaces</h1>
<div id="parentEl">
<pickle:dill id="first_element_child"/>
</div>
<div id="log"></div>
<p id="parentEl">The result of this test is
<span id="first_element_child" style="font-weight:bold;">logged above.</span></p>
<script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var fec = parentEl.firstElementChild;
assert_true(!!fec)
assert_equals(fec.nodeType, 1)
assert_equals(fec.getAttribute("id"), "first_element_child")
assert_equals(fec.localName, "dill")
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>firstElementChild</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Test of firstElementChild</h1>
<div id="log"></div>
<p id="parentEl">The result of this test is
<span id="first_element_child" style="font-weight:bold;">logged above.</span></p>
<script>
test(function() {
var parentEl = document.getElementById("parentEl");
var fec = parentEl.firstElementChild;
assert_true(!!fec)
assert_equals(fec.nodeType, 1)
assert_equals(fec.getAttribute("id"), "first_element_child")
})
</script>

Просмотреть файл

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>firstElementChild</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of firstElementChild</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of this test is
<tspan id="first_element_child" font-weight="bold">unknown.</tspan></text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var fec = parentEl.firstElementChild;
assert_true(!!fec)
assert_equals(fec.nodeType, 1)
assert_equals(fec.getAttribute("id"), "first_element_child")
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 889 B

Просмотреть файл

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>firstElementChild</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of firstElementChild</h1>
<div id="log"></div>
<p id="parentEl">The result of this test is
<span id="first_element_child" style="font-weight:bold;">logged above.</span></p>
<script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var fec = parentEl.firstElementChild;
assert_true(!!fec)
assert_equals(fec.nodeType, 1)
assert_equals(fec.getAttribute("id"), "first_element_child")
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,21 @@
<!DOCTYPE html>
<title>Element.getElementsByClassName</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var a = document.createElement("a"), b = document.createElement("b")
b.className = "foo"
a.appendChild(b)
var list = a.getElementsByClassName("foo")
assert_array_equals(list, [b])
var secondList = a.getElementsByClassName("foo")
assert_true(list === secondList || list !== secondList, "Caching is allowed.")
}, "getElementsByClassName should work on disconnected subtrees.")
test(function() {
var list = document.getElementsByClassName("foo")
assert_false(list instanceof NodeList, "NodeList")
assert_true(list instanceof HTMLCollection, "HTMLCollection")
}, "Interface should be correct.")
</script>

Просмотреть файл

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>lastElementChild</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Test of lastElementChild</h1>
<div id="log"></div>
<p id="parentEl">The result of <span id="first_element_child">this test</span> is <span id="last_element_child" style="font-weight:bold;">logged</span> above.</p>
<script>
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = parentEl.lastElementChild;
assert_true(!!lec)
assert_equals(lec.nodeType, 1)
assert_equals(lec.getAttribute("id"), "last_element_child")
})
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>lastElementChild</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of lastElementChild</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of <tspan id="first_element_child">this test</tspan> is <tspan id="last_element_child" font-weight="bold">not</tspan> known.</text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = parentEl.lastElementChild;
assert_true(!!lec)
assert_equals(lec.nodeType, 1)
assert_equals(lec.getAttribute("id"), "last_element_child")
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 926 B

Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>firstElementChild</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of firstElementChild</h1>
<div id="log"></div>
<p id="parentEl">The result of <span id="first_element_child">this test</span> is <span id="last_element_child" style="font-weight:bold;">logged</span> above.</p>
<script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = parentEl.lastElementChild;
assert_true(!!lec)
assert_equals(lec.nodeType, 1)
assert_equals(lec.getAttribute("id"), "last_element_child")
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>nextElementSibling</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Test of nextElementSibling</h1>
<div id="log"></div>
<p id="parentEl">The result of <span id="first_element_child">this test</span> is <span id="last_element_child" style="font-weight:bold;">unknown.</span></p>
<script>
test(function() {
var parentEl = document.getElementById("parentEl");
var fec = document.getElementById("first_element_child");
var nes = fec.nextElementSibling;
assert_true(!!nes)
assert_equals(nes.nodeType, 1)
assert_equals(nes.getAttribute("id"), "last_element_child")
})
</script>

Просмотреть файл

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>nextElementSibling</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of nextElementSibling</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of <tspan id="first_element_child">this test</tspan> is <tspan id="last_element_child" font-weight="bold">unknown.</tspan></text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var fec = document.getElementById("first_element_child");
var nes = fec.nextElementSibling;
assert_true(!!nes)
assert_equals(nes.nodeType, 1)
assert_equals(nes.getAttribute("id"), "last_element_child")
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 985 B

Просмотреть файл

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>nextElementSibling</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of nextElementSibling</h1>
<div id="log"></div>
<p id="parentEl">The result of <span id="first_element_child">this test</span> is <span id="last_element_child" style="font-weight:bold;">unknown.</span></p>
<script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var fec = document.getElementById("first_element_child");
var nes = fec.nextElementSibling;
assert_true(!!nes)
assert_equals(nes.nodeType, 1)
assert_equals(nes.getAttribute("id"), "last_element_child")
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>previousElementSibling</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Test of previousElementSibling</h1>
<div id="log"></div>
<p id="parentEl">The result of <span id="first_element_child">this test</span> is
<span id="middle_element_child" style="font-weight:bold;">unknown.</span>
<span id="last_element_child" style="display:none;">fnord</span> </p>
<script>
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = document.getElementById("last_element_child");
var pes = lec.previousElementSibling;
assert_true(!!pes)
assert_equals(pes.nodeType, 1)
assert_equals(pes.getAttribute("id"), "middle_element_child")
})
</script>

Просмотреть файл

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>previousElementSibling</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of previousElementSibling</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of <tspan id="first_element_child">this test</tspan> is
<tspan id="middle_element_child" font-weight="bold">unknown.</tspan>
<tspan id="last_element_child" display="none">fnord</tspan> </text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = document.getElementById("last_element_child");
var pes = lec.previousElementSibling;
assert_true(!!pes)
assert_equals(pes.nodeType, 1)
assert_equals(pes.getAttribute("id"), "middle_element_child")
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 1.0 KiB

Просмотреть файл

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>previousElementSibling</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of previousElementSibling</h1>
<div id="log"></div>
<p id="parentEl">The result of <span id="first_element_child">this test</span> is
<span id="middle_element_child" style="font-weight:bold;">unknown.</span>
<span id="last_element_child" style="display:none;">fnord</span> </p>
<script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = document.getElementById("last_element_child");
var pes = lec.previousElementSibling;
assert_true(!!pes)
assert_equals(pes.nodeType, 1)
assert_equals(pes.getAttribute("id"), "middle_element_child")
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,18 @@
<!DOCTYPE html>
<title>Element.removeAttributeNS</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="attributes.js"></script>
<div id="log"></div>
<script>
var XML = "http://www.w3.org/XML/1998/namespace"
test(function() {
var el = document.createElement("foo")
el.setAttributeNS(XML, "a:bb", "pass")
attr_is(el.attributes[0], "pass", "bb", XML, "a", "a:bb")
el.removeAttributeNS(XML, "a:bb")
assert_equals(el.attributes.length, 1)
attr_is(el.attributes[0], "pass", "bb", XML, "a", "a:bb")
}, "removeAttributeNS should take a local name.")
</script>

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Null test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1>Test of previousElementSibling and nextElementSibling returning null</h1>
<div id="log"></div>
<p id="parentEl">The result of this test is <span id="first_element_child" style="font-weight:bold;">unknown.</span></p>
<script>
test(function() {
var fec = document.getElementById("first_element_child");
assert_equals(fec.previousElementSibling, null)
assert_equals(fec.nextElementSibling, null)
})
</script>

Просмотреть файл

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>Null test</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of previousElementSibling and nextElementSibling returning null</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of this test is <tspan id="first_element_child" font-weight="bold">unknown.</tspan></text>
<h:script><![CDATA[
test(function() {
var fec = document.getElementById("first_element_child");
assert_equals(fec.previousElementSibling, null)
assert_equals(fec.nextElementSibling, null)
})
]]></h:script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 870 B

Просмотреть файл

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Null Test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Test of previousElementSibling and nextElementSibling returning null</h1>
<div id="log"></div>
<p id="parentEl">The result of this test is <span id="first_element_child" style="font-weight:bold;">unknown.</span></p>
<script><![CDATA[
test(function() {
var fec = document.getElementById("first_element_child");
assert_equals(fec.previousElementSibling, null)
assert_equals(fec.nextElementSibling, null)
})
]]></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,26 @@
<!DOCTYPE html>
<title>Element.tagName</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var HTMLNS = "http://www.w3.org/1999/xhtml",
SVGNS = "http://www.w3.org/2000/svg"
assert_equals(document.createElementNS(HTMLNS, "I").tagName, "I")
assert_equals(document.createElementNS(HTMLNS, "i").tagName, "I")
assert_equals(document.createElementNS(SVGNS, "svg").tagName, "svg")
assert_equals(document.createElementNS(SVGNS, "SVG").tagName, "SVG")
assert_equals(document.createElementNS(HTMLNS, "x:b").tagName, "X:B")
})
test(function() {
if ("DOMParser" in window) {
var xmlel = new DOMParser()
.parseFromString('<div xmlns="http://www.w3.org/1999/xhtml">Test</div>', 'text/xml')
.documentElement;
assert_equals(xmlel.tagName, "div", "tagName should be lowercase in XML")
var htmlel = document.importNode(xmlel, true)
assert_equals(htmlel.tagName, "DIV", "tagName should be uppercase in HTML")
}
}, "tagName should be updated when changing ownerDocument")
</script>

Просмотреть файл

@ -0,0 +1,20 @@
<!doctype html>
<title>Event constants</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="constants.js"></script>
<div id="log"></div>
<script>
var objects = [
Event,
Event.prototype,
document.createEvent("Event"),
document.createEvent("CustomEvent")
]
testConstants(objects, [
["NONE", 0],
["CAPTURING_PHASE", 1],
["AT_TARGET", 2],
["BUBBLING_PHASE", 3]
], "eventPhase")
</script>

Просмотреть файл

@ -0,0 +1,59 @@
<!doctype html>
<title>Event constructors</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function() {
var ev = new Event("test")
assert_equals(ev.type, "test")
assert_equals(ev.target, null)
assert_equals(ev.currentTarget, null)
assert_equals(ev.eventPhase, Event.AT_TARGET)
assert_equals(ev.bubbles, false)
assert_equals(ev.cancelable, false)
assert_equals(ev.defaultPrevented, false)
assert_equals(ev.isTrusted, false)
assert_true(ev.timeStamp > 0)
assert_true("initEvent" in ev)
})
test(function() {
var ev = new Event("I am an event", { bubbles: true, cancelable: false})
assert_equals(ev.type, "I am an event")
assert_equals(ev.bubbles, true)
assert_equals(ev.cancelable, false)
})
test(function() {
var ev = new Event("@", { bubblesIGNORED: true, cancelable: true})
assert_equals(ev.type, "@")
assert_equals(ev.bubbles, false)
assert_equals(ev.cancelable, true)
})
test(function() {
var ev = new Event("Xx", { cancelable: true})
assert_equals(ev.type, "Xx")
assert_equals(ev.bubbles, false)
assert_equals(ev.cancelable, true)
})
test(function() {
var ev = new Event("Xx", {})
assert_equals(ev.type, "Xx")
assert_equals(ev.bubbles, false)
assert_equals(ev.cancelable, false)
})
test(function() {
var ev = new Event("Xx", {bubbles: true, cancelable: false, sweet: "x"})
assert_equals(ev.type, "Xx")
assert_equals(ev.bubbles, true)
assert_equals(ev.cancelable, false)
assert_equals(ev.sweet, undefined)
})
test(function() {
var ev = new CustomEvent("$", {detail: 54, sweet: "x", sweet2: "x", cancelable:true})
assert_equals(ev.type, "$")
assert_equals(ev.bubbles, false)
assert_equals(ev.cancelable, true)
assert_equals(ev.sweet, undefined)
assert_equals(ev.detail, 54)
})
</script>

Просмотреть файл

@ -0,0 +1,42 @@
<!doctype html>
<title>Event.defaultPrevented</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var ev;
test(function() {
ev = document.createEvent("Event");
assert_equals(ev.defaultPrevented, false, "defaultPrevented");
}, "When an event is created, defaultPrevented should be initialized to false.");
test(function() {
ev.initEvent("foo", true, false);
assert_equals(ev.bubbles, true, "bubbles");
assert_equals(ev.cancelable, false, "cancelable");
assert_equals(ev.defaultPrevented, false, "defaultPrevented");
}, "initEvent should work correctly (not cancelable).");
test(function() {
assert_equals(ev.cancelable, false, "cancelable (before)");
ev.preventDefault();
assert_equals(ev.cancelable, false, "cancelable (after)");
assert_equals(ev.defaultPrevented, false, "defaultPrevented");
}, "preventDefault() should not change defaultPrevented if cancelable is false.");
test(function() {
ev.initEvent("foo", true, true);
assert_equals(ev.bubbles, true, "bubbles");
assert_equals(ev.cancelable, true, "cancelable");
assert_equals(ev.defaultPrevented, false, "defaultPrevented");
}, "initEvent should work correctly (cancelable).");
test(function() {
assert_equals(ev.cancelable, true, "cancelable (before)");
ev.preventDefault();
assert_equals(ev.cancelable, true, "cancelable (after)");
assert_equals(ev.defaultPrevented, true, "defaultPrevented");
}, "preventDefault() should change defaultPrevented if cancelable is false.");
test(function() {
ev.initEvent("foo", true, true);
assert_equals(ev.bubbles, true, "bubbles");
assert_equals(ev.cancelable, true, "cancelable");
assert_equals(ev.defaultPrevented, false, "defaultPrevented");
}, "initEvent should unset defaultPrevented.");
</script>

Просмотреть файл

@ -0,0 +1,30 @@
<!DOCTYPE html>
<title>Event.initEvent</title>
<link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var t = async_test("Calling initEvent must not have an effect during dispatching.")
t.step(function() {
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=17715
var e = document.createEvent("Event")
e.initEvent("type", false, false)
assert_equals(e.type, "type", "type (first init)")
assert_equals(e.bubbles, false, "bubbles (first init)")
assert_equals(e.cancelable, false, "cancelable (first init)")
var target = document.createElement("div")
target.addEventListener("type", t.step_func(function() {
e.initEvent("fail", true, true)
assert_equals(e.type, "type", "type (second init)")
assert_equals(e.bubbles, false, "bubbles (second init)")
assert_equals(e.cancelable, false, "cancelable (second init)")
}), false)
assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
t.done()
})
</script>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше