2008-02-06 11:00:09 -08:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
|
|
|
|
<!--
|
|
|
|
XUL Widget Test for textbox with emptyText
|
|
|
|
-->
|
|
|
|
<window title="Textbox with emptyText test" width="500" height="600"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
|
|
|
|
<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");
|
|
|
|
|
|
|
|
t1.emptyText = 1;
|
2009-04-24 04:20:03 -07:00
|
|
|
ok(t1.hasAttribute("isempty"), "emptyText but no value => 'isempty' attribute is present");
|
2008-02-10 22:16:23 -08:00
|
|
|
ok("1" === t1.label, "emptyText exposed as label");
|
|
|
|
ok("" === t1.value, "emptyText 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");
|
|
|
|
ok("1" === t1.emptyText, "emptyText persists after setting label");
|
2008-02-06 11:00:09 -08:00
|
|
|
|
|
|
|
t1.value = 3;
|
2009-04-24 04:20:03 -07:00
|
|
|
ok(!t1.hasAttribute("isempty"), "value present => 'isempty' attribute not present");
|
2008-02-10 22:16:23 -08:00
|
|
|
ok("3" === t1.value, "value setter/getter works while emptyText is present");
|
|
|
|
ok("1" === t1.emptyText, "emptyText persists after setting value");
|
2008-02-06 11:00:09 -08:00
|
|
|
|
2008-02-10 22:16:23 -08:00
|
|
|
t1.value = "";
|
2009-01-12 11:55:37 -08:00
|
|
|
is(t1.inputField.value, 1, "emptyText is displayed");
|
|
|
|
is(t1.textLength, 0, "textLength while emptyText is displayed");
|
2008-02-10 22:16:23 -08:00
|
|
|
|
2009-01-12 11:55:37 -08:00
|
|
|
t1.focus();
|
|
|
|
is(t1.inputField.value, "", "emptyText is not displayed as the textbox has focus");
|
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>
|