Bug 816103 - Part b: Update webapps tests; r=bz

This commit is contained in:
Ms2ger 2012-12-02 09:52:36 +01:00
parent 3879ea24fe
commit fe27bb312c
60 changed files with 1619 additions and 158 deletions

View File

@ -13,6 +13,7 @@ DIRS := \
$(NULL)
MOCHITEST_FILES := \
test_Node-properties.html.json \
test_Range-cloneContents.html.json \
test_Range-cloneRange.html.json \
test_Range-collapse.html.json \
@ -23,8 +24,8 @@ MOCHITEST_FILES := \
test_Range-extractContents.html.json \
test_Range-intersectsNode.html.json \
test_Range-isPointInRange.html.json \
test_Range-mutations.html.json \
test_Range-set.html.json \
test_exceptions.html.json \
test_interfaces.html.json \
$(NULL)

View File

@ -0,0 +1,9 @@
{
"document.characterSet": true,
"foreignDoc.characterSet": true,
"xmlDoc.characterSet": true,
"xmlElement.namespaceURI": true,
"xmlElement.className": true,
"detachedXmlElement.namespaceURI": true,
"detachedXmlElement.className": true
}

View File

@ -7,34 +7,33 @@
"Node 5 foreignPara1.firstChild, detached range": true,
"Node 6 detachedPara1, detached range": true,
"Node 7 detachedPara1.firstChild, detached range": true,
"Node 8 detachedPara1, detached range": true,
"Node 9 detachedPara1.firstChild, detached range": true,
"Node 8 detachedPara2, detached range": true,
"Node 9 detachedPara2.firstChild, detached range": true,
"Node 10 testDiv, detached range": true,
"Node 11 document, detached range": true,
"Node 12 detachedDiv, detached range": true,
"Node 13 detachedPara2, detached range": true,
"Node 14 foreignDoc, detached range": true,
"Node 15 foreignPara2, detached range": true,
"Node 16 xmlDoc, detached range": true,
"Node 17 xmlElement, detached range": true,
"Node 18 detachedXmlElement, detached range": true,
"Node 19 detachedTextNode, detached range": true,
"Node 20 foreignTextNode, detached range": true,
"Node 21 detachedForeignTextNode, detached range": true,
"Node 22 xmlTextNode, detached range": true,
"Node 23 detachedXmlTextNode, detached range": true,
"Node 24 processingInstruction, detached range": true,
"Node 25 detachedProcessingInstruction, detached range": true,
"Node 26 comment, detached range": true,
"Node 27 detachedComment, detached range": true,
"Node 28 foreignComment, detached range": true,
"Node 29 detachedForeignComment, detached range": true,
"Node 30 xmlComment, detached range": true,
"Node 31 detachedXmlComment, detached range": true,
"Node 32 docfrag, detached range": true,
"Node 33 foreignDocfrag, detached range": true,
"Node 34 xmlDocfrag, detached range": true,
"Node 35 doctype, detached range": true,
"Node 36 foreignDoctype, detached range": true,
"Node 37 xmlDoctype, detached range": true
"Node 13 foreignDoc, detached range": true,
"Node 14 foreignPara2, detached range": true,
"Node 15 xmlDoc, detached range": true,
"Node 16 xmlElement, detached range": true,
"Node 17 detachedXmlElement, detached range": true,
"Node 18 detachedTextNode, detached range": true,
"Node 19 foreignTextNode, detached range": true,
"Node 20 detachedForeignTextNode, detached range": true,
"Node 21 xmlTextNode, detached range": true,
"Node 22 detachedXmlTextNode, detached range": true,
"Node 23 processingInstruction, detached range": true,
"Node 24 detachedProcessingInstruction, detached range": true,
"Node 25 comment, detached range": true,
"Node 26 detachedComment, detached range": true,
"Node 27 foreignComment, detached range": true,
"Node 28 detachedForeignComment, detached range": true,
"Node 29 xmlComment, detached range": true,
"Node 30 detachedXmlComment, detached range": true,
"Node 31 docfrag, detached range": true,
"Node 32 foreignDocfrag, detached range": true,
"Node 33 xmlDocfrag, detached range": true,
"Node 34 doctype, detached range": true,
"Node 35 foreignDoctype, detached range": true,
"Node 36 xmlDoctype, detached range": true
}

View File

@ -0,0 +1,6 @@
{
"exception.hasOwnProperty(\"message\")": true,
"Object.getOwnPropertyDescriptor(exception, \"message\")": true,
"In iframe: exception.hasOwnProperty(\"message\")": true,
"In iframe: Object.getOwnPropertyDescriptor(exception, \"message\")": true
}

View File

@ -88,6 +88,7 @@
"MutationRecord interface: attribute oldValue": true,
"Node interface: operation cloneNode(boolean)": true,
"Document interface: existence and properties of interface object": true,
"Document interface constructor": true,
"Document interface: existence and properties of interface prototype object": true,
"Document interface: existence and properties of interface prototype object's \"constructor\" property": true,
"Document interface: attribute implementation": true,

View File

@ -13,14 +13,17 @@ DIRS := \
$(NULL)
MOCHITEST_FILES := \
test_CharacterData-remove.html.json \
test_DOMImplementation-createDocument.html.json \
test_DOMImplementation-createHTMLDocument.html.json \
test_Document-createElementNS.html.json \
test_Document-getElementsByTagName.html.json \
test_DocumentType-remove.html.json \
test_Element-remove.html.json \
test_Event-constructors.html.json \
test_Event-defaultPrevented.html.json \
test_EventTarget-dispatchEvent.html.json \
test_Node-isEqualNode.xhtml.json \
test_Node-replaceChild.html.json \
test_NodeFilter-constants.html.json \
test_Range-attributes.html.json \
test_Range-commonAncestorContainer.html.json \

View File

@ -0,0 +1,5 @@
{
"CharacterData.remove": true,
"CharacterData.remove 1": true,
"CharacterData.remove 2": true
}

View File

@ -1,11 +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
"createDocument test 15: \"http://example.com/\",null,null,null": true,
"createDocument test 30: \"/\",null,null,null": true,
"createDocument test 45: \"http://www.w3.org/XML/1998/namespace\",null,null,null": true,
"createDocument test 60: \"http://www.w3.org/2000/xmlns/\",null,null,null": true,
"createDocument test 75: \"foo:\",null,null,null": true,
"createDocument test 91: null,null,DocumentType node,\"WRONG_DOCUMENT_ERR\"": true,
"createDocument test 92: null,null,DocumentType node,\"WRONG_DOCUMENT_ERR\"": true,
"createDocument test 94: null,null,DocumentType node,\"WRONG_DOCUMENT_ERR\"": true,
"createDocument test 96: \"foo\",null,DocumentType node,null": true
}

View File

@ -0,0 +1,3 @@
{
"Missing title argument": true
}

View File

@ -0,0 +1,3 @@
{
"DocumentType.remove": true
}

View File

@ -0,0 +1,3 @@
{
"Element.remove": true
}

View File

@ -14,8 +14,10 @@ DIRS := \
MOCHITEST_FILES := \
test_missing_arguments.html.json \
test_storage_local_builtins.html.json \
test_storage_local_in_js.html.json \
test_storage_local_removeitem_js.html.json \
test_storage_session_builtins.html.json \
test_storage_session_in_js.html.json \
test_storage_session_removeitem_js.html.json \
$(NULL)

View File

@ -13,7 +13,11 @@ DIRS := \
$(NULL)
MOCHITEST_FILES := \
test_exceptions.html \
test_interfaces.html \
test_Node-compareDocumentPosition.html \
test_Node-contains.html \
test_Node-properties.html \
test_Range-cloneContents.html \
test_Range-cloneRange.html \
test_Range-collapse.html \

View File

