test_hypertext.html (4625B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>nsIAccessibleText getText related function tests for rich text</title> 5 <link rel="stylesheet" type="text/css" 6 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 7 8 <style> 9 #listitemnone { 10 list-style-type: none; 11 } 12 h6.gencontent:before { 13 content: "aga" 14 } 15 </style> 16 17 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 18 <script type="application/javascript" 19 src="../common.js"></script> 20 <script type="application/javascript" 21 src="../text.js"></script> 22 23 <script type="application/javascript"> 24 function doTest() { 25 // //////////////////////////////////////////////////////////////////////// 26 // null getText 27 // //////////////////////////////////////////////////////////////////////// 28 29 var emptyTextAcc = getAccessible("nulltext", [nsIAccessibleText]); 30 is(emptyTextAcc.getText(0, -1), "", "getText() END_OF_TEXT with null string"); 31 is(emptyTextAcc.getText(0, 0), "", "getText() Len==0 with null string"); 32 33 // //////////////////////////////////////////////////////////////////////// 34 // hypertext 35 // //////////////////////////////////////////////////////////////////////// 36 37 // ! - embedded object char 38 // __h__e__l__l__o__ __!__ __s__e__e__ __!__ 39 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 40 41 var IDs = [ "hypertext", "hypertext2", "ht_displaycontents" ]; 42 43 // ////////////////////////////////////////////////////////////////////// 44 // characterCount 45 46 testCharacterCount(IDs, 13); 47 48 // ////////////////////////////////////////////////////////////////////// 49 // getText 50 51 testText(IDs, 0, 1, "h"); 52 testText(IDs, 5, 7, " " + kEmbedChar); 53 testText(IDs, 10, 13, "e " + kEmbedChar); 54 testText(IDs, 0, 13, "hello " + kEmbedChar + " see " + kEmbedChar); 55 56 // ////////////////////////////////////////////////////////////////////// 57 // getTextAtOffset line boundary 58 59 testTextAtOffset(0, BOUNDARY_LINE_START, "line ", 0, 5, 60 "hypertext3", kOk, kOk, kOk); 61 62 // XXX: see bug 634202. 63 testTextAtOffset(0, BOUNDARY_LINE_START, "line ", 0, 5, 64 "hypertext4", kOk, kOk, kOk); 65 66 // //////////////////////////////////////////////////////////////////////// 67 // list 68 // //////////////////////////////////////////////////////////////////////// 69 70 IDs = [ "list" ]; 71 testCharacterCount(IDs, 2); 72 testText(IDs, 0, 2, kEmbedChar + kEmbedChar); 73 74 IDs = [ "listitem" ]; 75 testCharacterCount(IDs, 6); 76 testText(IDs, 0, 6, "1. foo"); 77 78 IDs = [ "listitemnone" ]; 79 testCharacterCount(IDs, 3); 80 testText(IDs, 0, 3, "bar"); 81 82 testText(["testbr"], 0, 3, "foo"); 83 84 testTextAtOffset(2, nsIAccessibleText.BOUNDARY_CHAR, "o", 2, 3, "testbr", 85 kOk, kOk, kOk); 86 testTextAtOffset(2, nsIAccessibleText.BOUNDARY_WORD_START, "foo\n", 0, 4, 87 "testbr", kOk, kOk, kOk); 88 testTextBeforeOffset(2, nsIAccessibleText.BOUNDARY_LINE_START, "foo\n", 89 0, 4, "testbr", kTodo, kOk, kTodo); 90 91 SimpleTest.finish(); 92 } 93 94 SimpleTest.waitForExplicitFinish(); 95 addA11yLoadEvent(doTest); 96 </script> 97 </head> 98 <body> 99 100 <a target="_blank" 101 title="Fix getText" 102 href="https://bugzilla.mozilla.org/show_bug.cgi?id=630001"> 103 Bug 630001, part3 104 </a> 105 <a target="_blank" 106 title="getTextAtOffset line boundary may return more than one line" 107 href="https://bugzilla.mozilla.org/show_bug.cgi?id=638326"> 108 Bug 638326 109 </a> 110 <a target="_blank" 111 title="getText(0, -1) fails with empty text" 112 href="https://bugzilla.mozilla.org/show_bug.cgi?id=749810"> 113 Bug 749810 114 </a> 115 116 <p id="display"></p> 117 <div id="content" style="display: none"></div> 118 <pre id="test"> 119 </pre> 120 121 <div id="nulltext"></div> 122 123 <div id="hypertext">hello <a>friend</a> see <img src="about:blank"></div> 124 <div id="hypertext2">hello <a>friend</a> see <input></div> 125 <div id="ht_displaycontents">hello <a>friend</a> see <ul id="ul" style="display: contents;"> 126 <li>Supermarket 1</li> 127 <li>Supermarket 2</li> 128 </ul></div> 129 <ol id="list"> 130 <li id="listitem">foo</li> 131 <li id="listitemnone">bar</li> 132 </ol> 133 134 <div id="hypertext3">line 135 <!-- haha --> 136 <!-- hahaha --> 137 <h6>heading</h6> 138 </div> 139 140 <div id="hypertext4">line 141 <!-- haha --> 142 <!-- hahaha --> 143 <h6 role="presentation" class="gencontent">heading</h6> 144 </div> 145 146 <div id="testbr">foo<br/></div> 147 148 <div></div> 149 </body> 150 </html>