PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/toolkit/content/tests/chrome/test_bug418874.xul

http://github.com/zpao/v8monkey
Unknown | 104 lines | 89 code | 15 blank | 0 comment | 0 complexity | 7debfffec5a0f114cf2e92c62a4ed32e MD5 | raw file
  1<?xml version="1.0"?>
  2
  3<!-- ***** BEGIN LICENSE BLOCK *****
  4   - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5   -
  6   - The contents of this file are subject to the Mozilla Public License Version
  7   - 1.1 (the "License"); you may not use this file except in compliance with
  8   - the License. You may obtain a copy of the License at
  9   - http://www.mozilla.org/MPL/
 10   -
 11   - Software distributed under the License is distributed on an "AS IS" basis,
 12   - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 13   - for the specific language governing rights and limitations under the
 14   - License.
 15   -
 16   - The Original Code is XUL Textbox Widget Test code
 17   -
 18   - The Initial Developer of the Original Code is
 19   - Graeme McCutcheon <graememcc_firefox@graeme-online.co.uk>.
 20   - Portions created by the Initial Developer are Copyright (C) 2008
 21   - the Initial Developer. All Rights Reserved.
 22   -
 23   - Contributor(s):
 24   -
 25   -
 26   - Alternatively, the contents of this file may be used under the terms of
 27   - either the GNU General Public License Version 2 or later (the "GPL"), or
 28   - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 29   - in which case the provisions of the GPL or the LGPL are applicable instead
 30   - of those above. If you wish to allow use of your version of this file only
 31   - under the terms of either the GPL or the LGPL, and not to allow others to
 32   - use your version of this file under the terms of the MPL, indicate your
 33   - decision by deleting the provisions above and replace them with the notice
 34   - and other provisions required by the GPL or the LGPL. If you do not delete
 35   - the provisions above, a recipient may use your version of this file under
 36   - the terms of any one of the MPL, the GPL or the LGPL.
 37   -
 38   - ***** END LICENSE BLOCK ***** -->
 39
 40
 41<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 42<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 43
 44<window title="Textbox with placeholder test" width="500" height="600"
 45        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 46  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 47  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 48
 49  <hbox>
 50    <textbox id="t1" placeholder="empty"/>
 51  </hbox>
 52
 53  <hbox>
 54    <textbox id="t2" placeholder="empty"/>
 55  </hbox>
 56
 57  <!-- test results are displayed in the html:body -->
 58  <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;">
 59    <p id="display">
 60    </p>
 61    <div id="content" style="display: none">
 62    </div>
 63    <pre id="test">
 64    </pre>
 65  </body>
 66
 67  <!-- test code goes here -->
 68  <script type="application/javascript"><![CDATA[
 69    SimpleTest.waitForExplicitFinish();
 70
 71    function doTest() {
 72      var t1 = $("t1");
 73      var t2 = $("t2");
 74      setTextboxValue(t1, "1");
 75      var t1Enabled = {};
 76      var t1CanUndo = {};
 77      t1.editor.canUndo(t1Enabled, t1CanUndo);
 78      is(t1CanUndo.value, true,
 79         "undo correctly enabled when placeholder was not changed through property");
 80
 81      t2.placeholder = "reallyempty";
 82      setTextboxValue(t2, "2");
 83      var t2Enabled = {};
 84      var t2CanUndo = {};
 85      t2.editor.canUndo(t2Enabled, t2CanUndo);
 86      is(t2CanUndo.value, true,
 87         "undo correctly enabled when placeholder explicitly changed through property");
 88
 89      SimpleTest.finish();
 90   }
 91
 92   function setTextboxValue(textbox, value) {
 93      textbox.focus();
 94      for (var i = 0; i < value.length; ++i) {
 95          synthesizeKey(value.charAt(i), {});
 96      }
 97      textbox.blur();
 98   }
 99
100   SimpleTest.waitForFocus(doTest);
101
102  ]]></script>
103
104</window>