@ -25,14 +25,37 @@ function setupRangeTests() {
testDiv = document.createElement("div");
testDiv.id = "test";
document.body.insertBefore(testDiv, document.body.firstChild);
paras = [];
paras.push(document.createElement("p"));
paras[0].setAttribute("id", "a");
// Test some diacritics, to make sure browsers are using code units here
// and not something like grapheme clusters.
testDiv.innerHTML = "<p id=a>A&#x308;b&#x308;c&#x308;d&#x308;e&#x308;f&#x308;g&#x308;h&#x308;\n"
+ "<p id=b style=display:none>Ijklmnop\n"
+ "<p id=c>Qrstuvwx"
+ "<p id=d style=display:none>Yzabcdef"
+ "<p id=e style=display:none>Ghijklmn";
paras = testDiv.querySelectorAll("p");
paras[0].textContent = "A\u0308b\u0308c\u0308d\u0308e\u0308f\u0308g\u0308h\u0308\n";
testDiv.appendChild(paras[0]);
paras.push(document.createElement("p"));
paras[1].setAttribute("id", "b");
paras[1].setAttribute("style", "display:none");
paras[1].textContent = "Ijklmnop\n";
testDiv.appendChild(paras[1]);
paras.push(document.createElement("p"));
paras[2].setAttribute("id", "c");
paras[2].textContent = "Qrstuvwx";
testDiv.appendChild(paras[2]);
paras.push(document.createElement("p"));
paras[3].setAttribute("id", "d");
paras[3].setAttribute("style", "display:none");
paras[3].textContent = "Yzabcdef";
testDiv.appendChild(paras[3]);
paras.push(document.createElement("p"));
paras[4].setAttribute("id", "e");
paras[4].setAttribute("style", "display:none");
paras[4].textContent = "Ghijklmn";
testDiv.appendChild(paras[4]);
detachedDiv = document.createElement("div");
detachedPara1 = document.createElement("p");
@ -272,12 +295,11 @@ function setupRangeTests() {
"foreignPara1.firstChild",
"detachedPara1",
"detachedPara1.firstChild",
"detachedPara1",
"detachedPara1.firstChild",
"detachedPara2",
"detachedPara2.firstChild",
"testDiv",
"document",
"detachedDiv",
"detachedPara2",
"foreignDoc",
"foreignPara2",
"xmlDoc",

View File

@ -0,0 +1,87 @@
<!doctype html>
<title>Node.compareDocumentPosition() tests</title>
<link rel=author title="Aryeh Gregor" href=ayg@aryeh.name>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=common.js></script>
<script>
"use strict";
testNodes.forEach(function(referenceName) {
var reference = eval(referenceName);
testNodes.forEach(function(otherName) {
var other = eval(otherName);
test(function() {
var result = reference.compareDocumentPosition(other);
// "If other and reference are the same object, return zero and
// terminate these steps."
if (other === reference) {
assert_equals(result, 0);
return;
}
// "If other and reference are not in the same tree, return the result of
// adding DOCUMENT_POSITION_DISCONNECTED,
// DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, and either
// DOCUMENT_POSITION_PRECEDING or DOCUMENT_POSITION_FOLLOWING, with the
// constraint that this is to be consistent, together and terminate these
// steps."
if (furthestAncestor(reference) !== furthestAncestor(other)) {
// TODO: Test that it's consistent.
assert_in_array(result, [Node.DOCUMENT_POSITION_DISCONNECTED +
Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +
Node.DOCUMENT_POSITION_PRECEDING,
Node.DOCUMENT_POSITION_DISCONNECTED +
Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +
Node.DOCUMENT_POSITION_FOLLOWING]);
return;
}
// "If other is an ancestor of reference, return the result of
// adding DOCUMENT_POSITION_CONTAINS to DOCUMENT_POSITION_PRECEDING
// and terminate these steps."
var ancestor = reference.parentNode;
while (ancestor && ancestor !== other) {
ancestor = ancestor.parentNode;
}
if (ancestor === other) {
assert_equals(result, Node.DOCUMENT_POSITION_CONTAINS +
Node.DOCUMENT_POSITION_PRECEDING);
return;
}
// "If other is a descendant of reference, return the result of adding
// DOCUMENT_POSITION_CONTAINED_BY to DOCUMENT_POSITION_FOLLOWING and
// terminate these steps."
ancestor = other.parentNode;
while (ancestor && ancestor !== reference) {
ancestor = ancestor.parentNode;
}
if (ancestor === reference) {
assert_equals(result, Node.DOCUMENT_POSITION_CONTAINED_BY +
Node.DOCUMENT_POSITION_FOLLOWING);
return;
}
// "If other is preceding reference return DOCUMENT_POSITION_PRECEDING
// and terminate these steps."
var prev = previousNode(reference);
while (prev && prev !== other) {
prev = previousNode(prev);
}
if (prev === other) {
assert_equals(result, Node.DOCUMENT_POSITION_PRECEDING);
return;
}
// "Return DOCUMENT_POSITION_FOLLOWING."
assert_equals(result, Node.DOCUMENT_POSITION_FOLLOWING);
}, referenceName + ".compareDocumentPosition(" + otherName + ")");
});
});
testDiv.parentNode.removeChild(testDiv);
</script>
<!-- vim: set expandtab tabstop=2 shiftwidth=2: -->

View File

@ -0,0 +1,36 @@
<!doctype html>
<title>Node.contains() tests</title>
<link rel=author title="Aryeh Gregor" href=ayg@aryeh.name>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=common.js></script>
<script>
"use strict";
testNodes.forEach(function(referenceName) {
var reference = eval(referenceName);
test(function() {
assert_false(reference.contains(null));
}, referenceName + ".contains(null)");
testNodes.forEach(function(otherName) {
var other = eval(otherName);
test(function() {
var ancestor = other;
while (ancestor && ancestor !== reference) {
ancestor = ancestor.parentNode;
}
if (ancestor === reference) {
assert_true(reference.contains(other));
} else {
assert_false(reference.contains(other));
}
}, referenceName + ".compareDocumentPosition(" + otherName + ")");
});
});
testDiv.parentNode.removeChild(testDiv);
</script>
<!-- vim: set expandtab tabstop=2 shiftwidth=2: -->

View File

@ -0,0 +1,686 @@
<!doctype html>
<title>Node assorted property tests</title>
<link rel=author title="Aryeh Gregor" href=ayg@aryeh.name>
<meta charset=utf-8>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=common.js></script>
<script>
"use strict";
/**
* First we define a data structure to tell us what tests to run. The keys
* will be eval()ed, and are mostly global variables defined in common.js. The
* values are objects, which maps properties to expected values. So
*
* foo: {
* bar: "baz",
* quz: 7,
* },
*
* will test that eval("foo.bar") === "baz" and eval("foo.quz") === 7. "foo"
* and "bar" could thus be expressions, like "document.documentElement" and
* "childNodes[4]" respectively.
*
* To avoid repetition, some values are automatically added based on others.
* For instance, if we specify nodeType: Node.TEXT_NODE, we'll automatically
* also test nodeName: "#text". This is handled by code after this variable is
* defined.
*/
var expected = {
testDiv: {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: document,
parentNode: document.body,
parentElement: document.body,
"childNodes.length": 6,
"childNodes[0]": paras[0],
"childNodes[1]": paras[1],
"childNodes[2]": paras[2],
"childNodes[3]": paras[3],
"childNodes[4]": paras[4],
"childNodes[5]": comment,
previousSibling: null,
nextSibling: document.getElementById("log"),
textContent: "A\u0308b\u0308c\u0308d\u0308e\u0308f\u0308g\u0308h\u0308\nIjklmnop\nQrstuvwxYzabcdefGhijklmn",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "div",
tagName: "DIV",
id: "test",
"children[0]": paras[0],
"children[1]": paras[1],
"children[2]": paras[2],
"children[3]": paras[3],
"children[4]": paras[4],
previousElementSibling: null,
// nextSibling isn't explicitly set
//nextElementSibling: ,
childElementCount: 5,
},
detachedDiv: {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: document,
parentNode: null,
parentElement: null,
"childNodes.length": 2,
"childNodes[0]": detachedPara1,
"childNodes[1]": detachedPara2,
previousSibling: null,
nextSibling: null,
textContent: "OpqrstuvWxyzabcd",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "div",
tagName: "DIV",
"children[0]": detachedPara1,
"children[1]": detachedPara2,
previousElementSibling: null,
nextElementSibling: null,
childElementCount: 2,
},
detachedPara1: {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: document,
parentNode: detachedDiv,
parentElement: detachedDiv,
"childNodes.length": 1,
previousSibling: null,
nextSibling: detachedPara2,
textContent: "Opqrstuv",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "p",
tagName: "P",
previousElementSibling: null,
nextElementSibling: detachedPara2,
childElementCount: 0,
},
detachedPara2: {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: document,
parentNode: detachedDiv,
parentElement: detachedDiv,
"childNodes.length": 1,
previousSibling: detachedPara1,
nextSibling: null,
textContent: "Wxyzabcd",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "p",
tagName: "P",
previousElementSibling: detachedPara1,
nextElementSibling: null,
childElementCount: 0,
},
document: {
// Node
nodeType: Node.DOCUMENT_NODE,
"childNodes.length": 2,
"childNodes[0]": document.doctype,
"childNodes[1]": document.documentElement,
// Document
URL: String(location),
compatMode: "CSS1Compat",
characterSet: "utf-8",
contentType: "text/html",
doctype: doctype,
//documentElement: ,
},
foreignDoc: {
// Node
nodeType: Node.DOCUMENT_NODE,
"childNodes.length": 3,
"childNodes[0]": foreignDoc.doctype,
"childNodes[1]": foreignDoc.documentElement,
"childNodes[2]": foreignComment,
// Document
URL: "about:blank",
compatMode: "CSS1Compat",
characterSet: "utf-8",
contentType: "text/html",
//doctype: ,
//documentElement: ,
},
foreignPara1: {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: foreignDoc,
parentNode: foreignDoc.body,
parentElement: foreignDoc.body,
"childNodes.length": 1,
previousSibling: null,
nextSibling: foreignPara2,
textContent: "Efghijkl",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "p",
tagName: "P",
previousElementSibling: null,
nextElementSibling: foreignPara2,
childElementCount: 0,
},
foreignPara2: {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: foreignDoc,
parentNode: foreignDoc.body,
parentElement: foreignDoc.body,
"childNodes.length": 1,
previousSibling: foreignPara1,
nextSibling: foreignTextNode,
textContent: "Mnopqrst",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "p",
tagName: "P",
previousElementSibling: foreignPara1,
nextElementSibling: null,
childElementCount: 0,
},
xmlDoc: {
// Node
nodeType: Node.DOCUMENT_NODE,
"childNodes.length": 4,
"childNodes[0]": xmlDoctype,
"childNodes[1]": xmlElement,
"childNodes[2]": processingInstruction,
"childNodes[3]": xmlComment,
// Document
URL: "about:blank",
compatMode: "CSS1Compat",
characterSet: "utf-8",
contentType: "application/xml",
//doctype: ,
//documentElement: ,
},
xmlElement: {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: xmlDoc,
parentNode: xmlDoc,
parentElement: null,
"childNodes.length": 1,
"childNodes[0]": xmlTextNode,
previousSibling: xmlDoctype,
nextSibling: processingInstruction,
textContent: "do re mi fa so la ti",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "igiveuponcreativenames",
tagName: "igiveuponcreativenames",
previousElementSibling: null,
nextElementSibling: null,
childElementCount: 0,
},
detachedXmlElement: {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: xmlDoc,
parentNode: null,
parentElement: null,
"childNodes.length": 0,
previousSibling: null,
nextSibling: null,
textContent: "",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "everyone-hates-hyphenated-element-names",
tagName: "everyone-hates-hyphenated-element-names",
previousElementSibling: null,
nextElementSibling: null,
childElementCount: 0,
},
detachedTextNode: {
// Node
nodeType: Node.TEXT_NODE,
ownerDocument: document,
parentNode: null,
parentElement: null,
previousSibling: null,
nextSibling: null,
nodeValue: "Uvwxyzab",
// Text
wholeText: "Uvwxyzab",
},
foreignTextNode: {
// Node
nodeType: Node.TEXT_NODE,
ownerDocument: foreignDoc,
parentNode: foreignDoc.body,
parentElement: foreignDoc.body,
previousSibling: foreignPara2,
nextSibling: null,
nodeValue: "I admit that I harbor doubts about whether we really need so many things to test, but it's too late to stop now.",
// Text
wholeText: "I admit that I harbor doubts about whether we really need so many things to test, but it's too late to stop now.",
},
detachedForeignTextNode: {
// Node
nodeType: Node.TEXT_NODE,
ownerDocument: foreignDoc,
parentNode: null,
parentElement: null,
previousSibling: null,
nextSibling: null,
nodeValue: "Cdefghij",
// Text
wholeText: "Cdefghij",
},
xmlTextNode: {
// Node
nodeType: Node.TEXT_NODE,
ownerDocument: xmlDoc,
parentNode: xmlElement,
parentElement: xmlElement,
previousSibling: null,
nextSibling: null,
nodeValue: "do re mi fa so la ti",
// Text
wholeText: "do re mi fa so la ti",
},
detachedXmlTextNode: {
// Node
nodeType: Node.TEXT_NODE,
ownerDocument: xmlDoc,
parentNode: null,
parentElement: null,
previousSibling: null,
nextSibling: null,
nodeValue: "Klmnopqr",
// Text
wholeText: "Klmnopqr",
},
processingInstruction: {
// Node
nodeType: Node.PROCESSING_INSTRUCTION_NODE,
ownerDocument: xmlDoc,
parentNode: xmlDoc,
parentElement: null,
previousSibling: xmlElement,
nextSibling: xmlComment,
nodeValue: 'Did you know that ":syn sync fromstart" is very useful when using vim to edit large amounts of JavaScript embedded in HTML?',
// ProcessingInstruction
target: "somePI",
},
detachedProcessingInstruction: {
// Node
nodeType: Node.PROCESSING_INSTRUCTION_NODE,
ownerDocument: xmlDoc,
parentNode: null,
parentElement: null,
previousSibling: null,
nextSibling: null,
nodeValue: "chirp chirp chirp",
// ProcessingInstruction
target: "whippoorwill",
},
comment: {
// Node
nodeType: Node.COMMENT_NODE,
ownerDocument: document,
parentNode: testDiv,
parentElement: testDiv,
previousSibling: paras[4],
nextSibling: null,
nodeValue: "Alphabet soup?",
},
detachedComment: {
// Node
nodeType: Node.COMMENT_NODE,
ownerDocument: document,
parentNode: null,
parentElement: null,
previousSibling: null,
nextSibling: null,
nodeValue: "Stuvwxyz",
},
foreignComment: {
// Node
nodeType: Node.COMMENT_NODE,
ownerDocument: foreignDoc,
parentNode: foreignDoc,
parentElement: null,
previousSibling: foreignDoc.documentElement,
nextSibling: null,
nodeValue: '"Commenter" and "commentator" mean different things. I\'ve seen non-native speakers trip up on this.',
},
detachedForeignComment: {
// Node
nodeType: Node.COMMENT_NODE,
ownerDocument: foreignDoc,
parentNode: null,
parentElement: null,
previousSibling: null,
nextSibling: null,
nodeValue: "אריה יהודה",
},
xmlComment: {
// Node
nodeType: Node.COMMENT_NODE,
ownerDocument: xmlDoc,
parentNode: xmlDoc,
parentElement: null,
previousSibling: processingInstruction,
nextSibling: null,
nodeValue: "I maliciously created a comment that will break incautious XML serializers, but Firefox threw an exception, so all I got was this lousy T-shirt",
},
detachedXmlComment: {
// Node
nodeType: Node.COMMENT_NODE,
ownerDocument: xmlDoc,
parentNode: null,
parentElement: null,
previousSibling: null,
nextSibling: null,
nodeValue: "בן חיים אליעזר",
},
docfrag: {
// Node
nodeType: Node.DOCUMENT_FRAGMENT_NODE,
ownerDocument: document,
"childNodes.length": 0,
textContent: "",
},
foreignDocfrag: {
// Node
nodeType: Node.DOCUMENT_FRAGMENT_NODE,
ownerDocument: foreignDoc,
"childNodes.length": 0,
textContent: "",
},
xmlDocfrag: {
// Node
nodeType: Node.DOCUMENT_FRAGMENT_NODE,
ownerDocument: xmlDoc,
"childNodes.length": 0,
textContent: "",
},
doctype: {
// Node
nodeType: Node.DOCUMENT_TYPE_NODE,
ownerDocument: document,
parentNode: document,
previousSibling: null,
nextSibling: document.documentElement,
// DocumentType
name: "html",
publicId: "",
systemId: "",
},
foreignDoctype: {
// Node
nodeType: Node.DOCUMENT_TYPE_NODE,
ownerDocument: foreignDoc,
parentNode: foreignDoc,
previousSibling: null,
nextSibling: foreignDoc.documentElement,
// DocumentType
name: "html",
publicId: "",
systemId: "",
},
xmlDoctype: {
// Node
nodeType: Node.DOCUMENT_TYPE_NODE,
ownerDocument: xmlDoc,
parentNode: xmlDoc,
previousSibling: null,
nextSibling: xmlElement,
// DocumentType
name: "qorflesnorf",
publicId: "abcde",
systemId: "x\"'y",
},
"paras[0]": {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: document,
parentNode: testDiv,
parentElement: testDiv,
"childNodes.length": 1,
previousSibling: null,
nextSibling: paras[1],
textContent: "A\u0308b\u0308c\u0308d\u0308e\u0308f\u0308g\u0308h\u0308\n",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "p",
tagName: "P",
id: "a",
previousElementSibling: null,
nextElementSibling: paras[1],
childElementCount: 0,
},
"paras[1]": {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: document,
parentNode: testDiv,
parentElement: testDiv,
"childNodes.length": 1,
previousSibling: paras[0],
nextSibling: paras[2],
textContent: "Ijklmnop\n",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "p",
tagName: "P",
id: "b",
previousElementSibling: paras[0],
nextElementSibling: paras[2],
childElementCount: 0,
},
"paras[2]": {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: document,
parentNode: testDiv,
parentElement: testDiv,
"childNodes.length": 1,
previousSibling: paras[1],
nextSibling: paras[3],
textContent: "Qrstuvwx",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "p",
tagName: "P",
id: "c",
previousElementSibling: paras[1],
nextElementSibling: paras[3],
childElementCount: 0,
},
"paras[3]": {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: document,
parentNode: testDiv,
parentElement: testDiv,
"childNodes.length": 1,
previousSibling: paras[2],
nextSibling: paras[4],
textContent: "Yzabcdef",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "p",
tagName: "P",
id: "d",
previousElementSibling: paras[2],
nextElementSibling: paras[4],
childElementCount: 0,
},
"paras[4]": {
// Node
nodeType: Node.ELEMENT_NODE,
ownerDocument: document,
parentNode: testDiv,
parentElement: testDiv,
"childNodes.length": 1,
previousSibling: paras[3],
nextSibling: comment,
textContent: "Ghijklmn",
// Element
namespaceURI: "http://www.w3.org/1999/xhtml",
prefix: null,
localName: "p",
tagName: "P",
id: "e",
previousElementSibling: paras[3],
nextElementSibling: null,
childElementCount: 0,
},
};
for (var node in expected) {
// Now we set various default values by node type.
switch (expected[node].nodeType) {
case Node.ELEMENT_NODE:
expected[node].nodeName = expected[node].tagName;
expected[node].nodeValue = null;
expected[node]["children.length"] = expected[node].childElementCount;
if (expected[node].id === undefined) {
expected[node].id = "";
}
if (expected[node].className === undefined) {
expected[node].className = "";
}
var len = expected[node].childElementCount;
if (len === 0) {
expected[node].firstElementChild =
expected[node].lastElementChild = null;
} else {
// If we have expectations for the first/last child in children,
// use those. Otherwise, at least check that .firstElementChild ==
// .children[0] and .lastElementChild == .children[len - 1], even
// if we aren't sure what they should be.
expected[node].firstElementChild = expected[node]["children[0]"]
? expected[node]["children[0]"]
: eval(node).children[0];
expected[node].lastElementChild =
expected[node]["children[" + (len - 1) + "]"]
? expected[node]["children[" + (len - 1) + "]"]
: eval(node).children[len - 1];
}
break;
case Node.TEXT_NODE:
expected[node].nodeName = "#text";
expected[node]["childNodes.length"] = 0;
expected[node].textContent = expected[node].data =
expected[node].nodeValue;
expected[node].length = expected[node].nodeValue.length;
break;
case Node.PROCESSING_INSTRUCTION_NODE:
expected[node].nodeName = expected[node].target;
expected[node]["childNodes.length"] = 0;
expected[node].textContent = expected[node].data =
expected[node].nodeValue;
expected[node].length = expected[node].nodeValue.length;
break;
case Node.COMMENT_NODE:
expected[node].nodeName = "#comment";
expected[node]["childNodes.length"] = 0;
expected[node].textContent = expected[node].data =
expected[node].nodeValue;
expected[node].length = expected[node].nodeValue.length;
break;
case Node.DOCUMENT_NODE:
expected[node].nodeName = "#document";
expected[node].ownerDocument = expected[node].parentNode =
expected[node].parentElement = expected[node].previousSibling =
expected[node].nextSibling = expected[node].nodeValue =
expected[node].textContent = null;
expected[node].documentURI = expected[node].URL;
break;
case Node.DOCUMENT_TYPE_NODE:
expected[node].nodeName = expected[node].name;
expected[node]["childNodes.length"] = 0;
expected[node].parentElement = expected[node].nodeValue =
expected[node].textContent = null;
break;
case Node.DOCUMENT_FRAGMENT_NODE:
expected[node].nodeName = "#document-fragment";
expected[node].parentNode = expected[node].parentElement =
expected[node].previousSibling = expected[node].nextSibling =
expected[node].nodeValue = null;
break;
}
// Now we set some further default values that are independent of node
// type.
var len = expected[node]["childNodes.length"];
if (len === 0) {
expected[node].firstChild = expected[node].lastChild = null;
} else {
// If we have expectations for the first/last child in childNodes, use
// those. Otherwise, at least check that .firstChild == .childNodes[0]
// and .lastChild == .childNodes[len - 1], even if we aren't sure what
// they should be.
expected[node].firstChild = expected[node]["childNodes[0]"]
? expected[node]["childNodes[0]"]
: eval(node).childNodes[0];
expected[node].lastChild =
expected[node]["childNodes[" + (len - 1) + "]"]
? expected[node]["childNodes[" + (len - 1) + "]"]
: eval(node).childNodes[len - 1];
}
expected[node]["hasChildNodes()"] = !!expected[node]["childNodes.length"];
// Finally, we test!
for (var prop in expected[node]) {
test(function() {
assert_equals(eval(node + "." + prop), expected[node][prop]);
}, node + "." + prop);
}
}
testDiv.parentNode.removeChild(testDiv);
</script>

View File

@ -224,26 +224,41 @@ function testSplitText(oldNode, offset, startContainer, startOffset, endContaine
// Finally, the splitText stuff itself:
//
// "If old node's parent is not null, then for every boundary point whose
// node is old node:"
// "If parent is not null, run these substeps:
//
// * "Let original offset equal what the boundary point's offset was
// before this splitText invocation replaced the data of node."
// * "For each range whose start node is node and start offset is greater
// than offset, set its start node to new node and decrease its start
// offset by offset.
//
// * "If original offset is greater than offset, set the boundary point's
// node to new node and its offset to original offset minus offset."
if (oldNode.parentNode
&& startContainer == oldNode
&& originalStartOffset > offset) {
startContainer = newNode;
startOffset = originalStartOffset - offset;
}
// * "For each range whose end node is node and end offset is greater
// than offset, set its end node to new node and decrease its end offset
// by offset.
//
// * "For each range whose start node is parent and start offset is equal
// to the index of node + 1, increase its start offset by one.
//
// * "For each range whose end node is parent and end offset is equal to
// the index of node + 1, increase its end offset by one."
if (oldNode.parentNode) {
if (startContainer == oldNode && originalStartOffset > offset) {
startContainer = newNode;
startOffset = originalStartOffset - offset;
}
if (oldNode.parentNode
&& endContainer == oldNode
&& originalEndOffset > offset) {
endContainer = newNode;
endOffset = originalEndOffset - offset;
if (endContainer == oldNode && originalEndOffset > offset) {
endContainer = newNode;
endOffset = originalEndOffset - offset;
}
if (startContainer == oldNode.parentNode
&& startOffset == 1 + indexOf(oldNode)) {
startOffset++;
}
if (endContainer == oldNode.parentNode
&& endOffset == 1 + indexOf(oldNode)) {
endOffset++;
}
}
return [startContainer, startOffset, endContainer, endOffset];

View File

@ -0,0 +1,100 @@
<!doctype html>
<title>DOMException-throwing tests</title>
<link rel=author title="Aryeh Gregor" href=ayg@aryeh.name>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
/**
* This file just picks one case where browsers are supposed to throw an
* exception, and tests the heck out of whether it meets the spec. In the
* future, all these checks should be in assert_throws(), but we don't want
* every browser failing every assert_throws() check until they fix every
* single bug in their exception-throwing.
*
* We don't go out of our way to test everything that's already tested by
* interfaces.html, like whether all constants are present on the object, but
* some things are duplicated.
*/
setup({explicit_done: true});
function testException(exception, global, desc) {
test(function() {
assert_equals(global.Object.getPrototypeOf(exception),
global.DOMException.prototype);
}, desc + "Object.getPrototypeOf(exception) === DOMException.prototype");
test(function() {
// WebIDL 4.9.2 as of September 28, 2012: "There must be a property named
// “name” on the exception interface prototype object with attributes {
// [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } and
// whose value is the identifier of the exception." Thus, this is
// inherited, not own.
assert_false(exception.hasOwnProperty("name"));
}, desc + "!exception.hasOwnProperty(\"name\")");
test(function() {
assert_equals(exception.name, "HierarchyRequestError");
}, desc + "exception.name === \"HierarchyRequestError\"");
test(function() {
// WebIDL 4.9.1.1 as of September 28, 2012: "Call the [[DefineOwnProperty]]
// internal method of O passing “message”, Property Descriptor { [[Value]]:
// S, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true },
// and false as arguments." Thus, this is an own property.
assert_true(exception.hasOwnProperty("message"));
}, desc + "exception.hasOwnProperty(\"message\")");
test(function() {
var desc = global.Object.getOwnPropertyDescriptor(exception, "message");
assert_true(desc.writable, "must be writable");
assert_false(desc.enumerable, "must not be enumerable");
assert_true(desc.configurable, "must be configurable");
}, desc + "Object.getOwnPropertyDescriptor(exception, \"message\")");
test(function() {
// Can't test anything more specific, since it's implementation-defined :(
assert_equals(typeof exception.message, "string");
}, desc + "typeof exception.message === \"string\"");
test(function() {
// WebIDL: "The class string of the exception object must be the identifier
// of the exception."
assert_equals(global.Object.prototype.toString.call(exception),
"[object DOMException]");
}, desc + "Object.prototype.toString.call(exception) === \"[object DOMException]\"");
test(function() {
assert_equals(exception.code, global.DOMException.HIERARCHY_REQUEST_ERR);
}, desc + "exception.code === DOMException.HIERARCHY_REQUEST_ERR");
}
// Test in current window
var exception = null;
try {
// This should throw a HierarchyRequestError in every browser since the
// Stone Age, so we're really only testing exception-throwing details.
document.documentElement.appendChild(document);
} catch(e) {
exception = e;
}
testException(exception, window, "");
// Test in iframe
var iframe = document.createElement("iframe");
iframe.src = "about:blank";
iframe.onload = function() {
var exception = null;
try {
iframe.contentDocument.documentElement.appendChild(iframe.contentDocument);
} catch(e) {
exception = e;
}
testException(exception, iframe.contentWindow, "In iframe: ");
document.body.removeChild(iframe);
done();
};
document.body.appendChild(iframe);
</script>

View File

@ -209,6 +209,7 @@ interface Node : EventTarget {
boolean isDefaultNamespace(DOMString? namespace);
};
[Constructor]
interface Document : Node {
readonly attribute DOMImplementation implementation;
readonly attribute DOMString URL;

View File

@ -18,7 +18,9 @@ MOCHITEST_FILES := \
test_CharacterData-appendData.html \
test_CharacterData-deleteData.html \
test_CharacterData-insertData.html \
test_CharacterData-remove.html \
test_CharacterData-replaceData.html \
test_ChildNode-remove.js \
test_Document-adoptNode.html \
test_Document-createComment.html \
test_Document-createElement.html \
@ -32,10 +34,12 @@ MOCHITEST_FILES := \
test_Document-getElementsByTagName.html \
test_Document-getElementsByTagNameNS.html \
test_Document-importNode.html \
test_DocumentType-remove.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 \
@ -70,6 +74,7 @@ MOCHITEST_FILES := \
test_Element-previousElementSibling.html \
test_Element-previousElementSibling.svg \
test_Element-previousElementSibling.xhtml \
test_Element-remove.html \
test_Element-removeAttributeNS.html \
test_Element-siblingElement-null.html \
test_Element-siblingElement-null.svg \

View File

@ -1,5 +1,8 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.appendData</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-appenddata">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>

View File

@ -1,5 +1,8 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.deleteData</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-deletedata">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
@ -10,7 +13,10 @@ function testNode(node) {
assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(5, 0) })
node.deleteData(2, 10)
assert_equals(node.data, "te")
})
test(function() {
node.data = "test"
assert_equals(node.data, "test")
node.deleteData(1, 1)
assert_equals(node.data, "tst")
})

View File

@ -1,5 +1,8 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.insertData</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-insertdata">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
@ -10,7 +13,10 @@ function testNode(node) {
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "") })
node.insertData(2, "X")
assert_equals(node.data, "teXst")
})
test(function() {
node.data = "test"
assert_equals(node.data, "test")
node.insertData(4, "ing")
assert_equals(node.data, "testing")
})

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.remove</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-childnode-remove">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="ChildNode-remove.js"></script>
<div id=log></div>
<script>
test(function() {
var node = document.createTextNode("text");
var parent = document.createElement("div");
testRemove(node, parent, "text");
});
test(function() {
var node = document.createComment("comment");
var parent = document.createElement("div");
testRemove(node, parent, "comment");
});
test(function() {
var node = document.createProcessingInstruction("foo", "bar");
var parent = document.createElement("div");
testRemove(node, parent, "PI");
});
</script>

