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