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