tor-browser

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

test_bug542914.html (3717B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=542914
      5 -->
      6 <head>
      7  <title>Test for Bug 542914</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=542914">Mozilla Bug 542914</a>
     14 <p id="display">
     15  <input type="text" id="a" value="test">
     16  <input type="text" id="b">
     17  <input type="text" id="c">
     18 </p>
     19 <div id="content" style="display: none">
     20  
     21 </div>
     22 <pre id="test">
     23 <script type="application/javascript">
     24 
     25 /** Test for Bug 542914 */
     26 SimpleTest.waitForExplicitFinish();
     27 function runTests(callback, type) {
     28  var a = $("a");
     29 
     30  // Test that the initial value of the control is available to script
     31  // without initilization of the editor
     32  is(a.value, "test", "The value is available before initialization");
     33  // Initialize the editor
     34  a.focus();
     35  // Test that the value does not change after initialization
     36  is(a.value, "test", "The value does not change after initializtion");
     37 
     38  var b = $("b");
     39 
     40  // Test that the initial value is empty before initialization.
     41  is(b.value, "", "The value is empty before initialization");
     42  // Make sure that the value can be changed before initialization
     43  b.value ="some value";
     44  is(b.value, "some value", "The value can be changed before initialization");
     45  // Initialize the editor
     46  b.focus();
     47  // Make sure that the value does not change after initialization
     48  is(b.value, "some value", "The value does not change after initialization");
     49  // Make sure that the value does not change if the element is hidden
     50  b.style.display = "none";
     51  document.body.offsetHeight;
     52  is(b.value, "some value", "The value does not change while hidden");
     53  b.style.display = "";
     54  document.body.offsetHeight;
     55  b.focus();
     56  is(b.value, "some value", "The value does not change after being shown");
     57 
     58  var c = $("c");
     59 
     60  // Make sure that the control accepts input events without explicit initialization
     61  is(c.value, "", "Control is empty initially");
     62  c.focus();
     63  sendChar("a");
     64  is(c.value, "a", "Control accepts input without explicit initialization");
     65  // Make sure that the control retains its caret position
     66  c.focus();
     67  c.blur();
     68  c.focus();
     69  sendChar("b");
     70  is(c.value, "ab", "Control retains caret position after being re-focused");
     71 
     72  var d = document.createElement("input");
     73  d.setAttribute("type", type);
     74  $("display").appendChild(d);
     75  document.body.offsetHeight;
     76 
     77  // Make sure dynamically injected inputs work as expected
     78  is(d.value, "", "Dynamic control's initial value should be empty");
     79  d.value = "new";
     80  d.focus();
     81  is(d.value, "new", "Dynamic control's value can be set before initialization");
     82  sendChar("x");
     83  is(d.value, "newx", "Dynamic control accepts keyboard input without explicit initialization");
     84  $("display").removeChild(d);
     85  is(d.value, "newx", "Dynamic control retains value after being removed from the document");
     86 
     87  callback();
     88 }
     89 
     90 var gPreviousType = "text";
     91 function setTypes(aType) {
     92  var content = document.getElementById("display");
     93  content.innerHTML = content.innerHTML.replace(gPreviousType, aType);
     94  gPreviousType = aType;
     95 }
     96 
     97 addLoadEvent(function() {
     98  ok(true, "Running tests on <input type=text>");
     99  runTests(function() {
    100    ok(true, "Running tests on <input type=password>");
    101    setTypes("password");
    102    runTests(function() {
    103      ok(true, "Running tests on <input type=tel>");
    104      setTypes("tel");
    105      runTests(function() {
    106        SimpleTest.finish();
    107      }, "tel");
    108    }, "password");
    109  }, "text");
    110 });
    111 
    112 </script>
    113 </pre>
    114 </body>
    115 </html>