import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo

This commit is contained in:
Roy Tam 2018-01-19 03:59:58 +08:00
commit dcd9973243
150858 changed files with 23884658 additions and 0 deletions

View file

@ -0,0 +1,34 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Node.appendChild applied to CharacterData</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-appendchild">
<link rel=help href="https://dom.spec.whatwg.org/#introduction-to-the-dom">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function create(type) {
switch (type) {
case "Text": return document.createTextNode("test"); break;
case "Comment": return document.createComment("test"); break;
case "ProcessingInstruction": return document.createProcessingInstruction("target", "test"); break;
}
}
function testNode(type1, type2) {
test(function() {
var node1 = create(type1);
var node2 = create(type2);
assert_throws("HierarchyRequestError", function () {
node1.appendChild(node2);
}, "CharacterData type " + type1 + " must not have children");
}, type1 + ".appendChild(" + type2 + ")");
}
var types = ["Text", "Comment", "ProcessingInstruction"];
types.forEach(function(type1) {
types.forEach(function(type2) {
testNode(type1, type2);
});
});
</script>

View file

@ -0,0 +1,70 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.appendData</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-appenddata">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(create, type) {
test(function() {
var node = create()
assert_equals(node.data, "test")
node.appendData("bar")
assert_equals(node.data, "testbar")
}, type + ".appendData('bar')")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.appendData("")
assert_equals(node.data, "test")
}, type + ".appendData('')")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.appendData(", append more 資料,測試資料");
assert_equals(node.data, "test, append more 資料,測試資料");
assert_equals(node.length, 25);
}, type + ".appendData(non-ASCII)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.appendData(null)
assert_equals(node.data, "testnull")
}, type + ".appendData(null)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.appendData(undefined)
assert_equals(node.data, "testundefined")
}, type + ".appendData(undefined)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.appendData("", "bar")
assert_equals(node.data, "test")
}, type + ".appendData('', 'bar')")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws(new TypeError(), function() { node.appendData() });
assert_equals(node.data, "test")
}, type + ".appendData()")
}
testNode(function() { return document.createTextNode("test") }, "Text")
testNode(function() { return document.createComment("test") }, "Comment")
</script>

View file

@ -0,0 +1,82 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.data</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(create, type) {
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.length, 4)
}, type + ".data initial value")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = null;
assert_equals(node.data, "")
assert_equals(node.length, 0)
}, type + ".data = null")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = undefined;
assert_equals(node.data, "undefined")
assert_equals(node.length, 9)
}, type + ".data = undefined")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = 0;
assert_equals(node.data, "0")
assert_equals(node.length, 1)
}, type + ".data = 0")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "";
assert_equals(node.data, "")
assert_equals(node.length, 0)
}, type + ".data = ''")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "--";
assert_equals(node.data, "--")
assert_equals(node.length, 2)
}, type + ".data = '--'")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "資料";
assert_equals(node.data, "資料")
assert_equals(node.length, 2)
}, type + ".data = '資料'")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "🌠 test 🌠 TEST";
assert_equals(node.data, "🌠 test 🌠 TEST")
assert_equals(node.length, 15) // Counting UTF-16 code units
}, type + ".data = '🌠 test 🌠 TEST'")
}
testNode(function() { return document.createTextNode("test") }, "Text")
testNode(function() { return document.createComment("test") }, "Comment")
</script>

View file

@ -0,0 +1,95 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.deleteData</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-deletedata">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(create, type) {
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(5, 10) })
assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(5, 0) })
assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(-1, 10) })
assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(-1, 0) })
}, type + ".deleteData() out of bounds")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.deleteData(0, 2)
assert_equals(node.data, "st")
}, type + ".deleteData() at the start")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.deleteData(2, 10)
assert_equals(node.data, "te")
}, type + ".deleteData() at the end")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.deleteData(1, 1)
assert_equals(node.data, "tst")
}, type + ".deleteData() in the middle")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.deleteData(2, 0)
assert_equals(node.data, "test")
node.deleteData(0, 0)
assert_equals(node.data, "test")
}, type + ".deleteData() with zero count")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.deleteData(2, -1)
assert_equals(node.data, "te")
}, type + ".deleteData() with small negative count")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.deleteData(1, -0x100000000 + 2)
assert_equals(node.data, "tt")
}, type + ".deleteData() with large negative count")
test(function() {
var node = create()
node.data = "This is the character data test, append more 資料,更多測試資料";
node.deleteData(40, 5);
assert_equals(node.data, "This is the character data test, append 資料,更多測試資料");
node.deleteData(45, 2);
assert_equals(node.data, "This is the character data test, append 資料,更多資料");
}, type + ".deleteData() with non-ascii data")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "🌠 test 🌠 TEST"
node.deleteData(5, 8); // Counting UTF-16 code units
assert_equals(node.data, "🌠 teST");
}, type + ".deleteData() with non-BMP data")
}
testNode(function() { return document.createTextNode("test") }, "Text")
testNode(function() { return document.createComment("test") }, "Comment")
</script>

View file

@ -0,0 +1,90 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.insertData</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-insertdata">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(create, type) {
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "x") })
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "") })
}, type + ".insertData() out of bounds")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(-1, "x") })
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(-0x100000000 + 5, "x") })
}, type + ".insertData() negative out of bounds")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.insertData(-0x100000000 + 2, "X")
assert_equals(node.data, "teXst")
}, type + ".insertData() negative in bounds")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.insertData(0, "")
assert_equals(node.data, "test")
}, type + ".insertData('')")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.insertData(0, "X")
assert_equals(node.data, "Xtest")
}, type + ".insertData() at the start")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.insertData(2, "X")
assert_equals(node.data, "teXst")
}, type + ".insertData() in the middle")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.insertData(4, "ing")
assert_equals(node.data, "testing")
}, type + ".insertData() at the end")
test(function() {
var node = create()
node.data = "This is the character data, append more 資料,測試資料";
node.insertData(26, " test");
assert_equals(node.data, "This is the character data test, append more 資料,測試資料");
node.insertData(48, "更多");
assert_equals(node.data, "This is the character data test, append more 資料,更多測試資料");
}, type + ".insertData() with non-ascii data")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "🌠 test 🌠 TEST"
node.insertData(5, "--"); // Counting UTF-16 code units
assert_equals(node.data, "🌠 te--st 🌠 TEST");
}, type + ".insertData() with non-BMP data")
}
testNode(function() { return document.createTextNode("test") }, "Text")
testNode(function() { return document.createComment("test") }, "Comment")
</script>

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.remove</title>
<link rel=help href="https://dom.spec.whatwg.org/#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>
var text, text_parent,
comment, comment_parent,
pi, pi_parent;
setup(function() {
text = document.createTextNode("text");
text_parent = document.createElement("div");
comment = document.createComment("comment");
comment_parent = document.createElement("div");
pi = document.createProcessingInstruction("foo", "bar");
pi_parent = document.createElement("div");
});
testRemove(text, text_parent, "text");
testRemove(comment, comment_parent, "comment");
testRemove(pi, pi_parent, "PI");
</script>

View file

@ -0,0 +1,163 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.replaceData</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-replacedata">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(create, type) {
// Step 2.
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws("IndexSizeError", function() { node.replaceData(5, 1, "x") })
assert_throws("IndexSizeError", function() { node.replaceData(5, 0, "") })
assert_throws("IndexSizeError", function() { node.replaceData(-1, 1, "x") })
assert_throws("IndexSizeError", function() { node.replaceData(-1, 0, "") })
assert_equals(node.data, "test")
}, type + ".replaceData() with invalid offset")
// Step 3.
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(2, 10, "yo")
assert_equals(node.data, "teyo")
}, type + ".replaceData() with clamped count")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(2, -1, "yo")
assert_equals(node.data, "teyo")
}, type + ".replaceData() with negative clamped count")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(0, 0, "yo")
assert_equals(node.data, "yotest")
}, type + ".replaceData() before the start")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(0, 2, "y")
assert_equals(node.data, "yst")
}, type + ".replaceData() at the start (shorter)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(0, 2, "yo")
assert_equals(node.data, "yost")
}, type + ".replaceData() at the start (equal length)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(0, 2, "yoa")
assert_equals(node.data, "yoast")
}, type + ".replaceData() at the start (longer)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(1, 2, "o")
assert_equals(node.data, "tot")
}, type + ".replaceData() in the middle (shorter)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(1, 2, "yo")
assert_equals(node.data, "tyot")
}, type + ".replaceData() in the middle (equal length)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(1, 1, "waddup")
assert_equals(node.data, "twaddupst")
node.replaceData(1, 1, "yup")
assert_equals(node.data, "tyupaddupst")
}, type + ".replaceData() in the middle (longer)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(1, 20, "yo")
assert_equals(node.data, "tyo")
}, type + ".replaceData() at the end (shorter)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(2, 20, "yo")
assert_equals(node.data, "teyo")
}, type + ".replaceData() at the end (same length)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(4, 20, "yo")
assert_equals(node.data, "testyo")
}, type + ".replaceData() at the end (longer)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(0, 4, "quux")
assert_equals(node.data, "quux")
}, type + ".replaceData() the whole string")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.replaceData(0, 4, "")
assert_equals(node.data, "")
}, type + ".replaceData() with the empty string")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "This is the character data test, append 資料,更多資料";
node.replaceData(33, 6, "other");
assert_equals(node.data, "This is the character data test, other 資料,更多資料");
node.replaceData(44, 2, "文字");
assert_equals(node.data, "This is the character data test, other 資料,更多文字");
}, type + ".replaceData() with non-ASCII data")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "🌠 test 🌠 TEST"
node.replaceData(5, 8, "--"); // Counting UTF-16 code units
assert_equals(node.data, "🌠 te--ST");
}, type + ".replaceData() with non-BMP data")
}
testNode(function() { return document.createTextNode("test") }, "Text")
testNode(function() { return document.createComment("test") }, "Comment")
</script>

View file

@ -0,0 +1,137 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.substringData</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-substringdata">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(create, type) {
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws(new TypeError(), function() { node.substringData() })
assert_throws(new TypeError(), function() { node.substringData(0) })
}, type + ".substringData() with too few arguments")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 1, "test"), "t")
}, type + ".substringData() with too many arguments")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws("IndexSizeError", function() { node.substringData(5, 0) })
assert_throws("IndexSizeError", function() { node.substringData(6, 0) })
assert_throws("IndexSizeError", function() { node.substringData(-1, 0) })
}, type + ".substringData() with invalid offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 1), "t")
assert_equals(node.substringData(1, 1), "e")
assert_equals(node.substringData(2, 1), "s")
assert_equals(node.substringData(3, 1), "t")
assert_equals(node.substringData(4, 1), "")
}, type + ".substringData() with in-bounds offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 0), "")
assert_equals(node.substringData(1, 0), "")
assert_equals(node.substringData(2, 0), "")
assert_equals(node.substringData(3, 0), "")
assert_equals(node.substringData(4, 0), "")
}, type + ".substringData() with zero count")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0x100000000 + 0, 1), "t")
assert_equals(node.substringData(0x100000000 + 1, 1), "e")
assert_equals(node.substringData(0x100000000 + 2, 1), "s")
assert_equals(node.substringData(0x100000000 + 3, 1), "t")
assert_equals(node.substringData(0x100000000 + 4, 1), "")
}, type + ".substringData() with very large offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(-0x100000000 + 2, 1), "s")
}, type + ".substringData() with negative offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData("test", 3), "tes")
}, type + ".substringData() with string offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 1), "t")
assert_equals(node.substringData(0, 2), "te")
assert_equals(node.substringData(0, 3), "tes")
assert_equals(node.substringData(0, 4), "test")
}, type + ".substringData() with in-bounds count")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 5), "test")
assert_equals(node.substringData(2, 20), "st")
}, type + ".substringData() with large count")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(2, 0x100000000 + 1), "s")
}, type + ".substringData() with very large count")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, -1), "test")
assert_equals(node.substringData(0, -0x100000000 + 2), "te")
}, type + ".substringData() with negative count")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "This is the character data test, other 資料,更多文字"
assert_equals(node.substringData(12, 4), "char")
assert_equals(node.substringData(39, 2), "資料")
}, type + ".substringData() with non-ASCII data")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "🌠 test 🌠 TEST"
assert_equals(node.substringData(5, 8), "st 🌠 TE") // Counting UTF-16 code units
}, type + ".substringData() with non-BMP data")
}
testNode(function() { return document.createTextNode("test") }, "Text")
testNode(function() { return document.createComment("test") }, "Comment")
</script>

View file

@ -0,0 +1,74 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Splitting and joining surrogate pairs in CharacterData methods</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-substringdata">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-replacedata">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-insertdata">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-deletedata">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(create, type) {
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "🌠 test 🌠 TEST"
assert_equals(node.substringData(1, 8), "\uDF20 test \uD83C")
}, type + ".substringData() splitting surrogate pairs")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "🌠 test 🌠 TEST"
node.replaceData(1, 4, "--");
assert_equals(node.data, "\uD83C--st 🌠 TEST");
node.replaceData(1, 2, "\uDF1F ");
assert_equals(node.data, "🌟 st 🌠 TEST");
node.replaceData(5, 2, "---");
assert_equals(node.data, "🌟 st---\uDF20 TEST");
node.replaceData(6, 2, " \uD83D");
assert_equals(node.data, "🌟 st- 🜠 TEST");
}, type + ".replaceData() splitting and creating surrogate pairs")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "🌠 test 🌠 TEST"
node.deleteData(1, 4);
assert_equals(node.data, "\uD83Cst 🌠 TEST");
node.deleteData(1, 4);
assert_equals(node.data, "🌠 TEST");
}, type + ".deleteData() splitting and creating surrogate pairs")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.data = "🌠 test 🌠 TEST"
node.insertData(1, "--");
assert_equals(node.data, "\uD83C--\uDF20 test 🌠 TEST");
node.insertData(1, "\uDF1F ");
assert_equals(node.data, "🌟 --\uDF20 test 🌠 TEST");
node.insertData(5, " \uD83D");
assert_equals(node.data, "🌟 -- 🜠 test 🌠 TEST");
}, type + ".insertData() splitting and creating surrogate pairs")
}
testNode(function() { return document.createTextNode("test") }, "Text")
testNode(function() { return document.createComment("test") }, "Comment")
</script>

View file

@ -0,0 +1,166 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>ChildNode.after</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-childnode-after">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function test_after(child, nodeName, innerHTML) {
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.after();
assert_equals(parent.innerHTML, innerHTML);
}, nodeName + '.after() without any argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.after(null);
var expected = innerHTML + 'null';
assert_equals(parent.innerHTML, expected);
}, nodeName + '.after() with null as an argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.after(undefined);
var expected = innerHTML + 'undefined';
assert_equals(parent.innerHTML, expected);
}, nodeName + '.after() with undefined as an argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.after('');
assert_equals(parent.lastChild.data, '');
}, nodeName + '.after() with the empty string as an argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.after('text');
var expected = innerHTML + 'text';
assert_equals(parent.innerHTML, expected);
}, nodeName + '.after() with only text as an argument.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
parent.appendChild(child);
child.after(x);
var expected = innerHTML + '<x></x>';
assert_equals(parent.innerHTML, expected);
}, nodeName + '.after() with only one element as an argument.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
parent.appendChild(child);
child.after(x, 'text');
var expected = innerHTML + '<x></x>text';
assert_equals(parent.innerHTML, expected);
}, nodeName + '.after() with one element and text as arguments.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.after('text', child);
var expected = 'text' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.after() with context object itself as the argument.');
test(function() {
var parent = document.createElement('div')
var x = document.createElement('x');
parent.appendChild(x);
parent.appendChild(child);
child.after(child, x);
var expected = innerHTML + '<x></x>';
assert_equals(parent.innerHTML, expected);
}, nodeName + '.after() with context object itself and node as the arguments, switching positions.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
var y = document.createElement('y');
var z = document.createElement('z');
parent.appendChild(y);
parent.appendChild(child);
parent.appendChild(x);
child.after(x, y, z);
var expected = innerHTML + '<x></x><y></y><z></z>';
assert_equals(parent.innerHTML, expected);
}, nodeName + '.after() with all siblings of child as arguments.');
test(function() {
var parent = document.createElement('div')
var x = document.createElement('x');
var y = document.createElement('y');
var z = document.createElement('z');
parent.appendChild(child);
parent.appendChild(x);
parent.appendChild(y);
parent.appendChild(z);
child.after(x, y);
var expected = innerHTML + '<x></x><y></y><z></z>';
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with some siblings of child as arguments; no changes in tree; viable sibling is first child.');
test(function() {
var parent = document.createElement('div')
var v = document.createElement('v');
var x = document.createElement('x');
var y = document.createElement('y');
var z = document.createElement('z');
parent.appendChild(child);
parent.appendChild(v);
parent.appendChild(x);
parent.appendChild(y);
parent.appendChild(z);
child.after(v, x);
var expected = innerHTML + '<v></v><x></x><y></y><z></z>';
assert_equals(parent.innerHTML, expected);
}, nodeName + '.after() with some siblings of child as arguments; no changes in tree.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
var y = document.createElement('y');
parent.appendChild(child);
parent.appendChild(x);
parent.appendChild(y);
child.after(y, x);
var expected = innerHTML + '<y></y><x></x>';
assert_equals(parent.innerHTML, expected);
}, nodeName + '.after() when pre-insert behaves like append.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
var y = document.createElement('y');
parent.appendChild(child);
parent.appendChild(x);
parent.appendChild(document.createTextNode('1'));
parent.appendChild(y);
child.after(x, '2');
var expected = innerHTML + '<x></x>21<y></y>';
assert_equals(parent.innerHTML, expected);
}, nodeName + '.after() with one sibling of child and text as arguments.');
test(function() {
var x = document.createElement('x');
var y = document.createElement('y');
x.after(y);
assert_equals(x.nextSibling, null);
}, nodeName + '.after() on a child without any parent.');
}
test_after(document.createComment('test'), 'Comment', '<!--test-->');
test_after(document.createElement('test'), 'Element', '<test></test>');
test_after(document.createTextNode('test'), 'Text', 'test');
</script>
</html>

View file

@ -0,0 +1,166 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>ChildNode.before</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-childnode-before">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function test_before(child, nodeName, innerHTML) {
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.before();
assert_equals(parent.innerHTML, innerHTML);
}, nodeName + '.before() without any argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.before(null);
var expected = 'null' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with null as an argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.before(undefined);
var expected = 'undefined' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with undefined as an argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.before('');
assert_equals(parent.firstChild.data, '');
}, nodeName + '.before() with the empty string as an argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.before('text');
var expected = 'text' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with only text as an argument.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
parent.appendChild(child);
child.before(x);
var expected = '<x></x>' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with only one element as an argument.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
parent.appendChild(child);
child.before(x, 'text');
var expected = '<x></x>text' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with one element and text as arguments.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.before('text', child);
var expected = 'text' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with context object itself as the argument.');
test(function() {
var parent = document.createElement('div')
var x = document.createElement('x');
parent.appendChild(child);
parent.appendChild(x);
child.before(x, child);
var expected = '<x></x>' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with context object itself and node as the arguments, switching positions.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
var y = document.createElement('y');
var z = document.createElement('z');
parent.appendChild(y);
parent.appendChild(child);
parent.appendChild(x);
child.before(x, y, z);
var expected = '<x></x><y></y><z></z>' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with all siblings of child as arguments.');
test(function() {
var parent = document.createElement('div')
var x = document.createElement('x');
var y = document.createElement('y');
var z = document.createElement('z');
parent.appendChild(x);
parent.appendChild(y);
parent.appendChild(z);
parent.appendChild(child);
child.before(y, z);
var expected = '<x></x><y></y><z></z>' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with some siblings of child as arguments; no changes in tree; viable sibling is first child.');
test(function() {
var parent = document.createElement('div')
var v = document.createElement('v');
var x = document.createElement('x');
var y = document.createElement('y');
var z = document.createElement('z');
parent.appendChild(v);
parent.appendChild(x);
parent.appendChild(y);
parent.appendChild(z);
parent.appendChild(child);
child.before(y, z);
var expected = '<v></v><x></x><y></y><z></z>' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with some siblings of child as arguments; no changes in tree.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
var y = document.createElement('y');
parent.appendChild(x);
parent.appendChild(y);
parent.appendChild(child);
child.before(y, x);
var expected = '<y></y><x></x>' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() when pre-insert behaves like prepend.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
parent.appendChild(x);
parent.appendChild(document.createTextNode('1'));
var y = document.createElement('y');
parent.appendChild(y);
parent.appendChild(child);
child.before(x, '2');
var expected = '1<y></y><x></x>2' + innerHTML;
assert_equals(parent.innerHTML, expected);
}, nodeName + '.before() with one sibling of child and text as arguments.');
test(function() {
var x = document.createElement('x');
var y = document.createElement('y');
x.before(y);
assert_equals(x.previousSibling, null);
}, nodeName + '.before() on a child without any parent.');
}
test_before(document.createComment('test'), 'Comment', '<!--test-->');
test_before(document.createElement('test'), 'Element', '<test></test>');
test_before(document.createTextNode('test'), 'Text', 'test');
</script>
</html>

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

@ -0,0 +1,110 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>ChildNode.replaceWith</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-childnode-replaceWith">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function test_replaceWith(child, nodeName, innerHTML) {
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.replaceWith();
assert_equals(parent.innerHTML, '');
}, nodeName + '.replaceWith() without any argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.replaceWith(null);
assert_equals(parent.innerHTML, 'null');
}, nodeName + '.replaceWith() with null as an argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.replaceWith(undefined);
assert_equals(parent.innerHTML, 'undefined');
}, nodeName + '.replaceWith() with undefined as an argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.replaceWith('');
assert_equals(parent.innerHTML, '');
}, nodeName + '.replaceWith() with empty string as an argument.');
test(function() {
var parent = document.createElement('div');
parent.appendChild(child);
child.replaceWith('text');
assert_equals(parent.innerHTML, 'text');
}, nodeName + '.replaceWith() with only text as an argument.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
parent.appendChild(child);
child.replaceWith(x);
assert_equals(parent.innerHTML, '<x></x>');
}, nodeName + '.replaceWith() with only one element as an argument.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
var y = document.createElement('y');
var z = document.createElement('z');
parent.appendChild(y);
parent.appendChild(child);
parent.appendChild(x);
child.replaceWith(x, y, z);
assert_equals(parent.innerHTML, '<x></x><y></y><z></z>');
}, nodeName + '.replaceWith() with sibling of child as arguments.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
parent.appendChild(child);
parent.appendChild(x);
parent.appendChild(document.createTextNode('1'));
child.replaceWith(x, '2');
assert_equals(parent.innerHTML, '<x></x>21');
}, nodeName + '.replaceWith() with one sibling of child and text as arguments.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
parent.appendChild(child);
parent.appendChild(x);
parent.appendChild(document.createTextNode('text'));
child.replaceWith(x, child);
assert_equals(parent.innerHTML, '<x></x>' + innerHTML + 'text');
}, nodeName + '.replaceWith() with one sibling of child and child itself as arguments.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
parent.appendChild(child);
child.replaceWith(x, 'text');
assert_equals(parent.innerHTML, '<x></x>text');
}, nodeName + '.replaceWith() with one element and text as arguments.');
test(function() {
var parent = document.createElement('div');
var x = document.createElement('x');
var y = document.createElement('y');
parent.appendChild(x);
parent.appendChild(y);
child.replaceWith(x, y);
assert_equals(parent.innerHTML, '<x></x><y></y>');
}, nodeName + '.replaceWith() on a parentless child with two elements as arguments.');
}
test_replaceWith(document.createComment('test'), 'Comment', '<!--test-->');
test_replaceWith(document.createElement('test'), 'Element', '<test></test>');
test_replaceWith(document.createTextNode('test'), 'Text', 'test');
</script>
</html>

View file

@ -0,0 +1,77 @@
function test_constructor(ctor) {
test(function() {
var object = new window[ctor]();
assert_equals(Object.getPrototypeOf(object),
window[ctor].prototype, "Prototype chain: " + ctor);
assert_equals(Object.getPrototypeOf(Object.getPrototypeOf(object)),
CharacterData.prototype, "Prototype chain: CharacterData");
assert_equals(Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(object))),
Node.prototype, "Prototype chain: Node");
}, "new " + ctor + "(): prototype chain");
test(function() {
var object = new window[ctor]();
assert_true(object instanceof Node, "Should be a Node");
assert_true(object instanceof CharacterData, "Should be a CharacterData");
assert_true(object instanceof window[ctor], "Should be a " + ctor);
}, "new " + ctor + "(): instanceof");
test(function() {
var object = new window[ctor]();
assert_equals(object.data, "");
assert_equals(object.nodeValue, "");
assert_equals(object.ownerDocument, document);
}, "new " + ctor + "(): no arguments");
var arguments = [
[undefined, ""],
[null, "null"],
[42, "42"],
["", ""],
["-", "-"],
["--", "--"],
["-->", "-->"],
["<!--", "<!--"],
["\u0000", "\u0000"],
["\u0000test", "\u0000test"],
["&amp;", "&amp;"],
];
arguments.forEach(function(a) {
var argument = a[0], expected = a[1];
test(function() {
var object = new window[ctor](argument);
assert_equals(object.data, expected);
assert_equals(object.nodeValue, expected);
assert_equals(object.ownerDocument, document);
}, "new " + ctor + "(): " + format_value(argument));
});
test(function() {
var called = [];
var object = new window[ctor]({
toString: function() {
called.push("first");
return "text";
}
}, {
toString: function() {
called.push("second");
assert_unreached("Should not look at the second argument.");
}
});
assert_equals(object.data, "text");
assert_equals(object.nodeValue, "text");
assert_equals(object.ownerDocument, document);
assert_array_equals(called, ["first"]);
}, "new " + ctor + "(): two arguments")
async_test("new " + ctor + "() should get the correct ownerDocument across globals").step(function() {
var iframe = document.createElement("iframe");
iframe.onload = this.step_func_done(function() {
var object = new iframe.contentWindow[ctor]();
assert_equals(object.ownerDocument, iframe.contentDocument);
});
document.body.appendChild(iframe);
});
}

View file

@ -0,0 +1,11 @@
<!doctype html>
<meta charset=utf-8>
<title>Comment constructor</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-comment">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="Comment-Text-constructor.js"></script>
<div id="log"></div>
<script>
test_constructor("Comment");
</script>

View file

@ -0,0 +1,166 @@
<!doctype html>
<meta charset=utf-8>
<title>DOMImplementation.createDocument(namespace, qualifiedName, doctype)</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-domimplementation-createdocument">
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-createelementns">
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-nodetype">
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-documentelement">
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-doctype">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="Document-createElementNS.js"></script>
<div id="log"></div>
<script>
var htmlNamespace = "http://www.w3.org/1999/xhtml"
var svgNamespace = "http://www.w3.org/2000/svg"
var mathMLNamespace = "http://www.w3.org/1998/Math/MathML"
// Make DocumentTypes distinct
function my_format_value(val) {
if (val instanceof DocumentType) {
return "DocumentType node <!DOCTYPE " + val.name
+ (val.publicId ? " " + val.publicId : "")
+ (val.systemId ? " " + val.systemId : "")
+ ">";
}
return format_value(val);
}
test(function() {
var tests = createElementNS_tests.map(function(t) {
return [t[0], t[1], null, t[2]]
}).concat([
/* Arrays with four elements:
* the namespace argument
* the qualifiedName argument
* the doctype argument
* the expected exception, or null if none
*/
[null, null, false, new TypeError()],
[null, null, null, null],
[null, "", null, null],
[undefined, null, undefined, null],
[undefined, undefined, undefined, null],
[undefined, "", undefined, null],
["http://example.com/", null, null, null],
["http://example.com/", "", null, null],
["/", null, null, null],
["/", "", 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/2000/xmlns/", null, null, null],
["http://www.w3.org/2000/xmlns/", "", null, null],
["foo:", null, null, null],
["foo:", "", null, null],
[null, null, document.implementation.createDocumentType("foo", "", ""), null],
[null, null, document.doctype, null], // This causes a horrible WebKit bug (now fixed in trunk).
[null, null, function() {
var foo = document.implementation.createDocumentType("bar", "", "");
document.implementation.createDocument(null, null, foo);
return foo;
}(), null], // DOCTYPE already associated with a document.
[null, null, function() {
var bar = document.implementation.createDocument(null, null, null);
return bar.implementation.createDocumentType("baz", "", "");
}(), null], // DOCTYPE created by a different implementation.
[null, null, function() {
var bar = document.implementation.createDocument(null, null, null);
var magic = bar.implementation.createDocumentType("quz", "", "");
bar.implementation.createDocument(null, null, magic);
return magic;
}(), null], // 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],
[htmlNamespace, "", null, null],
[svgNamespace, "", null, null],
[mathMLNamespace, "", null, null],
[null, "html", null, null],
[null, "svg", null, null],
[null, "math", null, null],
[null, "", document.implementation.createDocumentType("html",
"-//W3C//DTD XHTML 1.0 Transitional//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")],
[null, "", document.implementation.createDocumentType("svg",
"-//W3C//DTD SVG 1.1//EN",
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd")],
[null, "", document.implementation.createDocumentType("math",
"-//W3C//DTD MathML 2.0//EN",
"http://www.w3.org/Math/DTD/mathml2/mathml2.dtd")],
])
tests.forEach(function(t, i) {
var namespace = t[0], qualifiedName = t[1], doctype = t[2], expected = t[3]
test(function() {
if (expected != null) {
assert_throws(expected, function() { document.implementation.createDocument(namespace, qualifiedName, doctype) })
} else {
var doc = document.implementation.createDocument(namespace, qualifiedName, doctype)
assert_equals(doc.nodeType, Node.DOCUMENT_NODE)
assert_equals(doc.nodeType, doc.DOCUMENT_NODE)
assert_equals(doc.nodeName, "#document")
assert_equals(doc.nodeValue, null)
assert_equals(Object.getPrototypeOf(doc), XMLDocument.prototype)
var omitRootElement = qualifiedName === null || String(qualifiedName) === ""
if (omitRootElement) {
assert_equals(doc.documentElement, null)
} else {
var element = doc.documentElement
assert_not_equals(element, null)
assert_equals(element.nodeType, Node.ELEMENT_NODE)
assert_equals(element.ownerDocument, doc)
var qualified = String(qualifiedName), names = []
if (qualified.indexOf(":") >= 0) {
names = qualified.split(":", 2)
} else {
names = [null, qualified]
}
assert_equals(element.prefix, names[0])
assert_equals(element.localName, names[1])
assert_equals(element.namespaceURI, namespace === undefined ? null : namespace)
}
if (!doctype) {
assert_equals(doc.doctype, null)
} else {
assert_equals(doc.doctype, doctype)
assert_equals(doc.doctype.ownerDocument, doc)
}
assert_equals(doc.childNodes.length, !omitRootElement + !!doctype)
}
}, "createDocument test: " + t.map(my_format_value))
if (expected === null) {
test(function() {
var doc = document.implementation.createDocument(namespace, qualifiedName, doctype)
assert_equals(doc.compatMode, "CSS1Compat")
assert_equals(doc.characterSet, "UTF-8")
assert_equals(doc.contentType, namespace == htmlNamespace ? "application/xhtml+xml"
: namespace == svgNamespace ? "image/svg+xml"
: "application/xml")
assert_equals(doc.URL, "about:blank")
assert_equals(doc.documentURI, "about:blank")
assert_equals(doc.createElement("DIV").localName, "DIV");
}, "createDocument test " + i + ": metadata for " +
[namespace, qualifiedName, doctype].map(my_format_value))
test(function() {
var doc = document.implementation.createDocument(namespace, qualifiedName, doctype)
assert_equals(doc.characterSet, "UTF-8", "characterSet");
assert_equals(doc.charset, "UTF-8", "charset");
assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
}, "createDocument test " + i + ": characterSet aliases for " +
[namespace, qualifiedName, doctype].map(my_format_value))
}
})
})
test(function() {
assert_throws(new TypeError(), function() {
document.implementation.createDocument()
}, "createDocument() should throw")
assert_throws(new TypeError(), function() {
document.implementation.createDocument('')
}, "createDocument('') should throw")
}, "createDocument with missing arguments");
</script>

View file

@ -0,0 +1,123 @@
<!doctype html>
<meta charset=utf-8>
<title>DOMImplementation.createDocumentType(qualifiedName, publicId, systemId)</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype">
<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-name">
<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-publicid">
<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-systemid">
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-ownerdocument">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var tests = [
["", "", "", "INVALID_CHARACTER_ERR"],
["test:root", "1234", "", null],
["test:root", "1234", "test", null],
["test:root", "test", "", null],
["test:root", "test", "test", null],
["_:_", "", "", null],
["_:h0", "", "", null],
["_:test", "", "", null],
["_:_.", "", "", null],
["_:a-", "", "", null],
["l_:_", "", "", null],
["ns:_0", "", "", null],
["ns:a0", "", "", null],
["ns0:test", "", "", null],
["ns:EEE.", "", "", null],
["ns:_-", "", "", null],
["a.b:c", "", "", null],
["a-b:c.j", "", "", null],
["a-b:c", "", "", null],
["foo", "", "", null],
["1foo", "", "", "INVALID_CHARACTER_ERR"],
["foo1", "", "", null],
["f1oo", "", "", null],
["@foo", "", "", "INVALID_CHARACTER_ERR"],
["foo@", "", "", "INVALID_CHARACTER_ERR"],
["f@oo", "", "", "INVALID_CHARACTER_ERR"],
["edi:{", "", "", "INVALID_CHARACTER_ERR"],
["edi:}", "", "", "INVALID_CHARACTER_ERR"],
["edi:~", "", "", "INVALID_CHARACTER_ERR"],
["edi:'", "", "", "INVALID_CHARACTER_ERR"],
["edi:!", "", "", "INVALID_CHARACTER_ERR"],
["edi:@", "", "", "INVALID_CHARACTER_ERR"],
["edi:#", "", "", "INVALID_CHARACTER_ERR"],
["edi:$", "", "", "INVALID_CHARACTER_ERR"],
["edi:%", "", "", "INVALID_CHARACTER_ERR"],
["edi:^", "", "", "INVALID_CHARACTER_ERR"],
["edi:&", "", "", "INVALID_CHARACTER_ERR"],
["edi:*", "", "", "INVALID_CHARACTER_ERR"],
["edi:(", "", "", "INVALID_CHARACTER_ERR"],
["edi:)", "", "", "INVALID_CHARACTER_ERR"],
["edi:+", "", "", "INVALID_CHARACTER_ERR"],
["edi:=", "", "", "INVALID_CHARACTER_ERR"],
["edi:[", "", "", "INVALID_CHARACTER_ERR"],
["edi:]", "", "", "INVALID_CHARACTER_ERR"],
["edi:\\", "", "", "INVALID_CHARACTER_ERR"],
["edi:/", "", "", "INVALID_CHARACTER_ERR"],
["edi:;", "", "", "INVALID_CHARACTER_ERR"],
["edi:`", "", "", "INVALID_CHARACTER_ERR"],
["edi:<", "", "", "INVALID_CHARACTER_ERR"],
["edi:>", "", "", "INVALID_CHARACTER_ERR"],
["edi:,", "", "", "INVALID_CHARACTER_ERR"],
["edi:a ", "", "", "INVALID_CHARACTER_ERR"],
["edi:\"", "", "", "INVALID_CHARACTER_ERR"],
["{", "", "", "INVALID_CHARACTER_ERR"],
["}", "", "", "INVALID_CHARACTER_ERR"],
["'", "", "", "INVALID_CHARACTER_ERR"],
["~", "", "", "INVALID_CHARACTER_ERR"],
["`", "", "", "INVALID_CHARACTER_ERR"],
["@", "", "", "INVALID_CHARACTER_ERR"],
["#", "", "", "INVALID_CHARACTER_ERR"],
["$", "", "", "INVALID_CHARACTER_ERR"],
["%", "", "", "INVALID_CHARACTER_ERR"],
["^", "", "", "INVALID_CHARACTER_ERR"],
["&", "", "", "INVALID_CHARACTER_ERR"],
["*", "", "", "INVALID_CHARACTER_ERR"],
["(", "", "", "INVALID_CHARACTER_ERR"],
[")", "", "", "INVALID_CHARACTER_ERR"],
["f:oo", "", "", null],
[":foo", "", "", "NAMESPACE_ERR"],
["foo:", "", "", "NAMESPACE_ERR"],
["prefix::local", "", "", "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.nodeName, aQualifiedName, "nodeName")
assert_equals(doctype.publicId, aPublicId, "publicId")
assert_equals(doctype.systemId, aSystemId, "systemId")
assert_equals(doctype.ownerDocument, aDocument, "ownerDocument")
assert_equals(doctype.nodeValue, null, "nodeValue")
}
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>

View file

@ -0,0 +1,90 @@
<!DOCTYPE html>
<meta charset=windows-1252>
<!-- Using windows-1252 to ensure that DOMImplementation.createHTMLDocument()
doesn't inherit utf-8 from the parent document. -->
<title>DOMImplementation.createHTMLDocument</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument">
<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-name">
<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-publicid">
<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-systemid">
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-documentelement">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="DOMImplementation-createHTMLDocument.js"></script>
<div id="log"></div>
<script>
createHTMLDocuments(function(doc, expectedtitle, normalizedtitle) {
assert_true(doc instanceof Document, "Should be a Document")
assert_true(doc instanceof Node, "Should be a Node")
assert_equals(doc.childNodes.length, 2,
"Document should have two child nodes")
var doctype = doc.doctype
assert_true(doctype instanceof DocumentType,
"Doctype should be a DocumentType")
assert_true(doctype instanceof Node, "Doctype should be a Node")
assert_equals(doctype.name, "html")
assert_equals(doctype.publicId, "")
assert_equals(doctype.systemId, "")
var documentElement = doc.documentElement
assert_true(documentElement instanceof HTMLHtmlElement,
"Document element should be a HTMLHtmlElement")
assert_equals(documentElement.childNodes.length, 2,
"Document element should have two child nodes")
assert_equals(documentElement.localName, "html")
assert_equals(documentElement.tagName, "HTML")
var head = documentElement.firstChild
assert_true(head instanceof HTMLHeadElement,
"Head should be a HTMLHeadElement")
assert_equals(head.localName, "head")
assert_equals(head.tagName, "HEAD")
if (expectedtitle !== undefined) {
assert_equals(head.childNodes.length, 1)
var title = head.firstChild
assert_true(title instanceof HTMLTitleElement,
"Title should be a HTMLTitleElement")
assert_equals(title.localName, "title")
assert_equals(title.tagName, "TITLE")
assert_equals(title.childNodes.length, 1)
assert_equals(title.firstChild.data, expectedtitle)
} else {
assert_equals(head.childNodes.length, 0)
}
var body = documentElement.lastChild
assert_true(body instanceof HTMLBodyElement,
"Body should be a HTMLBodyElement")
assert_equals(body.localName, "body")
assert_equals(body.tagName, "BODY")
assert_equals(body.childNodes.length, 0)
})
test(function() {
var doc = document.implementation.createHTMLDocument("test");
assert_equals(doc.URL, "about:blank");
assert_equals(doc.documentURI, "about:blank");
assert_equals(doc.compatMode, "CSS1Compat");
assert_equals(doc.characterSet, "UTF-8");
assert_equals(doc.contentType, "text/html");
assert_equals(doc.createElement("DIV").localName, "div");
}, "createHTMLDocument(): metadata")
test(function() {
var doc = document.implementation.createHTMLDocument("test");
assert_equals(doc.characterSet, "UTF-8", "characterSet");
assert_equals(doc.charset, "UTF-8", "charset");
assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
}, "createHTMLDocument(): characterSet aliases")
test(function() {
var doc = document.implementation.createHTMLDocument("test");
var a = doc.createElement("a");
// In UTF-8: 0xC3 0xA4
a.href = "http://example.org/?\u00E4";
assert_equals(a.href, "http://example.org/?%C3%A4");
}, "createHTMLDocument(): URL parsing")
</script>

View file

@ -0,0 +1,25 @@
function createHTMLDocuments(checkDoc) {
var tests = [
["", "", ""],
[null, "null", "null"],
[undefined, undefined, ""],
["foo bar baz", "foo bar baz", "foo bar baz"],
["foo\t\tbar baz", "foo\t\tbar baz", "foo bar baz"],
["foo\n\nbar baz", "foo\n\nbar baz", "foo bar baz"],
["foo\f\fbar baz", "foo\f\fbar baz", "foo bar baz"],
["foo\r\rbar baz", "foo\r\rbar baz", "foo bar baz"],
]
tests.forEach(function(t, i) {
var title = t[0], expectedtitle = t[1], normalizedtitle = t[2]
test(function() {
var doc = document.implementation.createHTMLDocument(title);
checkDoc(doc, expectedtitle, normalizedtitle)
}, "createHTMLDocument test " + i + ": " + t.map(function(el) { return format_value(el) }))
})
test(function() {
var doc = document.implementation.createHTMLDocument();
checkDoc(doc, undefined, "")
}, "Missing title argument");
}

View file

@ -0,0 +1,155 @@
<!doctype html>
<meta charset=utf-8>
<title>DOMImplementation.hasFeature(feature, version)</title>
<link rel=help href="https://dom.spec.whatwg.org/#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"],
["XML"],
["org.w3c.svg"],
["org.w3c.dom.svg"],
["http://www.w3.org/TR/SVG11/feature#Script"],
["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, ""],
["org.w3c.svg", ""],
["org.w3c.svg", "1.0"],
["org.w3c.svg", "1.1"],
["org.w3c.dom.svg", ""],
["org.w3c.dom.svg", "1.0"],
["org.w3c.dom.svg", "1.1"],
["http://www.w3.org/TR/SVG11/feature#Script", "7.5"],
];
tests.forEach(function(data) {
test(function() {
assert_equals(document.implementation.hasFeature
.apply(document.implementation, data), true)
}, "hasFeature(" + data.map(format_value).join(", ") + ")")
})
})
</script>