View File

@ -1,5 +1,8 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.replaceData</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-replacedata">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
@ -10,7 +13,10 @@ function testNode(node) {
assert_throws("INDEX_SIZE_ERR", function() { node.replaceData(5, 0, "") })
node.replaceData(2, 10, "yo")
assert_equals(node.data, "teyo")
})
test(function() {
node.data = "test"
assert_equals(node.data, "test")
node.replaceData(1, 1, "waddup")
assert_equals(node.data, "twaddupst")
node.replaceData(1, 1, "yup")

View File

@ -0,0 +1,30 @@
function testRemove(node, parent, type) {
test(function() {
assert_true("remove" in node);
assert_equals(typeof node.remove, "function");
assert_equals(node.remove.length, 0);
}, type + " should support remove()");
test(function() {
assert_equals(node.parentNode, null, "Node should not have a parent");
assert_equals(node.remove(), undefined);
assert_equals(node.parentNode, null, "Removed new node should not have a parent");
}, "remove() should work if " + type + " doesn't have a parent");
test(function() {
assert_equals(node.parentNode, null, "Node should not have a parent");
parent.appendChild(node);
assert_equals(node.parentNode, parent, "Appended node should have a parent");
assert_equals(node.remove(), undefined);
assert_equals(node.parentNode, null, "Removed node should not have a parent");
assert_array_equals(parent.childNodes, [], "Parent should not have children");
}, "remove() should work if " + type + " does have a parent");
test(function() {
assert_equals(node.parentNode, null, "Node should not have a parent");
var before = parent.appendChild(document.createComment("before"));
parent.appendChild(node);
var after = parent.appendChild(document.createComment("after"));
assert_equals(node.parentNode, parent, "Appended node should have a parent");
assert_equals(node.remove(), undefined);
assert_equals(node.parentNode, null, "Removed node should not have a parent");
assert_array_equals(parent.childNodes, [before, after], "Parent should have two children left");
}, "remove() should work if " + type + " does have a parent and siblings");
}

View File

@ -1,5 +1,8 @@
<!doctype html>
<meta charset=utf-8>
<title>DOMException constants</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#domexception">
<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-exception-constants">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
@ -32,10 +35,14 @@ test(function() {
"INVALID_NODE_TYPE_ERR",
"DATA_CLONE_ERR"
]
for (var i = 0; i < constants.length; i++) {
var name = constants[i];
if (name)
constants.forEach(function(name, i) {
test(function() {
assert_equals(DOMException[name], i + 1, name)
}
var pd = Object.getOwnPropertyDescriptor(DOMException, name)
assert_equals(pd.writable, false, "not writable")
assert_equals(pd.enumerable, true, "enumerable")
assert_equals(pd.configurable, false, "not configurable")
}, "Constant: " + name)
})
})
</script>

View File

@ -1,11 +1,23 @@
<!doctype html>
<title>DOMImplementation.createDocument(namespaceURI, qualifiedName, doctype)</title>
<meta charset=utf-8>
<title>DOMImplementation.createDocument(namespace, qualifiedName, doctype)</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domimplementation-createdocument">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelementns">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nodetype">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-documentelement">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-doctype">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var tests = [
/* Arrays with four elements:
* the namespace argument
* the qualifiedName argument
* the doctype argument
* the expected exception, or null if none
*/
[null, null, null, null],
[null, "", null, null],
[null, "foo", null, null],
@ -126,30 +138,25 @@ test(function() {
assert_unreached()
}
for (var i in tests) {
tests.forEach(function(t, i) {
test(function() {
var test = tests[i],
namespaceURI = test[0],
qualifiedName = test[1],
doctype = test[2],
expected = test[3]
var namespace = t[0], qualifiedName = t[1], doctype = t[2], expected = t[3]
if (expected != null) {
assert_throws(expected, function() { document.implementation.createDocument(namespaceURI, qualifiedName, doctype) })
assert_throws(expected, function() { document.implementation.createDocument(namespace, qualifiedName, doctype) })
} else {
var doc = document.implementation.createDocument(namespaceURI, qualifiedName, doctype)
var doc = document.implementation.createDocument(namespace, qualifiedName, doctype)
assert_equals(doc.nodeType, Node.DOCUMENT_NODE)
assert_equals(doc.nodeType, doc.DOCUMENT_NODE)
if(!qualifiedName) {
if (qualifiedName === "" || qualifiedName === null) {
assert_equals(doc.documentElement, null)
} else {
assert_not_equals(doc.documentElement, null)
assert_equals(doc.documentElement.nodeType, Node.ELEMENT_NODE)
}
if(!doctype) {
assert_equals(doc.doctype, null)
}
if(!qualifiedName && !doctype) {
assert_equals(doc.childNodes.length, 0)
}
assert_equals(doc.doctype, doctype)
assert_equals(doc.childNodes.length, !!qualifiedName + !!doctype)
}
})
}
}, "createDocument test " + i + ": " + t.map(function(el) { return format_value(el) }))
})
})
</script>

