| OLD | NEW |
| 1 "use strict"; | 1 "use strict"; |
| 2 // TODO: iframes, contenteditable/designMode | 2 // TODO: iframes, contenteditable/designMode |
| 3 | 3 |
| 4 // Everything is done in functions in this test harness, so we have to declare | 4 // Everything is done in functions in this test harness, so we have to declare |
| 5 // all the variables before use to make sure they can be reused. | 5 // all the variables before use to make sure they can be reused. |
| 6 var selection; | 6 var selection; |
| 7 var testDiv, paras, detachedDiv, detachedPara1, detachedPara2, | 7 var testDiv, paras, detachedDiv, detachedPara1, detachedPara2, |
| 8 foreignDoc, foreignPara1, foreignPara2, xmlDoc, xmlElement, | 8 foreignDoc, foreignPara1, foreignPara2, xmlDoc, xmlElement, |
| 9 detachedXmlElement, detachedTextNode, foreignTextNode, | 9 detachedXmlElement, detachedTextNode, foreignTextNode, |
| 10 detachedForeignTextNode, xmlTextNode, detachedXmlTextNode, | 10 detachedForeignTextNode, xmlTextNode, detachedXmlTextNode, |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 selection.collapse(endpoints[2], endpoints[3]); | 957 selection.collapse(endpoints[2], endpoints[3]); |
| 958 selection.extend(endpoints[0], endpoints[1]); | 958 selection.extend(endpoints[0], endpoints[1]); |
| 959 } | 959 } |
| 960 } | 960 } |
| 961 | 961 |
| 962 /** | 962 /** |
| 963 * Verify that the specified func doesn't change the selection. | 963 * Verify that the specified func doesn't change the selection. |
| 964 * This function should be used in testharness tests. | 964 * This function should be used in testharness tests. |
| 965 */ | 965 */ |
| 966 function assertSelectionNoChange(func) { | 966 function assertSelectionNoChange(func) { |
| 967 var originalCount = getSelection().rangeCount; | 967 var originalCount = selection.rangeCount; |
| 968 var originalRange = originalCount == 0 ? null : selection.getRangeAt(0); | 968 var originalRange = originalCount == 0 ? null : selection.getRangeAt(0); |
| 969 var originalAnchorNode = selection.anchorNode; |
| 970 var originalAnchorOffset = selection.anchorOffset; |
| 971 var originalFocusNode = selection.focusNode; |
| 972 var originalFocusOffset = selection.focusOffset; |
| 969 | 973 |
| 970 func(); | 974 func(); |
| 971 | 975 |
| 972 assert_equals(selection.rangeCount, originalCount, | 976 assert_equals(selection.rangeCount, originalCount, |
| 973 "The operation should not add Range"); | 977 "The operation should not add Range"); |
| 978 assert_equals(selection.anchorNode, originalAnchorNode, |
| 979 "The operation should not update anchorNode"); |
| 980 assert_equals(selection.anchorOffset, originalAnchorOffset, |
| 981 "The operation should not update anchorOffset"); |
| 982 assert_equals(selection.focusNode, originalFocusNode, |
| 983 "The operation should not update focusNode"); |
| 984 assert_equals(selection.focusOffset, originalFocusOffset, |
| 985 "The operation should not update focusOffset"); |
| 974 if (originalCount < 1) | 986 if (originalCount < 1) |
| 975 return; | 987 return; |
| 976 assert_equals(selection.getRangeAt(0), originalRange, | 988 assert_equals(selection.getRangeAt(0), originalRange, |
| 977 "The operation should not replace a registered Range"); | 989 "The operation should not replace a registered Range"); |
| 978 } | 990 } |
| 979 | 991 |
| 980 /** | 992 /** |
| 981 * Check if the specified node can be selectable with window.getSelection() | 993 * Check if the specified node can be selectable with window.getSelection() |
| 982 * methods. | 994 * methods. |
| 983 */ | 995 */ |
| 984 function isSelectableNode(node) { | 996 function isSelectableNode(node) { |
| 985 if (!node) | 997 if (!node) |
| 986 return false; | 998 return false; |
| 987 if (node.nodeType == Node.DOCUMENT_TYPE_NODE) | 999 if (node.nodeType == Node.DOCUMENT_TYPE_NODE) |
| 988 return false; | 1000 return false; |
| 989 return document.contains(node); | 1001 return document.contains(node); |
| 990 } | 1002 } |
| OLD | NEW |