mirror of
https://github.com/servo/servo.git
synced 2025-07-31 19:20:22 +01:00
Add tests for CharacterDataMethods with non-BMP code points
This commit is contained in:
parent
006dd1002f
commit
dcc8f63d52
8 changed files with 143 additions and 2 deletions
|
@ -29105,8 +29105,24 @@
|
|||
]
|
||||
},
|
||||
"local_changes": {
|
||||
"deleted": [],
|
||||
"items": {},
|
||||
"deleted": [
|
||||
"shadow-dom/shadow-trees/hosting-multiple-shadow-trees-002.html",
|
||||
"shadow-dom/shadow-trees/hosting-multiple-shadow-trees-006.html",
|
||||
"shadow-dom/shadow-trees/hosting-multiple-shadow-trees-004.html",
|
||||
"shadow-dom/shadow-trees/hosting-multiple-shadow-trees-003.html",
|
||||
"2dcontext/transformations/canvas_transformations_reset_001.htm",
|
||||
"shadow-dom/shadow-trees/hosting-multiple-shadow-trees-005.html"
|
||||
],
|
||||
"items": {
|
||||
"testharness": {
|
||||
"dom/nodes/CharacterData-surrogates.html": [
|
||||
{
|
||||
"path": "dom/nodes/CharacterData-surrogates.html",
|
||||
"url": "/dom/nodes/CharacterData-surrogates.html"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"reftest_nodes": {}
|
||||
},
|
||||
"reftest_nodes": {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[CharacterData-surrogates.html]
|
||||
type: testharness
|
||||
expected: CRASH
|
|
@ -66,6 +66,15 @@ function testNode(create, type) {
|
|||
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")
|
||||
|
|
|
@ -78,6 +78,16 @@ function testNode(create, type) {
|
|||
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")
|
||||
|
|
|
@ -73,6 +73,16 @@ function testNode(create, type) {
|
|||
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")
|
||||
|
|
|
@ -146,6 +146,16 @@ function testNode(create, type) {
|
|||
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")
|
||||
|
|
|
@ -121,6 +121,15 @@ function testNode(create, type) {
|
|||
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")
|
||||
|
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue