2010-01-29 10:22:15 -08:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=542914
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 542914</title>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=542914">Mozilla Bug 542914</a>
|
|
|
|
<p id="display">
|
|
|
|
<input type="text" id="a" value="test">
|
|
|
|
<input type="text" id="b">
|
|
|
|
<input type="text" id="c">
|
|
|
|
</p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 542914 **/
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2010-05-13 15:56:24 -07:00
|
|
|
function runTests(callback, type) {
|
2010-01-29 10:22:15 -08:00
|
|
|
var a = $("a");
|
|
|
|
|
|
|
|
// Test that the initial value of the control is available to script
|
|
|
|
// without initilization of the editor
|
|
|
|
is(a.value, "test", "The value is available before initialization");
|
|
|
|
// Initialize the editor
|
|
|
|
a.focus();
|
|
|
|
// Test that the value does not change after initialization
|
|
|
|
is(a.value, "test", "The value does not change after initializtion");
|
|
|
|
|
|
|
|
var b = $("b");
|
|
|
|
|
|
|
|
// Test that the initial value is empty before initialization.
|
|
|
|
is(b.value, "", "The value is empty before initialization");
|
|
|
|
// Make sure that the value can be changed before initialization
|
|
|
|
b.value ="some value";
|
|
|
|
is(b.value, "some value", "The value can be changed before initialization");
|
|
|
|
// Initialize the editor
|
|
|
|
b.focus();
|
|
|
|
// Make sure that the value does not change after initialization
|
|
|
|
is(b.value, "some value", "The value does not change after initialization");
|
|
|
|
// Make sure that the value does not change if the element is hidden
|
|
|
|
b.style.display = "none";
|
|
|
|
document.body.offsetHeight;
|
|
|
|
is(b.value, "some value", "The value does not change while hidden");
|
|
|
|
b.style.display = "";
|
|
|
|
document.body.offsetHeight;
|
|
|
|
b.focus();
|
|
|
|
is(b.value, "some value", "The value does not change after being shown");
|
|
|
|
|
|
|
|
var c = $("c");
|
|
|
|
|
|
|
|
// Make sure that the control accepts input events without explicit initialization
|
|
|
|
is(c.value, "", "Control is empty initially");
|
2011-12-16 05:38:45 -08:00
|
|
|
c.focus();
|
|
|
|
sendChar("a");
|
2010-01-29 10:22:15 -08:00
|
|
|
is(c.value, "a", "Control accepts input without explicit initialization");
|
|
|
|
// Make sure that the control retains its caret position
|
|
|
|
c.focus();
|
|
|
|
c.blur();
|
|
|
|
c.focus();
|
2011-12-16 05:38:45 -08:00
|
|
|
sendChar("b");
|
2010-01-29 10:22:15 -08:00
|
|
|
is(c.value, "ab", "Control retains caret position after being re-focused");
|
|
|
|
|
|
|
|
var d = document.createElement("input");
|
2010-05-13 15:56:24 -07:00
|
|
|
d.setAttribute("type", type);
|
2010-01-29 10:22:15 -08:00
|
|
|
$("display").appendChild(d);
|
|
|
|
document.body.offsetHeight;
|
|
|
|
|
|
|
|
// Make sure dynamically injected inputs work as expected
|
|
|
|
is(d.value, "", "Dynamic control's initial value should be empty");
|
|
|
|
d.value = "new";
|
2011-12-16 05:38:45 -08:00
|
|
|
d.focus();
|
2010-01-29 10:22:15 -08:00
|
|
|
is(d.value, "new", "Dynamic control's value can be set before initialization");
|
2011-12-16 05:38:45 -08:00
|
|
|
sendChar("x");
|
2011-05-12 06:52:38 -07:00
|
|
|
is(d.value, "xnew", "Dynamic control accepts keyboard input without explicit initialization");
|
2010-01-29 10:22:15 -08:00
|
|
|
$("display").removeChild(d);
|
2011-05-12 06:52:38 -07:00
|
|
|
is(d.value, "xnew", "Dynamic control retains value after being removed from the document");
|
2010-01-29 10:22:15 -08:00
|
|
|
|
2010-05-13 15:56:24 -07:00
|
|
|
callback();
|
|
|
|
}
|
|
|
|
|
|
|
|
var gPreviousType = "text";
|
|
|
|
function setTypes(aType) {
|
|
|
|
var content = document.getElementById("display");
|
|
|
|
content.innerHTML = content.innerHTML.replace(gPreviousType, aType);
|
|
|
|
gPreviousType = aType;
|
|
|
|
}
|
|
|
|
|
|
|
|
addLoadEvent(function() {
|
|
|
|
ok(true, "Running tests on <input type=text>");
|
|
|
|
runTests(function() {
|
|
|
|
ok(true, "Running tests on <input type=password>");
|
|
|
|
setTypes("password");
|
|
|
|
runTests(function() {
|
|
|
|
ok(true, "Running tests on <input type=tel>");
|
|
|
|
setTypes("tel");
|
|
|
|
runTests(function() {
|
|
|
|
SimpleTest.finish();
|
|
|
|
}, "tel");
|
|
|
|
}, "password");
|
|
|
|
}, "text");
|
2010-01-29 10:22:15 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|