View File

@ -1,5 +1,11 @@
<!doctype html>
<meta charset=utf-8>
<title>DOMImplementation.createDocumentType(qualifiedName, publicId, systemId)</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domimplementation-createdocumenttype">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-documenttype-name">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-documenttype-publicid">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-documenttype-systemid">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>

View File

@ -1,5 +1,11 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>DOMImplementation.createHTMLDocument</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domimplementation-createhtmldocument">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-documenttype-name">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-documenttype-publicid">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-documenttype-systemid">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-documentelement">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
@ -28,4 +34,17 @@ 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")
test(function() {
var doc = document.implementation.createHTMLDocument();
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, 0)
assert_equals(doc.documentElement.lastChild.localName, "body")
assert_equals(doc.documentElement.lastChild.childNodes.length, 0)
}, "Missing title argument");
</script>

View File

@ -0,0 +1,141 @@
<!doctype html>
<meta charset=utf-8>
<title>DOMImplementation.hasFeature(feature, version)</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domimplementation-hasfeature">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var tests = [
["Core", "1.0"],
["Core", "2.0"],
["Core", "3.0"],
["Core", "100.0"],
["XML", "1.0"],
["XML", "2.0"],
["XML", "3.0"],
["XML", "100.0"],
["Core", "1"],
["Core", "2"],
["Core", "3"],
["Core", "100"],
["XML", "1"],
["XML", "2"],
["XML", "3"],
["XML", "100"],
["Core", "1.1"],
["Core", "2.1"],
["Core", "3.1"],
["Core", "100.1"],
["XML", "1.1"],
["XML", "2.1"],
["XML", "3.1"],
["XML", "100.1"],
["Core", ""],
["XML", ""],
["core", ""],
["xml", ""],
["CoRe", ""],
["XmL", ""],
[" Core", ""],
[" XML", ""],
["Core ", ""],
["XML ", ""],
["Co re", ""],
["XM L", ""],
["aCore", ""],
["aXML", ""],
["Corea", ""],
["XMLa", ""],
["Coare", ""],
["XMaL", ""],
["Core", " "],
["XML", " "],
["Core", " 1.0"],
["Core", " 2.0"],
["Core", " 3.0"],
["Core", " 100.0"],
["XML", " 1.0"],
["XML", " 2.0"],
["XML", " 3.0"],
["XML", " 100.0"],
["Core", "1.0 "],
["Core", "2.0 "],
["Core", "3.0 "],
["Core", "100.0 "],
["XML", "1.0 "],
["XML", "2.0 "],
["XML", "3.0 "],
["XML", "100.0 "],
["Core", "1. 0"],
["Core", "2. 0"],
["Core", "3. 0"],
["Core", "100. 0"],
["XML", "1. 0"],
["XML", "2. 0"],
["XML", "3. 0"],
["XML", "100. 0"],
["Core", "a1.0"],
["Core", "a2.0"],
["Core", "a3.0"],
["Core", "a100.0"],
["XML", "a1.0"],
["XML", "a2.0"],
["XML", "a3.0"],
["XML", "a100.0"],
["Core", "1.0a"],
["Core", "2.0a"],
["Core", "3.0a"],
["Core", "100.0a"],
["XML", "1.0a"],
["XML", "2.0a"],
["XML", "3.0a"],
["XML", "100.0a"],
["Core", "1.a0"],
["Core", "2.a0"],
["Core", "3.a0"],
["Core", "100.a0"],
["XML", "1.a0"],
["XML", "2.a0"],
["XML", "3.a0"],
["XML", "100.a0"],
["Core", 1],
["Core", 2],
["Core", 3],
["Core", 100],
["XML", 1],
["XML", 2],
["XML", 3],
["XML", 100],
["Core", null],
["XML", null],
["core", null],
["xml", null],
["CoRe", null],
["XmL", null],
[" Core", null],
[" XML", null],
["Core ", null],
["XML ", null],
["Co re", null],
["XM L", null],
["aCore", null],
["aXML", null],
["Corea", null],
["XMLa", null],
["Coare", null],
["XMaL", null],
["Core", undefined],
["XML", undefined],
["This is filler text.", ""],
[null, ""],
[undefined, ""],
];
tests.forEach(function(data) {
test(function() {
assert_equals(document.implementation.hasFeature(data[0], data[1]), true)
}, "hasFeature(" + format_value(data[0]) + ", " + format_value(data[1]) + ")")
})
})
</script>

