accessible/tests/mochitest/text/test_charboundary.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.

michael@0 1 <!DOCTYPE html>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Char boundary text tests</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 <script type="application/javascript"
michael@0 9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <script type="application/javascript"
michael@0 11 src="../common.js"></script>
michael@0 12 <script type="application/javascript"
michael@0 13 src="../text.js"></script>
michael@0 14
michael@0 15 <script type="application/javascript">
michael@0 16 function doTest()
michael@0 17 {
michael@0 18 //////////////////////////////////////////////////////////////////////////
michael@0 19 //
michael@0 20 // __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__
michael@0 21 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
michael@0 22
michael@0 23 var IDs = [ "i1", "d1", "e1", "t1" ];
michael@0 24
michael@0 25 testCharBeforeOffset(IDs, 0, "", 0, 0);
michael@0 26 testCharBeforeOffset(IDs, 1, "h", 0, 1);
michael@0 27 testCharBeforeOffset(IDs, 14, "n", 13, 14);
michael@0 28 testCharBeforeOffset(IDs, 15, "d", 14, 15);
michael@0 29
michael@0 30 testCharAtOffset(IDs, 0, "h", 0, 1);
michael@0 31 testCharAtOffset(IDs, 1, "e", 1, 2);
michael@0 32 testCharAtOffset(IDs, 14, "d", 14, 15);
michael@0 33 testCharAtOffset(IDs, 15, "", 15, 15);
michael@0 34
michael@0 35 testCharAfterOffset(IDs, 0, "e", 1, 2);
michael@0 36 testCharAfterOffset(IDs, 1, "l", 2, 3);
michael@0 37 testCharAfterOffset(IDs, 14, "", 15, 15);
michael@0 38 testCharAfterOffset(IDs, 15, "", 15, 15);
michael@0 39
michael@0 40 //////////////////////////////////////////////////////////////////////////
michael@0 41 //
michael@0 42 // __B__r__a__v__e__ __S__i__r__ __ __R__o__b__i__n__ __ __ __r__a__n
michael@0 43 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
michael@0 44
michael@0 45 IDs = [ "i2", "d2", "e2", "t2" ];
michael@0 46
michael@0 47 testCharBeforeOffset(IDs, 0, "", 0, 0);
michael@0 48 testCharBeforeOffset(IDs, 1, "B", 0, 1);
michael@0 49 testCharBeforeOffset(IDs, 6, " ", 5, 6);
michael@0 50 testCharBeforeOffset(IDs, 10, " ", 9, 10);
michael@0 51 testCharBeforeOffset(IDs, 11, " ", 10, 11);
michael@0 52 testCharBeforeOffset(IDs, 17, " ", 16, 17);
michael@0 53 testCharBeforeOffset(IDs, 19, " ", 18, 19);
michael@0 54
michael@0 55 testCharAtOffset(IDs, 0, "B", 0, 1);
michael@0 56 testCharAtOffset(IDs, 1, "r", 1, 2);
michael@0 57 testCharAtOffset(IDs, 5, " ", 5, 6);
michael@0 58 testCharAtOffset(IDs, 9, " ", 9, 10);
michael@0 59 testCharAtOffset(IDs, 10, " ", 10, 11);
michael@0 60 testCharAtOffset(IDs, 17, " ", 17, 18);
michael@0 61
michael@0 62 testCharAfterOffset(IDs, 0, "r", 1, 2);
michael@0 63 testCharAfterOffset(IDs, 1, "a", 2, 3);
michael@0 64 testCharAfterOffset(IDs, 4, " ", 5, 6);
michael@0 65 testCharAfterOffset(IDs, 5, "S", 6, 7);
michael@0 66 testCharAfterOffset(IDs, 8, " ", 9, 10);
michael@0 67 testCharAfterOffset(IDs, 9, " ", 10, 11);
michael@0 68 testCharAfterOffset(IDs, 10, "R", 11, 12);
michael@0 69 testCharAfterOffset(IDs, 15, " ", 16, 17);
michael@0 70 testCharAfterOffset(IDs, 16, " ", 17, 18);
michael@0 71 testCharAfterOffset(IDs, 17, " ", 18, 19);
michael@0 72 testCharAfterOffset(IDs, 18, "r", 19, 20);
michael@0 73
michael@0 74 //////////////////////////////////////////////////////////////////////////
michael@0 75 //
michael@0 76 // __o__n__e__w__o__r__d__\n
michael@0 77 // 0 1 2 3 4 5 6 7
michael@0 78 // __\n
michael@0 79 // 8
michael@0 80 // __t__w__o__ __w__o__r__d__s__\n
michael@0 81 // 9 10 11 12 13 14 15 16 17 18
michael@0 82
michael@0 83 IDs = ["d3", "dbr3", "e3", "ebr3", "t3"];
michael@0 84
michael@0 85 testCharBeforeOffset(IDs, 8, "\n", 7, 8);
michael@0 86 testCharBeforeOffset(IDs, 9, "\n", 8, 9);
michael@0 87 testCharBeforeOffset(IDs, 10, "t", 9, 10);
michael@0 88
michael@0 89 testCharAtOffset(IDs, 7, "\n", 7, 8);
michael@0 90 testCharAtOffset(IDs, 8, "\n", 8, 9);
michael@0 91 testCharAtOffset(IDs, 9, "t", 9, 10);
michael@0 92
michael@0 93 testCharAfterOffset(IDs, 6, "\n", 7, 8);
michael@0 94 testCharAfterOffset(IDs, 7, "\n", 8, 9);
michael@0 95 testCharAfterOffset(IDs, 8, "t", 9, 10);
michael@0 96
michael@0 97 SimpleTest.finish();
michael@0 98 }
michael@0 99
michael@0 100 SimpleTest.waitForExplicitFinish();
michael@0 101 addA11yLoadEvent(doTest);
michael@0 102 </script>
michael@0 103 </head>
michael@0 104 <body>
michael@0 105
michael@0 106 <p id="display"></p>
michael@0 107 <div id="content" style="display: none"></div>
michael@0 108 <pre id="test">
michael@0 109 </pre>
michael@0 110
michael@0 111 <input id="i1" value="hello my friend"/>
michael@0 112 <div id="d1">hello my friend</div>
michael@0 113 <div id="e1" contenteditable="true">hello my friend</div>
michael@0 114 <textarea id="t1" contenteditable="true">hello my friend</textarea>
michael@0 115
michael@0 116 <input id="i2" value="Brave Sir Robin ran"/>
michael@0 117 <pre>
michael@0 118 <div id="d2">Brave Sir Robin ran</div>
michael@0 119 <div id="e2" contenteditable="true">Brave Sir Robin ran</div>
michael@0 120 </pre>
michael@0 121 <textarea id="t2" cols="300">Brave Sir Robin ran</textarea>
michael@0 122
michael@0 123 <pre>
michael@0 124 <div id="d3">oneword
michael@0 125
michael@0 126 two words
michael@0 127 </div>
michael@0 128 <div id="dbr3">oneword<br/><br/>two words<br/></div>
michael@0 129 <div id="e3" contenteditable="true">oneword
michael@0 130
michael@0 131 two words
michael@0 132 </div>
michael@0 133 <div id="ebr3" contenteditable="true">oneword<br/><br/>two words<br/></div>
michael@0 134 <textarea id="t3" cols="300">oneword
michael@0 135
michael@0 136 two words</textarea>
michael@0 137 </pre>
michael@0 138
michael@0 139 </body>
michael@0 140 </html>

mercurial