accessible/tests/mochitest/text/test_lineboundary.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4   <title>Line boundary getText* functions tests</title>
     5   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
     7   <script type="application/javascript"
     8           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="application/javascript"
    10           src="../common.js"></script>
    11   <script type="application/javascript"
    12           src="../text.js"></script>
    13   <script type="application/javascript">
    14     function doTest()
    15     {
    16       //////////////////////////////////////////////////////////////////////////
    17       // __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__
    18       //  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
    20       var IDs = [ "input", "div", "editable", "textarea",
    21                   getNode("ta", getNode("ta_cntr").contentDocument) ];
    23       testTextBeforeOffset(IDs, BOUNDARY_LINE_START,
    24                            [ [ 0, 15, "", 0, 0 ] ]);
    25       testTextBeforeOffset(IDs, BOUNDARY_LINE_END,
    26                            [ [ 0, 15, "", 0, 0 ] ]);
    28       testTextAtOffset(IDs, BOUNDARY_LINE_START,
    29                        [ [ 0, 15, "hello my friend", 0, 15 ] ]);
    30       testTextAtOffset(IDs, BOUNDARY_LINE_END,
    31                        [ [ 0, 15, "hello my friend", 0, 15 ] ]);
    33       testTextAfterOffset(IDs, BOUNDARY_LINE_START,
    34                           [ [ 0, 15, "", 15, 15 ] ]);
    35       testTextAfterOffset(IDs, BOUNDARY_LINE_END,
    36                           [ [ 0, 15, "", 15, 15 ] ]);
    38       //////////////////////////////////////////////////////////////////////////
    39       // __o__n__e__w__o__r__d__\n
    40       //  0  1  2  3  4  5  6  7
    41       // __\n
    42       //  8
    43       // __t__w__o__ __w__o__r__d__s__\n
    44       //  9 10 11 12 13 14 15 16 17 18
    46       IDs = [ "ml_div", "ml_divbr", "ml_editable", "ml_editablebr", "ml_textarea"];
    48       testTextBeforeOffset(IDs, BOUNDARY_LINE_START,
    49                            [ [ 0, 7, "", 0, 0 ],
    50                              [ 8, 8, "oneword\n", 0, 8 ],
    51                              [ 9, 18, "\n", 8, 9 ],
    52                              [ 19, 19, "two words\n", 9, 19 ]]);
    54       testTextBeforeOffset(IDs, BOUNDARY_LINE_END,
    55                           [ [ 0, 7, "", 0, 0 ],
    56                             [ 8, 8, "oneword", 0, 7 ],
    57                             [ 9, 18, "\n", 7, 8 ],
    58                             [ 19, 19, "\ntwo words", 8, 18 ]]);
    60       testTextAtOffset(IDs, BOUNDARY_LINE_START,
    61                        [ [ 0, 7, "oneword\n", 0, 8 ],
    62                          [ 8, 8, "\n", 8, 9 ],
    63                          [ 9, 18, "two words\n", 9, 19 ],
    64                          [ 19, 19, "", 19, 19 ]]);
    65       testTextAtOffset(IDs, BOUNDARY_LINE_END,
    66                        [ [ 0, 7, "oneword", 0, 7 ],
    67                          [ 8, 8, "\n", 7, 8 ],
    68                          [ 9, 18, "\ntwo words", 8, 18 ],
    69                          [ 19, 19, "\n", 18, 19 ]]);
    71       testTextAfterOffset(IDs, BOUNDARY_LINE_START,
    72                           [ [ 0, 7, "\n", 8, 9 ],
    73                             [ 8, 8, "two words\n", 9, 19 ],
    74                             [ 9, 19, "", 19, 19 ]]);
    75       testTextAfterOffset(IDs, BOUNDARY_LINE_END,
    76                           [ [ 0, 7, "\n", 7, 8 ],
    77                             [ 8, 8, "\ntwo words", 8, 18 ],
    78                             [ 9, 18, "\n", 18, 19 ],
    79                             [ 19, 19, "", 19, 19 ]]);
    81       //////////////////////////////////////////////////////////////////////////
    82       // a * b (* is embedded char for link)
    83       testTextBeforeOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
    84                            [ [ 0, 5, "", 0, 0 ] ]);
    86       testTextBeforeOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
    87                            [ [ 0, 5, "", 0, 0 ] ]);
    89       testTextAtOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
    90                        [ [ 0, 5, "a " + kEmbedChar + " c", 0, 5 ] ]);
    92       testTextAtOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
    93                        [ [ 0, 5, "a " + kEmbedChar + " c", 0, 5 ] ]);
    95       testTextAfterOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
    96                           [ [ 0, 5, "", 5, 5 ] ]);
    98       testTextAfterOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
    99                           [ [ 0, 5, "", 5, 5 ] ]);
   101       //////////////////////////////////////////////////////////////////////////
   102       // foo<br> and foo<br><br>
   104       testTextAtOffset([ getAccessible("ht_2").firstChild.firstChild ],
   105                        BOUNDARY_LINE_START,
   106                        [ [ 0, 3, "foo", 0, 3 ] ]);
   107       testTextAtOffset([ getAccessible("ht_3").firstChild.firstChild ],
   108                        BOUNDARY_LINE_START,
   109                        [ [ 0, 3, "foo\n", 0, 4 ], [ 4, 4, "", 4, 4 ] ]);
   111       //////////////////////////////////////////////////////////////////////////
   112       // 'Hello world ' (\n is rendered as space)
   114       testTextAtOffset([ "ht_4" ], BOUNDARY_LINE_START,
   115                        [ [ 0, 12, "Hello world ", 0, 12 ] ]);
   117       //////////////////////////////////////////////////////////////////////////
   118       // list items
   120       testTextAtOffset([ "li1" ], BOUNDARY_LINE_START,
   121                        [ [ 0, 5, kDiscBulletChar + "Item", 0, 5 ] ]);
   122       testTextAtOffset([ "li2" ], BOUNDARY_LINE_START,
   123                        [ [ 0, 1, kDiscBulletChar, 0, 1 ] ]);
   124       testTextAtOffset([ "li3" ], BOUNDARY_LINE_START,
   125                        [ [ 0, 7, kDiscBulletChar + "a long ", 0, 8 ],
   126                          [ 8, 11, "and ", 8, 12 ] ]);
   127       testTextAtOffset([ "li4" ], BOUNDARY_LINE_START,
   128                        [ [ 0, 6, kDiscBulletChar + "a " + kEmbedChar + " c", 0, 6 ] ]);
   129       testTextAtOffset([ "ul1" ], BOUNDARY_LINE_START,
   130                        [ [ 0, 0, kEmbedChar, 0, 1 ],
   131                          [ 1, 1, kEmbedChar, 1, 2 ],
   132                          [ 2, 2, kEmbedChar, 2, 3 ],
   133                          [ 3, 4, kEmbedChar, 3, 4 ] ]);
   135       //////////////////////////////////////////////////////////////////////////
   136       // Nested hypertexts
   138       testTextAtOffset(["ht_5" ], BOUNDARY_LINE_START,
   139                        [ [ 0, 0, kEmbedChar, 0, 1 ] ]);
   141       SimpleTest.finish();
   142     }
   144     SimpleTest.waitForExplicitFinish();
   145     addA11yLoadEvent(doTest);
   146   </script>
   147 </head>
   148 <body>
   150   <a target="_blank"
   151      title="getTextAtOffset for word boundaries: beginning of a new life"
   152      href="https://bugzilla.mozilla.org/show_bug.cgi?id=853340">
   153     Bug 853340
   154   </a>
   155   <a target="_blank"
   156      title="getTextBeforeOffset for word boundaries: evolving"
   157      href="https://bugzilla.mozilla.org/show_bug.cgi?id=855732">
   158     Bug 855732
   159   </a>
   160   <a target="_blank"
   161      title=" getTextAfterOffset for line boundary on new rails"
   162      href="https://bugzilla.mozilla.org/show_bug.cgi?id=882292">
   163     Bug 882292
   164   </a>
   165   <a target="_blank"
   166      title="getTextAtOffset broken for last object when closing tag is preceded by newline char"
   167      href="https://bugzilla.mozilla.org/show_bug.cgi?id=947170">
   168     Bug 947170
   169   </a>
   171   <p id="display"></p>
   172   <div id="content" style="display: none"></div>
   173   <pre id="test">
   174   </pre>
   176   <input id="input" value="hello my friend"/>
   177   <div id="div">hello my friend</div>
   178   <div id="editable" contenteditable="true">hello my friend</div>
   179   <textarea id="textarea">hello my friend</textarea>
   180   <iframe id="ta_cntr"
   181           src="data:text/html,<html><body><textarea id='ta'>hello my friend</textarea></body></html>"></iframe>
   183   <pre>
   184     <div id="ml_div" style="border-style:outset;">oneword
   186 two words
   187 </div>
   188   <div id="ml_divbr" style="border-style:outset;">oneword<br/><br/>two words<br/><br/></div>
   189   <div id="ml_editable" style="border-style:outset;" contenteditable="true">oneword
   191 two words
   192 </div>
   193   <div id="ml_editablebr" contenteditable="true" style="border-style:outset;">oneword<br/><br/>two words<br/><br/></div>
   194   <textarea id="ml_textarea" cols="300">oneword
   196 two words
   197 </textarea>
   198   </pre>
   200   <iframe id="ht_1" src="data:text/html,<html><body>a <a href=''>b</a> c</body></html>"></iframe>
   202   <iframe id="ht_2" src="data:text/html,<div contentEditable='true'>foo<br/></div>"></iframe>
   203   <iframe id="ht_3" src="data:text/html,<div contentEditable='true'>foo<br/><br/></div>"></iframe>
   205   <p id="ht_4">Hello world
   206 </p>
   208   <ul id="ul1">
   209     <li id="li1">Item</li>
   210     <li id="li2"></li>
   211     <li id="li3" style="width:10ex; font-family:monospace; font-size:10pt;">a long and winding road that lead me to your door</li>
   212     <li id="li4">a <a href=''>b</a> c</li>
   213   </ul>
   215   <div id="ht_5">
   216     <div>
   217       <p>sectiounus</p>
   218       <p>seciofarus</p>
   219     </div>
   220   </div>
   222 </body>
   223 </html>

mercurial