View file

@ -0,0 +1,193 @@
function test_getElementsByTagName(context, element) {
// TODO: getElementsByTagName("*")
test(function() {
assert_false(context.getElementsByTagName("html") instanceof NodeList,
"Should not return a NodeList")
assert_true(context.getElementsByTagName("html") instanceof HTMLCollection,
"Should return an HTMLCollection")
}, "Interfaces")
test(function() {
var firstCollection = context.getElementsByTagName("html"),
secondCollection = context.getElementsByTagName("html")
assert_true(firstCollection !== secondCollection ||
firstCollection === secondCollection)
}, "Caching is allowed")
test(function() {
var l = context.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 (non-strict mode)")
test(function() {
var l = context.getElementsByTagName("nosuchtag")
assert_throws(new TypeError(), function() {
"use strict";
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 (strict mode)")
test(function() {
var l = context.getElementsByTagName("nosuchtag")
var fn = l.item;
assert_equals(fn, HTMLCollection.prototype.item);
l.item = "pass"
assert_equals(l.item, "pass")
assert_equals(HTMLCollection.prototype.item, fn);
}, "Should be able to set expando shadowing a proto prop (item)")
test(function() {
var l = context.getElementsByTagName("nosuchtag")
var fn = l.namedItem;
assert_equals(fn, HTMLCollection.prototype.namedItem);
l.namedItem = "pass"
assert_equals(l.namedItem, "pass")
assert_equals(HTMLCollection.prototype.namedItem, fn);
}, "Should be able to set expando shadowing a proto prop (namedItem)")
test(function() {
var t1 = element.appendChild(document.createElement("pre"));
t1.id = "x";
var t2 = element.appendChild(document.createElement("pre"));
t2.setAttribute("name", "y");
var t3 = element.appendChild(document.createElementNS("", "pre"));
t3.setAttribute("id", "z");
var t4 = element.appendChild(document.createElementNS("", "pre"));
t4.setAttribute("name", "w");
this.add_cleanup(function() {
element.removeChild(t1)
element.removeChild(t2)
element.removeChild(t3)
element.removeChild(t4)
});
var list = context.getElementsByTagName('pre');
var pre = list[0];
assert_equals(pre.id, "x");
var exposedNames = { 'x': 0, 'y': 1, 'z': 2 };
for (var exposedName in exposedNames) {
assert_equals(list[exposedName], list[exposedNames[exposedName]]);
assert_equals(list[exposedName], list.namedItem(exposedName));
assert_true(exposedName in list, "'" + exposedName + "' in list");
assert_true(list.hasOwnProperty(exposedName),
"list.hasOwnProperty('" + exposedName + "')");
}
var unexposedNames = ["w"];
for (var unexposedName of unexposedNames) {
assert_false(unexposedName in list);
assert_false(list.hasOwnProperty(unexposedName));
assert_equals(list[unexposedName], undefined);
assert_equals(list.namedItem(unexposedName), null);
}
assert_array_equals(Object.getOwnPropertyNames(list).sort(),
["0", "1", "2", "3", "x", "y", "z"]);
var desc = Object.getOwnPropertyDescriptor(list, '0');
assert_equals(typeof desc, "object", "descriptor should be an object");
assert_true(desc.enumerable, "desc.enumerable");
assert_true(desc.configurable, "desc.configurable");
desc = Object.getOwnPropertyDescriptor(list, 'x');
assert_equals(typeof desc, "object", "descriptor should be an object");
assert_false(desc.enumerable, "desc.enumerable");
assert_true(desc.configurable, "desc.configurable");
}, "hasOwnProperty, getOwnPropertyDescriptor, getOwnPropertyNames")
test(function() {
assert_equals(document.createElementNS("http://www.w3.org/1999/xhtml", "i").localName, "i") // Sanity
var t = element.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "I"))
this.add_cleanup(function() {element.removeChild(t)})
assert_equals(t.localName, "I")
assert_equals(t.tagName, "I")
assert_equals(context.getElementsByTagName("I").length, 0)
assert_equals(context.getElementsByTagName("i").length, 0)
}, "HTML element with uppercase tagName never matches in HTML Documents")
test(function() {
var t = element.appendChild(document.createElementNS("test", "st"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("st"), [t])
assert_array_equals(context.getElementsByTagName("ST"), [])
}, "Element in non-HTML namespace, no prefix, lowercase name")
test(function() {
var t = element.appendChild(document.createElementNS("test", "ST"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("ST"), [t])
assert_array_equals(context.getElementsByTagName("st"), [])
}, "Element in non-HTML namespace, no prefix, uppercase name")
test(function() {
var t = element.appendChild(document.createElementNS("test", "te:st"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("st"), [])
assert_array_equals(context.getElementsByTagName("ST"), [])
assert_array_equals(context.getElementsByTagName("te:st"), [t])
assert_array_equals(context.getElementsByTagName("te:ST"), [])
}, "Element in non-HTML namespace, prefix, lowercase name")
test(function() {
var t = element.appendChild(document.createElementNS("test", "te:ST"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("st"), [])
assert_array_equals(context.getElementsByTagName("ST"), [])
assert_array_equals(context.getElementsByTagName("te:st"), [])
assert_array_equals(context.getElementsByTagName("te:ST"), [t])
}, "Element in non-HTML namespace, prefix, uppercase name")
test(function() {
var t = element.appendChild(document.createElement("aÇ"))
this.add_cleanup(function() {element.removeChild(t)})
assert_equals(t.localName, "aÇ")
assert_array_equals(context.getElementsByTagName("AÇ"), [t], "All uppercase input")
assert_array_equals(context.getElementsByTagName("aÇ"), [t], "Ascii lowercase input")
assert_array_equals(context.getElementsByTagName("aç"), [], "All lowercase input")
}, "Element in HTML namespace, no prefix, non-ascii characters in name")
test(function() {
var t = element.appendChild(document.createElementNS("test", "AÇ"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("AÇ"), [t])
assert_array_equals(context.getElementsByTagName("aÇ"), [])
assert_array_equals(context.getElementsByTagName("aç"), [])
}, "Element in non-HTML namespace, non-ascii characters in name")
test(function() {
var t = element.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "test:aÇ"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("TEST:AÇ"), [t], "All uppercase input")
assert_array_equals(context.getElementsByTagName("test:aÇ"), [t], "Ascii lowercase input")
assert_array_equals(context.getElementsByTagName("test:aç"), [], "All lowercase input")
}, "Element in HTML namespace, prefix, non-ascii characters in name")
test(function() {
var t = element.appendChild(document.createElementNS("test", "TEST:AÇ"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("TEST:AÇ"), [t], "All uppercase input")
assert_array_equals(context.getElementsByTagName("test:aÇ"), [], "Ascii lowercase input")
assert_array_equals(context.getElementsByTagName("test:aç"), [], "All lowercase input")
}, "Element in non-HTML namespace, prefix, non-ascii characters in name")
test(function() {
var actual = context.getElementsByTagName("*");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
expected.push(child);
get_elements(child);
}
}
}
get_elements(context);
assert_array_equals(actual, expected);
}, "getElementsByTagName('*')")
}

View file

@ -0,0 +1,128 @@
function test_getElementsByTagNameNS(context, element) {
test(function() {
assert_false(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html") instanceof NodeList, "NodeList")
assert_true(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html") instanceof HTMLCollection, "HTMLCollection")
var firstCollection = context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html"),
secondCollection = context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html")
assert_true(firstCollection !== secondCollection || firstCollection === secondCollection,
"Caching is allowed.")
})
test(function() {
var t = element.appendChild(document.createElementNS("test", "body"))
this.add_cleanup(function() {element.removeChild(t)})
var actual = context.getElementsByTagNameNS("*", "body");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
if (child.localName == "body") {
expected.push(child);
}
get_elements(child);
}
}
}
get_elements(context);
assert_array_equals(actual, expected);
}, "getElementsByTagNameNS('*', 'body')")
test(function() {
assert_array_equals(context.getElementsByTagNameNS("", "*"), []);
var t = element.appendChild(document.createElementNS("", "body"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("", "*"), [t]);
}, "Empty string namespace")
test(function() {
var t = element.appendChild(document.createElementNS("test", "body"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("test", "body"), [t]);
}, "body element in test namespace, no prefix")
test(function() {
var t = element.appendChild(document.createElementNS("test", "test:body"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("test", "body"), [t]);
}, "body element in test namespace, prefix")
test(function() {
var t = element.appendChild(document.createElementNS("test", "BODY"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("test", "BODY"), [t]);
assert_array_equals(context.getElementsByTagNameNS("test", "body"), []);
}, "BODY element in test namespace, no prefix")
test(function() {
var t = element.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "abc"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "abc"), [t]);
assert_array_equals(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "ABC"), []);
assert_array_equals(context.getElementsByTagNameNS("test", "ABC"), []);
}, "abc element in html namespace")
test(function() {
var t = element.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "ABC"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "abc"), []);
assert_array_equals(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "ABC"), [t]);
}, "ABC element in html namespace")
test(function() {
var t = element.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "AÇ"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "AÇ"), [t]);
assert_array_equals(context.getElementsByTagNameNS("test", "aÇ"), []);
assert_array_equals(context.getElementsByTagNameNS("test", "aç"), []);
}, "AÇ, case sensitivity")
test(function() {
var t = element.appendChild(document.createElementNS("test", "test:BODY"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("test", "BODY"), [t]);
assert_array_equals(context.getElementsByTagNameNS("test", "body"), []);
}, "BODY element in test namespace, prefix")
test(function() {
var t = element.appendChild(document.createElementNS("test", "test:test"))
this.add_cleanup(function() {element.removeChild(t)})
var actual = context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "*");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
if (child !== t) {
expected.push(child);
}
get_elements(child);
}
}
}
get_elements(context);
assert_array_equals(actual, expected);
}, "getElementsByTagNameNS('http://www.w3.org/1999/xhtml', '*')")
test(function() {
var actual = context.getElementsByTagNameNS("*", "*");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
expected.push(child);
get_elements(child);
}
}
}
get_elements(context);
assert_array_equals(actual, expected);
}, "getElementsByTagNameNS('*', '*')")
test(function() {
assert_array_equals(context.getElementsByTagNameNS("**", "*"), []);
assert_array_equals(context.getElementsByTagNameNS(null, "0"), []);
assert_array_equals(context.getElementsByTagNameNS(null, "div"), []);
}, "Empty lists")
}

