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=534785 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 534785</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="text/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=534785">Mozilla Bug 534785</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <input type="text" value="test"> |
michael@0 | 16 | <div id="reframe"> |
michael@0 | 17 | <textarea></textarea> |
michael@0 | 18 | <textarea>test</textarea> |
michael@0 | 19 | <input type="text"> |
michael@0 | 20 | <input type="text" value="test"> |
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 534785 **/ |
michael@0 | 26 | |
michael@0 | 27 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 28 | |
michael@0 | 29 | SimpleTest.waitForFocus(function() { |
michael@0 | 30 | var i = document.querySelector("input"); |
michael@0 | 31 | i.addEventListener("focus", function() { |
michael@0 | 32 | is(i.value, "test", "Sanity check"); |
michael@0 | 33 | |
michael@0 | 34 | is(document.activeElement, i, "Should be focused before frame reconstruction"); |
michael@0 | 35 | synthesizeKey("1", {}); |
michael@0 | 36 | is(i.value, "1test", "Can accept keyboard events before frame reconstruction"); |
michael@0 | 37 | |
michael@0 | 38 | // force frame reconstruction |
michael@0 | 39 | i.style.display = "none"; |
michael@0 | 40 | document.offsetHeight; |
michael@0 | 41 | i.style.display = ""; |
michael@0 | 42 | document.offsetHeight; |
michael@0 | 43 | |
michael@0 | 44 | is(document.activeElement, i, "Should be focused after frame reconstruction"); |
michael@0 | 45 | synthesizeKey("2", {}); |
michael@0 | 46 | is(i.value, "12test", "Can accept keyboard events after frame reconstruction"); |
michael@0 | 47 | |
michael@0 | 48 | // Make sure reframing happens gracefully |
michael@0 | 49 | var reframeDiv = document.getElementById("reframe"); |
michael@0 | 50 | var textAreaWithoutValue = reframeDiv.querySelectorAll("textarea")[0]; |
michael@0 | 51 | var textAreaWithValue = reframeDiv.querySelectorAll("textarea")[1]; |
michael@0 | 52 | var inputWithoutValue = reframeDiv.querySelectorAll("input")[0]; |
michael@0 | 53 | var inputWithValue = reframeDiv.querySelectorAll("input")[1]; |
michael@0 | 54 | reframeDiv.style.display = "none"; |
michael@0 | 55 | document.body.offsetWidth; |
michael@0 | 56 | reframeDiv.style.display = ""; |
michael@0 | 57 | document.body.offsetWidth; |
michael@0 | 58 | [textAreaWithoutValue, inputWithoutValue].forEach(function (elem) { |
michael@0 | 59 | is(elem.value, "", "Value should persist correctly"); |
michael@0 | 60 | }); |
michael@0 | 61 | [textAreaWithValue, inputWithValue].forEach(function (elem) { |
michael@0 | 62 | is(elem.value, "test", "Value should persist correctly"); |
michael@0 | 63 | }); |
michael@0 | 64 | [inputWithoutValue, inputWithValue].forEach(function (elem) elem.type = "submit"); |
michael@0 | 65 | document.body.offsetWidth; |
michael@0 | 66 | is(inputWithoutValue.value, "", "Value should persist correctly"); |
michael@0 | 67 | is(inputWithValue.value, "test", "Value should persist correctly"); |
michael@0 | 68 | [inputWithoutValue, inputWithValue].forEach(function (elem) elem.type = "text"); |
michael@0 | 69 | document.body.offsetWidth; |
michael@0 | 70 | is(inputWithoutValue.value, "", "Value should persist correctly"); |
michael@0 | 71 | is(inputWithValue.value, "test", "Value should persist correctly"); |
michael@0 | 72 | [inputWithoutValue, inputWithValue].forEach(function (elem) elem.focus()); // initialze the editor |
michael@0 | 73 | reframeDiv.style.display = "none"; |
michael@0 | 74 | document.body.offsetWidth; |
michael@0 | 75 | reframeDiv.style.display = ""; |
michael@0 | 76 | document.body.offsetWidth; |
michael@0 | 77 | is(inputWithoutValue.value, "", "Value should persist correctly with editor"); |
michael@0 | 78 | is(inputWithValue.value, "test", "Value should persist correctly with editor"); |
michael@0 | 79 | |
michael@0 | 80 | SimpleTest.finish(); |
michael@0 | 81 | }, false); |
michael@0 | 82 | i.focus(); |
michael@0 | 83 | }); |
michael@0 | 84 | |
michael@0 | 85 | </script> |
michael@0 | 86 | </pre> |
michael@0 | 87 | </body> |
michael@0 | 88 | </html> |