mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
add test case of dom characterdata
This commit is contained in:
parent
8ad3c5aeb6
commit
e45b104721
1 changed files with 44 additions and 0 deletions
44
tests/content/test_characterdata.html
Normal file
44
tests/content/test_characterdata.html
Normal file
|
@ -0,0 +1,44 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="harness.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>This is the character data</p>
|
||||
</body>
|
||||
<script>
|
||||
var a = document.getElementsByTagName('p')[0].childNodes[0];
|
||||
is(a.data, "This is the character data");
|
||||
// append test utf8
|
||||
a.appendData(", append more 資料,測試資料");
|
||||
is(a.data, "This is the character data, append more 資料,測試資料");
|
||||
|
||||
// length test utf8
|
||||
is(a.length, 47);
|
||||
|
||||
// insert test non-utf8
|
||||
a.insertData(26, " test");
|
||||
is(a.data, "This is the character data test, append more 資料,測試資料");
|
||||
// insert test utf8
|
||||
a.insertData(48, "更多");
|
||||
is(a.data, "This is the character data test, append more 資料,更多測試資料");
|
||||
|
||||
// delete test non-utf8
|
||||
a.deleteData(40, 5);
|
||||
is(a.data, "This is the character data test, append 資料,更多測試資料");
|
||||
// delete test utf8
|
||||
a.deleteData(45, 2);
|
||||
is(a.data, "This is the character data test, append 資料,更多資料");
|
||||
|
||||
// replace test non-utf8
|
||||
a.replaceData(33, 6, "other");
|
||||
is(a.data, "This is the character data test, other 資料,更多資料");
|
||||
// replace test non-utf8
|
||||
a.replaceData(44, 2, "文字");
|
||||
is(a.data, "This is the character data test, other 資料,更多文字");
|
||||
|
||||
// substring test non-utf8
|
||||
is(a.substringData(12, 4), "char");
|
||||
// substring test utf8
|
||||
is(a.substringData(39, 2), "資料");
|
||||
</script>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue