diff options
Diffstat (limited to 'testing/web-platform/tests/old-tests/submission/Microsoft/selection/addRange.htm')
-rw-r--r-- | testing/web-platform/tests/old-tests/submission/Microsoft/selection/addRange.htm | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/testing/web-platform/tests/old-tests/submission/Microsoft/selection/addRange.htm b/testing/web-platform/tests/old-tests/submission/Microsoft/selection/addRange.htm new file mode 100644 index 000000000..c4b5e9944 --- /dev/null +++ b/testing/web-platform/tests/old-tests/submission/Microsoft/selection/addRange.htm @@ -0,0 +1,72 @@ +<!DOCTYPE HTML> +<html> + <head> + <title id="desc">HTML5 Selection: Add a range to the selection</title> + <script type="text/javascript"> + var testPassed = true; + + function checkSelectionAttributes(anchorNode, anchorOffset, focusNode, focusOffset, collapsed, rangeCount) + { + var selection = window.getSelection(); + if (anchorNode != selection.anchorNode) + { + testPassed = false; + } + if (anchorOffset != selection.anchorOffset) + { + testPassed = false; + } + if (focusNode != selection.focusNode) + { + testPassed = false; + } + if (focusOffset != selection.focusOffset) + { + testPassed = false; + } + if (collapsed != selection.isCollapsed) + { + testPassed = false; + } + if (rangeCount != selection.rangeCount) + { + testPassed = false; + } + } + + function RunTest() + { + try + { + var selection = window.getSelection(); + var p1 = document.getElementById("p1"); + + var range = document.createRange(); + range.selectNode(p1); + selection.addRange(range); + + checkSelectionAttributes(range.startContainer, range.startOffset, range.endContainer, range.endOffset, range.collapsed, 1); + if (p1.firstChild.nodeValue != selection.toString()) + { + testPassed = false; + } + + if (testPassed) + { + document.getElementById("testresult").firstChild.data = "PASS"; + } + } + catch (ex) + { + document.getElementById("testresult").firstChild.data = "FAIL"; + } + } + </script> + </head> + <body onload="RunTest();"> + <p id="p1">Add a range to the selection</p> + <p>Test passes if the word "PASS" appears below.</p> + <div>Test result: </div> + <div id="testresult">FAIL</div> + </body> +</html> |