toolkit/content/tests/chrome/test_bug418874.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/test_bug418874.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +<?xml version="1.0"?>
     1.5 +
     1.6 +<!-- This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +   - License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     1.9 +
    1.10 +
    1.11 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
    1.12 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
    1.13 +
    1.14 +<window title="Textbox with placeholder test" width="500" height="600"
    1.15 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.16 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.17 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
    1.18 +
    1.19 +  <hbox>
    1.20 +    <textbox id="t1" placeholder="empty"/>
    1.21 +  </hbox>
    1.22 +
    1.23 +  <hbox>
    1.24 +    <textbox id="t2" placeholder="empty"/>
    1.25 +  </hbox>
    1.26 +
    1.27 +  <!-- test results are displayed in the html:body -->
    1.28 +  <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;">
    1.29 +    <p id="display">
    1.30 +    </p>
    1.31 +    <div id="content" style="display: none">
    1.32 +    </div>
    1.33 +    <pre id="test">
    1.34 +    </pre>
    1.35 +  </body>
    1.36 +
    1.37 +  <!-- test code goes here -->
    1.38 +  <script type="application/javascript"><![CDATA[
    1.39 +    SimpleTest.waitForExplicitFinish();
    1.40 +
    1.41 +    function doTest() {
    1.42 +      var t1 = $("t1");
    1.43 +      var t2 = $("t2");
    1.44 +      setTextboxValue(t1, "1");
    1.45 +      var t1Enabled = {};
    1.46 +      var t1CanUndo = {};
    1.47 +      t1.editor.canUndo(t1Enabled, t1CanUndo);
    1.48 +      is(t1CanUndo.value, true,
    1.49 +         "undo correctly enabled when placeholder was not changed through property");
    1.50 +
    1.51 +      t2.placeholder = "reallyempty";
    1.52 +      setTextboxValue(t2, "2");
    1.53 +      var t2Enabled = {};
    1.54 +      var t2CanUndo = {};
    1.55 +      t2.editor.canUndo(t2Enabled, t2CanUndo);
    1.56 +      is(t2CanUndo.value, true,
    1.57 +         "undo correctly enabled when placeholder explicitly changed through property");
    1.58 +
    1.59 +      SimpleTest.finish();
    1.60 +   }
    1.61 +
    1.62 +   function setTextboxValue(textbox, value) {
    1.63 +      textbox.focus();
    1.64 +      for (var i = 0; i < value.length; ++i) {
    1.65 +          synthesizeKey(value.charAt(i), {});
    1.66 +      }
    1.67 +      textbox.blur();
    1.68 +   }
    1.69 +
    1.70 +   SimpleTest.waitForFocus(doTest);
    1.71 +
    1.72 +  ]]></script>
    1.73 +
    1.74 +</window>

mercurial