|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=595310 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 595310</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.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=595310">Mozilla Bug 595310</a> |
|
14 <p id="display"></p> |
|
15 <div id="content"> |
|
16 <input id='i' value="bar"> |
|
17 <textarea id='t'>bar</textarea> |
|
18 </div> |
|
19 <pre id="test"> |
|
20 <script type="application/javascript"> |
|
21 |
|
22 /** Test for Bug 595310 **/ |
|
23 |
|
24 SimpleTest.waitForExplicitFinish(); |
|
25 |
|
26 addLoadEvent(function() { |
|
27 // We want to compare to value="bar" and no placeholder shown. |
|
28 // That is what is currently showed. |
|
29 var s1 = snapshotWindow(window, false); |
|
30 |
|
31 var content = document.getElementById('content'); |
|
32 var i = document.getElementById('i'); |
|
33 var t = SpecialPowers.wrap(document.getElementById('t')); |
|
34 i.value = ""; i.placeholder = "foo"; |
|
35 t.value = ""; t.placeholder = "foo"; |
|
36 |
|
37 // Flushing. |
|
38 // Note: one call would have been enough actually but I didn't want to favour |
|
39 // one element... ;) |
|
40 i.getBoundingClientRect(); |
|
41 t.getBoundingClientRect(); |
|
42 |
|
43 function synthesizeDropText(aElement, aText) |
|
44 { |
|
45 var editor = SpecialPowers.wrap(aElement) |
|
46 .QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement) |
|
47 .editor |
|
48 .QueryInterface(SpecialPowers.Ci.nsIPlaintextEditor); |
|
49 |
|
50 editor.insertText(aText); |
|
51 } |
|
52 |
|
53 // We insert "bar" and we should only see "bar" now. |
|
54 synthesizeDropText(i, "bar"); |
|
55 synthesizeDropText(t, "bar"); |
|
56 |
|
57 var s2 = snapshotWindow(window, false); |
|
58 |
|
59 ok(compareSnapshots(s1, s2, true)[0], |
|
60 "When setting the value, the placeholder should disappear."); |
|
61 |
|
62 SimpleTest.finish(); |
|
63 }); |
|
64 |
|
65 |
|
66 </script> |
|
67 </pre> |
|
68 </body> |
|
69 </html> |