tor-browser

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

test_bug300691-1.html (3965B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=300691
      5 -->
      6 <head>
      7  <title>Test for Bug 300691</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>        
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>        
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=300691">Mozilla Bug 300691</a>
     14 <p id="display">
     15  <textarea id="target"></textarea>
     16 </p>
     17 <div id="content" style="display: none">
     18  
     19 </div>
     20 <pre id="test">
     21 <script class="testbody" type="text/javascript">
     22 
     23 var t = $("target");
     24 
     25 // FIXME(bug 1838346): This shouldn't need to be async probably?
     26 SimpleTest.waitForExplicitFinish();
     27 onload = function() {
     28  
     29 /** Test for Bug 300691 */
     30 function valueIs(arg, reason) {
     31  is(t.value, arg, reason);
     32 }
     33 
     34 function defValueIs(arg, reason) {
     35  is(t.defaultValue, arg, reason);
     36 }
     37 
     38 valueIs("", "Nothing in the textarea");
     39 defValueIs("", "Nothing in the textarea 2");
     40 
     41 t.appendChild(document.createTextNode("ab"));
     42 valueIs("ab", "Appended textnode");
     43 defValueIs("ab", "Appended textnode 2");
     44 
     45 t.firstChild.data = "abcd";
     46 valueIs("abcd", "Modified textnode text");
     47 defValueIs("abcd", "Modified textnode text 2");
     48 
     49 t.appendChild(document.createTextNode("efgh"));
     50 valueIs("abcdefgh", "Appended another textnode");
     51 defValueIs("abcdefgh", "Appended another textnode 2");
     52 
     53 t.removeChild(t.lastChild);
     54 valueIs("abcd", "Removed textnode");
     55 defValueIs("abcd", "Removed textnode 2");
     56 
     57 t.appendChild(document.createTextNode("efgh"));
     58 valueIs("abcdefgh", "Appended yet another textnode");
     59 defValueIs("abcdefgh", "Appended yet another textnode 2");
     60 
     61 t.normalize();
     62 valueIs("abcdefgh", "Normalization changes nothing for the value");
     63 defValueIs("abcdefgh", "Normalization changes nothing for the value 2");
     64 
     65 t.defaultValue = "abc";
     66 valueIs("abc", "Just set the default value on non-edited textarea");
     67 defValueIs("abc", "Just set the default value on non-edited textarea 2");
     68 
     69 t.appendChild(document.createTextNode("defgh"));
     70 valueIs("abcdefgh", "Appended another textnode again");
     71 defValueIs("abcdefgh", "Appended another textnode again 2");
     72 
     73 t.focus(); // This puts the caret at the end of the textarea, and doing
     74           // something like "home" in a cross-platform way is kinda hard.
     75 sendKey("left");
     76 sendKey("left");
     77 sendKey("left");
     78 sendString("Test");
     79 
     80 valueIs("abcdeTestfgh", "Typed 'Test' after three left-arrows starting from end");
     81 defValueIs("abcdefgh", "Typing 'Test' shouldn't affect default value");
     82 
     83 sendKey("right");
     84 sendKey("right");
     85 sendKey("back_space");
     86 sendKey("back_space");
     87 
     88 valueIs("abcdeTesth",
     89        "Backspaced twice after two right-arrows starting from end of typing");
     90 defValueIs("abcdefgh", "Deleting shouldn't affect default value");
     91 
     92 t.appendChild(document.createTextNode("ijk"));
     93 valueIs("abcdeTesth",
     94        "Appending textnode shouldn't affect value in edited textarea");
     95 defValueIs("abcdefghijk", "Appended textnode 3");
     96 
     97 t.lastChild.data = "lmno";
     98 valueIs("abcdeTesth",
     99        "Modifying textnode text shouldn't affect value in edited textarea");
    100 defValueIs("abcdefghlmno", "Modified textnode text 3");
    101 
    102 t.firstChild.remove();
    103 valueIs("abcdeTesth",
    104        "Removing child textnode shouldn't affect value in edited textarea");
    105 defValueIs("defghlmno", "Removed textnode 3");
    106 
    107 t.insertBefore(document.createTextNode("abc"), t.firstChild);
    108 valueIs("abcdeTesth",
    109        "Inserting child textnode shouldn't affect value in edited textarea");
    110 defValueIs("abcdefghlmno", "Inserted a text node");
    111 
    112 t.normalize();
    113 valueIs("abcdeTesth", "Normalization changes nothing for the value 3");
    114 defValueIs("abcdefghlmno", "Normalization changes nothing for the value 4");
    115 
    116 t.defaultValue = "abc";
    117 valueIs("abcdeTesth", "Setting default value shouldn't affect edited textarea");
    118 defValueIs("abc", "Just set the default value textarea");
    119 SimpleTest.finish();
    120 
    121 };
    122 </script>
    123 </pre>
    124 </body>
    125 </html>