OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <!-- hidden area to create the ranges being tested --> | 7 <!-- hidden area to create the ranges being tested --> |
8 <div style="visibility: hidden"> | 8 <div style="visibility: hidden"> |
9 <div id=a1>a1 | 9 <div id=a1>a1 |
10 <div id=b1>b1</div> | 10 <div id=b1>b1</div> |
11 </div> | 11 </div> |
12 </div> | 12 </div> |
13 | 13 |
14 <script> | 14 <script> |
15 function message(method) { | 15 function execute(method) { |
16 return '"InvalidStateError: Failed to execute \'' + method + '\' on
\'Range\': The range has no container. Perhaps \'detatch()\' has been invoked on
this object?"'; | 16 return '"InvalidStateError: Failed to execute \'' + method + '\' on
\'Range\': The range has no container. Perhaps \'detatch()\' has been invoked on
this object?"'; |
17 } | 17 } |
| 18 function read(property) { |
| 19 return '"InvalidStateError: Failed to read the \'' + property + '\'
property from \'Range\': The range has no container. Perhaps \'detatch()\' has b
een invoked on this object?"'; |
| 20 } |
18 | 21 |
19 description("A variety of Range methods should throw if called on a deta
ched range."); | 22 description("A variety of Range methods should throw if called on a deta
ched range."); |
20 var range = document.createRange(); | 23 var range = document.createRange(); |
21 range.selectNode(document.getElementById("a1")); | 24 range.selectNode(document.getElementById("a1")); |
22 range.detach(); | 25 range.detach(); |
23 | 26 |
24 shouldThrow("range.cloneContents()", message("cloneContents")); | 27 shouldThrow("range.cloneContents()", execute("cloneContents")); |
25 shouldThrow("range.cloneRange()", message("cloneRange")); | 28 shouldThrow("range.cloneRange()", execute("cloneRange")); |
26 shouldThrow("range.collapsed()", message("collapsed")); | 29 shouldThrow("range.collapsed", read("collapsed")); |
27 shouldThrow("range.commonAncestorContainer()", message("commonAncestorCo
ntainer")); | 30 shouldThrow("range.commonAncestorContainer", read("commonAncestorContain
er")); |
28 shouldThrow("range.compareBoundaryPoints(Range.START_TO_END, range)", me
ssage("compareBoundaryPoints")); | 31 shouldThrow("range.compareBoundaryPoints(Range.START_TO_END, range)", ex
ecute("compareBoundaryPoints")); |
29 shouldThrow("range.comparePoint(document.getElementById('b1'), 1)", mess
age("comparePoint")); | 32 shouldThrow("range.comparePoint(document.getElementById('b1'), 1)", exec
ute("comparePoint")); |
30 shouldThrow("range.createContextualFragment('p')", message("createContex
tualFragment")); | 33 shouldThrow("range.createContextualFragment('p')", execute("createContex
tualFragment")); |
31 shouldThrow("range.deleteContents()", message("deleteContents")); | 34 shouldThrow("range.deleteContents()", execute("deleteContents")); |
32 shouldThrow("range.detach()", message("detach")); | 35 shouldThrow("range.detach()", execute("detach")); |
33 shouldThrow("range.endContainer()", message("endContainer")); | 36 shouldThrow("range.endContainer", read("endContainer")); |
34 shouldThrow("range.endOffset()", message("endOffset")); | 37 shouldThrow("range.endOffset", read("endOffset")); |
35 shouldThrow("range.extractContents()", message("extractContents")); | 38 shouldThrow("range.extractContents()", execute("extractContents")); |
36 shouldThrow("range.insertNode(document.getElementById('b1'))", message("
insertNode")); | 39 shouldThrow("range.insertNode(document.getElementById('b1'))", execute("
insertNode")); |
37 shouldThrow("range.intersectsNode(document.getElementById('b1'))", messa
ge("intersectsNode")); | 40 shouldThrow("range.intersectsNode(document.getElementById('b1'))", execu
te("intersectsNode")); |
38 shouldThrow("range.isPointInRange(document.getElementById('b1'))", messa
ge("isPointInRange")); | 41 shouldThrow("range.isPointInRange(document.getElementById('b1'))", execu
te("isPointInRange")); |
39 shouldThrow("range.selectNode(document.getElementById('b1'))", message("
selectNode")); | 42 shouldThrow("range.selectNode(document.getElementById('b1'))", execute("
selectNode")); |
40 shouldThrow("range.selectNodeContents(document.getElementById('b1'))", m
essage("selectNodeContents")); | 43 shouldThrow("range.selectNodeContents(document.getElementById('b1'))", e
xecute("selectNodeContents")); |
41 shouldThrow("range.setEnd(document.getElementById('b1'))", message("setE
nd")); | 44 shouldThrow("range.setEnd(document.getElementById('b1'))", execute("setE
nd")); |
42 shouldThrow("range.setStart(document.getElementById('b1'))", message("se
tStart")); | 45 shouldThrow("range.setStart(document.getElementById('b1'))", execute("se
tStart")); |
43 shouldThrow("range.startContainer()", message("startContainer")); | 46 shouldThrow("range.startContainer", read("startContainer")); |
44 shouldThrow("range.startContainer()", message("startContainer")); | 47 shouldThrow("range.startOffset", read("startOffset")); |
45 shouldThrow("range.startOffset()", message("startOffset")); | 48 shouldThrow("range.surroundContents(document.getElementById('b1'))", exe
cute("surroundContents")); |
46 shouldThrow("range.surroundContents(document.getElementById('b1'))", mes
sage("surroundContents")); | 49 shouldThrow("range.toString()", execute("toString")); |
47 shouldThrow("range.toString()", message("toString")); | |
48 </script> | 50 </script> |
49 </body> | 51 </body> |
50 </html> | 52 </html> |
OLD | NEW |