View file

@ -0,0 +1,18 @@
<!doctype html>
<meta charset=utf-8>
<title>Document.URL with redirect</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement("iframe");
iframe.src = "/common/redirect.py?location=/common/blank.html";
document.body.appendChild(iframe);
this.add_cleanup(function() { document.body.removeChild(iframe); });
iframe.onload = this.step_func_done(function() {
assert_equals(iframe.contentDocument.URL,
"http://{{host}}:{{ports[http][0]}}/common/blank.html");
});
})
</script>

View file

@ -0,0 +1,50 @@
<!doctype html>
<meta charset=utf-8>
<title>Document.adoptNode</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-adoptnode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<!--creates an element with local name "x<": --><x<>x</x<>
<script>
test(function() {
var y = document.getElementsByTagName("x<")[0]
var child = y.firstChild
assert_equals(y.parentNode, document.body)
assert_equals(y.ownerDocument, document)
assert_equals(document.adoptNode(y), y)
assert_equals(y.parentNode, null)
assert_equals(y.firstChild, child)
assert_equals(y.ownerDocument, document)
assert_equals(child.ownerDocument, document)
var doc = document.implementation.createDocument(null, null, null)
assert_equals(doc.adoptNode(y), y)
assert_equals(y.parentNode, null)
assert_equals(y.firstChild, child)
assert_equals(y.ownerDocument, doc)
assert_equals(child.ownerDocument, doc)
}, "Adopting an Element called 'x<' should work.")
test(function() {
var x = document.createElement(":good:times:")
assert_equals(document.adoptNode(x), x);
var doc = document.implementation.createDocument(null, null, null)
assert_equals(doc.adoptNode(x), 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)
assert_equals(document.adoptNode(doctype), 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>

View file

@ -0,0 +1,373 @@
<!doctype html>
<title>document.characterSet (inputEncoding and charset as aliases) normalization tests</title>
<link rel=author title="Aryeh Gregor" href=ayg@aryeh.name>
<meta name=timeout content=long>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<style>iframe { display: none }</style>
<script>
"use strict";
// Taken straight from https://encoding.spec.whatwg.org/
var encodingMap = {
"UTF-8": [
"unicode-1-1-utf-8",
"utf-8",
"utf8",
// As we use <meta>, utf-16 will map to utf-8 per
// https://html.spec.whatwg.org/multipage/#documentEncoding
"utf-16",
"utf-16le",
"utf-16be",
],
"IBM866": [
"866",
"cp866",
"csibm866",
"ibm866",
],
"ISO-8859-2": [
"csisolatin2",
"iso-8859-2",
"iso-ir-101",
"iso8859-2",
"iso88592",
"iso_8859-2",
"iso_8859-2:1987",
"l2",
"latin2",
],
"ISO-8859-3": [
"csisolatin3",
"iso-8859-3",
"iso-ir-109",
"iso8859-3",
"iso88593",
"iso_8859-3",
"iso_8859-3:1988",
"l3",
"latin3",
],
"ISO-8859-4": [
"csisolatin4",
"iso-8859-4",
"iso-ir-110",
"iso8859-4",
"iso88594",
"iso_8859-4",
"iso_8859-4:1988",
"l4",
"latin4",
],
"ISO-8859-5": [
"csisolatincyrillic",
"cyrillic",
"iso-8859-5",
"iso-ir-144",
"iso8859-5",
"iso88595",
"iso_8859-5",
"iso_8859-5:1988",
],
"ISO-8859-6": [
"arabic",
"asmo-708",
"csiso88596e",
"csiso88596i",
"csisolatinarabic",
"ecma-114",
"iso-8859-6",
"iso-8859-6-e",
"iso-8859-6-i",
"iso-ir-127",
"iso8859-6",
"iso88596",
"iso_8859-6",
"iso_8859-6:1987",
],
"ISO-8859-7": [
"csisolatingreek",
"ecma-118",
"elot_928",
"greek",
"greek8",
"iso-8859-7",
"iso-ir-126",
"iso8859-7",
"iso88597",
"iso_8859-7",
"iso_8859-7:1987",
"sun_eu_greek",
],
"ISO-8859-8": [
"csiso88598e",
"csisolatinhebrew",
"hebrew",
"iso-8859-8",
"iso-8859-8-e",
"iso-ir-138",
"iso8859-8",
"iso88598",
"iso_8859-8",
"iso_8859-8:1988",
"visual",
],
"ISO-8859-8-I": [
"csiso88598i",
"iso-8859-8-i",
"logical",
],
"ISO-8859-10": [
"csisolatin6",
"iso-8859-10",
"iso-ir-157",
"iso8859-10",
"iso885910",
"l6",
"latin6",
],
"ISO-8859-13": [
"iso-8859-13",
"iso8859-13",
"iso885913",
],
"ISO-8859-14": [
"iso-8859-14",
"iso8859-14",
"iso885914",
],
"ISO-8859-15": [
"csisolatin9",
"iso-8859-15",
"iso8859-15",
"iso885915",
"iso_8859-15",
"l9",
],
"ISO-8859-16": [
"iso-8859-16",
],
"KOI8-R": [
"cskoi8r",
"koi",
"koi8",
"koi8-r",
"koi8_r",
],
"KOI8-U": [
"koi8-ru",
"koi8-u",
],
"macintosh": [
"csmacintosh",
"mac",
"macintosh",
"x-mac-roman",
],
"windows-874": [
"dos-874",
"iso-8859-11",
"iso8859-11",
"iso885911",
"tis-620",
"windows-874",
],
"windows-1250": [
"cp1250",
"windows-1250",
"x-cp1250",
],
"windows-1251": [
"cp1251",
"windows-1251",
"x-cp1251",
],
"windows-1252": [
"ansi_x3.4-1968",
"ascii",
"cp1252",
"cp819",
"csisolatin1",
"ibm819",
"iso-8859-1",
"iso-ir-100",
"iso8859-1",
"iso88591",
"iso_8859-1",
"iso_8859-1:1987",
"l1",
"latin1",
"us-ascii",
"windows-1252",
"x-cp1252",
// As we use <meta>, x-user-defined will map to windows-1252 per
// https://html.spec.whatwg.org/multipage/#documentEncoding
"x-user-defined"
],
"windows-1253": [
"cp1253",
"windows-1253",
"x-cp1253",
],
"windows-1254": [
"cp1254",
"csisolatin5",
"iso-8859-9",
"iso-ir-148",
"iso8859-9",
"iso88599",
"iso_8859-9",
"iso_8859-9:1989",
"l5",
"latin5",
"windows-1254",
"x-cp1254",
],
"windows-1255": [
"cp1255",
"windows-1255",
"x-cp1255",
],
"windows-1256": [
"cp1256",
"windows-1256",
"x-cp1256",
],
"windows-1257": [
"cp1257",
"windows-1257",
"x-cp1257",
],
"windows-1258": [
"cp1258",
"windows-1258",
"x-cp1258",
],
"x-mac-cyrillic": [
"x-mac-cyrillic",
"x-mac-ukrainian",
],
"GBK": [
"chinese",
"csgb2312",
"csiso58gb231280",
"gb2312",
"gb_2312",
"gb_2312-80",
"gbk",
"iso-ir-58",
"x-gbk",
],
"gb18030": [
"gb18030",
],
"Big5": [
"big5",
"big5-hkscs",
"cn-big5",
"csbig5",
"x-x-big5",
],
"EUC-JP": [
"cseucpkdfmtjapanese",
"euc-jp",
"x-euc-jp",
],
"ISO-2022-JP": [
"csiso2022jp",
"iso-2022-jp",
],
"Shift_JIS": [
"csshiftjis",
"ms932",
"ms_kanji",
"shift-jis",
"shift_jis",
"sjis",
"windows-31j",
"x-sjis",
],
"EUC-KR": [
"cseuckr",
"csksc56011987",
"euc-kr",
"iso-ir-149",
"korean",
"ks_c_5601-1987",
"ks_c_5601-1989",
"ksc5601",
"ksc_5601",
"windows-949",
],
"replacement": [
"csiso2022kr",
"hz-gb-2312",
"iso-2022-cn",
"iso-2022-cn-ext",
"iso-2022-kr",
],
};
// Add spaces and mix up case
Object.keys(encodingMap).forEach(function(name) {
var lower = encodingMap[name];
var upper = encodingMap[name].map(function(s) { return s.toUpperCase() });
var mixed = encodingMap[name].map(function(s) {
var ret = "";
for (var i = 0; i < s.length; i += 2) {
ret += s[i].toUpperCase();
if (i + 1 < s.length) {
ret += s[i + 1];
}
}
return ret;
});
var spacey = encodingMap[name].map(function(s) {
return " \t\n\f\r" + s + " \t\n\f\r";
});
encodingMap[name] = [];
for (var i = 0; i < lower.length; i++) {
encodingMap[name].push(lower[i]);
/*
if (lower[i] != upper[i]) {
encodingMap[name].push(upper[i]);
}
if (lower[i] != mixed[i] && upper[i] != mixed[i]) {
encodingMap[name].push(mixed[i]);
}
encodingMap[name].push(spacey[i]);
*/
}
});
Object.keys(encodingMap).forEach(function(name) {
encodingMap[name].forEach(function(label) {
var iframe = document.createElement("iframe");
var t = async_test("Name " + format_value(name) +
" has label " + format_value(label) + " (characterSet)");
var t2 = async_test("Name " + format_value(name) +
" has label " + format_value(label) + " (inputEncoding)");
var t3 = async_test("Name " + format_value(name) +
" has label " + format_value(label) + " (charset)");
iframe.src = "encoding.py?label=" + label;
iframe.onload = function() {
t.step(function() {
assert_equals(iframe.contentDocument.characterSet, name);
});
t2.step(function() {
assert_equals(iframe.contentDocument.inputEncoding, name);
});
t3.step(function() {
assert_equals(iframe.contentDocument.charset, name);
});
document.body.removeChild(iframe);
t.done();
t2.done();
t3.done();
};
document.body.appendChild(iframe);
});
});
</script>
<!-- vim: set expandtab tabstop=2 shiftwidth=2: -->

View file

@ -0,0 +1,53 @@
<!doctype html>
<meta charset=windows-1252>
<!-- Using windows-1252 to ensure that new Document() doesn't inherit utf-8
from the parent document. -->
<title>Document constructor</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-document">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var doc = new Document();
assert_true(doc instanceof Node, "Should be a Node");
assert_true(doc instanceof Document, "Should be a Document");
assert_false(doc instanceof XMLDocument, "Should not be an XMLDocument");
assert_equals(Object.getPrototypeOf(doc), Document.prototype,
"Document should be the primary interface");
}, "new Document(): interfaces")
test(function() {
var doc = new Document();
assert_equals(doc.firstChild, null, "firstChild");
assert_equals(doc.lastChild, null, "lastChild");
assert_equals(doc.doctype, null, "doctype");
assert_equals(doc.documentElement, null, "documentElement");
assert_array_equals(doc.childNodes, [], "childNodes");
}, "new Document(): children")
test(function() {
var doc = new Document();
assert_equals(doc.URL, "about:blank");
assert_equals(doc.documentURI, "about:blank");
assert_equals(doc.compatMode, "CSS1Compat");
assert_equals(doc.characterSet, "UTF-8");
assert_equals(doc.contentType, "application/xml");
assert_equals(doc.createElement("DIV").localName, "DIV");
}, "new Document(): metadata")
test(function() {
var doc = new Document();
assert_equals(doc.characterSet, "UTF-8", "characterSet");
assert_equals(doc.charset, "UTF-8", "charset");
assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
}, "new Document(): characterSet aliases")
test(function() {
var doc = new Document();
var a = doc.createElement("a");
// In UTF-8: 0xC3 0xA4
a.href = "http://example.org/?\u00E4";
assert_equals(a.href, "http://example.org/?%C3%A4");
}, "new Document(): URL parsing")
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>BMP document.contentType === 'image/bmp'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "image/bmp");
}), false);
iframe.src = "../resources/t.bmp";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>CSS document.contentType === 'text/css'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "text/css");
}), false);
iframe.src = "../resources/style.css";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>Data URI document.contentType === 'text/plain' when data URI MIME type is not set</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "text/plain");
}), false);
iframe.src = "data:;,<!DOCTYPE html>";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>Data URI document.contentType === 'text/html' when data URI MIME type is set</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "text/html");
}), false);
iframe.src = "data:text/html;charset=utf-8,<!DOCTYPE html>";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>GIF document.contentType === 'image/gif'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "image/gif");
}), false);
iframe.src = "../resources/t.gif";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>HTM document.contentType === 'text/html'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "text/html");
}), false);
iframe.src = "../resources/blob.htm";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<title>Javascript URI document.contentType === 'text/html'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "text/html");
assert_equals(iframe.contentDocument.documentElement.textContent, "text/html");
}), false);
iframe.src = "javascript:document.contentType";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>JPG document.contentType === 'image/jpeg'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "image/jpeg");
}), false);
iframe.src = "../resources/t.jpg";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>Custom document.contentType === 'text/xml' when explicitly set to this value</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "text/xml");
}), false);
iframe.src = "../support/contenttype_setter.py?type=text&subtype=xml";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>Custom document.contentType === 'text/html' when explicitly set to this value and an attempt is made to override this value in an HTML meta header</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "text/html");
}), false);
iframe.src = "../support/contenttype_setter.py?type=text&subtype=html&mimeHead=text%2Fxml";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>PNG document.contentType === 'image/png'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "image/png");
}), false);
iframe.src = "../resources/t.png";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>TXT document.contentType === 'text/plain'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "text/plain");
}), false);
iframe.src = "../resources/blob.txt";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>XML document.contentType === 'application/xml'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement('iframe');
iframe.addEventListener('load', this.step_func_done(function() {
assert_equals(iframe.contentDocument.contentType, "application/xml");
}), false);
iframe.src = "../resources/blob.xml";
document.body.appendChild(iframe);
});
</script>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>document.implementation.createDocument: document.contentType === 'application/xhtml+xml'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
test(function() {
var doc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null);
assert_equals(doc.contentType, "application/xhtml+xml");
});
</script>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>document.implementation.createHTMLDocument: document.contentType === 'text/html'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
test(function() {
var doc = document.implementation.createHTMLDocument("test");
assert_equals(doc.contentType, "text/html");
});
</script>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<title>XHR - retrieve HTML document: document.contentType === 'application/xml'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var xhr = new XMLHttpRequest();
xhr.open("GET", "../resources/blob.xml");
xhr.responseType = "document";
xhr.onload = this.step_func_done(function(response) {
assert_equals(xhr.readyState, 4);
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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</blob>

View file

@ -0,0 +1,12 @@
.unknown
{
background-color:lightblue;
}
.pass
{
background-color:lime;
}
.fail
{
background-color:red;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

View file

@ -0,0 +1,20 @@
def main(request, response):
type = request.GET.first("type", None)
subtype = request.GET.first("subtype", None)
if type and subtype:
response.headers["Content-Type"] = type + "/" + subtype
removeContentType = request.GET.first("removeContentType", None)
if removeContentType:
try:
del response.headers["Content-Type"]
except KeyError:
pass
content = '<head>'
mimeHead = request.GET.first("mime", None);
if mimeHead:
content += '<meta http-equiv="Content-Type" content="%s; charset=utf-8"/>' % mimeHead
content += "</head>"
return content

View file

@ -0,0 +1,43 @@
<!doctype html>
<meta charset=utf-8>
<title>Document.createAttribute</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=attributes.js></script>
<script src=productions.js></script>
<div id=log>
<script>
var xml_document;
setup(function() {
xml_document = document.implementation.createDocument(null, null, null);
});
invalid_names.forEach(function(name) {
test(function() {
assert_throws("INVALID_CHARACTER_ERR", function() {
document.createAttribute(name, "test");
});
}, "HTML document.createAttribute(" + format_value(name) + ")");
test(function() {
assert_throws("INVALID_CHARACTER_ERR", function() {
xml_document.createAttribute(name, "test");
});
}, "XML document.createAttribute(" + format_value(name) + ")");
});
var tests = ["title", "TITLE", null, undefined];
tests.forEach(function(name) {
test(function() {
var attribute = document.createAttribute(name);
attr_is(attribute, "", String(name).toLowerCase(), null, null, String(name).toLowerCase());
assert_equals(attribute.ownerElement, null);
}, "HTML document.createAttribute(" + format_value(name) + ")");
test(function() {
var attribute = xml_document.createAttribute(name);
attr_is(attribute, "", String(name), null, null, String(name));
assert_equals(attribute.ownerElement, null);
}, "XML document.createAttribute(" + format_value(name) + ")");
});
</script>

View file

@ -0,0 +1,22 @@
function test_create(method, iface, nodeType, nodeName) {
["\u000b", "a -- b", "a-", "-b", null, undefined].forEach(function(value) {
test(function() {
var c = document[method](value);
var expected = String(value);
assert_true(c instanceof iface);
assert_true(c instanceof CharacterData);
assert_true(c instanceof Node);
assert_equals(c.ownerDocument, document);
assert_equals(c.data, expected, "data");
assert_equals(c.nodeValue, expected, "nodeValue");
assert_equals(c.textContent, expected, "textContent");
assert_equals(c.length, expected.length);
assert_equals(c.nodeType, nodeType);
assert_equals(c.nodeName, nodeName);
assert_equals(c.hasChildNodes(), false);
assert_equals(c.childNodes.length, 0);
assert_equals(c.firstChild, null);
assert_equals(c.lastChild, null);
}, method + "(" + format_value(value) + ")");
});
}

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.createComment</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-createcomment">
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-ownerdocument">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-nodevalue">
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-textcontent">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-length">
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-nodetype">
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-haschildnodes">
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-childnodes">
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-firstchild">
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-lastchild">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="Document-createComment-createTextNode.js"></script>
<div id="log"></div>
<script>
test_create("createComment", Comment, 8, "#comment");
</script>

View file

@ -0,0 +1 @@
<svg></svg>

After

Width:  |  Height:  |  Size: 11 B

View file

@ -0,0 +1 @@
<svg></svg>

After

Width:  |  Height:  |  Size: 11 B

View file

@ -0,0 +1 @@
<svg></svg>

After

Width:  |  Height:  |  Size: 11 B

View file

@ -0,0 +1 @@
<svg></svg>

After

Width:  |  Height:  |  Size: 11 B

View file

@ -0,0 +1,77 @@
#!/usr/bin/python
import os
import sys
THIS_NAME = "generate.py"
# Note: these lists must be kept in sync with the lists in
# Document-createElement-namespace.html, and this script must be run whenever
# the lists are updated. (We could keep the lists in a shared JSON file, but
# seems like too much effort.)
FILES = (
("empty", ""),
("minimal_html", "<!doctype html><title></title>"),
("xhtml", '<html xmlns="http://www.w3.org/1999/xhtml"></html>'),
("svg", '<svg xmlns="http://www.w3.org/2000/svg"></svg>'),
("mathml", '<mathml xmlns="http://www.w3.org/1998/Math/MathML"></mathml>'),
("bare_xhtml", "<html></html>"),
("bare_svg", "<svg></svg>"),
("bare_mathml", "<math></math>"),
("xhtml_ns_removed", """\
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script>
var newRoot = document.createElementNS(null, "html");
document.removeChild(document.documentElement);
document.appendChild(newRoot);
</script></head>
</html>
"""),
("xhtml_ns_changed", """\
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script>
var newRoot = document.createElementNS("http://www.w3.org/2000/svg", "abc");
document.removeChild(document.documentElement);
document.appendChild(newRoot);
</script></head>
</html>
"""),
)
EXTENSIONS = (
"html",
"xhtml",
"xml",
"svg",
# Was not able to get server MIME type working properly :(
#"mml",
)
def __main__():
if len(sys.argv) > 1:
print "No arguments expected, aborting"
return
if not os.access(THIS_NAME, os.F_OK):
print "Must be run from the directory of " + THIS_NAME + ", aborting"
return
for name in os.listdir("."):
if name == THIS_NAME:
continue
os.remove(name)
manifest = open("MANIFEST", "w")
for name, contents in FILES:
for extension in EXTENSIONS:
f = open(name + "." + extension, "w")
f.write(contents)
f.close()
manifest.write("support " + name + "." + extension + "\n")
manifest.close()
__main__()

View file

@ -0,0 +1 @@
<mathml xmlns="http://www.w3.org/1998/Math/MathML"></mathml>

View file

@ -0,0 +1 @@
<mathml xmlns="http://www.w3.org/1998/Math/MathML"></mathml>

View file

@ -0,0 +1 @@
<mathml xmlns="http://www.w3.org/1998/Math/MathML"></mathml>

View file

@ -0,0 +1 @@
<mathml xmlns="http://www.w3.org/1998/Math/MathML"></mathml>

View file

@ -0,0 +1 @@
<!doctype html><title></title>

View file

@ -0,0 +1 @@
<!doctype html><title></title>

View file

@ -0,0 +1 @@
<!doctype html><title></title>

View file

@ -0,0 +1 @@
<!doctype html><title></title>

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg"></svg>

After

Width:  |  Height:  |  Size: 46 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg"></svg>

After

Width:  |  Height:  |  Size: 46 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg"></svg>

After

Width:  |  Height:  |  Size: 46 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg"></svg>

After

Width:  |  Height:  |  Size: 46 B

View file

@ -0,0 +1 @@
<html xmlns="http://www.w3.org/1999/xhtml"></html>

View file

@ -0,0 +1 @@
<html xmlns="http://www.w3.org/1999/xhtml"></html>

View file

@ -0,0 +1 @@
<html xmlns="http://www.w3.org/1999/xhtml"></html>

View file

@ -0,0 +1 @@
<html xmlns="http://www.w3.org/1999/xhtml"></html>

View file

@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script>
var newRoot = document.createElementNS("http://www.w3.org/2000/svg", "abc");
document.removeChild(document.documentElement);
document.appendChild(newRoot);
</script></head>
</html>

View file

@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script>
var newRoot = document.createElementNS("http://www.w3.org/2000/svg", "abc");
document.removeChild(document.documentElement);
document.appendChild(newRoot);
</script></head>
</html>

View file

@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script>
var newRoot = document.createElementNS("http://www.w3.org/2000/svg", "abc");
document.removeChild(document.documentElement);
document.appendChild(newRoot);
</script></head>
</html>

View file

@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script>
var newRoot = document.createElementNS("http://www.w3.org/2000/svg", "abc");
document.removeChild(document.documentElement);
document.appendChild(newRoot);
</script></head>
</html>

View file

@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script>
var newRoot = document.createElementNS(null, "html");
document.removeChild(document.documentElement);
document.appendChild(newRoot);
</script></head>
</html>

View file

@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script>
var newRoot = document.createElementNS(null, "html");
document.removeChild(document.documentElement);
document.appendChild(newRoot);
</script></head>
</html>

View file

@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script>
var newRoot = document.createElementNS(null, "html");
document.removeChild(document.documentElement);
document.appendChild(newRoot);
</script></head>
</html>

View file

@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script>
var newRoot = document.createElementNS(null, "html");
document.removeChild(document.documentElement);
document.appendChild(newRoot);
</script></head>
</html>

View file

@ -0,0 +1,119 @@
<!doctype html>
<title>document.createElement() namespace 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>
"use strict";
/**
* This tests the namespace of elements created by the Document interface's
* createElement() method. See bug:
* https://www.w3.org/Bugs/Public/show_bug.cgi?id=19431
*/
/**
* Test that an element created using the Document object doc has the namespace
* that would be expected for the given contentType.
*/
function testDoc(doc, contentType) {
if (doc.contentType !== undefined) {
// Sanity check
assert_equals(doc.contentType, contentType,
"Wrong MIME type returned from doc.contentType");
}
var expectedNamespace = contentType == "text/html" ||
contentType == "application/xhtml+xml"
? "http://www.w3.org/1999/xhtml" : null;
assert_equals(doc.createElement("x").namespaceURI, expectedNamespace);
}
// First test various objects we create in JS
test(function() {
testDoc(document, "text/html")
}, "Created element's namespace in current document");
test(function() {
testDoc(document.implementation.createHTMLDocument(""), "text/html");
}, "Created element's namespace in created HTML document");
test(function() {
testDoc(document.implementation.createDocument(null, "", null),
"application/xml");
}, "Created element's namespace in created XML document");
test(function() {
testDoc(document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null),
"application/xhtml+xml");
}, "Created element's namespace in created XHTML document");
test(function() {
testDoc(document.implementation.createDocument("http://www.w3.org/2000/svg", "svg", null),
"image/svg+xml");
}, "Created element's namespace in created SVG document");
test(function() {
testDoc(document.implementation.createDocument("http://www.w3.org/1998/Math/MathML", "math", null),
"application/xml");
}, "Created element's namespace in created MathML document");
// Second also test document created by DOMParser
test(function() {
testDoc(new DOMParser().parseFromString("", "text/html"), "text/html");
}, "Created element's namespace in created HTML document by DOMParser ('text/html')");
test(function() {
testDoc(new DOMParser().parseFromString("<root/>", "text/xml"), "text/xml");
}, "Created element's namespace in created XML document by DOMParser ('text/xml')");
test(function() {
testDoc(new DOMParser().parseFromString("<root/>", "application/xml"), "application/xml");
}, "Created element's namespace in created XML document by DOMParser ('application/xml')");
test(function() {
testDoc(new DOMParser().parseFromString("<html/>", "application/xhtml+xml"), "application/xhtml+xml");
}, "Created element's namespace in created XHTML document by DOMParser ('application/xhtml+xml')");
test(function() {
testDoc(new DOMParser().parseFromString("<math/>", "image/svg+xml"), "image/svg+xml");
}, "Created element's namespace in created SVG document by DOMParser ('image/svg+xml')");
// Now for various externally-loaded files. Note: these lists must be kept
// synced with the lists in generate.py in the subdirectory, and that script
// must be run whenever the lists are updated. (We could keep the lists in a
// shared JSON file, but it seems like too much effort.)
var testExtensions = {
html: "text/html",
xhtml: "application/xhtml+xml",
xml: "application/xml",
svg: "image/svg+xml",
// Was not able to get server MIME type working properly :(
//mml: "application/mathml+xml",
};
var tests = [
"empty",
"minimal_html",
"xhtml",
"svg",
"mathml",
"bare_xhtml",
"bare_svg",
"bare_mathml",
"xhtml_ns_removed",
"xhtml_ns_changed",
];
tests.forEach(function(testName) {
Object.keys(testExtensions).forEach(function(ext) {
var iframe = document.createElement("iframe");
iframe.src = "Document-createElement-namespace-tests/" +
testName + "." + ext;
var t = async_test("Created element's namespace in " + testName + "." + ext);
iframe.onload = function() {
t.step(function() {
testDoc(iframe.contentDocument, testExtensions[ext]);
});
document.body.removeChild(iframe);
t.done();
};
document.body.appendChild(iframe);
});
});
</script>

View file

@ -0,0 +1,157 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.createElement</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-createelement">
<link rel=help href="https://dom.spec.whatwg.org/#dom-element-localname">
<link rel=help href="https://dom.spec.whatwg.org/#dom-element-tagname">
<link rel=help href="https://dom.spec.whatwg.org/#dom-element-prefix">
<link rel=help href="https://dom.spec.whatwg.org/#dom-element-namespaceuri">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src="/common/dummy.xml"></iframe>
<iframe src="/common/dummy.xhtml"></iframe>
<script>
function toASCIIUppercase(str) {
var diff = "a".charCodeAt(0) - "A".charCodeAt(0);
var res = "";
for (var i = 0; i < str.length; ++i) {
if ("a" <= str[i] && str[i] <= "z") {
res += String.fromCharCode(str.charCodeAt(i) - diff);
} else {
res += str[i];
}
}
return res;
}
function toASCIILowercase(str) {
var diff = "a".charCodeAt(0) - "A".charCodeAt(0);
var res = "";
for (var i = 0; i < str.length; ++i) {
if ("A" <= str[i] && str[i] <= "Z") {
res += String.fromCharCode(str.charCodeAt(i) + diff);
} else {
res += str[i];
}
}
return res;
}
var HTMLNS = "http://www.w3.org/1999/xhtml",
valid = [
undefined,
null,
"foo",
"f1oo",
"foo1",
"f\u0BC6",
"foo\u0BC6",
":",
":foo",
"f:oo",
"foo:",
"f:o:o",
"f::oo",
"f::oo:",
"foo:0",
"foo:_",
// combining char after :, invalid QName but valid Name
"foo:\u0BC6",
"foo:foo\u0BC6",
"foo\u0BC6:foo",
"xml",
"xmlns",
"xmlfoo",
"xml:foo",
"xmlns:foo",
"xmlfoo:bar",
"svg",
"math",
"FOO",
// Test that non-ASCII chars don't get uppercased/lowercased
"mar\u212a",
"\u0130nput",
"\u0131nput",
],
invalid = [
"",
"1foo",
"1:foo",
"fo o",
"\u0BC6foo",
"}foo",
"f}oo",
"foo}",
"\ufffffoo",
"f\uffffoo",
"foo\uffff",
"<foo",
"foo>",
"<foo>",
"f<oo",
"-foo",
".foo",
"\u0BC6",
]
var xmlIframe = document.querySelector('[src="/common/dummy.xml"]');
var xhtmlIframe = document.querySelector('[src="/common/dummy.xhtml"]');
function getWin(desc) {
if (desc == "HTML document") {
return window;
}
if (desc == "XML document") {
assert_equals(xmlIframe.contentDocument.documentElement.textContent,
"Dummy XML document", "XML document didn't load");
return xmlIframe.contentWindow;
}
if (desc == "XHTML document") {
assert_equals(xhtmlIframe.contentDocument.documentElement.textContent,
"Dummy XHTML document", "XHTML document didn't load");
return xhtmlIframe.contentWindow;
}
}
valid.forEach(function(t) {
["HTML document", "XML document", "XHTML document"].forEach(function(desc) {
async_test(function(testObj) {
window.addEventListener("load", function() {
testObj.step(function() {
var win = getWin(desc);
var doc = win.document;
var elt = doc.createElement(t)
assert_true(elt instanceof win.Element, "instanceof Element")
assert_true(elt instanceof win.Node, "instanceof Node")
assert_equals(elt.localName,
desc == "HTML document" ? toASCIILowercase(String(t))
: String(t),
"localName")
assert_equals(elt.tagName,
desc == "HTML document" ? toASCIIUppercase(String(t))
: String(t),
"tagName")
assert_equals(elt.prefix, null, "prefix")
assert_equals(elt.namespaceURI,
desc == "XML document" ? null : HTMLNS, "namespaceURI")
});
testObj.done();
});
}, "createElement(" + format_value(t) + ") in " + desc);
});
});
invalid.forEach(function(arg) {
["HTML document", "XML document", "XHTML document"].forEach(function(desc) {
async_test(function(testObj) {
window.addEventListener("load", function() {
testObj.step(function() {
var doc = getWin(desc).document;
assert_throws("InvalidCharacterError",
function() { doc.createElement(arg) })
});
testObj.done();
});
}, "createElement(" + format_value(arg) + ") in " + desc);
});
});
</script>

View file

@ -0,0 +1,226 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.createElementNS</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-createelementns">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="Document-createElementNS.js"></script>
<div id="log"></div>
<iframe src="/common/dummy.xml"></iframe>
<iframe src="/common/dummy.xhtml"></iframe>
<script>
var tests = createElementNS_tests.concat([
/* Arrays with three elements:
* the namespace argument
* the qualifiedName argument
* the expected exception, or null if none
*/
["", "", "INVALID_CHARACTER_ERR"],
[null, null, null],
[null, "", "INVALID_CHARACTER_ERR"],
[undefined, null, null],
[undefined, "", "INVALID_CHARACTER_ERR"],
["http://example.com/", null, null],
["http://example.com/", "", "INVALID_CHARACTER_ERR"],
["/", null, null],
["/", "", "INVALID_CHARACTER_ERR"],
["http://www.w3.org/XML/1998/namespace", null, null],
["http://www.w3.org/XML/1998/namespace", "", "INVALID_CHARACTER_ERR"],
["http://www.w3.org/2000/xmlns/", null, "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "", "INVALID_CHARACTER_ERR"],
["foo:", null, null],
["foo:", "", "INVALID_CHARACTER_ERR"],
])
var xmlIframe = document.querySelector('[src="/common/dummy.xml"]');
var xhtmlIframe = document.querySelector('[src="/common/dummy.xhtml"]');
function runTest(t, i, desc) {
async_test(function(testObj) {
window.addEventListener("load", function() {
testObj.step(function() {
var doc;
if (desc == "HTML document") {
doc = document;
} else if (desc == "XML document") {
doc = xmlIframe.contentDocument;
// Make sure we're testing the right document
assert_equals(doc.documentElement.textContent, "Dummy XML document");
} else if (desc == "XHTML document") {
doc = xhtmlIframe.contentDocument;
assert_equals(doc.documentElement.textContent, "Dummy XHTML document");
}
var namespace = t[0], qualifiedName = t[1], expected = t[2]
if (expected != null) {
assert_throws(expected, function() { doc.createElementNS(namespace, qualifiedName) })
} else {
var element = doc.createElementNS(namespace, qualifiedName)
assert_not_equals(element, null)
assert_equals(element.nodeType, Node.ELEMENT_NODE)
assert_equals(element.nodeType, element.ELEMENT_NODE)
assert_equals(element.nodeValue, null)
assert_equals(element.ownerDocument, doc)
var qualified = String(qualifiedName), names = []
if (qualified.indexOf(":") >= 0) {
names = qualified.split(":", 2)
} else {
names = [null, qualified]
}
assert_equals(element.prefix, names[0])
assert_equals(element.localName, names[1])
assert_equals(element.tagName, qualified)
assert_equals(element.nodeName, qualified)
assert_equals(element.namespaceURI,
namespace === undefined || namespace === "" ? null
: namespace)
}
});
testObj.done();
});
}, "createElementNS test in " + desc + ": " + t.map(format_value))
}
tests.forEach(function(t, i) {
runTest(t, i, "HTML document")
runTest(t, i, "XML document")
runTest(t, i, "XHTML document")
})
test(function() {
var HTMLNS = "http://www.w3.org/1999/xhtml";
var element = document.createElementNS(HTMLNS, "span");
assert_equals(element.namespaceURI, HTMLNS);
assert_equals(element.prefix, null);
assert_equals(element.localName, "span");
assert_equals(element.tagName, "SPAN");
assert_true(element instanceof Node, "Should be a Node");
assert_true(element instanceof Element, "Should be an Element");
assert_true(element instanceof HTMLElement, "Should be an HTMLElement");
assert_true(element instanceof HTMLSpanElement, "Should be an HTMLSpanElement");
}, "Lower-case HTML element without a prefix");
test(function() {
var HTMLNS = "http://www.w3.org/1999/xhtml";
var element = document.createElementNS(HTMLNS, "html:span");
assert_equals(element.namespaceURI, HTMLNS);
assert_equals(element.prefix, "html");
assert_equals(element.localName, "span");
assert_equals(element.tagName, "HTML:SPAN");
assert_true(element instanceof Node, "Should be a Node");
assert_true(element instanceof Element, "Should be an Element");
assert_true(element instanceof HTMLElement, "Should be an HTMLElement");
assert_true(element instanceof HTMLSpanElement, "Should be an HTMLSpanElement");
}, "Lower-case HTML element with a prefix");
test(function() {
var element = document.createElementNS("test", "span");
assert_equals(element.namespaceURI, "test");
assert_equals(element.prefix, null);
assert_equals(element.localName, "span");
assert_equals(element.tagName, "span");
assert_true(element instanceof Node, "Should be a Node");
assert_true(element instanceof Element, "Should be an Element");
assert_false(element instanceof HTMLElement, "Should not be an HTMLElement");
assert_false(element instanceof HTMLSpanElement, "Should not be an HTMLSpanElement");
}, "Lower-case non-HTML element without a prefix");
test(function() {
var element = document.createElementNS("test", "html:span");
assert_equals(element.namespaceURI, "test");
assert_equals(element.prefix, "html");
assert_equals(element.localName, "span");
assert_equals(element.tagName, "html:span");
assert_true(element instanceof Node, "Should be a Node");
assert_true(element instanceof Element, "Should be an Element");
assert_false(element instanceof HTMLElement, "Should not be an HTMLElement");
assert_false(element instanceof HTMLSpanElement, "Should not be an HTMLSpanElement");
}, "Lower-case non-HTML element with a prefix");
test(function() {
var HTMLNS = "http://www.w3.org/1999/xhtml";
var element = document.createElementNS(HTMLNS, "SPAN");
assert_equals(element.namespaceURI, HTMLNS);
assert_equals(element.prefix, null);
assert_equals(element.localName, "SPAN");
assert_equals(element.tagName, "SPAN");
assert_true(element instanceof Node, "Should be a Node");
assert_true(element instanceof Element, "Should be an Element");
assert_true(element instanceof HTMLElement, "Should be an HTMLElement");
assert_true(element instanceof HTMLUnknownElement, "Should be an HTMLUnknownElement");
assert_false(element instanceof HTMLSpanElement, "Should not be an HTMLSpanElement");
}, "Upper-case HTML element without a prefix");
test(function() {
var HTMLNS = "http://www.w3.org/1999/xhtml";
var element = document.createElementNS(HTMLNS, "html:SPAN");
assert_equals(element.namespaceURI, HTMLNS);
assert_equals(element.prefix, "html");
assert_equals(element.localName, "SPAN");
assert_equals(element.tagName, "HTML:SPAN");
assert_true(element instanceof Node, "Should be a Node");
assert_true(element instanceof Element, "Should be an Element");
assert_true(element instanceof HTMLElement, "Should be an HTMLElement");
assert_false(element instanceof HTMLSpanElement, "Should not be an HTMLSpanElement");
}, "Upper-case HTML element with a prefix");
test(function() {
var element = document.createElementNS("test", "SPAN");
assert_equals(element.namespaceURI, "test");
assert_equals(element.prefix, null);
assert_equals(element.localName, "SPAN");
assert_equals(element.tagName, "SPAN");
assert_true(element instanceof Node, "Should be a Node");
assert_true(element instanceof Element, "Should be an Element");
assert_false(element instanceof HTMLElement, "Should not be an HTMLElement");
assert_false(element instanceof HTMLSpanElement, "Should not be an HTMLSpanElement");
}, "Upper-case non-HTML element without a prefix");
test(function() {
var element = document.createElementNS("test", "html:SPAN");
assert_equals(element.namespaceURI, "test");
assert_equals(element.prefix, "html");
assert_equals(element.localName, "SPAN");
assert_equals(element.tagName, "html:SPAN");
assert_true(element instanceof Node, "Should be a Node");
assert_true(element instanceof Element, "Should be an Element");
assert_false(element instanceof HTMLElement, "Should not be an HTMLElement");
assert_false(element instanceof HTMLSpanElement, "Should not be an HTMLSpanElement");
}, "Upper-case non-HTML element with a prefix");
test(function() {
var element = document.createElementNS(null, "span");
assert_equals(element.namespaceURI, null);
assert_equals(element.prefix, null);
assert_equals(element.localName, "span");
assert_equals(element.tagName, "span");
assert_true(element instanceof Node, "Should be a Node");
assert_true(element instanceof Element, "Should be an Element");
assert_false(element instanceof HTMLElement, "Should not be an HTMLElement");
assert_false(element instanceof HTMLSpanElement, "Should not be an HTMLSpanElement");
}, "null namespace");
test(function() {
var element = document.createElementNS(undefined, "span");
assert_equals(element.namespaceURI, null);
assert_equals(element.prefix, null);
assert_equals(element.localName, "span");
assert_equals(element.tagName, "span");
assert_true(element instanceof Node, "Should be a Node");
assert_true(element instanceof Element, "Should be an Element");
assert_false(element instanceof HTMLElement, "Should not be an HTMLElement");
assert_false(element instanceof HTMLSpanElement, "Should not be an HTMLSpanElement");
}, "undefined namespace");
test(function() {
var element = document.createElementNS("", "span");
assert_equals(element.namespaceURI, null);
assert_equals(element.prefix, null);
assert_equals(element.localName, "span");
assert_equals(element.tagName, "span");
assert_true(element instanceof Node, "Should be a Node");
assert_true(element instanceof Element, "Should be an Element");
assert_false(element instanceof HTMLElement, "Should not be an HTMLElement");
assert_false(element instanceof HTMLSpanElement, "Should not be an HTMLSpanElement");
}, "empty string namespace");
</script>

View file

@ -0,0 +1,185 @@
var createElementNS_tests = [
/* Arrays with three elements:
* the namespace argument
* the qualifiedName argument
* the expected exception, or null if none
*/
[null, null, null],
[null, undefined, null],
[null, "foo", null],
[null, "1foo", "INVALID_CHARACTER_ERR"],
[null, "f1oo", null],
[null, "foo1", null],
[null, "\u0BC6foo", "INVALID_CHARACTER_ERR"],
[null, "}foo", "INVALID_CHARACTER_ERR"],
[null, "f}oo", "INVALID_CHARACTER_ERR"],
[null, "foo}", "INVALID_CHARACTER_ERR"],
[null, "\uFFFFfoo", "INVALID_CHARACTER_ERR"],
[null, "f\uFFFFoo", "INVALID_CHARACTER_ERR"],
[null, "foo\uFFFF", "INVALID_CHARACTER_ERR"],
[null, "<foo", "INVALID_CHARACTER_ERR"],
[null, "foo>", "INVALID_CHARACTER_ERR"],
[null, "<foo>", "INVALID_CHARACTER_ERR"],
[null, "f<oo", "INVALID_CHARACTER_ERR"],
[null, "^^", "INVALID_CHARACTER_ERR"],
[null, "fo o", "INVALID_CHARACTER_ERR"],
[null, "-foo", "INVALID_CHARACTER_ERR"],
[null, ".foo", "INVALID_CHARACTER_ERR"],
[null, ":foo", "NAMESPACE_ERR"],
[null, "f:oo", "NAMESPACE_ERR"],
[null, "foo:", "NAMESPACE_ERR"],
[null, "f:o:o", "NAMESPACE_ERR"],
[null, ":", "NAMESPACE_ERR"],
[null, "xml", null],
[null, "xmlns", "NAMESPACE_ERR"],
[null, "xmlfoo", null],
[null, "xml:foo", "NAMESPACE_ERR"],
[null, "xmlns:foo", "NAMESPACE_ERR"],
[null, "xmlfoo:bar", "NAMESPACE_ERR"],
[null, "null:xml", "NAMESPACE_ERR"],
["", null, null],
["", ":foo", "NAMESPACE_ERR"],
["", "f:oo", "NAMESPACE_ERR"],
["", "foo:", "NAMESPACE_ERR"],
[undefined, null, null],
[undefined, undefined, null],
[undefined, "foo", null],
[undefined, "1foo", "INVALID_CHARACTER_ERR"],
[undefined, "f1oo", null],
[undefined, "foo1", null],
[undefined, ":foo", "NAMESPACE_ERR"],
[undefined, "f:oo", "NAMESPACE_ERR"],
[undefined, "foo:", "NAMESPACE_ERR"],
[undefined, "f::oo", "NAMESPACE_ERR"],
[undefined, "xml", null],
[undefined, "xmlns", "NAMESPACE_ERR"],
[undefined, "xmlfoo", null],
[undefined, "xml:foo", "NAMESPACE_ERR"],
[undefined, "xmlns:foo", "NAMESPACE_ERR"],
[undefined, "xmlfoo:bar", "NAMESPACE_ERR"],
["http://example.com/", "foo", null],
["http://example.com/", "1foo", "INVALID_CHARACTER_ERR"],
["http://example.com/", "<foo>", "INVALID_CHARACTER_ERR"],
["http://example.com/", "fo<o", "INVALID_CHARACTER_ERR"],
["http://example.com/", "-foo", "INVALID_CHARACTER_ERR"],
["http://example.com/", ".foo", "INVALID_CHARACTER_ERR"],
["http://example.com/", "f1oo", null],
["http://example.com/", "foo1", null],
["http://example.com/", ":foo", "NAMESPACE_ERR"],
["http://example.com/", "f:oo", null],
["http://example.com/", "f:o:o", "NAMESPACE_ERR"],
["http://example.com/", "foo:", "NAMESPACE_ERR"],
["http://example.com/", "f::oo", "NAMESPACE_ERR"],
["http://example.com/", "a:0", "NAMESPACE_ERR"],
["http://example.com/", "0:a", "INVALID_CHARACTER_ERR"],
["http://example.com/", "a:_", null],
["http://example.com/", "a:\u0BC6", "NAMESPACE_ERR"],
["http://example.com/", "\u0BC6:a", "INVALID_CHARACTER_ERR"],
["http://example.com/", "a:a\u0BC6", null],
["http://example.com/", "a\u0BC6:a", null],
["http://example.com/", "xml:test", "NAMESPACE_ERR"],
["http://example.com/", "xmlns:test", "NAMESPACE_ERR"],
["http://example.com/", "test:xmlns", null],
["http://example.com/", "xmlns", "NAMESPACE_ERR"],
["http://example.com/", "_:_", null],
["http://example.com/", "_:h0", null],
["http://example.com/", "_:test", null],
["http://example.com/", "l_:_", null],
["http://example.com/", "ns:_0", null],
["http://example.com/", "ns:a0", null],
["http://example.com/", "ns0:test", null],
["http://example.com/", "a.b:c", null],
["http://example.com/", "a-b:c", null],
["http://example.com/", "xml", null],
["http://example.com/", "xmlns", "NAMESPACE_ERR"],
["http://example.com/", "XMLNS", null],
["http://example.com/", "xmlfoo", null],
["http://example.com/", "xml:foo", "NAMESPACE_ERR"],
["http://example.com/", "XML:foo", null],
["http://example.com/", "xmlns:foo", "NAMESPACE_ERR"],
["http://example.com/", "XMLNS:foo", null],
["http://example.com/", "xmlfoo:bar", null],
["http://example.com/", "prefix::local", "NAMESPACE_ERR"],
["http://example.com/", "namespaceURI:{", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:}", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:~", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:'", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:!", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:@", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:#", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:$", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:%", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:^", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:&", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:*", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:(", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:)", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:+", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:=", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:[", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:]", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:\\", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:/", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:;", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:`", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:<", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:>", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:,", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:a ", "INVALID_CHARACTER_ERR"],
["http://example.com/", "namespaceURI:\"", "INVALID_CHARACTER_ERR"],
["/", "foo", null],
["/", "1foo", "INVALID_CHARACTER_ERR"],
["/", "f1oo", null],
["/", "foo1", null],
["/", ":foo", "NAMESPACE_ERR"],
["/", "f:oo", null],
["/", "foo:", "NAMESPACE_ERR"],
["/", "xml", null],
["/", "xmlns", "NAMESPACE_ERR"],
["/", "xmlfoo", null],
["/", "xml:foo", "NAMESPACE_ERR"],
["/", "xmlns:foo", "NAMESPACE_ERR"],
["/", "xmlfoo:bar", null],
["http://www.w3.org/XML/1998/namespace", "foo", null],
["http://www.w3.org/XML/1998/namespace", "1foo", "INVALID_CHARACTER_ERR"],
["http://www.w3.org/XML/1998/namespace", "f1oo", null],
["http://www.w3.org/XML/1998/namespace", "foo1", null],
["http://www.w3.org/XML/1998/namespace", ":foo", "NAMESPACE_ERR"],
["http://www.w3.org/XML/1998/namespace", "f:oo", null],
["http://www.w3.org/XML/1998/namespace", "foo:", "NAMESPACE_ERR"],
["http://www.w3.org/XML/1998/namespace", "xml", null],
["http://www.w3.org/XML/1998/namespace", "xmlns", "NAMESPACE_ERR"],
["http://www.w3.org/XML/1998/namespace", "xmlfoo", null],
["http://www.w3.org/XML/1998/namespace", "xml:foo", null],
["http://www.w3.org/XML/1998/namespace", "xmlns:foo", "NAMESPACE_ERR"],
["http://www.w3.org/XML/1998/namespace", "xmlfoo:bar", null],
["http://www.w3.org/XML/1998/namespaces", "xml:foo", "NAMESPACE_ERR"],
["http://www.w3.org/xml/1998/namespace", "xml:foo", "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "foo", "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "1foo", "INVALID_CHARACTER_ERR"],
["http://www.w3.org/2000/xmlns/", "f1oo", "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "foo1", "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", ":foo", "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "f:oo", "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "foo:", "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "xml", "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "xmlns", null],
["http://www.w3.org/2000/xmlns/", "xmlfoo", "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "xml:foo", "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "xmlns:foo", null],
["http://www.w3.org/2000/xmlns/", "xmlfoo:bar", "NAMESPACE_ERR"],
["http://www.w3.org/2000/xmlns/", "foo:xmlns", "NAMESPACE_ERR"],
["foo:", "foo", null],
["foo:", "1foo", "INVALID_CHARACTER_ERR"],
["foo:", "f1oo", null],
["foo:", "foo1", null],
["foo:", ":foo", "NAMESPACE_ERR"],
["foo:", "f:oo", null],
["foo:", "foo:", "NAMESPACE_ERR"],
["foo:", "xml", null],
["foo:", "xmlns", "NAMESPACE_ERR"],
["foo:", "xmlfoo", null],
["foo:", "xml:foo", "NAMESPACE_ERR"],
["foo:", "xmlns:foo", "NAMESPACE_ERR"],
["foo:", "xmlfoo:bar", null],
]

Some files were not shown because too many files have changed in this diff Show more