tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_userinput.html (2344B)


      1 <html>
      2 
      3 <head>
      4  <title>Text selection by user input</title>
      5 
      6  <link rel="stylesheet" type="text/css"
      7        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
      8 
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     10  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
     11 
     12  <script type="application/javascript"
     13          src="../common.js"></script>
     14  <script type="application/javascript"
     15          src="../promisified-events.js"></script>
     16 
     17  <script type="application/javascript">
     18    async function doTests() {
     19      // Tab to 't2' and then tab out of it: it must not have any selection.
     20      info("Select all text in t1 and focus it");
     21      let focused = waitForEvent(EVENT_FOCUS, "t1");
     22      // Simulate tabbing to t1 by selecting all text before focusing it.
     23      selectAllTextAndFocus("t1");
     24      await focused;
     25 
     26      info("Tab to t2");
     27      const t2 = getNode("t2");
     28      focused = waitForEvent(EVENT_FOCUS, t2);
     29      synthesizeKey("VK_TAB");
     30      await focused;
     31 
     32      info("Tab to t3 and make sure there is no selection in t2 afterwards");
     33      const t3 = getNode("t3");
     34      focused = waitForEvent(EVENT_FOCUS, t3);
     35      synthesizeKey("VK_TAB");
     36      await focused;
     37      const prevFocus = getAccessible(t2, [ nsIAccessibleText ]);
     38      is(prevFocus.selectionCount, 0,
     39        "Wrong selection count for t2");
     40 
     41      let exceptionCaught = false;
     42      try {
     43        const startOffsetObj = {}, endOffsetObj = {};
     44        prevFocus.getSelectionBounds(0, startOffsetObj, endOffsetObj);
     45      } catch (e) {
     46        exceptionCaught = true;
     47      }
     48 
     49      ok(exceptionCaught, "No selection was expected for t2");
     50 
     51      SimpleTest.finish();
     52    }
     53 
     54    SimpleTest.waitForExplicitFinish();
     55    addA11yLoadEvent(doTests);
     56  </script>
     57 </head>
     58 
     59 <body>
     60 
     61  <a target="_blank"
     62     href="https://bugzilla.mozilla.org/show_bug.cgi?id=440590"
     63     title="Text selection information is not updated when HTML and XUL entries lose focus">
     64    Bug 440590
     65  </a>
     66  <p id="display"></p>
     67  <div id="content" style="display: none"></div>
     68  <pre id="test">
     69  </pre>
     70 
     71  <input type="text" id="t1" maxlength="3" size="3" value="1">
     72  <input type="text" id="t2" maxlength="3" size="3" value="1">
     73  <input type="text" id="t3" maxlength="3" size="3" value="1">
     74 
     75 </body>
     76 </html>