View File

@ -1,11 +1,9 @@
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>Document.adoptNode</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-adoptnode">
<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>
@ -13,19 +11,19 @@ test(function() {
var y = document.getElementsByTagName("x<")[0]
assert_equals(y.parentNode, document.body)
assert_equals(y.ownerDocument, document)
document.adoptNode(y)
assert_equals(document.adoptNode(y), y)
assert_equals(y.parentNode, null)
assert_equals(y.ownerDocument, document)
var doc = document.implementation.createDocument(null, null, null)
doc.adoptNode(y)
assert_equals(doc.adoptNode(y), 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)
assert_equals(document.adoptNode(x), x);
var doc = document.implementation.createDocument(null, null, null)
doc.adoptNode(x)
assert_equals(doc.adoptNode(x), x)
assert_equals(x.parentNode, null)
assert_equals(x.ownerDocument, doc)
}, "Adopting an Element called ':good:times:' should work.")
@ -33,7 +31,7 @@ test(function() {
var doctype = document.doctype;
assert_equals(doctype.parentNode, document)
assert_equals(doctype.ownerDocument, document)
document.adoptNode(doctype)
assert_equals(document.adoptNode(doctype), doctype)
assert_equals(doctype.parentNode, null)
assert_equals(doctype.ownerDocument, document)
}, "Explicitly adopting a DocumentType should work.")

