Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / text / selection-exceptions.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 </head>
5 <body>
6     <script src="../../resources/js-test.js"></script>
7     <script>
8         description("This tests that 'Selection' methods throw exceptions with reasonable messages.");
9
10         shouldThrow('getSelection().collapse(document.documentElement, -1)', '"IndexSizeError: Failed to execute \'collapse\' on \'Selection\': -1 is not a valid offset."');
11
12         getSelection().empty();
13         shouldThrow('getSelection().collapseToStart()', '"InvalidStateError: Failed to execute \'collapseToStart\' on \'Selection\': there is no selection."');
14         shouldThrow('getSelection().collapseToEnd()', '"InvalidStateError: Failed to execute \'collapseToEnd\' on \'Selection\': there is no selection."');
15
16         shouldThrow('getSelection().setBaseAndExtent(document.documentElement, -1, document.documentElement, 0)', '"IndexSizeError: Failed to execute \'setBaseAndExtent\' on \'Selection\': -1 is not a valid base offset."');
17         shouldThrow('getSelection().setBaseAndExtent(document.documentElement, 0, document.documentElement, -1)', '"IndexSizeError: Failed to execute \'setBaseAndExtent\' on \'Selection\': -1 is not a valid extent offset."');
18
19         shouldThrow('getSelection().collapse(document.documentElement, -1)', '"IndexSizeError: Failed to execute \'collapse\' on \'Selection\': -1 is not a valid offset."');
20
21         shouldThrow('getSelection().getRangeAt(-1)', '"IndexSizeError: Failed to execute \'getRangeAt\' on \'Selection\': -1 is not a valid index."');
22
23         shouldThrow('getSelection().extend(0, -1)', '"TypeError: Failed to execute \'extend\' on \'Selection\': parameter 1 is not of type \'Node\'."');
24         shouldThrow('getSelection().extend(document.documentElement, -1)', '"IndexSizeError: Failed to execute \'extend\' on \'Selection\': -1 is not a valid offset."');
25         shouldThrow('getSelection().extend(document.documentElement, 1000)', '"IndexSizeError: Failed to execute \'extend\' on \'Selection\': 1000 is larger than the given node\'s length."');
26     </script>
27 </body>
28 </html>