gecko-dev/testing/web-platform/tests/dom/nodes/CharacterData-substringData.html
James Graham 1ddbbd48c5 Bug 1201822 - Update web-platform-tests to revision d0571e01e1a2e4b8c5f696af2f81cbc1be9a5842, a=testonly
--HG--
rename : testing/web-platform/tests/content-security-policy/blink-contrib/combine-multiple-policies.sub.html.sub.headers => testing/web-platform/tests/content-security-policy/blink-contrib/combine-header-and-meta-policies.sub.html.sub.headers
rename : testing/web-platform/tests/content-security-policy/blink-contrib/resources/shared-worker-make-xhr-blocked.js.sub.headers => testing/web-platform/tests/content-security-policy/blink-contrib/resources/shared-worker-make-xhr-blocked.sub.js.sub.headers
rename : testing/web-platform/tests/content-security-policy/blink-contrib/resources/worker-make-xhr-blocked.js.sub.headers => testing/web-platform/tests/content-security-policy/blink-contrib/resources/worker-make-xhr-blocked.sub.js.sub.headers
rename : testing/web-platform/tests/quirks-mode/font-element-text-decoration-color/001-a.html => testing/web-platform/tests/html/rendering/non-replaced-elements/phrasing-content-0/font-element-text-decoration-color/001-a.html
rename : testing/web-platform/tests/quirks-mode/font-element-text-decoration-color/001-q.html => testing/web-platform/tests/html/rendering/non-replaced-elements/phrasing-content-0/font-element-text-decoration-color/001-q.html
rename : testing/web-platform/tests/quirks-mode/font-element-text-decoration-color/001-ref.html => testing/web-platform/tests/html/rendering/non-replaced-elements/phrasing-content-0/font-element-text-decoration-color/001-ref.html
rename : testing/web-platform/tests/quirks-mode/font-element-text-decoration-color/001-s.html => testing/web-platform/tests/html/rendering/non-replaced-elements/phrasing-content-0/font-element-text-decoration-color/001-s.html
rename : testing/web-platform/tests/quirks-mode/font-element-text-decoration-color/001-x.xhtml => testing/web-platform/tests/html/rendering/non-replaced-elements/phrasing-content-0/font-element-text-decoration-color/001-x.xhtml
2015-09-04 10:39:26 +01:00

137 lines
4.5 KiB
HTML

<!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>