|
1 <?xml version="1.0"?> |
|
2 |
|
3 <!-- This Source Code Form is subject to the terms of the Mozilla Public |
|
4 - License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
|
6 |
|
7 |
|
8 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
9 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
10 |
|
11 <window title="Textbox with placeholder test" width="500" height="600" |
|
12 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
13 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
14 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
15 |
|
16 <hbox> |
|
17 <textbox id="t1" placeholder="empty"/> |
|
18 </hbox> |
|
19 |
|
20 <hbox> |
|
21 <textbox id="t2" placeholder="empty"/> |
|
22 </hbox> |
|
23 |
|
24 <!-- test results are displayed in the html:body --> |
|
25 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"> |
|
26 <p id="display"> |
|
27 </p> |
|
28 <div id="content" style="display: none"> |
|
29 </div> |
|
30 <pre id="test"> |
|
31 </pre> |
|
32 </body> |
|
33 |
|
34 <!-- test code goes here --> |
|
35 <script type="application/javascript"><![CDATA[ |
|
36 SimpleTest.waitForExplicitFinish(); |
|
37 |
|
38 function doTest() { |
|
39 var t1 = $("t1"); |
|
40 var t2 = $("t2"); |
|
41 setTextboxValue(t1, "1"); |
|
42 var t1Enabled = {}; |
|
43 var t1CanUndo = {}; |
|
44 t1.editor.canUndo(t1Enabled, t1CanUndo); |
|
45 is(t1CanUndo.value, true, |
|
46 "undo correctly enabled when placeholder was not changed through property"); |
|
47 |
|
48 t2.placeholder = "reallyempty"; |
|
49 setTextboxValue(t2, "2"); |
|
50 var t2Enabled = {}; |
|
51 var t2CanUndo = {}; |
|
52 t2.editor.canUndo(t2Enabled, t2CanUndo); |
|
53 is(t2CanUndo.value, true, |
|
54 "undo correctly enabled when placeholder explicitly changed through property"); |
|
55 |
|
56 SimpleTest.finish(); |
|
57 } |
|
58 |
|
59 function setTextboxValue(textbox, value) { |
|
60 textbox.focus(); |
|
61 for (var i = 0; i < value.length; ++i) { |
|
62 synthesizeKey(value.charAt(i), {}); |
|
63 } |
|
64 textbox.blur(); |
|
65 } |
|
66 |
|
67 SimpleTest.waitForFocus(doTest); |
|
68 |
|
69 ]]></script> |
|
70 |
|
71 </window> |