accessible/tests/mochitest/text/test_selection.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>Test text selection functions</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/MochiKit/packed.js"></script>
michael@0 10 <script type="application/javascript"
michael@0 11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 12 <script type="application/javascript"
michael@0 13 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 14
michael@0 15 <script type="application/javascript"
michael@0 16 src="../common.js"></script>
michael@0 17 <script type="application/javascript"
michael@0 18 src="../text.js"></script>
michael@0 19
michael@0 20 <script type="application/javascript">
michael@0 21
michael@0 22 function doTest()
michael@0 23 {
michael@0 24 // Test selection count: clean selection / check count.
michael@0 25 testTextAddSelection("div0", 0, 2, 1); // |Test selection...
michael@0 26 cleanTextSelections("div0");
michael@0 27 testTextSelectionCount("div0", 0);
michael@0 28
michael@0 29 // Test addition: adding two equal selections, the second one should
michael@0 30 // not be added.
michael@0 31 testTextAddSelection("div1", 7, 9, 1); // Test ad|di|ng two...
michael@0 32 testTextAddSelection("div1", 7, 9, 1); // Test ad|di|ng two...
michael@0 33 testTextGetSelection("div1", 7, 9, 0);
michael@0 34
michael@0 35 // Test overlapping selections: adding three selections, one adjacent.
michael@0 36 testTextAddSelection("div2", 0, 3, 1); // |Tes|t adding 3...
michael@0 37 testTextAddSelection("div2", 7, 9, 2); // |Tes|t ad|di|ng 3...
michael@0 38 testTextAddSelection("div2", 3, 4, 3); // |Tes||t| ad|di|ng 3...
michael@0 39 testTextGetSelection("div2", 0, 3, 0);
michael@0 40 testTextGetSelection("div2", 3, 4, 1);
michael@0 41 testTextGetSelection("div2", 7, 9, 2);
michael@0 42
michael@0 43 // Test selection re-ordering: adding two selections.
michael@0 44 // NOTE: removeSelections aSelectionIndex is from start of document.
michael@0 45 testTextAddSelection("div3", 0, 3, 1); // |Tes|t adding 2...
michael@0 46 testTextAddSelection("div3", 7, 9, 2); // |Tes|t ad|di|ng 2...
michael@0 47 testTextRemoveSelection("div3", 4, 1); // Test ad|di|ng 2...
michael@0 48
michael@0 49 // Test extending existing selection.
michael@0 50 // NOTE: setSelectionBounds aSelectionIndex is from start of document.
michael@0 51 testTextAddSelection("div4", 4, 5, 1); // Test| |extending...
michael@0 52 testTextSetSelection("div4", 4, 9, 6, 1); // Test| exte|nding...
michael@0 53
michael@0 54 // Test moving an existing selection.
michael@0 55 // NOTE: setSelectionBounds aSelectionIndex is from start of document.
michael@0 56 testTextAddSelection("div5", 1, 3, 1); // T|es|t moving...
michael@0 57 testTextSetSelection("div5", 5, 9, 6, 1); // Test |movi|ng...
michael@0 58
michael@0 59 // Test adding selections to multiple inner elements.
michael@0 60 testTextAddSelection("div71", 0, 3, 1); // |Tes|t adding...
michael@0 61 testTextAddSelection("div71", 7, 8, 2); // |Tes|t ad|d|ing...
michael@0 62 testTextAddSelection("div72", 4, 6, 1); // Test| a|dding...
michael@0 63 testTextAddSelection("div72", 7, 8, 2); // Test| a|d|d|ing...
michael@0 64
michael@0 65 // Test adding selection to parent element.
michael@0 66 // NOTE: If inner elements are represented as embedded chars
michael@0 67 // we count their internal selections.
michael@0 68 testTextAddSelection("div7", 7, 8, 5); // Test ad|d|ing...
michael@0 69
michael@0 70 SimpleTest.finish();
michael@0 71 }
michael@0 72
michael@0 73 SimpleTest.waitForExplicitFinish();
michael@0 74 addA11yLoadEvent(doTest);
michael@0 75
michael@0 76 </script>
michael@0 77 </head>
michael@0 78
michael@0 79 <body>
michael@0 80
michael@0 81 <p id="display"></p>
michael@0 82 <div id="content" style="display: none"></div>
michael@0 83 <pre id="test">
michael@0 84 </pre>
michael@0 85
michael@0 86 <div id="div0">Test selection count</div>
michael@0 87 </br>
michael@0 88 <div id="div1">Test adding two equal selections </div>
michael@0 89 <div id="div2">Test adding 3 selections one adjacent </div>
michael@0 90 <div id="div3">Test adding 2 selections, remove first one </div>
michael@0 91 <div id="div4">Test extending a selection </div>
michael@0 92 <div id="div5">Test moving a selection </div>
michael@0 93 </br>
michael@0 94 <div id="div7">Test adding selections to parent element
michael@0 95 <div id="div71">Test adding selections to inner element1 </div>
michael@0 96 <div id="div72">Test adding selections to inner element2 </div>
michael@0 97 </div>
michael@0 98
michael@0 99 </body>
michael@0 100
michael@0 101 </html>

mercurial