Bug 542914 - Add some tests for text input fields to make sure their basic behavior and appearance does not regress; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 29 Jan 2010 13:22:15 -0500
changeset 37632 915147e9ed53475fdb5d4b3d4030ec964f9e01de
parent 37631 18672730444e8d75df6d538adc078ac008379184
child 37633 740e44bb94373b406a835feb270cfcedb34cbbf0
push id11411
push usereakhgari@mozilla.com
push dateFri, 29 Jan 2010 19:02:45 +0000
treeherdermozilla-central@915147e9ed53 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs542914
milestone1.9.3a1pre
Bug 542914 - Add some tests for text input fields to make sure their basic behavior and appearance does not regress; r=roc
layout/forms/test/Makefile.in
layout/forms/test/test_bug542914.html
layout/reftests/editor/dynamic-1.html
layout/reftests/editor/dynamic-ref.html
layout/reftests/editor/emptypasswd-1.html
layout/reftests/editor/emptypasswd-2.html
layout/reftests/editor/emptypasswd-ref.html
layout/reftests/editor/newline-1.html
layout/reftests/editor/newline-2.html
layout/reftests/editor/newline-3.html
layout/reftests/editor/newline-ref.html
layout/reftests/editor/passwd-1.html
layout/reftests/editor/passwd-2.html
layout/reftests/editor/passwd-3.html
layout/reftests/editor/passwd-4.html
layout/reftests/editor/passwd-ref.html
layout/reftests/editor/reftest.list
layout/reftests/reftest.list
--- a/layout/forms/test/Makefile.in
+++ b/layout/forms/test/Makefile.in
@@ -51,13 +51,14 @@ include $(topsrcdir)/config/rules.mk
 		test_bug378670.html \
 		test_bug402198.html \
 		test_bug411236.html \
 		test_bug446663.html \
 		test_bug476308.html \
 		test_bug477531.html \
 		test_bug477700.html \
 		test_bug478219.xhtml \
+		test_bug542914.html \
 		bug477700_subframe.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/layout/forms/test/test_bug542914.html
@@ -0,0 +1,92 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=542914
+-->
+<head>
+  <title>Test for Bug 542914</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <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();
+addLoadEvent(function() {
+  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");
+  sendChar("a", c);
+  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();
+  sendChar("b", c);
+  is(c.value, "ab", "Control retains caret position after being re-focused");
+
+  var d = document.createElement("input");
+  d.setAttribute("type", "text");
+  $("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";
+  is(d.value, "new", "Dynamic control's value can be set before initialization");
+  sendChar("x", d);
+  is(d.value, "newx", "Dynamic control accepts keyboard input without explicit initialization");
+  $("display").removeChild(d);
+  is(d.value, "newx", "Dynamic control retains value after being removed from the document");
+
+  SimpleTest.finish();
+});
+
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/dynamic-1.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="text">
+    <script>
+      document.getElementsByTagName("input")[0].value = "abcdef";
+    </script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/dynamic-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="text" value="abcdef">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/emptypasswd-1.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="password">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/emptypasswd-2.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="password" value="abcdef">
+    <script>
+      document.getElementsByTagName("input")[0].value = "";
+    </script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/emptypasswd-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="text">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/newline-1.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="text" value="aaa&#10;bbb">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/newline-2.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="text" value="&#10;aaa bbb">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/newline-3.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="text" value="aaa bbb&#10;">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/newline-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="text" value="aaa bbb">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/passwd-1.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="password" value="123456">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/passwd-2.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="text" value="abcdef">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/passwd-3.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="password">
+    <script>
+      document.getElementsByTagName("input")[0].value = "abcdef";
+    </script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/passwd-4.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<!--
+Make sure that focusing a password text element does not
+cause a non-breaking space character to show up.
+-->
+<html class="reftest-wait">
+<body onload="loaded()">
+    <input type="password">
+    <script>
+      function loaded() {
+        var i = document.getElementsByTagName("input")[0];
+        i.focus();
+        i.value += "abcdef";
+        i.blur();
+        document.documentElement.className = "";
+      }
+    </script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/passwd-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <input type="password" value="abcdef">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/reftest.list
@@ -0,0 +1,10 @@
+== newline-1.html newline-ref.html
+== newline-2.html newline-ref.html
+== newline-3.html newline-ref.html
+== dynamic-1.html dynamic-ref.html
+== passwd-1.html passwd-ref.html
+!= passwd-2.html passwd-ref.html
+== passwd-3.html passwd-ref.html
+== passwd-4.html passwd-ref.html
+== emptypasswd-1.html emptypasswd-ref.html
+== emptypasswd-2.html emptypasswd-ref.html
--- a/layout/reftests/reftest.list
+++ b/layout/reftests/reftest.list
@@ -66,16 +66,19 @@ include css-valuesandunits/reftest.list
 include columns/reftest.list
 
 # content/
 include ../../content/test/reftest/reftest.list
 
 # counters/
 include counters/reftest.list
 
+# editor/
+include editor/reftest.list
+
 # generated-content/
 include generated-content/reftest.list
 
 # first-letter/
 include first-letter/reftest.list
 
 # first-line/
 include first-line/reftest.list