Bug 1064657 - Add testSelectionHandler test to ensure readOnly input elements can't be cut, r=wesj
authorMark Capella <markcapella@twcny.rr.com>
Mon, 15 Sep 2014 16:47:25 -0400
changeset 205430 5ea18dc3e65523bbf2c9ff86d0a0d20f7c5b0691
parent 205429 cba8fb1e0e37b77123023ca36acda82c0ff910db
child 205431 3c0d141374a7aab7282736304f5cefcbe9836281
push id27493
push usernigelbabu@gmail.com
push dateTue, 16 Sep 2014 03:14:08 +0000
treeherdermozilla-central@0e581e529fd6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs1064657
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1064657 - Add testSelectionHandler test to ensure readOnly input elements can't be cut, r=wesj
mobile/android/base/tests/roboextender/testSelectionHandler.html
--- a/mobile/android/base/tests/roboextender/testSelectionHandler.html
+++ b/mobile/android/base/tests/roboextender/testSelectionHandler.html
@@ -4,31 +4,33 @@
     <meta name="viewport" content="initial-scale=1.0"/>
     <script type="application/javascript"
       src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
     <script type="application/javascript">
 
 const DIV_POINT_TEXT = "Under";
 const INPUT_TEXT = "Text for select all in an <input>";
 const TEXTAREA_TEXT = "Text for select all in a <textarea>";
+const READONLY_INPUT_TEXT = "readOnly text";
 
 const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
 Cu.import("resource://gre/modules/Messaging.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 /* =================================================================================
  *
  * Start of all text selection tests, check initialization state.
  *
  */
 function startTests() {
   testSelectAllDivs().
     then(testSelectDivAtPoint).
     then(testSelectInput).
     then(testSelectTextarea).
+    then(testReadonlyInput).
     then(testCloseSelection).
     then(finishTests, function(err) {
       ok(false, "Error in selection test " + err);
       finishTests();
     });
 }
 
 /* =================================================================================
@@ -152,16 +154,37 @@ function testSelectTextarea() {
     return Promise.all([
       ok(!sh.isSelectionActive(), "Selection should not be active"),
     ]);
   });
 }
 
 /* =================================================================================
  *
+ * Ensure that readonly inputs aren't editable, and not subject to
+ * SelectionHandler actions such as "cut".
+ *
+ */
+function testReadonlyInput() {
+  var sh = getSelectionHandler();
+  var readOnlyNode = document.getElementById("readOnlyTextInput");
+  readOnlyNode.value = READONLY_INPUT_TEXT;
+
+  return Promise.all([
+    ok(!sh.isSelectionActive(), "Selection should not be active at start of testReadonlyInput"),
+
+  ]).then(function() {
+    return Promise.all([
+      ok(!sh.isElementEditableText(readOnlyNode), "Selected element should be readOnly (not editable)"),
+    ]);
+  });
+}
+
+/* =================================================================================
+ *
  * Various text selection tests to end active selections, including:
  *   1.) Clicking outside the selection.
  *   2.) SelectionEnd or Tab:Selected messages from java.
  *
  */
 function testCloseSelection() {
   var sh = getSelectionHandler();
   var inputNode = document.getElementById("inputNode");
@@ -282,10 +305,12 @@ function is(one, two, msg) {
       ornare lorem. Pellentesque nec dictum ante. Nam quis ligula ultricies, auctor
       nunc vel, fringilla turpis. Nulla lacinia, leo ut egestas hendrerit, risus
       ligula interdum enim, vel varius libero sem ut ligula.</div><br>
 
     <input id="inputNode" type="text"><br>
 
     <textarea id="textareaNode"></textarea><br>
 
+    <input id="readOnlyTextInput" type="text" readonly><br>
+
   </body>
 </html>