| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!doctype html> |
| 2 <html> | 2 <script src="../../../resources/testharness.js"></script> |
| 3 <head> | 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <script src="../../../resources/js-test.js"></script> | |
| 5 </head> | |
| 6 <body> | |
| 7 <script> | 4 <script> |
| 8 description("Test deleteData() + replaceData() overflow handling."); | 5 test(() => { |
| 6 const textNode = new Text('chopped off and then some'); |
| 7 const range = new Range(); |
| 8 range.setStart(textNode, textNode.length); |
| 9 textNode.deleteData(11, 0xfffffff7); |
| 10 assert_equals(textNode.data, 'chopped off'); |
| 11 assert_equals(range.endOffset, 11); |
| 12 }, 'Range#deleteData() with huge end offset'); |
| 9 | 13 |
| 10 var textNode; | 14 test(() => { |
| 11 var range; | 15 const textNode = new Text('hello world'); |
| 16 const range = new Range(); |
| 17 range.setStart(textNode, textNode.length); |
| 18 textNode.replaceData(6, 0xfffffffe, 'bob'); |
| 19 assert_equals(textNode.data, 'hello bob'); |
| 20 assert_equals(range.endOffset, 6); |
| 21 }, 'Range#replaceData() with huge end offset'); |
| 12 | 22 |
| 13 shouldBeNonNull("textNode = new Text('chopped off and then some'); textNode"); | 23 test(() => { |
| 14 document.body.appendChild(textNode); | 24 const textNode = new Text('hello world'); |
| 15 document.getSelection().extend(textNode, textNode.length); | 25 const range = new Range(); |
| 16 range = document.getSelection().getRangeAt(0); | 26 range.setStart(textNode, textNode.length); |
| 27 textNode.replaceData(6, -1, 'bob'); |
| 28 assert_equals(textNode.data, 'hello bob'); |
| 29 assert_equals(range.endOffset, 6); |
| 30 }, 'Range#replaceData() with negative end offset(-1)'); |
| 17 | 31 |
| 18 shouldBeEqualToString("textNode.deleteData(11, 0xfffffff7); textNode.data", "cho
pped off"); | 32 test(() => { |
| 19 shouldBe("range.endOffset", "11"); | 33 const textNode = new Text('hello world'); |
| 20 document.body.removeChild(textNode); | 34 const range = new Range(); |
| 21 | 35 range.setStart(textNode, textNode.length); |
| 22 shouldBeNonNull("textNode = new Text('hello world'); textNode"); | 36 textNode.replaceData(6, -2, 'bob'); |
| 23 document.body.appendChild(textNode); | 37 assert_equals(textNode.data, 'hello bob'); |
| 24 document.getSelection().extend(textNode, textNode.length); | 38 assert_equals(range.endOffset, 6); |
| 25 range = document.getSelection().getRangeAt(0); | 39 }, 'Range#replaceData() with negative end offset(-2)'); |
| 26 | |
| 27 shouldBeEqualToString("textNode.replaceData(6, 0xfffffffe, 'bob'); textNode.data
", "hello bob"); | |
| 28 shouldBe("range.endOffset", "6"); | |
| 29 document.body.removeChild(textNode); | |
| 30 | |
| 31 shouldBeNonNull("textNode = new Text('hello world'); textNode"); | |
| 32 shouldBeEqualToString("textNode.replaceData(6, -1, 'bob'); textNode.data", "hell
o bob"); | |
| 33 shouldBeNonNull("textNode = new Text('hello world'); textNode"); | |
| 34 shouldBeEqualToString("textNode.replaceData(6, -2, 'bob'); textNode.data", "hell
o bob"); | |
| 35 </script> | 40 </script> |
| 36 </body> | |
| 37 </html> | |
| OLD | NEW |