2008-02-06 11:00:09 -08:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
2011-06-24 09:39:13 -07:00
|
|
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
2008-02-06 11:00:09 -08:00
|
|
|
<!--
|
2010-03-03 23:13:27 -08:00
|
|
|
XUL Widget Test for textbox with placeholder
|
2008-02-06 11:00:09 -08:00
|
|
|
-->
|
2010-03-03 23:13:27 -08:00
|
|
|
<window title="Textbox with placeholder test" width="500" height="600"
|
2008-02-06 11:00:09 -08:00
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
2011-06-24 09:39:13 -07:00
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
2008-02-06 11:00:09 -08:00
|
|
|
|
|
|
|
<hbox>
|
|
|
|
<textbox id="t1"/>
|
|
|
|
</hbox>
|
|
|
|
|
2008-03-28 23:45:45 -07:00
|
|
|
<!-- test results are displayed in the html:body -->
|
2008-02-06 11:00:09 -08:00
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
|
|
|
|
|
|
|
|
<!-- test code goes here -->
|
|
|
|
<script type="application/javascript"><![CDATA[
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
function doTests() {
|
|
|
|
var t1 = $("t1");
|
|
|
|
|
2010-03-03 23:13:27 -08:00
|
|
|
t1.placeholder = 1;
|
|
|
|
ok("1" === t1.label, "placeholder exposed as label");
|
|
|
|
ok("" === t1.value, "placeholder not exposed as value");
|
2008-02-06 11:00:09 -08:00
|
|
|
|
|
|
|
t1.label = 2;
|
2008-02-10 22:16:23 -08:00
|
|
|
ok("2" === t1.label, "label can be set explicitly");
|
2010-03-03 23:13:27 -08:00
|
|
|
ok("1" === t1.placeholder, "placeholder persists after setting label");
|
2008-02-06 11:00:09 -08:00
|
|
|
|
|
|
|
t1.value = 3;
|
2010-03-03 23:13:27 -08:00
|
|
|
ok("3" === t1.value, "value setter/getter works while placeholder is present");
|
|
|
|
ok("1" === t1.placeholder, "placeholder persists after setting value");
|
2008-02-06 11:00:09 -08:00
|
|
|
|
2008-02-10 22:16:23 -08:00
|
|
|
t1.value = "";
|
2010-03-03 23:13:27 -08:00
|
|
|
is(t1.textLength, 0, "textLength while placeholder is displayed");
|
2008-02-10 22:16:23 -08:00
|
|
|
|
2009-01-12 11:55:37 -08:00
|
|
|
SimpleTest.finish();
|
2008-02-06 11:00:09 -08:00
|
|
|
}
|
|
|
|
|
2009-09-03 12:30:06 -07:00
|
|
|
SimpleTest.waitForFocus(doTests);
|
|
|
|
|
2008-02-06 11:00:09 -08:00
|
|
|
]]></script>
|
|
|
|
|
|
|
|
</window>
|