2008-12-31 02:40:23 -08:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
2012-05-21 04:12:37 -07:00
|
|
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
2008-12-31 02:40:23 -08:00
|
|
|
|
|
|
|
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
|
|
|
|
2010-03-03 23:13:27 -08:00
|
|
|
<window title="Textbox with placeholder test" width="500" height="600"
|
2008-12-31 02:40:23 -08:00
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
|
|
|
|
<hbox>
|
2010-03-03 23:13:27 -08:00
|
|
|
<textbox id="t1" placeholder="empty"/>
|
2008-12-31 02:40:23 -08:00
|
|
|
</hbox>
|
|
|
|
|
|
|
|
<hbox>
|
2010-03-03 23:13:27 -08:00
|
|
|
<textbox id="t2" placeholder="empty"/>
|
2008-12-31 02:40:23 -08:00
|
|
|
</hbox>
|
|
|
|
|
|
|
|
<!-- test results are displayed in the html:body -->
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;">
|
|
|
|
<p id="display">
|
|
|
|
</p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
<!-- test code goes here -->
|
|
|
|
<script type="application/javascript"><![CDATA[
|
2009-03-09 04:21:20 -07:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2008-12-31 02:40:23 -08:00
|
|
|
function doTest() {
|
|
|
|
var t1 = $("t1");
|
|
|
|
var t2 = $("t2");
|
2010-04-06 13:43:39 -07:00
|
|
|
setTextboxValue(t1, "1");
|
2008-12-31 02:40:23 -08:00
|
|
|
var t1Enabled = {};
|
|
|
|
var t1CanUndo = {};
|
|
|
|
t1.editor.canUndo(t1Enabled, t1CanUndo);
|
2009-03-08 12:05:23 -07:00
|
|
|
is(t1CanUndo.value, true,
|
2010-03-03 23:13:27 -08:00
|
|
|
"undo correctly enabled when placeholder was not changed through property");
|
2008-12-31 02:40:23 -08:00
|
|
|
|
2010-03-03 23:13:27 -08:00
|
|
|
t2.placeholder = "reallyempty";
|
2010-04-06 13:43:39 -07:00
|
|
|
setTextboxValue(t2, "2");
|
2009-01-12 11:55:37 -08:00
|
|
|
var t2Enabled = {};
|
|
|
|
var t2CanUndo = {};
|
|
|
|
t2.editor.canUndo(t2Enabled, t2CanUndo);
|
2009-03-08 12:05:23 -07:00
|
|
|
is(t2CanUndo.value, true,
|
2010-03-03 23:13:27 -08:00
|
|
|
"undo correctly enabled when placeholder explicitly changed through property");
|
2009-03-09 04:21:20 -07:00
|
|
|
|
|
|
|
SimpleTest.finish();
|
2008-12-31 02:40:23 -08:00
|
|
|
}
|
|
|
|
|
2010-04-06 13:43:39 -07:00
|
|
|
function setTextboxValue(textbox, value) {
|
|
|
|
textbox.focus();
|
|
|
|
for (var i = 0; i < value.length; ++i) {
|
|
|
|
synthesizeKey(value.charAt(i), {});
|
|
|
|
}
|
|
|
|
textbox.blur();
|
|
|
|
}
|
|
|
|
|
2009-09-03 12:30:06 -07:00
|
|
|
SimpleTest.waitForFocus(doTest);
|
|
|
|
|
2008-12-31 02:40:23 -08:00
|
|
|
]]></script>
|
|
|
|
|
|
|
|
</window>
|