View File

@ -1,23 +1,39 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.createComment</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createcomment">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-data">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nodevalue">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-textcontent">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-length">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nodetype">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-haschildnodes">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-childnodes">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-firstchild">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-lastchild">
<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);
["\u000b", "a -- b", "a-", "-b"].forEach(function(value) {
test(function() {
var c = document.createComment(value);
assert_true(c instanceof Comment);
assert_true(c instanceof Node);
assert_equals(c.ownerDocument, document);
assert_equals(c.data, value);
assert_equals(c.nodeValue, value);
assert_equals(c.textContent, value);
assert_equals(c.length, value.length);
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);
}, "createComment(" + format_value(value) + ")");
});
});
</script>

View File

@ -1,5 +1,11 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.createElement</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-localname">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-tagname">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-prefix">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-namespaceuri">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
@ -9,6 +15,7 @@ test(function() {
valid = [
//[input, localName],
[undefined, "undefined"],
[null, "null"],
["foo", "foo"],
["f1oo", "f1oo"],
["foo1", "foo1"],
@ -43,17 +50,21 @@ test(function() {
"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]) })
}
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, t[1].toUpperCase())
assert_equals(elt.prefix, null)
assert_equals(elt.namespaceURI, HTMLNS)
}, "createElement(" + format_value(t[0]) + ")");
});
invalid.forEach(function(arg) {
test(function() {
assert_throws("INVALID_CHARACTER_ERR", function() { document.createElement(arg) })
}, "createElement(" + format_value(arg) + ")");
});
})
</script>

