Bug 1337392 - Update test cases to match new cursor behavior. r=smaug, a=jcristau
authorAndreas Farre <farre@mozilla.com>
Fri, 07 Apr 2017 04:15:00 -0400
changeset 355605 13f2d85da9a7d80ca4674f7d1b3c9e195d72e2c1
parent 355604 4ab6d5c43036602ca978833665453418104ce3a2
child 355606 143d5fa98ef7bfd6e89f70211d210e12e0de70a6
push id7010
push userryanvm@gmail.com
push dateFri, 07 Apr 2017 21:02:01 +0000
treeherdermozilla-esr52@143d5fa98ef7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, jcristau
bugs1337392
milestone52.0.3
Bug 1337392 - Update test cases to match new cursor behavior. r=smaug, a=jcristau MozReview-Commit-ID: 4BdZyeqTBAx
accessible/tests/mochitest/jsat/test_content_text.html
accessible/tests/mochitest/states/test_inputs.html
devtools/client/debugger/new/test/mochitest/browser_dbg-breakpoints-cond.js
devtools/client/netmonitor/test/browser_net_resend.js
dom/browser-element/mochitest/browserElement_SetInputMethodActive.js
dom/html/test/test_bug613019.html
editor/libeditor/tests/test_bug850043.html
layout/base/tests/bug1082486-1.html
layout/base/tests/bug646382-1-ref.html
layout/base/tests/bug646382-2-ref.html
layout/base/tests/bug664087-1-ref.html
layout/base/tests/bug664087-2-ref.html
layout/base/tests/bug956530-1.html
layout/base/tests/input-maxlength-invalid-change.html
layout/base/tests/input-maxlength-ui-invalid-change.html
layout/base/tests/input-maxlength-ui-valid-change.html
layout/base/tests/input-maxlength-valid-change.html
layout/base/tests/input-minlength-invalid-change.html
layout/base/tests/input-minlength-ui-invalid-change.html
layout/base/tests/input-minlength-ui-valid-change.html
layout/base/tests/input-minlength-valid-change.html
layout/base/tests/textarea-maxlength-invalid-change.html
layout/base/tests/textarea-maxlength-ui-invalid-change.html
layout/base/tests/textarea-maxlength-ui-valid-change.html
layout/base/tests/textarea-maxlength-valid-change.html
layout/base/tests/textarea-minlength-invalid-change.html
layout/base/tests/textarea-minlength-ui-invalid-change.html
layout/base/tests/textarea-minlength-ui-valid-change.html
layout/base/tests/textarea-minlength-valid-change.html
layout/forms/test/bug287446_subframe.html
layout/forms/test/test_bug353539.html
layout/forms/test/test_bug534785.html
layout/reftests/bugs/240933-1.html
widget/tests/test_native_key_bindings_mac.html
--- a/accessible/tests/mochitest/jsat/test_content_text.html
+++ b/accessible/tests/mochitest/jsat/test_content_text.html
@@ -63,26 +63,26 @@
              { android_todo: true /* Bug 980512 */})],
 
           // Editable text tests.
           [ContentMessages.focusSelector('textarea'),
            new ExpectedAnnouncement('editing'),
            new ExpectedEditState({
             editing: true,
             multiline: true,
-            atStart: false,
-            atEnd: true
+            atStart: true,
+            atEnd: false
            }),
            new ExpectedCursorChange(
             ['Please refrain from Mayoneggs during this salmonella scare.',
              {string: 'textarea'}]),
-           new ExpectedTextSelectionChanged(59, 59)
+           new ExpectedTextSelectionChanged(0, 0)
           ],
           [ContentMessages.activateCurrent(10),
-           new ExpectedTextCaretChanged(10, 59),
+           new ExpectedTextCaretChanged(0, 10),
            new ExpectedEditState({ editing: true,
              multiline: true,
              atStart: false,
              atEnd: false }),
            new ExpectedTextSelectionChanged(10, 10)],
           [ContentMessages.activateCurrent(20),
            new ExpectedTextCaretChanged(10, 20),
            new ExpectedTextSelectionChanged(20, 20)
--- a/accessible/tests/mochitest/states/test_inputs.html
+++ b/accessible/tests/mochitest/states/test_inputs.html
@@ -102,16 +102,17 @@
       testStates(valid[i] + "2", 0, 0, STATE_INVALID);
     }
 
     ////////////////////////////////////////////////////////////////////////////
     // 'invalid' state
     // (per spec, min/maxlength validity is affected by interactive edits)
     var mininp = document.getElementById("minlength");
     mininp.focus();
