accessible/tests/mochitest/text/test_hypertext.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial