1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/text/test_charboundary.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,140 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<head> 1.7 + <title>Char boundary text tests</title> 1.8 + <link rel="stylesheet" type="text/css" 1.9 + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.10 + 1.11 + <script type="application/javascript" 1.12 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <script type="application/javascript" 1.14 + src="../common.js"></script> 1.15 + <script type="application/javascript" 1.16 + src="../text.js"></script> 1.17 + 1.18 + <script type="application/javascript"> 1.19 + function doTest() 1.20 + { 1.21 + ////////////////////////////////////////////////////////////////////////// 1.22 + // 1.23 + // __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__ 1.24 + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1.25 + 1.26 + var IDs = [ "i1", "d1", "e1", "t1" ]; 1.27 + 1.28 + testCharBeforeOffset(IDs, 0, "", 0, 0); 1.29 + testCharBeforeOffset(IDs, 1, "h", 0, 1); 1.30 + testCharBeforeOffset(IDs, 14, "n", 13, 14); 1.31 + testCharBeforeOffset(IDs, 15, "d", 14, 15); 1.32 + 1.33 + testCharAtOffset(IDs, 0, "h", 0, 1); 1.34 + testCharAtOffset(IDs, 1, "e", 1, 2); 1.35 + testCharAtOffset(IDs, 14, "d", 14, 15); 1.36 + testCharAtOffset(IDs, 15, "", 15, 15); 1.37 + 1.38 + testCharAfterOffset(IDs, 0, "e", 1, 2); 1.39 + testCharAfterOffset(IDs, 1, "l", 2, 3); 1.40 + testCharAfterOffset(IDs, 14, "", 15, 15); 1.41 + testCharAfterOffset(IDs, 15, "", 15, 15); 1.42 + 1.43 + ////////////////////////////////////////////////////////////////////////// 1.44 + // 1.45 + // __B__r__a__v__e__ __S__i__r__ __ __R__o__b__i__n__ __ __ __r__a__n 1.46 + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1.47 + 1.48 + IDs = [ "i2", "d2", "e2", "t2" ]; 1.49 + 1.50 + testCharBeforeOffset(IDs, 0, "", 0, 0); 1.51 + testCharBeforeOffset(IDs, 1, "B", 0, 1); 1.52 + testCharBeforeOffset(IDs, 6, " ", 5, 6); 1.53 + testCharBeforeOffset(IDs, 10, " ", 9, 10); 1.54 + testCharBeforeOffset(IDs, 11, " ", 10, 11); 1.55 + testCharBeforeOffset(IDs, 17, " ", 16, 17); 1.56 + testCharBeforeOffset(IDs, 19, " ", 18, 19); 1.57 + 1.58 + testCharAtOffset(IDs, 0, "B", 0, 1); 1.59 + testCharAtOffset(IDs, 1, "r", 1, 2); 1.60 + testCharAtOffset(IDs, 5, " ", 5, 6); 1.61 + testCharAtOffset(IDs, 9, " ", 9, 10); 1.62 + testCharAtOffset(IDs, 10, " ", 10, 11); 1.63 + testCharAtOffset(IDs, 17, " ", 17, 18); 1.64 + 1.65 + testCharAfterOffset(IDs, 0, "r", 1, 2); 1.66 + testCharAfterOffset(IDs, 1, "a", 2, 3); 1.67 + testCharAfterOffset(IDs, 4, " ", 5, 6); 1.68 + testCharAfterOffset(IDs, 5, "S", 6, 7); 1.69 + testCharAfterOffset(IDs, 8, " ", 9, 10); 1.70 + testCharAfterOffset(IDs, 9, " ", 10, 11); 1.71 + testCharAfterOffset(IDs, 10, "R", 11, 12); 1.72 + testCharAfterOffset(IDs, 15, " ", 16, 17); 1.73 + testCharAfterOffset(IDs, 16, " ", 17, 18); 1.74 + testCharAfterOffset(IDs, 17, " ", 18, 19); 1.75 + testCharAfterOffset(IDs, 18, "r", 19, 20); 1.76 + 1.77 + ////////////////////////////////////////////////////////////////////////// 1.78 + // 1.79 + // __o__n__e__w__o__r__d__\n 1.80 + // 0 1 2 3 4 5 6 7 1.81 + // __\n 1.82 + // 8 1.83 + // __t__w__o__ __w__o__r__d__s__\n 1.84 + // 9 10 11 12 13 14 15 16 17 18 1.85 + 1.86 + IDs = ["d3", "dbr3", "e3", "ebr3", "t3"]; 1.87 + 1.88 + testCharBeforeOffset(IDs, 8, "\n", 7, 8); 1.89 + testCharBeforeOffset(IDs, 9, "\n", 8, 9); 1.90 + testCharBeforeOffset(IDs, 10, "t", 9, 10); 1.91 + 1.92 + testCharAtOffset(IDs, 7, "\n", 7, 8); 1.93 + testCharAtOffset(IDs, 8, "\n", 8, 9); 1.94 + testCharAtOffset(IDs, 9, "t", 9, 10); 1.95 + 1.96 + testCharAfterOffset(IDs, 6, "\n", 7, 8); 1.97 + testCharAfterOffset(IDs, 7, "\n", 8, 9); 1.98 + testCharAfterOffset(IDs, 8, "t", 9, 10); 1.99 + 1.100 + SimpleTest.finish(); 1.101 + } 1.102 + 1.103 + SimpleTest.waitForExplicitFinish(); 1.104 + addA11yLoadEvent(doTest); 1.105 + </script> 1.106 +</head> 1.107 +<body> 1.108 + 1.109 + <p id="display"></p> 1.110 + <div id="content" style="display: none"></div> 1.111 + <pre id="test"> 1.112 + </pre> 1.113 + 1.114 + <input id="i1" value="hello my friend"/> 1.115 + <div id="d1">hello my friend</div> 1.116 + <div id="e1" contenteditable="true">hello my friend</div> 1.117 + <textarea id="t1" contenteditable="true">hello my friend</textarea> 1.118 + 1.119 + <input id="i2" value="Brave Sir Robin ran"/> 1.120 + <pre> 1.121 + <div id="d2">Brave Sir Robin ran</div> 1.122 + <div id="e2" contenteditable="true">Brave Sir Robin ran</div> 1.123 + </pre> 1.124 + <textarea id="t2" cols="300">Brave Sir Robin ran</textarea> 1.125 + 1.126 + <pre> 1.127 + <div id="d3">oneword 1.128 + 1.129 +two words 1.130 +</div> 1.131 + <div id="dbr3">oneword<br/><br/>two words<br/></div> 1.132 + <div id="e3" contenteditable="true">oneword 1.133 + 1.134 +two words 1.135 +</div> 1.136 + <div id="ebr3" contenteditable="true">oneword<br/><br/>two words<br/></div> 1.137 + <textarea id="t3" cols="300">oneword 1.138 + 1.139 +two words</textarea> 1.140 + </pre> 1.141 + 1.142 +</body> 1.143 +</html>