View File

@ -1,9 +1,12 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.createElementNS</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelementns">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
// TODO: valid arguments
test(function() {
var invalidNames = [
"",

View File

@ -1,22 +1,28 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.createEvent</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createevent">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
// TODO: values of attributes
function testAlias(arg, iface) {
test(function() {
if (iface in window) {
if (iface === "Event" || iface in window) {
var ev = document.createEvent(arg);
assert_true(ev instanceof window[iface]);
assert_true(ev instanceof Event);
}
}, arg + " should be an alias for " + iface + ".");
}
[
["Event", "Event"],
["Events", "Event"],
["HTMLEvents", "Event"],
["MouseEvent", "MouseEvent"],
["MouseEvents", "MouseEvent"],
["MutationEvents", "MutationEvent"],
["UIEvent", "UIEvent"]
["UIEvents", "UIEvent"]
].forEach(function(alias) {
testAlias(alias[0], alias[1]);
@ -28,5 +34,9 @@ test(function() {
assert_throws("NOT_SUPPORTED_ERR", function() {
var evt = document.createEvent("foo");
});
assert_throws("NOT_SUPPORTED_ERR", function() {
// 'LATIN CAPITAL LETTER I WITH DOT ABOVE' (U+0130)
var evt = document.createEvent("U\u0130Event");
});
}, "Should throw NOT_SUPPORTED_ERR for unrecognized arguments");
</script>

View File

@ -1,7 +1,9 @@
<?xml-stylesheet href="support/style.css" type="text/css"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Document.createProcessingInstruction</title>
<title>ProcessingInstruction literals</title>
<link rel="help" href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-processinginstruction-target"/>
<link rel="help" href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-data"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>

View File

@ -1,5 +1,10 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.createProcessingInstruction in HTML documents</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createprocessinginstruction">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-processinginstruction-target">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-data">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>

View File

@ -1,6 +1,10 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Document.createProcessingInstruction in XML documents</title>
<link rel="help" href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createprocessinginstruction"/>
<link rel="help" href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-processinginstruction-target"/>
<link rel="help" href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-data"/>
<link rel="help" href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>

View File

@ -1,5 +1,7 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.getElementById with an empty string</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-getelementbyid">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>

View File

@ -1,15 +1,18 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.getElementsByTagName</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-getelementsbytagname">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id="log"></div>
<script>
// TODO: getElementsByTagName("*")
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"),
var firstCollection = document.getElementsByTagName("html"),
secondCollection = document.getElementsByTagName("html")
assert_true(firstCollection !== secondCollection || firstCollection === secondCollection,
"Caching is allowed.")
})
test(function() {

View File

@ -1,16 +1,18 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.getElementsByTagNameNS</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-getelementsbytagnamens">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id="log"></div>
<script>
// TODO: Actual tests; wildcards.
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.")
var firstCollection = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html"),
secondCollection = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html")
assert_true(firstCollection !== secondCollection || firstCollection === secondCollection,
"Caching is allowed.")
})
</script>

View File

@ -1,6 +1,7 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.importNode</title>
<link rel="stylesheet" href="/resources/testharness.css">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-importnode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>DocumentType.remove</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-childnode-remove">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="ChildNode-remove.js"></script>
<div id=log></div>
<script>
test(function() {
var node = document.implementation.createDocumentType("html", "", "");
var parent = document.implementation.createDocument(null, "", null);
testRemove(node, parent, "doctype");
});
</script>

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Element.remove</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-childnode-remove">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="ChildNode-remove.js"></script>
<div id=log></div>
<script>
test(function() {
var node = document.createElement("div");
var parent = document.createElement("div");
testRemove(node, parent, "element");
});
</script>

View File

@ -5,14 +5,18 @@
<div id="log"></div>
<script>
test(function() {
var HTMLNS = "http://www.w3.org/1999/xhtml",
SVGNS = "http://www.w3.org/2000/svg"
var HTMLNS = "http://www.w3.org/1999/xhtml"
assert_equals(document.createElementNS(HTMLNS, "I").tagName, "I")
assert_equals(document.createElementNS(HTMLNS, "i").tagName, "I")
assert_equals(document.createElementNS(HTMLNS, "x:b").tagName, "X:B")
}, "tagName should upper-case for HTML elements in HTML documents.")
test(function() {
var SVGNS = "http://www.w3.org/2000/svg"
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")
})
assert_equals(document.createElementNS(SVGNS, "s:svg").tagName, "s:svg")
assert_equals(document.createElementNS(SVGNS, "s:SVG").tagName, "s:SVG")
}, "tagName should not upper-case for SVG elements in HTML documents.")
test(function() {
if ("DOMParser" in window) {
var xmlel = new DOMParser()

View File

@ -39,11 +39,20 @@ test(function() {
var e = document.createEvent("Event")
e.initEvent("type", false, false)
var called = []
var target = document.createElement("div")
target.addEventListener("type", function() {
called.push("First")
throw new Error()
}, false);
}, false)
target.addEventListener("type", function() {
called.push("Second")
}, false)
assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
assert_array_equals(called, ["First", "Second"],
"Should have continued to call other event listeners")
}, "Exceptions from event listeners must not be propagated.")
</script>

View File

@ -1,37 +1,59 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Node.appendChild</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-appendchild">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src=about:blank></iframe>
<script>
function testHRE(node) {
// TODO: Exhaustive tests
function testLeaf(node, desc) {
// WebIDL.
test(function() {
assert_throws(new TypeError(), function() { node.appendChild(null) })
}, "Appending null to a " + desc)
// Pre-insert step 1.
test(function() {
assert_throws("HIERARCHY_REQUEST_ERR", function() { node.appendChild(document.createTextNode("fail")) })
assert_throws(new TypeError(), function() { node.appendChild(null) })
})
}, "Appending to a " + desc)
}
// WebIDL.
test(function() {
assert_throws(new TypeError(), function() { document.body.appendChild(null) })
assert_throws(new TypeError(), function() { document.body.appendChild({'a':'b'}) })
}, "WebIDL tests")
// WebIDL and pre-insert step 1.
test(function() {
testLeaf(document.createTextNode("Foo"), "text node")
testLeaf(document.createComment("Foo"), "comment")
testLeaf(document.doctype, "doctype")
}, "Appending to a leaf node.")
// Pre-insert step 5.
test(function() {
var frameDoc = frames[0].document
assert_throws("HIERARCHY_REQUEST_ERR", function() { document.body.appendChild(frameDoc) })
}, "Appending a document")
// Pre-insert step 8.
test(function() {
var frameDoc = frames[0].document
var s = frameDoc.createElement("a")
assert_equals(s.ownerDocument, frameDoc)
document.body.appendChild(s)
assert_equals(s.ownerDocument, document)
assert_throws("HIERARCHY_REQUEST_ERR", function() { document.body.appendChild(frameDoc) })
s = frameDoc.createElement("b")
}, "Adopting an orphan")
test(function() {
var frameDoc = frames[0].document
var s = frameDoc.createElement("b")
assert_equals(s.ownerDocument, frameDoc)
frameDoc.body.appendChild(s)
assert_equals(s.ownerDocument, frameDoc)
document.body.appendChild(s)
assert_equals(s.ownerDocument, document)
assert_throws(new TypeError(), function() { document.body.appendChild(null) })
assert_throws(new TypeError(), function() { document.body.appendChild({'a':'b'}) })
testHRE(document.createTextNode("Foo"));
testHRE(document.createComment("Foo"));
testHRE(document.doctype);
})
}, "Adopting a non-orphan")
</script>

