OLD | NEW |
1 description( | 1 description( |
2 "This test checks some DOM Range exceptions." | 2 "This test checks some DOM Range exceptions." |
3 ); | 3 ); |
4 | 4 |
5 // Test to be sure the name BAD_BOUNDARYPOINTS_ERR dumps properly. | 5 // Test to be sure the name BAD_BOUNDARYPOINTS_ERR dumps properly. |
6 var node = document.createElement("DIV"); | 6 var node = document.createElement("DIV"); |
7 node.innerHTML = "<BAR>AB<MOO>C</MOO>DE</BAR>"; | 7 node.innerHTML = "<BAR>AB<MOO>C</MOO>DE</BAR>"; |
8 shouldBe("node.innerHTML", "'<bar>AB<moo>C</moo>DE</bar>'"); | 8 shouldBe("node.innerHTML", "'<bar>AB<moo>C</moo>DE</bar>'"); |
9 var range = document.createRange(); | |
10 range.setStart(node.firstChild, 1); | |
11 range.setEnd(node.firstChild, 2); | |
12 var foo = document.createElement("FOO"); | |
13 shouldBe("foo.outerHTML", "'<foo></foo>'"); | |
14 shouldThrow("range.surroundContents(foo)"); | |
15 | 9 |
16 // Ensure that we throw BAD_BOUNDARYPOINTS_ERR when trying to split a comment | 10 // Ensure that we throw BAD_BOUNDARYPOINTS_ERR when trying to split a comment |
17 // (non-text but character-offset node). (Test adapted from Acid3.) | 11 // (non-text but character-offset node). (Test adapted from Acid3.) |
18 var c1 = document.createComment("aaaaa"); | 12 var c1 = document.createComment("aaaaa"); |
19 node.appendChild(c1); | 13 node.appendChild(c1); |
20 var c2 = document.createComment("bbbbb"); | 14 var c2 = document.createComment("bbbbb"); |
21 node.appendChild(c2); | 15 node.appendChild(c2); |
22 var r = document.createRange(); | 16 var r = document.createRange(); |
23 r.setStart(c1, 2); | 17 r.setStart(c1, 2); |
24 r.setEnd(c2, 3); | 18 r.setEnd(c2, 3); |
25 shouldThrow("r.surroundContents(document.createElement('a'))", '"InvalidStateErr
or: An attempt was made to use an object that is not, or is no longer, usable."'
); | 19 shouldThrow("r.surroundContents(document.createElement('a'))", '"InvalidStateErr
or: An attempt was made to use an object that is not, or is no longer, usable."'
); |
26 | 20 |
27 // But not when we don't try to split the comment. | 21 // But not when we don't try to split the comment. |
28 r.setStart(c1, 0); | 22 r.setStart(c1, 0); |
29 r.setEnd(c1, 5); | 23 r.setEnd(c1, 5); |
30 shouldThrow("r.surroundContents(document.createElement('a'))", '"HierarchyReques
tError: A Node was inserted somewhere it doesn\'t belong."'); | 24 shouldThrow("r.surroundContents(document.createElement('a'))", '"HierarchyReques
tError: A Node was inserted somewhere it doesn\'t belong."'); |
OLD | NEW |