+    mininp.setSelectionRange(mininp.value.length, mininp.value.length);
     synthesizeKey("VK_BACK_SPACE", {});
     ok(!mininp.validity.valid,
        "input should be invalid after interactive edits");
     testStates(mininp, STATE_INVALID);
     // inputs currently cannot be made longer than maxlength interactively,
     // so we're not testing that case.
 
     ////////////////////////////////////////////////////////////////////////////
--- a/devtools/client/debugger/new/test/mochitest/browser_dbg-breakpoints-cond.js
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-breakpoints-cond.js
@@ -27,17 +27,17 @@ add_task(function* () {
   yield waitForDispatch(dbg, "ADD_BREAKPOINT");
   let bp = findBreakpoint(dbg, "simple2", 5);
   is(bp.condition, "1", "breakpoint is created with the condition");
 
   // Editing a conditional Breakpoint
   yield setConditionalBreakpoint(dbg, 5, "2");
   yield waitForDispatch(dbg, "SET_BREAKPOINT_CONDITION");
   bp = findBreakpoint(dbg, "simple2", 5);
-  is(bp.condition, "12", "breakpoint is created with the condition");
+  is(bp.condition, "21", "breakpoint is created with the condition");
 
   // Removing a conditional breakpoint
   clickElement(dbg, "gutter", 5);
   yield waitForDispatch(dbg, "REMOVE_BREAKPOINT");
   bp = findBreakpoint(dbg, "simple2", 5);
   is(bp, null, "breakpoint was removed");
 
   // Adding a condition to a breakpoint
--- a/devtools/client/netmonitor/test/browser_net_resend.js
+++ b/devtools/client/netmonitor/test/browser_net_resend.js
@@ -109,39 +109,42 @@ add_task(function* () {
    */
   function* editCustomForm() {
     panelWin.focus();
 
     let query = document.getElementById("custom-query-value");
     let queryFocus = once(query, "focus", false);
     // Bug 1195825: Due to some unexplained dark-matter with promise,
     // focus only works if delayed by one tick.
+    query.setSelectionRange(query.value.length, query.value.length);
     executeSoon(() => query.focus());
     yield queryFocus;
 
     // add params to url query string field
     type(["VK_RETURN"]);
     type(ADD_QUERY);
 
     let headers = document.getElementById("custom-headers-value");
     let headersFocus = once(headers, "focus", false);
+    headers.setSelectionRange(headers.value.length, headers.value.length);
     headers.focus();
     yield headersFocus;
 
     // add a header
     type(["VK_RETURN"]);
     type(ADD_HEADER);
 
     // add a User-Agent header, to check if default headers can be modified
     // (there will be two of them, first gets overwritten by the second)
     type(["VK_RETURN"]);
     type(ADD_UA_HEADER);
 
     let postData = document.getElementById("custom-postdata-value");
     let postFocus = once(postData, "focus", false);
+    postData.setSelectionRange(postData.value.length, postData.value.length);
     postData.focus();
     yield postFocus;
 
     // add to POST data
     type(ADD_POSTDATA);
   }
 
   /*
--- a/dom/browser-element/mochitest/browserElement_SetInputMethodActive.js
+++ b/dom/browser-element/mochitest/browserElement_SetInputMethodActive.js
@@ -223,17 +223,17 @@ function next(msg) {
 
         case 'im1':
           is(false, 'Shouldn\'t be hearing anything from second frame.');
 
           break;
 
         case 'input':
           if (gFrameMsgCounts.input === 1) {
-            is(value, 'hello#0',
+            is(value, '#0hello',
               'Failed to get correct input from the first iframe.');
           } else {
             ok(false, 'Unexpected multiple messages from input.')
           }
 
           break;
       }
 
@@ -278,17 +278,17 @@ function next(msg) {
           } else {
             ok(false, 'Unexpected multiple messages from im0.')
           }
 
           break;
 
         case 'input':
           if (gFrameMsgCounts.input === 2) {
-            is(value, 'hello#0#1',
+            is(value, '#0#1hello',
                'Failed to get correct input from the second iframe.');
           } else {
             ok(false, 'Unexpected multiple messages from input.')
           }
           break;
       }
 
       if (gFrameMsgCounts.input !== 2 ||
--- a/dom/html/test/test_bug613019.html
+++ b/dom/html/test/test_bug613019.html
@@ -22,16 +22,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 /** Test for Bug 613019 **/
 
 function testInteractivityOfMaxLength(elem) {
   // verify that user interactivity is necessary for validity state to apply.
   is(elem.value, "Test", "Element has incorrect starting value.");
   is(elem.validity.tooLong, false, "Element should not be tooLong.");
 
+  elem.setSelectionRange(elem.value.length, elem.value.length)
   elem.focus();
 
   synthesizeKey("VK_BACK_SPACE", {});
   is(elem.value, "Tes", "Element value was not changed correctly.");
   is(elem.validity.tooLong, true, "Element should still be tooLong.");
 
   synthesizeKey("VK_BACK_SPACE", {});
   is(elem.value, "Te", "Element value was not changed correctly.");
@@ -42,16 +43,17 @@ function testInteractivityOfMaxLength(el
      "Element should not be tooLong after non-interactive value change.");
 }
 
 function testInteractivityOfMinLength(elem) {
   // verify that user interactivity is necessary for validity state to apply.
   is(elem.value, "Test", "Element has incorrect starting value.");
   is(elem.validity.tooLong, false, "Element should not be tooShort.");
 
+  elem.setSelectionRange(elem.value.length, elem.value.length)
   elem.focus();
 
   synthesizeKey("e", {});
   is(elem.value, "Teste", "Element value was not changed correctly.");
   is(elem.validity.tooShort, true, "Element should still be tooShort.");
 
   synthesizeKey("d", {});
   is(elem.value, "Tested", "Element value was not changed correctly.");
--- a/editor/libeditor/tests/test_bug850043.html
+++ b/editor/libeditor/tests/test_bug850043.html
@@ -25,16 +25,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </pre>
 <script>
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(() => {
   let fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
     getService(SpecialPowers.Ci.nsIFocusManager);
 
   let element = document.getElementById("textarea");
+  element.setSelectionRange(element.value.length, element.value.length);
   element.focus();
   is(SpecialPowers.unwrap(fm.focusedElement), element, "failed to move focus");
 
   synthesizeKey("VK_END", { });
   synthesizeKey("a", { });
   is(element.value, "b\u{9080}\u{e010f}\u{8fba}\u{e0101}a", "a isn't last character");
 
   synthesizeKey("VK_BACK_SPACE", { });
--- a/layout/base/tests/bug1082486-1.html
+++ b/layout/base/tests/bug1082486-1.html
@@ -10,18 +10,16 @@
        outline: none;
      }
      </style>
   </head>
   <body onload="focusInput();">
     <script>
       function focusInput() {
         var inp = document.getElementById('i');
-        inp.selectionStart = 0;
-        inp.selectionEnd = 0;
         inp.focus();
       }
     </script>
 
     <a target="_blank" href="https://bugzil.la/1082486">Mozilla Bug 1082486</a>
 
     <!-- The caret will not be seen when the input is focused. -->
     <input id='i' value="abcdefghd" style="text-indent: -10px">
--- a/layout/base/tests/bug646382-1-ref.html
+++ b/layout/base/tests/bug646382-1-ref.html
@@ -2,18 +2,16 @@
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   </head>
   <body onload="start()">
     <textarea onfocus="done()" style="-moz-appearance: none">س</textarea>
     <script>
       var textarea = document.querySelector("textarea");
       function start() {
-        textarea.selectionStart = 0;
-        textarea.selectionEnd = 0;
         textarea.focus();
       }
       function done() {
         document.documentElement.removeAttribute("class");
       }
     </script>
   </body>
 </html>
--- a/layout/base/tests/bug646382-2-ref.html
+++ b/layout/base/tests/bug646382-2-ref.html
@@ -1,16 +1,14 @@
 <html class="reftest-wait">
   <body onload="start()">
     <textarea dir="rtl" onfocus="done()" style="-moz-appearance: none">s</textarea>
     <script>
       var textarea = document.querySelector("textarea");
       function start() {
-        textarea.selectionStart = 0;
-        textarea.selectionEnd = 0;
         textarea.focus();
       }
       function done() {
         document.documentElement.removeAttribute("class");
       }
     </script>
   </body>
 </html>
--- a/layout/base/tests/bug664087-1-ref.html
+++ b/layout/base/tests/bug664087-1-ref.html
@@ -4,18 +4,16 @@
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   </head>
   <body onload="start()">
     <textarea rows="3" onfocus="done()" spellcheck="false" style="-moz-appearance: none">אב
 ג</textarea>
     <script>
       var textarea = document.querySelector("textarea");
       function start() {
-        textarea.selectionStart = 0;
-        textarea.selectionEnd = 0;
         textarea.focus();
       }
       function done() {
         synthesizeKey("VK_LEFT", {});
         synthesizeKey("VK_LEFT", {});
         document.documentElement.removeAttribute("class");
       }
     </script>
--- a/layout/base/tests/bug664087-2-ref.html
+++ b/layout/base/tests/bug664087-2-ref.html
@@ -4,18 +4,16 @@
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   </head>
   <body onload="start()">
     <textarea dir="rtl" onfocus="done()" spellcheck="false" style="-moz-appearance: none">ab
 c</textarea>
     <script>
       var textarea = document.querySelector("textarea");
       function start() {
-        textarea.selectionStart = 0;
-        textarea.selectionEnd = 0;
         textarea.focus();
       }
       function done() {
         synthesizeKey("VK_RIGHT", {});
         synthesizeKey("VK_RIGHT", {});
         document.documentElement.removeAttribute("class");
       }
     </script>
--- a/layout/base/tests/bug956530-1.html
+++ b/layout/base/tests/bug956530-1.html
@@ -6,18 +6,19 @@
     background: none;
     border: none;
     outline: none;
   }
   </style>
   <script src="/tests/SimpleTest/EventUtils.js"></script>
   <script>
     function test() {
+      var i = document.querySelector("input");
+      i.setSelectionRange(i.value.length,i.value.length);
       focus();
-      var i = document.querySelector("input");
       synthesizeMouseAtCenter(i, {});
       setTimeout(function() {
         synthesizeMouseAtCenter(document.body, {});
         setTimeout(function() {
           synthesizeMouseAtCenter(i, {});
         }, 0);
       }, 0);
     }
--- a/layout/base/tests/input-maxlength-invalid-change.html
+++ b/layout/base/tests/input-maxlength-invalid-change.html
@@ -6,20 +6,20 @@
       :valid { background-color:green; }
       :invalid { background-color:red; }
       * { box-shadow:none; background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var input = document.getElementById('input');
+        input.setSelectionRange(input.value.length, input.value.length)
         input.focus();
         synthesizeKey('VK_BACK_SPACE', {});
         input.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <input id="input" maxlength="2" value="fooo">
   </body>
 </html>
-
--- a/layout/base/tests/input-maxlength-ui-invalid-change.html
+++ b/layout/base/tests/input-maxlength-ui-invalid-change.html
@@ -6,20 +6,20 @@
       :-moz-ui-valid { background-color:green; }
       :-moz-ui-invalid { background-color:red; }
       * { box-shadow:none; background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var input = document.getElementById('input');
+        input.setSelectionRange(input.value.length, input.value.length)
         input.focus();
         synthesizeKey('VK_BACK_SPACE', {});
         input.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <input id="input" maxlength="2" value="fooo">
   </body>
 </html>
-
--- a/layout/base/tests/input-maxlength-ui-valid-change.html
+++ b/layout/base/tests/input-maxlength-ui-valid-change.html
@@ -6,23 +6,23 @@
       :-moz-ui-valid { background-color:green; }
       :-moz-ui-invalid { background-color:red; }
       * { background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var input = document.getElementById('input');
+        input.setSelectionRange(input.value.length, input.value.length)
         input.focus();
         synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first
         input.blur();
         input.focus();
         synthesizeKey('VK_BACK_SPACE', {});
         input.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <input id="input" maxlength="3" value="foooo">
   </body>
 </html>
-
--- a/layout/base/tests/input-maxlength-valid-change.html
+++ b/layout/base/tests/input-maxlength-valid-change.html
@@ -6,23 +6,23 @@
       :valid { background-color:green; }
       :invalid { background-color:red; }
       * { background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var input = document.getElementById('input');
+        input.setSelectionRange(input.value.length, input.value.length)
         input.focus();
         synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first
         input.blur();
         input.focus();
         synthesizeKey('VK_BACK_SPACE', {});
         input.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <input id="input" maxlength="3" value="foooo">
   </body>
 </html>
-
--- a/layout/base/tests/input-minlength-invalid-change.html
+++ b/layout/base/tests/input-minlength-invalid-change.html
@@ -6,20 +6,20 @@
       :valid { background-color:green; }
       :invalid { background-color:red; }
       * { box-shadow:none; background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var input = document.getElementById('input');
+        input.setSelectionRange(input.value.length, input.value.length)
         input.focus();
         synthesizeKey('o', {});
         input.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <input id="input" minlength="4" value="fo">
   </body>
 </html>
-
--- a/layout/base/tests/input-minlength-ui-invalid-change.html
+++ b/layout/base/tests/input-minlength-ui-invalid-change.html
@@ -6,20 +6,20 @@
       :-moz-ui-valid { background-color:green; }
       :-moz-ui-invalid { background-color:red; }
       * { box-shadow:none; background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var input = document.getElementById('input');
+        input.setSelectionRange(input.value.length, input.value.length)
         input.focus();
         synthesizeKey('o', {});
         input.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <input id="input" minlength="4" value="fo">
   </body>
 </html>
-
--- a/layout/base/tests/input-minlength-ui-valid-change.html
+++ b/layout/base/tests/input-minlength-ui-valid-change.html
@@ -6,23 +6,23 @@
       :-moz-ui-valid { background-color:green; }
       :-moz-ui-invalid { background-color:red; }
       * { background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var input = document.getElementById('input');
+        input.setSelectionRange(input.value.length, input.value.length)
         input.focus();
         synthesizeKey('o', {}); // so that it becomes invalid first
         input.blur();
         input.focus();
         synthesizeKey('o', {});
         input.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <input id="input" minlength="3" value="f">
   </body>
 </html>
-
--- a/layout/base/tests/input-minlength-valid-change.html
+++ b/layout/base/tests/input-minlength-valid-change.html
@@ -6,23 +6,23 @@
       :valid { background-color:green; }
       :invalid { background-color:red; }
       * { background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var input = document.getElementById('input');
+        input.setSelectionRange(input.value.length, input.value.length)
         input.focus();
         synthesizeKey('o', {}); // so that it becomes invalid first
         input.blur();
         input.focus();
         synthesizeKey('o', {});
         input.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <input id="input" minlength="3" value="f">
   </body>
 </html>
-
--- a/layout/base/tests/textarea-maxlength-invalid-change.html
+++ b/layout/base/tests/textarea-maxlength-invalid-change.html
@@ -6,20 +6,20 @@
       :valid { background-color:green; }
       :invalid { background-color:red; }
       * { box-shadow:none; background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var textarea = document.getElementById('textarea');
+        textarea.setSelectionRange(textarea.value.length, textarea.value.length)
         textarea.focus();
         synthesizeKey('VK_BACK_SPACE', {});
         textarea.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <textarea id="textarea" maxlength="2">fooo</textarea>
   </body>
 </html>
-
--- a/layout/base/tests/textarea-maxlength-ui-invalid-change.html
+++ b/layout/base/tests/textarea-maxlength-ui-invalid-change.html
@@ -6,20 +6,20 @@
       :-moz-ui-valid { background-color:green; }
       :-moz-ui-invalid { background-color:red; }
       * { box-shadow:none; background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var textarea = document.getElementById('textarea');
+        textarea.setSelectionRange(textarea.value.length, textarea.value.length)
         textarea.focus();
         synthesizeKey('VK_BACK_SPACE', {});
         textarea.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <textarea id="textarea" maxlength="2">fooo</textarea>
   </body>
 </html>
-
--- a/layout/base/tests/textarea-maxlength-ui-valid-change.html
+++ b/layout/base/tests/textarea-maxlength-ui-valid-change.html
@@ -6,23 +6,23 @@
       :-moz-ui-valid { background-color:green; }
       :-moz-ui-invalid { background-color:red; }
       * { background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var textarea = document.getElementById('textarea');
+        textarea.setSelectionRange(textarea.value.length, textarea.value.length)
         textarea.focus();
         synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first
         textarea.blur();
         textarea.focus();
         synthesizeKey('VK_BACK_SPACE', {});
         textarea.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <textarea id="textarea" maxlength="3">foooo</textarea>
   </body>
 </html>
-
--- a/layout/base/tests/textarea-maxlength-valid-change.html
+++ b/layout/base/tests/textarea-maxlength-valid-change.html
@@ -6,23 +6,23 @@
       :valid { background-color:green; }
       :invalid { background-color:red; }
       * { background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var textarea = document.getElementById('textarea');
+        textarea.setSelectionRange(textarea.value.length, textarea.value.length)
         textarea.focus();
         synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first
         textarea.blur();
         textarea.focus();
         synthesizeKey('VK_BACK_SPACE', {});
         textarea.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <textarea id="textarea" maxlength="3">foooo</textarea>
   </body>
 </html>
-
--- a/layout/base/tests/textarea-minlength-invalid-change.html
+++ b/layout/base/tests/textarea-minlength-invalid-change.html
@@ -6,20 +6,20 @@
       :valid { background-color:green; }
       :invalid { background-color:red; }
       * { box-shadow:none; background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var textarea = document.getElementById('textarea');
+        textarea.setSelectionRange(textarea.value.length, textarea.value.length)
         textarea.focus();
         synthesizeKey('o', {});
         textarea.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <textarea id="textarea" minlength="4">fo</textarea>
   </body>
 </html>
-
--- a/layout/base/tests/textarea-minlength-ui-invalid-change.html
+++ b/layout/base/tests/textarea-minlength-ui-invalid-change.html
@@ -6,20 +6,20 @@
       :-moz-ui-valid { background-color:green; }
       :-moz-ui-invalid { background-color:red; }
       * { box-shadow:none; background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var textarea = document.getElementById('textarea');
+        textarea.setSelectionRange(textarea.value.length, textarea.value.length)
         textarea.focus();
         synthesizeKey('o', {});
         textarea.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <textarea id="textarea" minlength="4">fo</textarea>
   </body>
 </html>
-
--- a/layout/base/tests/textarea-minlength-ui-valid-change.html
+++ b/layout/base/tests/textarea-minlength-ui-valid-change.html
@@ -6,23 +6,23 @@
       :-moz-ui-valid { background-color:green; }
       :-moz-ui-invalid { background-color:red; }
       * { background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var textarea = document.getElementById('textarea');
+        textarea.setSelectionRange(textarea.value.length, textarea.value.length)
         textarea.focus();
         synthesizeKey('o', {}); // so that it becomes invalid first
         textarea.blur();
         textarea.focus();
         synthesizeKey('o', {});
         textarea.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <textarea id="textarea" minlength="3">f</textarea>
   </body>
 </html>
-
--- a/layout/base/tests/textarea-minlength-valid-change.html
+++ b/layout/base/tests/textarea-minlength-valid-change.html
@@ -6,23 +6,23 @@
       :valid { background-color:green; }
       :invalid { background-color:red; }
       * { background-color:white; }
     </style>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script>
       function runTest() {
         var textarea = document.getElementById('textarea');
+        textarea.setSelectionRange(textarea.value.length, textarea.value.length)
         textarea.focus();
         synthesizeKey('o', {}); // so that it becomes invalid first
         textarea.blur();
         textarea.focus();
         synthesizeKey('o', {});
         textarea.blur(); // to hide the caret
         document.documentElement.className='';
       }
     </script>
   </head>
   <body onload="runTest()">
     <textarea id="textarea" minlength="3">f</textarea>
   </body>
 </html>
-
--- a/layout/forms/test/bug287446_subframe.html
+++ b/layout/forms/test/bug287446_subframe.html
@@ -13,27 +13,26 @@
 
       window.addEventListener("message",
         function(evt) {
           var t = $("target");
           if (evt.data == "start") {
             doIs(t.value, "Test", "Shouldn't have lost our initial value");
             t.focus();
             sendString("Foo");
-            doIs(t.value, "TestFoo", "Typing should work");
+            doIs(t.value, "FooTest", "Typing should work");
             window.parent.postMessage("c", "*");
           } else {
             doIs(evt.data, "continue", "Unexpected message");
-            doIs(t.value, "TestFoo", "Shouldn't have lost our typed value");
+            doIs(t.value, "FooTest", "Shouldn't have lost our typed value");
             sendString("Bar");
-            doIs(t.value, "TestFooBar", "Typing should still work");
+            doIs(t.value, "FooBarTest", "Typing should still work");
             window.parent.postMessage("f", "*");
           }
         },
         "false");
-      
+
     </script>
   </head>
   <body>
     <input id="target" value="Test">
   </body>
 </html>
-           
--- a/layout/forms/test/test_bug353539.html
+++ b/layout/forms/test/test_bug353539.html
@@ -22,29 +22,27 @@ https://bugzilla.mozilla.org/show_bug.cg
   we're
   using
   for
   testing
   purposes
   </textarea>
 </p>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 353539 **/
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(function() {
   var area = document.getElementById("area");
 
   is(area.scrollTop, 0, "The textarea should not be scrolled initially");
-  area.selectionStart = 0;
-  area.selectionEnd = 0;
   area.focus();
   setTimeout(function() {
     is(area.scrollTop, 0, "The textarea's insertion point should not be scrolled into view");
 
     SimpleTest.finish();
   }, 0);
 });
 
--- a/layout/forms/test/test_bug534785.html
+++ b/layout/forms/test/test_bug534785.html
@@ -28,27 +28,27 @@ SimpleTest.waitForExplicitFinish();
 
 SimpleTest.waitForFocus(function() {
   var i = document.querySelector("input");
   i.addEventListener("focus", function() {
     is(i.value, "test", "Sanity check");
 
     is(document.activeElement, i, "Should be focused before frame reconstruction");
     synthesizeKey("1", {});
-    is(i.value, "test1", "Can accept keyboard events before frame reconstruction");
+    is(i.value, "1test", "Can accept keyboard events before frame reconstruction");
 
     // force frame reconstruction
     i.style.display = "none";
     document.offsetHeight;
     i.style.display = "";
     document.offsetHeight;
 
     is(document.activeElement, i, "Should be focused after frame reconstruction");
     synthesizeKey("2", {});
-    is(i.value, "test12", "Can accept keyboard events after frame reconstruction");
+    is(i.value, "12test", "Can accept keyboard events after frame reconstruction");
 
     // Make sure reframing happens gracefully
     var reframeDiv = document.getElementById("reframe");
     var textAreaWithoutValue = reframeDiv.querySelectorAll("textarea")[0];
     var textAreaWithValue = reframeDiv.querySelectorAll("textarea")[1];
     var inputWithoutValue = reframeDiv.querySelectorAll("input")[0];
     var inputWithValue = reframeDiv.querySelectorAll("input")[1];
     reframeDiv.style.display = "none";
--- a/layout/reftests/bugs/240933-1.html
+++ b/layout/reftests/bugs/240933-1.html
@@ -7,13 +7,13 @@
 
 </textarea>
 <textarea id="tb">
 
 abc
 
 </textarea>
 
-<div id="coords1">6</div>
-<div id="coords2">6</div>
+<div id="coords1">0</div>
+<div id="coords2">0</div>
 
 </body>
 </html>
--- a/widget/tests/test_native_key_bindings_mac.html
+++ b/widget/tests/test_native_key_bindings_mac.html
@@ -93,20 +93,16 @@
       Nullam pellentesque rip the couch iaculis rhoncus nibh, give me fish orci
       turpis purr sleep on your face quis nunc bibendum.">
 
     <script type="text/javascript;version=1.8">
       SimpleTest.waitForExplicitFinish();
 
       let synthesizedKeys = [];
       let expectations = [];
-      
-      let textarea = document.getElementById("textarea");
-      textarea.selectionStart = 0;
-      textarea.selectionEnd = 0;
 
       // Move to beginning of line
       synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_LeftArrow,
                             {ctrlKey: true}, "\uf702", "\uf702"]);
       expectations.push({
         editable: [0, 0],
         textarea: [0, 0],
         input:    [0, 0]