1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/text/test_hypertext.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,137 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<head> 1.7 + <title>nsIAccessibleText getText related function tests for rich text</title> 1.8 + <link rel="stylesheet" type="text/css" 1.9 + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.10 + 1.11 + <style> 1.12 + h6.gencontent:before { 1.13 + content: "aga" 1.14 + } 1.15 + </style> 1.16 + 1.17 + <script type="application/javascript" 1.18 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.19 + <script type="application/javascript" 1.20 + src="../common.js"></script> 1.21 + <script type="application/javascript" 1.22 + src="../text.js"></script> 1.23 + 1.24 + <script type="application/javascript"> 1.25 + function doTest() 1.26 + { 1.27 + ////////////////////////////////////////////////////////////////////////// 1.28 + // null getText 1.29 + ////////////////////////////////////////////////////////////////////////// 1.30 + 1.31 + var emptyTextAcc = getAccessible("nulltext", [nsIAccessibleText]); 1.32 + is(emptyTextAcc.getText(0, -1), "", "getText() END_OF_TEXT with null string"); 1.33 + is(emptyTextAcc.getText(0, 0), "", "getText() Len==0 with null string"); 1.34 + 1.35 + ////////////////////////////////////////////////////////////////////////// 1.36 + // hypertext 1.37 + ////////////////////////////////////////////////////////////////////////// 1.38 + 1.39 + // ! - embedded object char 1.40 + // __h__e__l__l__o__ __!__ __s__e__e__ __!__ 1.41 + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 1.42 + 1.43 + var IDs = [ "hypertext", "hypertext2" ]; 1.44 + 1.45 + //////////////////////////////////////////////////////////////////////// 1.46 + // characterCount 1.47 + 1.48 + testCharacterCount(IDs, 13); 1.49 + 1.50 + //////////////////////////////////////////////////////////////////////// 1.51 + // getText 1.52 + 1.53 + testText(IDs, 0, 1, "h"); 1.54 + testText(IDs, 5, 7, " " + kEmbedChar); 1.55 + testText(IDs, 10, 13, "e " + kEmbedChar); 1.56 + testText(IDs, 0, 13, "hello " + kEmbedChar + " see " + kEmbedChar); 1.57 + 1.58 + //////////////////////////////////////////////////////////////////////// 1.59 + // getTextAtOffset line boundary 1.60 + 1.61 + testTextAtOffset(0, BOUNDARY_LINE_START, "line ", 0, 5, 1.62 + "hypertext3", kOk, kOk, kOk); 1.63 + 1.64 + // XXX: see bug 634202. 1.65 + testTextAtOffset(0, BOUNDARY_LINE_START, "line ", 0, 5, 1.66 + "hypertext4", kTodo, kOk, kTodo); 1.67 + 1.68 + ////////////////////////////////////////////////////////////////////////// 1.69 + // list 1.70 + ////////////////////////////////////////////////////////////////////////// 1.71 + 1.72 + IDs = [ "list" ]; 1.73 + testCharacterCount(IDs, 1); 1.74 + testText(IDs, 0, 1, kEmbedChar); 1.75 + 1.76 + IDs = [ "listitem" ]; 1.77 + testCharacterCount(IDs, 5); 1.78 + testText(IDs, 0, 5, "1.foo"); 1.79 + 1.80 + testText(["testbr"], 0, 3, "foo"); 1.81 + 1.82 + testTextAtOffset(2, nsIAccessibleText.BOUNDARY_CHAR, "o", 2, 3, "testbr", 1.83 + kOk, kOk, kOk); 1.84 + testTextAtOffset(2, nsIAccessibleText.BOUNDARY_WORD_START, "foo\n", 0, 4, 1.85 + "testbr", kTodo, kOk, kTodo); 1.86 + testTextBeforeOffset(2, nsIAccessibleText.BOUNDARY_LINE_START, "foo\n", 1.87 + 0, 4, "testbr", kTodo, kOk, kTodo); 1.88 + 1.89 + SimpleTest.finish(); 1.90 + } 1.91 + 1.92 + SimpleTest.waitForExplicitFinish(); 1.93 + addA11yLoadEvent(doTest); 1.94 + </script> 1.95 +</head> 1.96 +<body> 1.97 + 1.98 + <a target="_blank" 1.99 + title="Fix getText" 1.100 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=630001"> 1.101 + Bug 630001, part3 1.102 + </a> 1.103 + <a target="_blank" 1.104 + title="getTextAtOffset line boundary may return more than one line" 1.105 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=638326"> 1.106 + Bug 638326 1.107 + </a> 1.108 + <a target="_blank" 1.109 + title="getText(0, -1) fails with empty text" 1.110 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=749810"> 1.111 + Bug 749810 1.112 + </a> 1.113 + 1.114 + <p id="display"></p> 1.115 + <div id="content" style="display: none"></div> 1.116 + <pre id="test"> 1.117 + </pre> 1.118 + 1.119 + <div id="nulltext"></div> 1.120 + 1.121 + <div id="hypertext">hello <a>friend</a> see <img></div> 1.122 + <div id="hypertext2">hello <a>friend</a> see <input></div> 1.123 + <ol id="list"><li id="listitem">foo</li></ol> 1.124 + 1.125 + <div id="hypertext3">line 1.126 +<!-- haha --> 1.127 +<!-- hahaha --> 1.128 +<h6>heading</h6> 1.129 + </div> 1.130 + 1.131 + <div id="hypertext4">line 1.132 +<!-- haha --> 1.133 +<!-- hahaha --> 1.134 +<h6 role="presentation" class="gencontent">heading</h6> 1.135 + </div> 1.136 + 1.137 + <div id="testbr">foo<br/></div> 1.138 + 1.139 +</body> 1.140 +</html>