View File

@ -1,5 +1,7 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Node.cloneNode</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-clonenode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>

View File

@ -32,4 +32,23 @@ test(function() {
assert_equals(t3.data, "34")
assert_equals(t4.data, "4")
})
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=19837
test(function() {
var div = document.createElement("div")
var t1 = div.appendChild(document.createTextNode(""))
var t2 = div.appendChild(document.createTextNode("a"))
var t3 = div.appendChild(document.createTextNode(""))
assert_array_equals(div.childNodes, [t1, t2, t3])
div.normalize();
assert_array_equals(div.childNodes, [t2])
}, "Empty text nodes separated by a non-empty text node")
test(function() {
var div = document.createElement("div")
var t1 = div.appendChild(document.createTextNode(""))
var t2 = div.appendChild(document.createTextNode(""))
assert_array_equals(div.childNodes, [t1, t2])
div.normalize();
assert_array_equals(div.childNodes, [])
}, "Empty text nodes")
</script>

View File

@ -47,7 +47,6 @@ test(function() {
});
}, "If child's parent is not the context node, a NotFoundError exception should be thrown")
test(function() {
// TODO: https://www.w3.org/Bugs/Public/show_bug.cgi?id=17318
var nodes = [
document.implementation.createDocumentType("html", "", ""),
document.createTextNode("text"),
@ -58,7 +57,7 @@ test(function() {
var a = document.createElement("div");
var b = document.createElement("div");
nodes.forEach(function(node) {
assert_throws("NotFoundError", function() {
assert_throws("HierarchyRequestError", function() {
node.replaceChild(a, b);
});
});

View File

@ -1,5 +1,9 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Attributes tests</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#attr">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-setattribute">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-setattributens">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="attributes.js"></script>

View File

@ -1,5 +1,17 @@
<meta charset=utf8>
<script>is_html=true;</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Tests for case-sensitivity in APIs</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelementns">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-getelementsbytagname">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-getelementsbytagnamens">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-setattribute">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-setattributens">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-hasattribute">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-hasattributens">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-getelementsbytagname">
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-getelementsbytagnamens">
<script>var is_html = true;</script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="case.js"></script>

View File

@ -15,6 +15,7 @@ DIRS := \
MOCHITEST_FILES := \
test_event_constructor_js.html \
test_missing_arguments.html \
test_storage_local_builtins.html \
test_storage_local_clear_js.html \
test_storage_local_getitem_js.html \
test_storage_local_index_js.html \
@ -22,6 +23,7 @@ MOCHITEST_FILES := \
test_storage_local_length_js.html \
test_storage_local_removeitem_js.html \
test_storage_local_setitem_js.html \
test_storage_session_builtins.html \
test_storage_session_clear_js.html \
test_storage_session_getitem_js.html \
test_storage_session_index_js.html \
@ -29,6 +31,7 @@ MOCHITEST_FILES := \
test_storage_session_length_js.html \
test_storage_session_removeitem_js.html \
test_storage_session_setitem_js.html \
storage_builtins.js \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,15 @@
function test_storage_builtins(aStorage) {
test(function() {
aStorage.clear();
assert_equals(aStorage.length, 0, "aStorage.length");
var builtins = ["key", "getItem", "setItem", "removeItem", "clear"];
var origBuiltins = builtins.map(function(b) { return Storage.prototype[b]; });
assert_array_equals(builtins.map(function(b) { return aStorage[b]; }), origBuiltins, "a");
builtins.forEach(function(b) { aStorage[b] = b; });
assert_array_equals(builtins.map(function(b) { return aStorage[b]; }), origBuiltins, "b");
assert_array_equals(builtins.map(function(b) { return aStorage.getItem(b); }), builtins, "c");
assert_equals(aStorage.length, builtins.length, "aStorage.length");
});
}

View File

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="storage_builtins.js"></script>
</head>
<body>
<h1>storage_local_builtins</h1>
<div id="log"></div>
<script>
test_storage_builtins(localStorage);
</script>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="storage_builtins.js"></script>
</head>
<body>
<h1>storage_session_builtins</h1>
<div id="log"></div>
<script>
test_storage_builtins(sessionStorage);
</script>
</body>
</html>