tor-browser

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

test_pasting_text_longer_than_maxlength.html (1654B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1320229
      5 
      6 Checks if a user can paste a password longer than `maxlength` and if the field
      7 is then marked as `tooLong`.
      8 -->
      9 <head>
     10  <title>Test pasting text longer than maxlength</title>
     11  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     12  <script src="/tests/SimpleTest/EventUtils.js"></script>
     13  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     14 </head>
     15 <body>
     16 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1320229">Mozilla Bug 1320229</a>
     17 <p id="display"></p>
     18 <div id="content">
     19  <div id="src">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
     20  <input id="form-password" type="password" maxlength="20">
     21 </div>
     22 <pre id="test">
     23 <script type="application/javascript">
     24 
     25 /** Test for Bug 1320229 */
     26 SimpleTest.waitForExplicitFinish();
     27 SimpleTest.waitForFocus(async function() {
     28  await SpecialPowers.pushPrefEnv({"set": [["editor.truncate_user_pastes", false]]});
     29  var src = document.getElementById("src");
     30  var pwd = document.getElementById("form-password");
     31  SimpleTest.waitForClipboard(src.textContent,
     32    function() {
     33      getSelection().selectAllChildren(src);
     34      synthesizeKey("C", {accelKey: true});
     35    },
     36    function() {
     37      pwd.focus();
     38      synthesizeKey("V", {accelKey: true});
     39      is(pwd.value, src.textContent,
     40         "Pasting should paste the clipboard contents regardless of maxlength");
     41      is(pwd.validity.tooLong, true, "Pasting over maxlength should set the tooLong flag")
     42      SimpleTest.finish();
     43    },
     44    function() {
     45      SimpleTest.finish();
     46    }
     47  );
     48 });
     49 
     50 </script>
     51 </pre>
     52 </body>
     53 </html>