accessible/tests/mochitest/text/test_selection.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/text/test_selection.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,101 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test text selection functions</title>
     1.8 +  <link rel="stylesheet" type="text/css"
     1.9 +        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    1.10 +
    1.11 +  <script type="application/javascript"
    1.12 +          src="chrome://mochikit/content/MochiKit/packed.js"></script>
    1.13 +  <script type="application/javascript"
    1.14 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.15 +  <script type="application/javascript"
    1.16 +          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
    1.17 +
    1.18 +  <script type="application/javascript"
    1.19 +          src="../common.js"></script>
    1.20 +  <script type="application/javascript"
    1.21 +          src="../text.js"></script>
    1.22 +
    1.23 +  <script type="application/javascript">
    1.24 +    
    1.25 +    function doTest()
    1.26 +    {
    1.27 +      // Test selection count: clean selection / check count.
    1.28 +      testTextAddSelection("div0", 0, 2, 1); // |Test selection...
    1.29 +      cleanTextSelections("div0");
    1.30 +      testTextSelectionCount("div0", 0);
    1.31 +
    1.32 +      // Test addition: adding two equal selections, the second one should
    1.33 +      // not be added.
    1.34 +      testTextAddSelection("div1", 7, 9, 1); // Test ad|di|ng two...
    1.35 +      testTextAddSelection("div1", 7, 9, 1); // Test ad|di|ng two...
    1.36 +      testTextGetSelection("div1", 7, 9, 0);
    1.37 +
    1.38 +      // Test overlapping selections: adding three selections, one adjacent.
    1.39 +      testTextAddSelection("div2", 0, 3, 1); // |Tes|t adding 3...
    1.40 +      testTextAddSelection("div2", 7, 9, 2); // |Tes|t ad|di|ng 3...
    1.41 +      testTextAddSelection("div2", 3, 4, 3); // |Tes||t| ad|di|ng 3...
    1.42 +      testTextGetSelection("div2", 0, 3, 0);
    1.43 +      testTextGetSelection("div2", 3, 4, 1);
    1.44 +      testTextGetSelection("div2", 7, 9, 2);
    1.45 +
    1.46 +      // Test selection re-ordering: adding two selections.
    1.47 +      // NOTE: removeSelections aSelectionIndex is from start of document.
    1.48 +      testTextAddSelection("div3", 0, 3, 1); // |Tes|t adding 2...
    1.49 +      testTextAddSelection("div3", 7, 9, 2); // |Tes|t ad|di|ng 2...
    1.50 +      testTextRemoveSelection("div3", 4, 1); // Test ad|di|ng 2...
    1.51 +
    1.52 +      // Test extending existing selection.
    1.53 +      // NOTE: setSelectionBounds aSelectionIndex is from start of document.
    1.54 +      testTextAddSelection("div4", 4, 5, 1); // Test| |extending...
    1.55 +      testTextSetSelection("div4", 4, 9, 6, 1); // Test| exte|nding...
    1.56 +
    1.57 +      // Test moving an existing selection.
    1.58 +      // NOTE: setSelectionBounds aSelectionIndex is from start of document.
    1.59 +      testTextAddSelection("div5", 1, 3, 1); // T|es|t moving...
    1.60 +      testTextSetSelection("div5", 5, 9, 6, 1); // Test |movi|ng...
    1.61 +
    1.62 +      // Test adding selections to multiple inner elements.
    1.63 +      testTextAddSelection("div71", 0, 3, 1); // |Tes|t adding...
    1.64 +      testTextAddSelection("div71", 7, 8, 2); // |Tes|t ad|d|ing...
    1.65 +      testTextAddSelection("div72", 4, 6, 1); // Test| a|dding...
    1.66 +      testTextAddSelection("div72", 7, 8, 2); // Test| a|d|d|ing...
    1.67 +
    1.68 +      // Test adding selection to parent element.
    1.69 +      // NOTE: If inner elements are represented as embedded chars
    1.70 +      //       we count their internal selections.
    1.71 +      testTextAddSelection("div7", 7, 8, 5); // Test ad|d|ing...
    1.72 +
    1.73 +      SimpleTest.finish();
    1.74 +    }
    1.75 +
    1.76 +    SimpleTest.waitForExplicitFinish();
    1.77 +    addA11yLoadEvent(doTest);
    1.78 +
    1.79 +</script>
    1.80 +</head>
    1.81 +
    1.82 +<body>
    1.83 +
    1.84 +  <p id="display"></p>
    1.85 +  <div id="content" style="display: none"></div>
    1.86 +  <pre id="test">
    1.87 +  </pre>
    1.88 +
    1.89 +  <div id="div0">Test selection count</div>
    1.90 +  </br>
    1.91 +  <div id="div1">Test adding two equal selections </div>
    1.92 +  <div id="div2">Test adding 3 selections one adjacent </div>
    1.93 +  <div id="div3">Test adding 2 selections, remove first one </div>
    1.94 +  <div id="div4">Test extending a selection </div>
    1.95 +  <div id="div5">Test moving a selection </div>
    1.96 +  </br>
    1.97 +  <div id="div7">Test adding selections to parent element
    1.98 +    <div id="div71">Test adding selections to inner element1 </div>
    1.99 +    <div id="div72">Test adding selections to inner element2 </div>
   1.100 +  </div>
   1.101 +
   1.102 +</body>
   1.103 +
   1.104 +</html>

mercurial