Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/CharacterData-insertData.html

Issue 1529523002: Import dom/ from web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak W3CImportExpectations Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>CharacterData.insertData</title>
4 <link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-insertdata">
5 <link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
6 <script src="../../../../resources/testharness.js"></script>
7 <script src="../../../../resources/testharnessreport.js"></script>
8 <div id="log"></div>
9 <script>
10 function testNode(create, type) {
11 test(function() {
12 var node = create()
13 assert_equals(node.data, "test")
14
15 assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "x") })
16 assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "") })
17 }, type + ".insertData() out of bounds")
18
19 test(function() {
20 var node = create()
21 assert_equals(node.data, "test")
22
23 assert_throws("INDEX_SIZE_ERR", function() { node.insertData(-1, "x") })
24 assert_throws("INDEX_SIZE_ERR", function() { node.insertData(-0x100000000 + 5, "x") })
25 }, type + ".insertData() negative out of bounds")
26
27 test(function() {
28 var node = create()
29 assert_equals(node.data, "test")
30
31 node.insertData(-0x100000000 + 2, "X")
32 assert_equals(node.data, "teXst")
33 }, type + ".insertData() negative in bounds")
34
35 test(function() {
36 var node = create()
37 assert_equals(node.data, "test")
38
39 node.insertData(0, "")
40 assert_equals(node.data, "test")
41 }, type + ".insertData('')")
42
43 test(function() {
44 var node = create()
45 assert_equals(node.data, "test")
46
47 node.insertData(0, "X")
48 assert_equals(node.data, "Xtest")
49 }, type + ".insertData() at the start")
50
51 test(function() {
52 var node = create()
53 assert_equals(node.data, "test")
54
55 node.insertData(2, "X")
56 assert_equals(node.data, "teXst")
57 }, type + ".insertData() in the middle")
58
59 test(function() {
60 var node = create()
61 assert_equals(node.data, "test")
62
63 node.insertData(4, "ing")
64 assert_equals(node.data, "testing")
65 }, type + ".insertData() at the end")
66
67 test(function() {
68 var node = create()
69 node.data = "This is the character data, append more 資料,測試資料";
70
71 node.insertData(26, " test");
72 assert_equals(node.data, "This is the character data test, append more 資料,測試 資料");
73 node.insertData(48, "更多");
74 assert_equals(node.data, "This is the character data test, append more 資料,更多 測試資料");
75 }, type + ".insertData() with non-ascii data")
76
77 test(function() {
78 var node = create()
79 assert_equals(node.data, "test")
80
81 node.data = "🌠 test 🌠 TEST"
82
83 node.insertData(5, "--"); // Counting UTF-16 code units
84 assert_equals(node.data, "🌠 te--st 🌠 TEST");
85 }, type + ".insertData() with non-BMP data")
86 }
87
88 testNode(function() { return document.createTextNode("test") }, "Text")
89 testNode(function() { return document.createComment("test") }, "Comment")
90 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698