toolkit/content/tests/chrome/test_textbox_emptytext.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/test_textbox_emptytext.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,48 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     1.7 +<!--
     1.8 +  XUL Widget Test for textbox with placeholder
     1.9 +  -->
    1.10 +<window title="Textbox with placeholder test" width="500" height="600"
    1.11 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +
    1.14 +  <hbox>
    1.15 +    <textbox id="t1"/>
    1.16 +  </hbox>
    1.17 +
    1.18 +  <!-- test results are displayed in the html:body -->
    1.19 +  <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
    1.20 +
    1.21 +  <!-- test code goes here -->
    1.22 +  <script type="application/javascript"><![CDATA[
    1.23 +
    1.24 +SimpleTest.waitForExplicitFinish();
    1.25 +
    1.26 +function doTests() {
    1.27 +  var t1 = $("t1");
    1.28 +
    1.29 +  t1.placeholder = 1;
    1.30 +  ok("1" === t1.label,          "placeholder exposed as label");
    1.31 +  ok(""  === t1.value,          "placeholder not exposed as value");
    1.32 +
    1.33 +  t1.label = 2;
    1.34 +  ok("2" === t1.label,          "label can be set explicitly");
    1.35 +  ok("1" === t1.placeholder,    "placeholder persists after setting label");
    1.36 +
    1.37 +  t1.value = 3;
    1.38 +  ok("3" === t1.value,          "value setter/getter works while placeholder is present");
    1.39 +  ok("1" === t1.placeholder,    "placeholder persists after setting value");
    1.40 +
    1.41 +  t1.value = "";
    1.42 +  is(t1.textLength, 0,          "textLength while placeholder is displayed");
    1.43 +
    1.44 +  SimpleTest.finish();
    1.45 +}
    1.46 +
    1.47 +SimpleTest.waitForFocus(doTests);
    1.48 +
    1.49 +  ]]></script>
    1.50 +
    1.51 +</window>

mercurial