Backed out changeset ea659450b0da (bug 1345237)
authorWes Kocher <wkocher@mozilla.com>
Thu, 09 Mar 2017 15:27:15 -0800
changeset 397330 ac6e090b6365fc0c298c15e7dcd5a522b91fb145
parent 397329 dbe10b788f4f56309536b854b1877928804bb2b8
child 397331 a6a31be4591879b37d6c33a849958400819e8559
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1345237
milestone55.0a1
backs outea659450b0dace878800077ba5e40c779535837b
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
Backed out changeset ea659450b0da (bug 1345237) MozReview-Commit-ID: JQ2dsysX25w
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/html/HTMLInputElement.cpp
dom/html/HTMLInputElement.h
dom/html/HTMLTextAreaElement.cpp
dom/html/HTMLTextAreaElement.h
dom/html/nsTextEditorState.cpp
dom/html/nsTextEditorState.h
editor/libeditor/TextEditRules.cpp
editor/libeditor/TextEditRules.h
layout/forms/nsITextControlFrame.h
layout/forms/nsTextControlFrame.cpp
layout/forms/nsTextControlFrame.h
testing/web-platform/meta/html/semantics/forms/textfieldselection/textfieldselection-setSelectionRange.html.ini
testing/web-platform/tests/html/semantics/forms/textfieldselection/selection-start-end.html
testing/web-platform/tests/html/semantics/forms/textfieldselection/textfieldselection-setSelectionRange.html
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -7053,18 +7053,18 @@ nsContentUtils::GetAdjustedOffsetInTextC
   // has already been correctly calculated.
   return aOffset;
 }
 
 // static
 void
 nsContentUtils::GetSelectionInTextControl(Selection* aSelection,
                                           Element* aRoot,
-                                          uint32_t& aOutStartOffset,
-                                          uint32_t& aOutEndOffset)
+                                          int32_t& aOutStartOffset,
+                                          int32_t& aOutEndOffset)
 {
   MOZ_ASSERT(aSelection && aRoot);
 
   // We don't care which end of this selection is anchor and which is focus.  In
   // fact, we explicitly want to know which is the _start_ and which is the
   // _end_, not anchor vs focus.
   const nsRange* range = aSelection->GetAnchorFocusRange();
   if (!range) {
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -2412,18 +2412,18 @@ public:
    *
    * @param aSelection      Selection to check
    * @param aRoot           Root <input> or <textarea> element
    * @param aOutStartOffset Output start offset
    * @param aOutEndOffset   Output end offset
    */
   static void GetSelectionInTextControl(mozilla::dom::Selection* aSelection,
                                         Element* aRoot,
-                                        uint32_t& aOutStartOffset,
-                                        uint32_t& aOutEndOffset);
+                                        int32_t& aOutStartOffset,
+                                        int32_t& aOutEndOffset);
 
   /**
    * Takes a frame for anonymous content within a text control (<input> or
    * <textarea>), and returns an offset in the text content, adjusted for a
    * trailing <br> frame.
    *
    * @param aOffsetFrame      Frame for the text content in which the offset
    *                          lies
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -6327,17 +6327,17 @@ HTMLInputElement::SetValueFromSetRangeTe
 
 Nullable<uint32_t>
 HTMLInputElement::GetSelectionStart(ErrorResult& aRv)
 {
   if (!SupportsTextSelection()) {
     return Nullable<uint32_t>();
   }
 
-  uint32_t selEnd, selStart;
+  int32_t selEnd, selStart;
   GetSelectionRange(&selStart, &selEnd, aRv);
   return Nullable<uint32_t>(selStart);
 }
 
 void
 HTMLInputElement::SetSelectionStart(const Nullable<uint32_t>& aSelectionStart,
                                     ErrorResult& aRv)
 {
@@ -6353,17 +6353,17 @@ HTMLInputElement::SetSelectionStart(cons
 
 Nullable<uint32_t>
 HTMLInputElement::GetSelectionEnd(ErrorResult& aRv)
 {
   if (!SupportsTextSelection()) {
     return Nullable<uint32_t>();
   }
 
-  uint32_t selEnd, selStart;
+  int32_t selEnd, selStart;
   GetSelectionRange(&selStart, &selEnd, aRv);
   return Nullable<uint32_t>(selEnd);
 }
 
 void
 HTMLInputElement::SetSelectionEnd(const Nullable<uint32_t>& aSelectionEnd,
                                   ErrorResult& aRv)
 {
@@ -6381,18 +6381,18 @@ NS_IMETHODIMP
 HTMLInputElement::GetFiles(nsIDOMFileList** aFileList)
 {
   RefPtr<FileList> list = GetFiles();
   list.forget(aFileList);
   return NS_OK;
 }
 
 void
-HTMLInputElement::GetSelectionRange(uint32_t* aSelectionStart,
-                                    uint32_t* aSelectionEnd,
+HTMLInputElement::GetSelectionRange(int32_t* aSelectionStart,
+                                    int32_t* aSelectionEnd,
                                     ErrorResult& aRv)
 {
   nsTextEditorState* state = GetEditorState();
   if (!state) {
     // Not a text control.
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
--- a/dom/html/HTMLInputElement.h
+++ b/dom/html/HTMLInputElement.h
@@ -1481,18 +1481,18 @@ protected:
    * decide whether to add this element into its dispatch-to-content region.
    */
   void UpdateApzAwareFlag();
 
   /**
    * A helper to get the current selection range.  Will throw on the ErrorResult
    * if we have no editor state.
    */
-  void GetSelectionRange(uint32_t* aSelectionStart,
-                         uint32_t* aSelectionEnd,
+  void GetSelectionRange(int32_t* aSelectionStart,
+                         int32_t* aSelectionEnd,
                          ErrorResult& aRv);
 
   nsCOMPtr<nsIControllers> mControllers;
 
   /*
    * In mInputData, the mState field is used if IsSingleLineTextControl returns
    * true and mValue is used otherwise.  We have to be careful when handling it
    * on a type change.
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -696,46 +696,46 @@ HTMLTextAreaElement::GetTextLength(int32
   *aTextLength = GetTextLength();
 
   return NS_OK;
 }
 
 Nullable<uint32_t>
 HTMLTextAreaElement::GetSelectionStart(ErrorResult& aError)
 {
-  uint32_t selStart, selEnd;
+  int32_t selStart, selEnd;
   GetSelectionRange(&selStart, &selEnd, aError);
   return Nullable<uint32_t>(selStart);
 }
 
 void
 HTMLTextAreaElement::SetSelectionStart(const Nullable<uint32_t>& aSelectionStart,
                                        ErrorResult& aError)
 {
   mState.SetSelectionStart(aSelectionStart, aError);
 }
 
 Nullable<uint32_t>
 HTMLTextAreaElement::GetSelectionEnd(ErrorResult& aError)
 {
-  uint32_t selStart, selEnd;
+  int32_t selStart, selEnd;
   GetSelectionRange(&selStart, &selEnd, aError);
   return Nullable<uint32_t>(selEnd);
 }
 
 void
 HTMLTextAreaElement::SetSelectionEnd(const Nullable<uint32_t>& aSelectionEnd,
                                      ErrorResult& aError)
 {
   mState.SetSelectionEnd(aSelectionEnd, aError);
 }
 
 void
-HTMLTextAreaElement::GetSelectionRange(uint32_t* aSelectionStart,
-                                       uint32_t* aSelectionEnd,
+HTMLTextAreaElement::GetSelectionRange(int32_t* aSelectionStart,
+                                       int32_t* aSelectionEnd,
                                        ErrorResult& aRv)
 {
   return mState.GetSelectionRange(aSelectionStart, aSelectionEnd, aRv);
 }
 
 void
 HTMLTextAreaElement::GetSelectionDirection(nsAString& aDirection, ErrorResult& aError)
 {
--- a/dom/html/HTMLTextAreaElement.h
+++ b/dom/html/HTMLTextAreaElement.h
@@ -391,18 +391,18 @@ protected:
    * @return whether the current value is the empty string.
    */
   bool IsValueEmpty() const;
 
   /**
    * A helper to get the current selection range.  Will throw on the ErrorResult
    * if we have no editor state.
    */
-  void GetSelectionRange(uint32_t* aSelectionStart,
-                         uint32_t* aSelectionEnd,
+  void GetSelectionRange(int32_t* aSelectionStart,
+                         int32_t* aSelectionEnd,
                          ErrorResult& aRv);
 private:
   static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
                                     GenericSpecifiedValues* aGenericData);
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -1572,18 +1572,18 @@ nsTextEditorState::SetSelectionPropertie
                                    aProps.GetEnd(),
                                    aProps.GetDirection());
   } else {
     mSelectionProperties = aProps;
   }
 }
 
 void
-nsTextEditorState::GetSelectionRange(uint32_t* aSelectionStart,
-                                     uint32_t* aSelectionEnd,
+nsTextEditorState::GetSelectionRange(int32_t* aSelectionStart,
+                                     int32_t* aSelectionEnd,
                                      ErrorResult& aRv)
 {
   MOZ_ASSERT(aSelectionStart);
   MOZ_ASSERT(aSelectionEnd);
   MOZ_ASSERT(IsSelectionCached() || GetSelectionController(),
              "How can we not have a cached selection if we have no selection "
              "controller?");
 
@@ -1635,17 +1635,17 @@ nsTextEditorState::GetSelectionDirection
     return nsITextControlFrame::eForward;
   }
 
   MOZ_ASSERT(direction == eDirPrevious);
   return nsITextControlFrame::eBackward;
 }
 
 void
-nsTextEditorState::SetSelectionRange(uint32_t aStart, uint32_t aEnd,
+nsTextEditorState::SetSelectionRange(int32_t aStart, int32_t aEnd,
                                      nsITextControlFrame::SelectionDirection aDirection,
                                      ErrorResult& aRv)
 {
   MOZ_ASSERT(IsSelectionCached() || mBoundFrame,
              "How can we have a non-cached selection but no frame?");
 
   if (aStart > aEnd) {
     aStart = aEnd;
@@ -1654,20 +1654,20 @@ nsTextEditorState::SetSelectionRange(uin
   bool changed = false;
   nsresult rv = NS_OK; // For the ScrollSelectionIntoView() return value.
   if (IsSelectionCached()) {
     nsAutoString value;
     // XXXbz is "false" the right thing to pass here?  Hard to tell, given the
     // various mismatches between our impl and the spec.
     GetValue(value, false);
     uint32_t length = value.Length();
-    if (aStart > length) {
+    if (uint32_t(aStart) > length) {
       aStart = length;
     }
-    if (aEnd > length) {
+    if (uint32_t(aEnd) > length) {
       aEnd = length;
     }
     SelectionProperties& props = GetSelectionProperties();
     changed = props.GetStart() != aStart ||
               props.GetEnd() != aEnd ||
               props.GetDirection() != aDirection;
     props.SetStart(aStart);
     props.SetEnd(aEnd);
@@ -1698,25 +1698,27 @@ nsTextEditorState::SetSelectionRange(uin
   }
 
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
   }
 }
 
 void
-nsTextEditorState::SetSelectionStart(const Nullable<uint32_t>& aStart,
+nsTextEditorState::SetSelectionStart(const mozilla::dom::Nullable<uint32_t>& aStart,
                                      ErrorResult& aRv)
 {
-  uint32_t start = 0;
+  int32_t start = 0;
   if (!aStart.IsNull()) {
+    // XXXbz This will do the wrong thing for input values that are out of the
+    // int32_t range...
     start = aStart.Value();
   }
 
-  uint32_t ignored, end;
+  int32_t ignored, end;
   GetSelectionRange(&ignored, &end, aRv);
   if (aRv.Failed()) {
     return;
   }
 
   nsITextControlFrame::SelectionDirection dir = GetSelectionDirection(aRv);
   if (aRv.Failed()) {
     return;
@@ -1725,25 +1727,27 @@ nsTextEditorState::SetSelectionStart(con
   if (end < start) {
     end = start;
   }
 
   SetSelectionRange(start, end, dir, aRv);
 }
 
 void
-nsTextEditorState::SetSelectionEnd(const Nullable<uint32_t>& aEnd,
+nsTextEditorState::SetSelectionEnd(const mozilla::dom::Nullable<uint32_t>& aEnd,
                                    ErrorResult& aRv)
 {
-  uint32_t end = 0;
+  int32_t end = 0;
   if (!aEnd.IsNull()) {
+    // XXXbz This will do the wrong thing for input values that are out of the
+    // int32_t range...
     end = aEnd.Value();
   }
 
-  uint32_t start, ignored;
+  int32_t start, ignored;
   GetSelectionRange(&start, &ignored, aRv);
   if (aRv.Failed()) {
     return;
   }
 
   nsITextControlFrame::SelectionDirection dir = GetSelectionDirection(aRv);
   if (aRv.Failed()) {
     return;
@@ -1796,17 +1800,17 @@ nsTextEditorState::SetSelectionDirection
   nsITextControlFrame::SelectionDirection dir =
     DirectionStringToSelectionDirection(aDirection);
 
   if (IsSelectionCached()) {
     GetSelectionProperties().SetDirection(dir);
     return;
   }
 
-  uint32_t start, end;
+  int32_t start, end;
   GetSelectionRange(&start, &end, aRv);
   if (aRv.Failed()) {
     return;
   }
 
   SetSelectionRange(start, end, dir, aRv);
 }
 
@@ -1817,47 +1821,46 @@ DirectionStringToSelectionDirection(cons
     // We don't support directionless selections.
     return nsITextControlFrame::eForward;
   }
 
   return DirectionStringToSelectionDirection(aDirection.Value());
 }
 
 void
-nsTextEditorState::SetSelectionRange(uint32_t aSelectionStart,
-                                     uint32_t aSelectionEnd,
+nsTextEditorState::SetSelectionRange(int32_t aSelectionStart,
+                                     int32_t aSelectionEnd,
                                      const Optional<nsAString>& aDirection,
                                      ErrorResult& aRv)
 {
   nsITextControlFrame::SelectionDirection dir =
     DirectionStringToSelectionDirection(aDirection);
 
   SetSelectionRange(aSelectionStart, aSelectionEnd, dir, aRv);
 }
 
 void
 nsTextEditorState::SetRangeText(const nsAString& aReplacement,
                                 ErrorResult& aRv)
 {
-  uint32_t start, end;
+  int32_t start, end;
   GetSelectionRange(&start, &end, aRv);
   if (aRv.Failed()) {
     return;
   }
 
   SetRangeText(aReplacement, start, end, SelectionMode::Preserve,
-               aRv, Some(start), Some(end));
+               aRv, start, end);
 }
 
 void
 nsTextEditorState::SetRangeText(const nsAString& aReplacement, uint32_t aStart,
                                 uint32_t aEnd, SelectionMode aSelectMode,
-                                ErrorResult& aRv,
-                                const Maybe<uint32_t>& aSelectionStart,
-                                const Maybe<uint32_t>& aSelectionEnd)
+                                ErrorResult& aRv, int32_t aSelectionStart,
+                                int32_t aSelectionEnd)
 {
   if (aStart > aEnd) {
     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return;
   }
 
   nsAutoString value;
   mTextCtrlElement->GetValueFromSetRangeText(value);
@@ -1866,77 +1869,71 @@ nsTextEditorState::SetRangeText(const ns
   if (aStart > inputValueLength) {
     aStart = inputValueLength;
   }
 
   if (aEnd > inputValueLength) {
     aEnd = inputValueLength;
   }
 
-  uint32_t selectionStart, selectionEnd;
-  if (!aSelectionStart) {
-    MOZ_ASSERT(!aSelectionEnd);
-    GetSelectionRange(&selectionStart, &selectionEnd, aRv);
+  if (aSelectionStart == -1 && aSelectionEnd == -1) {
+    GetSelectionRange(&aSelectionStart, &aSelectionEnd, aRv);
     if (aRv.Failed()) {
       return;
     }
-  } else {
-    MOZ_ASSERT(aSelectionEnd);
-    selectionStart = *aSelectionStart;
-    selectionEnd = *aSelectionEnd;
   }
 
   MOZ_ASSERT(aStart <= aEnd);
   value.Replace(aStart, aEnd - aStart, aReplacement);
   nsresult rv = mTextCtrlElement->SetValueFromSetRangeText(value);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return;
   }
 
   uint32_t newEnd = aStart + aReplacement.Length();
   int32_t delta =  aReplacement.Length() - (aEnd - aStart);
 
   switch (aSelectMode) {
     case mozilla::dom::SelectionMode::Select:
     {
-      selectionStart = aStart;
-      selectionEnd = newEnd;
+      aSelectionStart = aStart;
+      aSelectionEnd = newEnd;
     }
     break;
     case mozilla::dom::SelectionMode::Start:
     {
-      selectionStart = selectionEnd = aStart;
+      aSelectionStart = aSelectionEnd = aStart;
     }
     break;
     case mozilla::dom::SelectionMode::End:
     {
-      selectionStart = selectionEnd = newEnd;
+      aSelectionStart = aSelectionEnd = newEnd;
     }
     break;
     case mozilla::dom::SelectionMode::Preserve:
     {
-      if (selectionStart > aEnd) {
-        selectionStart += delta;
-      } else if (selectionStart > aStart) {
-        selectionStart = aStart;
+      if ((uint32_t)aSelectionStart > aEnd) {
+        aSelectionStart += delta;
+      } else if ((uint32_t)aSelectionStart > aStart) {
+        aSelectionStart = aStart;
       }
 
-      if (selectionEnd > aEnd) {
-        selectionEnd += delta;
-      } else if (selectionEnd > aStart) {
-        selectionEnd = newEnd;
+      if ((uint32_t)aSelectionEnd > aEnd) {
+        aSelectionEnd += delta;
+      } else if ((uint32_t)aSelectionEnd > aStart) {
+        aSelectionEnd = newEnd;
       }
     }
     break;
     default:
       MOZ_CRASH("Unknown mode!");
   }
 
-  SetSelectionRange(selectionStart, selectionEnd, Optional<nsAString>(), aRv);
+  SetSelectionRange(aSelectionStart, aSelectionEnd, Optional<nsAString>(), aRv);
 }
 
 HTMLInputElement*
 nsTextEditorState::GetParentNumberControl(nsFrame* aFrame) const
 {
   MOZ_ASSERT(aFrame);
   nsIContent* content = aFrame->GetContent();
   MOZ_ASSERT(content);
@@ -2006,17 +2003,17 @@ nsTextEditorState::UnbindFromFrame(nsTex
 
   // Save our selection state if needed.
   // Note that GetSelectionRange will attempt to work with our selection
   // controller, so we should make sure we do it before we start doing things
   // like destroying our editor (if we have one), tearing down the selection
   // controller, and so forth.
   if (!IsSelectionCached()) {
     // Go ahead and cache it now.
-    uint32_t start = 0, end = 0;
+    int32_t start = 0, end = 0;
     IgnoredErrorResult rangeRv;
     GetSelectionRange(&start, &end, rangeRv);
 
     IgnoredErrorResult dirRv;
     nsITextControlFrame::SelectionDirection direction =
       GetSelectionDirection(dirRv);
 
     MOZ_ASSERT(aFrame == mBoundFrame);
@@ -2573,18 +2570,18 @@ nsTextEditorState::SetValue(const nsAStr
     // Since we have no editor we presumably have cached selection state.
     if (IsSelectionCached()) {
       SelectionProperties& props = GetSelectionProperties();
       if (aFlags & eSetValue_MoveCursorToEnd) {
         props.SetStart(value.Length());
         props.SetEnd(value.Length());
       } else {
         // Make sure our cached selection position is not outside the new value.
-        props.SetStart(std::min(props.GetStart(), value.Length()));
-        props.SetEnd(std::min(props.GetEnd(), value.Length()));
+        props.SetStart(std::min(uint32_t(props.GetStart()), value.Length()));
+        props.SetEnd(std::min(uint32_t(props.GetEnd()), value.Length()));
       }
     }
 
     // Update the frame display if needed
     if (mBoundFrame) {
       mBoundFrame->UpdateValueDisplay(true);
     }
   }
--- a/dom/html/nsTextEditorState.h
+++ b/dom/html/nsTextEditorState.h
@@ -222,30 +222,30 @@ public:
     public:
       SelectionProperties() : mStart(0), mEnd(0),
         mDirection(nsITextControlFrame::eForward) {}
       bool IsDefault() const
       {
         return mStart == 0 && mEnd == 0 &&
                mDirection == nsITextControlFrame::eForward;
       }
-      uint32_t GetStart() const
+      int32_t GetStart() const
       {
         return mStart;
       }
-      void SetStart(uint32_t value)
+      void SetStart(int32_t value)
       {
         mIsDirty = true;
         mStart = value;
       }
-      uint32_t GetEnd() const
+      int32_t GetEnd() const
       {
         return mEnd;
       }
-      void SetEnd(uint32_t value)
+      void SetEnd(int32_t value)
       {
         mIsDirty = true;
         mEnd = value;
       }
       nsITextControlFrame::SelectionDirection GetDirection() const
       {
         return mDirection;
       }
@@ -255,33 +255,33 @@ public:
         mDirection = value;
       }
       // return true only if mStart, mEnd, or mDirection have been modified
       bool IsDirty() const
       {
         return mIsDirty;
       }
     private:
-      uint32_t mStart, mEnd;
+      int32_t mStart, mEnd;
       bool mIsDirty = false;
       nsITextControlFrame::SelectionDirection mDirection;
   };
 
   bool IsSelectionCached() const;
   SelectionProperties& GetSelectionProperties();
   void SetSelectionProperties(SelectionProperties& aProps);
   void WillInitEagerly() { mSelectionRestoreEagerInit = true; }
   bool HasNeverInitializedBefore() const { return !mEverInited; }
   // Sync up our selection properties with our editor prior to being destroyed.
   // This will invoke UnbindFromFrame() to ensure that we grab whatever
   // selection state may be at the moment.
   void SyncUpSelectionPropertiesBeforeDestruction();
 
   // Get the selection range start and end points in our text.
-  void GetSelectionRange(uint32_t* aSelectionStart, uint32_t* aSelectionEnd,
+  void GetSelectionRange(int32_t* aSelectionStart, int32_t* aSelectionEnd,
                          mozilla::ErrorResult& aRv);
 
   // Get the selection direction
   nsITextControlFrame::SelectionDirection
     GetSelectionDirection(mozilla::ErrorResult& aRv);
 
   // Set the selection range (start, end, direction).  aEnd is allowed to be
   // smaller than aStart; in that case aStart will be reset to the same value as
@@ -290,25 +290,25 @@ public:
   // but with the start/end already coerced to zero if null (and without the
   // special infinity value), and the direction already converted to a
   // SelectionDirection.
   //
   // If we have a frame, this method will scroll the selection into view.
   //
   // XXXbz This should really take uint32_t, but none of our guts (either the
   // frame or our cached selection state) work with uint32_t at the moment...
-  void SetSelectionRange(uint32_t aStart, uint32_t aEnd,
+  void SetSelectionRange(int32_t aStart, int32_t aEnd,
                          nsITextControlFrame::SelectionDirection aDirection,
                          mozilla::ErrorResult& aRv);
 
   // Set the selection range, but with an optional string for the direction.
   // This will convert aDirection to an nsITextControlFrame::SelectionDirection
   // and then call our other SetSelectionRange overload.
-  void SetSelectionRange(uint32_t aSelectionStart,
-                         uint32_t aSelectionEnd,
+  void SetSelectionRange(int32_t aSelectionStart,
+                         int32_t aSelectionEnd,
                          const mozilla::dom::Optional<nsAString>& aDirection,
                          mozilla::ErrorResult& aRv);
 
   // Set the selection start.  This basically implements the
   // https://html.spec.whatwg.org/multipage/forms.html#dom-textarea/input-selectionstart
   // setter.
   void SetSelectionStart(const mozilla::dom::Nullable<uint32_t>& aStart,
                          mozilla::ErrorResult& aRv);
@@ -333,21 +333,18 @@ public:
 
   // Set the range text.  This basically implements
   // https://html.spec.whatwg.org/multipage/forms.html#dom-textarea/input-setrangetext
   void SetRangeText(const nsAString& aReplacement, mozilla::ErrorResult& aRv);
   // The last two arguments are -1 if we don't know our selection range;
   // otherwise they're the start and end of our selection range.
   void SetRangeText(const nsAString& aReplacement, uint32_t aStart,
                     uint32_t aEnd, mozilla::dom::SelectionMode aSelectMode,
-                    mozilla::ErrorResult& aRv,
-                    const mozilla::Maybe<uint32_t>& aSelectionStart =
-                      mozilla::Nothing(),
-                    const mozilla::Maybe<uint32_t>& aSelectionEnd =
-                      mozilla::Nothing());
+                    mozilla::ErrorResult& aRv, int32_t aSelectionStart = -1,
+                    int32_t aSelectionEnd = -1);
 
   void UpdateEditableState(bool aNotify) {
     if (mRootNode) {
       mRootNode->UpdateEditableState(aNotify);
     }
   }
 
 private:
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -626,18 +626,18 @@ TextEditRules::WillInsertText(EditAction
   // If we're exceeding the maxlength when composing IME, we need to clean up
   // the composing text, so we shouldn't return early.
   if (truncated && outString->IsEmpty() &&
       aAction != EditAction::insertIMEText) {
     *aCancel = true;
     return NS_OK;
   }
 
-  uint32_t start = 0;
-  uint32_t end = 0;
+  int32_t start = 0;
+  int32_t end = 0;
 
   // handle password field docs
   if (IsPasswordEditor()) {
     NS_ENSURE_STATE(mTextEditor);
     nsContentUtils::GetSelectionInTextControl(aSelection,
                                               mTextEditor->GetRoot(),
                                               start, end);
   }
@@ -850,34 +850,34 @@ TextEditRules::WillDeleteSelection(Selec
 
   if (IsPasswordEditor()) {
     NS_ENSURE_STATE(mTextEditor);
     nsresult rv =
       mTextEditor->ExtendSelectionForDelete(aSelection, &aCollapsedAction);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // manage the password buffer
-    uint32_t start, end;
+    int32_t start, end;
     nsContentUtils::GetSelectionInTextControl(aSelection,
                                               mTextEditor->GetRoot(),
                                               start, end);
 
     if (LookAndFeel::GetEchoPassword()) {
       HideLastPWInput();
       mLastStart = start;
       mLastLength = 0;
       if (mTimer) {
         mTimer->Cancel();
       }
     }
 
     // Collapsed selection.
     if (end == start) {
       // Deleting back.
-      if (nsIEditor::ePrevious == aCollapsedAction && start > 0) {
+      if (nsIEditor::ePrevious == aCollapsedAction && 0<start) {
         mPasswordText.Cut(start-1, 1);
       }
       // Deleting forward.
       else if (nsIEditor::eNext == aCollapsedAction) {
         mPasswordText.Cut(start, 1);
       }
       // Otherwise nothing to do for this collapsed selection.
     }
@@ -1272,25 +1272,25 @@ TextEditRules::TruncateInsertionIfNeeded
     // If (resultingDocLength) + (length of input) > max,
     //    set aOutString to subset of inString so length = max
     int32_t docLength;
     nsresult rv = mTextEditor->GetTextLength(&docLength);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
-    uint32_t start, end;
+    int32_t start, end;
     nsContentUtils::GetSelectionInTextControl(aSelection,
                                               mTextEditor->GetRoot(),
                                               start, end);
 
     TextComposition* composition = mTextEditor->GetComposition();
-    uint32_t oldCompStrLength = composition ? composition->String().Length() : 0;
+    int32_t oldCompStrLength = composition ? composition->String().Length() : 0;
 
-    const uint32_t selectionLength = end - start;
+    const int32_t selectionLength = end - start;
     const int32_t resultingDocLength = docLength - selectionLength - oldCompStrLength;
     if (resultingDocLength >= aMaxLength) {
       // This call is guaranteed to reduce the capacity of the string, so it
       // cannot cause an OOM.
       aOutString->Truncate();
       if (aTruncated) {
         *aTruncated = true;
       }
@@ -1322,17 +1322,17 @@ TextEditRules::TruncateInsertionIfNeeded
 
 void
 TextEditRules::ResetIMETextPWBuf()
 {
   mPasswordIMEText.Truncate();
 }
 
 void
-TextEditRules::RemoveIMETextFromPWBuf(uint32_t& aStart,
+TextEditRules::RemoveIMETextFromPWBuf(int32_t& aStart,
                                       nsAString* aIMEString)
 {
   MOZ_ASSERT(aIMEString);
 
   // initialize PasswordIME
   if (mPasswordIMEText.IsEmpty()) {
     mPasswordIMEIndex = aStart;
   } else {
@@ -1366,26 +1366,24 @@ TextEditRules::HideLastPWInput()
   }
 
   nsAutoString hiddenText;
   FillBufWithPWChars(&hiddenText, mLastLength);
 
   NS_ENSURE_STATE(mTextEditor);
   RefPtr<Selection> selection = mTextEditor->GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
-  uint32_t start, end;
+  int32_t start, end;
   nsContentUtils::GetSelectionInTextControl(selection, mTextEditor->GetRoot(),
                                             start, end);
 
   nsCOMPtr<nsINode> selNode = GetTextNode(selection);
   NS_ENSURE_TRUE(selNode, NS_OK);
 
   selNode->GetAsText()->ReplaceData(mLastStart, mLastLength, hiddenText);
-  // XXXbz Selection::Collapse/Extend take int32_t, but there are tons of
-  // callsites... Converting all that is a battle for another day.
   selection->Collapse(selNode, start);
   if (start != end) {
     selection->Extend(selNode, end);
   }
   return NS_OK;
 }
 
 // static
--- a/editor/libeditor/TextEditRules.h
+++ b/editor/libeditor/TextEditRules.h
@@ -194,17 +194,17 @@ protected:
                                      const nsAString* aInString,
                                      nsAString* aOutString,
                                      int32_t aMaxLength,
                                      bool* aTruncated);
 
   /**
    * Remove IME composition text from password buffer.
    */
-  void RemoveIMETextFromPWBuf(uint32_t& aStart, nsAString* aIMEString);
+  void RemoveIMETextFromPWBuf(int32_t& aStart, nsAString* aIMEString);
 
   nsresult CreateMozBR(nsIDOMNode* inParent, int32_t inOffset,
                        nsIDOMNode** outBRNode = nullptr);
 
   void UndefineCaretBidiLevel(Selection* aSelection);
 
   nsresult CheckBidiLevelForDeletion(Selection* aSelection,
                                      nsIDOMNode* aSelNode,
--- a/layout/forms/nsITextControlFrame.h
+++ b/layout/forms/nsITextControlFrame.h
@@ -20,18 +20,18 @@ public:
   enum SelectionDirection {
     eNone,
     eForward,
     eBackward
   };
 
   NS_IMETHOD    GetEditor(nsIEditor **aEditor) = 0;
 
-  NS_IMETHOD    SetSelectionRange(uint32_t aSelectionStart,
-                                  uint32_t aSelectionEnd,
+  NS_IMETHOD    SetSelectionRange(int32_t aSelectionStart,
+                                  int32_t aSelectionEnd,
                                   SelectionDirection aDirection = eNone) = 0;
 
   NS_IMETHOD    GetOwnedSelectionController(nsISelectionController** aSelCon) = 0;
   virtual nsFrameSelection* GetOwnedFrameSelection() = 0;
 
   virtual nsresult GetPhonetic(nsAString& aPhonetic) = 0;
 
   /**
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -301,17 +301,17 @@ nsTextControlFrame::EnsureEditorInitiali
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_STATE(weakFrame.IsAlive());
 
     // Set mEditorHasBeenInitialized so that subsequent calls will use the
     // editor.
     mEditorHasBeenInitialized = true;
 
     if (weakFrame.IsAlive()) {
-      uint32_t position = 0;
+      int32_t position = 0;
 
       // Set the selection to the end of the text field (bug 1287655),
       // but only if the contents has changed (bug 1337392).
       if (txtCtrl->ValueChanged()) {
         nsAutoString val;
         txtCtrl->GetTextEditorValue(val, true);
         position = val.Length();
       }
@@ -739,35 +739,30 @@ nsTextControlFrame::GetEditor(nsIEditor 
   NS_ASSERTION(txtCtrl, "Content not a text control element");
   *aEditor = txtCtrl->GetTextEditor();
   NS_IF_ADDREF(*aEditor);
   return NS_OK;
 }
 
 nsresult
 nsTextControlFrame::SetSelectionInternal(nsIDOMNode *aStartNode,
-                                         uint32_t aStartOffset,
+                                         int32_t aStartOffset,
                                          nsIDOMNode *aEndNode,
-                                         uint32_t aEndOffset,
+                                         int32_t aEndOffset,
                                          nsITextControlFrame::SelectionDirection aDirection)
 {
   // Create a new range to represent the new selection.
   // Note that we use a new range to avoid having to do
   // isIncreasing checks to avoid possible errors.
 
   RefPtr<nsRange> range = new nsRange(mContent);
   // Be careful to use internal nsRange methods which do not check to make sure
   // we have access to the node.
   nsCOMPtr<nsINode> start = do_QueryInterface(aStartNode);
   nsCOMPtr<nsINode> end = do_QueryInterface(aEndNode);
-  // XXXbz nsRange::Set takes int32_t (and ranges generally work on int32_t),
-  // but we're passing uint32_t.  The good news is that at this point our
-  // endpoints should really be within our length, so not really that big.  And
-  // if they _are_ that big, Set() will simply error out, which is not too bad
-  // for a case we don't expect to happen.
   nsresult rv = range->Set(start, aStartOffset, end, aEndOffset);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get the selection, clear it and add the new range to it!
   nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
   NS_ASSERTION(txtCtrl, "Content not a text control element");
   nsISelectionController* selCon = txtCtrl->GetSelectionController();
   NS_ENSURE_TRUE(selCon, NS_ERROR_FAILURE);
@@ -861,26 +856,26 @@ nsTextControlFrame::SelectAllOrCollapseT
   rv = SetSelectionInternal(rootNode, aSelect ? 0 : numChildren,
                             rootNode, numChildren);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return ScrollSelectionIntoView();
 }
 
 nsresult
-nsTextControlFrame::SetSelectionEndPoints(uint32_t aSelStart, uint32_t aSelEnd,
+nsTextControlFrame::SetSelectionEndPoints(int32_t aSelStart, int32_t aSelEnd,
                                           nsITextControlFrame::SelectionDirection aDirection)
 {
   NS_ASSERTION(aSelStart <= aSelEnd, "Invalid selection offsets!");
 
   if (aSelStart > aSelEnd)
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIDOMNode> startNode, endNode;
-  uint32_t startOffset, endOffset;
+  int32_t startOffset, endOffset;
 
   // Calculate the selection start point.
 
   nsresult rv = OffsetToDOMPoint(aSelStart, getter_AddRefs(startNode), &startOffset);
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (aSelStart == aSelEnd) {
@@ -896,17 +891,17 @@ nsTextControlFrame::SetSelectionEndPoint
 
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return SetSelectionInternal(startNode, startOffset, endNode, endOffset, aDirection);
 }
 
 NS_IMETHODIMP
-nsTextControlFrame::SetSelectionRange(uint32_t aSelStart, uint32_t aSelEnd,
+nsTextControlFrame::SetSelectionRange(int32_t aSelStart, int32_t aSelEnd,
                                       nsITextControlFrame::SelectionDirection aDirection)
 {
   nsresult rv = EnsureEditorInitialized();
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (aSelStart > aSelEnd) {
     // Simulate what we'd see SetSelectionStart() was called, followed
     // by a SetSelectionEnd().
@@ -914,19 +909,19 @@ nsTextControlFrame::SetSelectionRange(ui
     aSelStart   = aSelEnd;
   }
 
   return SetSelectionEndPoints(aSelStart, aSelEnd, aDirection);
 }
 
 
 nsresult
-nsTextControlFrame::OffsetToDOMPoint(uint32_t aOffset,
+nsTextControlFrame::OffsetToDOMPoint(int32_t aOffset,
                                      nsIDOMNode** aResult,
-                                     uint32_t* aPosition)
+                                     int32_t* aPosition)
 {
   NS_ENSURE_ARG_POINTER(aResult && aPosition);
 
   *aResult = nullptr;
   *aPosition = 0;
 
   nsCOMPtr<nsIDOMElement> rootElement;
   nsresult rv = GetRootNodeAndInitializeEditor(getter_AddRefs(rootElement));
@@ -948,31 +943,31 @@ nsTextControlFrame::OffsetToDOMPoint(uin
 
   NS_ASSERTION(length <= 2, "We should have one text node and one mozBR at most");
 
   nsCOMPtr<nsIDOMNode> firstNode;
   rv = nodeList->Item(0, getter_AddRefs(firstNode));
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIDOMText> textNode = do_QueryInterface(firstNode);
 
-  if (length == 0) {
+  if (length == 0 || aOffset < 0) {
     NS_IF_ADDREF(*aResult = rootNode);
     *aPosition = 0;
   } else if (textNode) {
     uint32_t textLength = 0;
     textNode->GetLength(&textLength);
-    if (length == 2 && aOffset == textLength) {
+    if (length == 2 && uint32_t(aOffset) == textLength) {
       // If we're at the end of the text node and we have a trailing BR node,
       // set the selection on the BR node.
       NS_IF_ADDREF(*aResult = rootNode);
       *aPosition = 1;
     } else {
       // Otherwise, set the selection on the textnode itself.
       NS_IF_ADDREF(*aResult = firstNode);
-      *aPosition = std::min(aOffset, textLength);
+      *aPosition = std::min(aOffset, int32_t(textLength));
     }
   } else {
     NS_IF_ADDREF(*aResult = rootNode);
     *aPosition = 0;
   }
 
   return NS_OK;
 }
--- a/layout/forms/nsTextControlFrame.h
+++ b/layout/forms/nsTextControlFrame.h
@@ -137,18 +137,18 @@ public:
   virtual void SetFocus(bool aOn , bool aRepaint) override;
   virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) override;
 
 //==== END NSIFORMCONTROLFRAME
 
 //==== NSITEXTCONTROLFRAME
 
   NS_IMETHOD    GetEditor(nsIEditor **aEditor) override;
-  NS_IMETHOD    SetSelectionRange(uint32_t aSelectionStart,
-                                  uint32_t aSelectionEnd,
+  NS_IMETHOD    SetSelectionRange(int32_t aSelectionStart,
+                                  int32_t aSelectionEnd,
                                   SelectionDirection aDirection = eNone) override;
   NS_IMETHOD    GetOwnedSelectionController(nsISelectionController** aSelCon) override;
   virtual nsFrameSelection* GetOwnedFrameSelection() override;
 
   nsresult GetPhonetic(nsAString& aPhonetic) override;
 
   /**
    * Ensure mEditor is initialized with the proper flags and the default value.
@@ -260,17 +260,17 @@ protected:
     void Revoke() {
       mFrame = nullptr;
     }
 
   private:
     nsTextControlFrame* mFrame;
   };
 
-  nsresult OffsetToDOMPoint(uint32_t aOffset, nsIDOMNode** aResult, uint32_t* aPosition);
+  nsresult OffsetToDOMPoint(int32_t aOffset, nsIDOMNode** aResult, int32_t* aPosition);
 
   /**
    * Update the textnode under our anonymous div to show the new
    * value. This should only be called when we have no editor yet.
    * @throws NS_ERROR_UNEXPECTED if the div has no text content
    */
   nsresult UpdateValueDisplay(bool aNotify,
                               bool aBeforeEditorInit = false,
@@ -303,21 +303,21 @@ protected:
   mozilla::LogicalSize CalcIntrinsicSize(nsRenderingContext* aRenderingContext,
                                          mozilla::WritingMode aWM,
                                          float aFontSizeInflation) const;
 
   nsresult ScrollSelectionIntoView() override;
 
 private:
   //helper methods
-  nsresult SetSelectionInternal(nsIDOMNode *aStartNode, uint32_t aStartOffset,
-                                nsIDOMNode *aEndNode, uint32_t aEndOffset,
+  nsresult SetSelectionInternal(nsIDOMNode *aStartNode, int32_t aStartOffset,
+                                nsIDOMNode *aEndNode, int32_t aEndOffset,
                                 SelectionDirection aDirection = eNone);
   nsresult SelectAllOrCollapseToEndOfText(bool aSelect);
-  nsresult SetSelectionEndPoints(uint32_t aSelStart, uint32_t aSelEnd,
+  nsresult SetSelectionEndPoints(int32_t aSelStart, int32_t aSelEnd,
                                  SelectionDirection aDirection = eNone);
 
   /**
    * Return the root DOM element, and implicitly initialize the editor if
    * needed.
    *
    * XXXbz This function is slow.  Very slow.  Consider using
    * EnsureEditorInitialized() if you need that, and
--- a/testing/web-platform/meta/html/semantics/forms/textfieldselection/textfieldselection-setSelectionRange.html.ini
+++ b/testing/web-platform/meta/html/semantics/forms/textfieldselection/textfieldselection-setSelectionRange.html.ini
@@ -18,8 +18,15 @@
   [textarea direction of setSelectionRange(0,1,"hoge")]
     expected: FAIL
 
   [textarea direction of setSelectionRange(0,1,"BACKWARD")]
     expected: FAIL
 
   [textarea direction of setSelectionRange(0,1)]
     expected: FAIL
+
+  [input setSelectionRange(1,-1)]
+    expected: FAIL
+
+  [input setSelectionRange(-1,1)]
+    expected: FAIL
+
--- a/testing/web-platform/tests/html/semantics/forms/textfieldselection/selection-start-end.html
+++ b/testing/web-platform/tests/html/semantics/forms/textfieldselection/selection-start-end.html
@@ -22,40 +22,21 @@
 
     el.id = "textarea" + (append ? "-appended" : "-not-appended");
     if (append) {
       document.body.appendChild(el);
     }
     return el;
   };
 
-  function createPrefocusedInputElement(value, append) {
-    var el = createInputElement(value, append);
-    el.focus();
-    el.blur();
-    return el;
-  }
-
-  function createPrefocusedTextareaElement(value, append) {
-    var el = createTextareaElement(value, append);
-    el.focus();
-    el.blur();
-    return el;
-  }
-
   function createTestElements(value) {
     return [ createInputElement(value, true),
              createInputElement(value, false),
-             createPrefocusedInputElement(value, true),
-             createPrefocusedInputElement(value, false),
              createTextareaElement(value, true),
-             createTextareaElement(value, false),
-             createPrefocusedTextareaElement(value, true),
-             createPrefocusedTextareaElement(value, false),
-           ];
+             createTextareaElement(value, false) ];
   }
 
   const testValue = "abcdefghij";
 
   test(function() {
     assert_equals(testValue.length, 10);
   }, "Sanity check for testValue length; if this fails, variou absolute offsets in the test below need to be adjusted to be less than testValue.length");
 
@@ -106,43 +87,9 @@
                     `Initial .value set on ${el.id} should set selectionEnd to end of value`);
       el.selectionStart = 8;
       el.selectionEnd = 5;
       assert_equals(el.selectionStart, 5, `selectionStart on ${el.id}`);
       assert_equals(el.selectionEnd, 5, `selectionEnd on ${el.id}`);
       el.remove();
     }
   }, "Setting selectionEnd to a value smaller than selectionStart should decrease selectionStart");
-
-  test(function() {
-    for (let el of createTestElements(testValue)) {
-      el.selectionStart = 0;
-      assert_equals(el.selectionStart, 0, `We just set it on ${el.id}`);
-      el.selectionStart = -1;
-      assert_equals(el.selectionStart, testValue.length,
-                    `selectionStart setter on ${el.id} should convert -1 to 2^32-1`);
-      el.selectionStart = Math.pow(2, 32);
-      assert_equals(el.selectionStart, 0,
-                    `selectionStart setter on ${el.id} should convert 2^32 to 0`);
-      el.selectionStart = Math.pow(2, 32) - 1;
-      assert_equals(el.selectionStart, testValue.length,
-                    `selectionStart setter on ${el.id} should leave 2^32-1 as-is`);
-      el.remove();
-    }
-  }, "selectionStart edge-case values");
-
-  test(function() {
-    for (let el of createTestElements(testValue)) {
-      el.selectionEnd = 0;
-      assert_equals(el.selectionEnd, 0, `We just set it on ${el.id}`);
-      el.selectionEnd = -1;
-      assert_equals(el.selectionEnd, testValue.length,
-                    `selectionEnd setter on ${el.id} should convert -1 to 2^32-1`);
-      el.selectionEnd = Math.pow(2, 32);
-      assert_equals(el.selectionEnd, 0,
-                    `selectionEnd setter on ${el.id} should convert 2^32 to 0`);
-      el.selectionEnd = Math.pow(2, 32) - 1;
-      assert_equals(el.selectionEnd, testValue.length,
-                    `selectionEnd setter on ${el.id} should leave 2^32-1 as-is`);
-      el.remove();
-    }
-  }, "selectionEnd edge-case values");
 </script>
--- a/testing/web-platform/tests/html/semantics/forms/textfieldselection/textfieldselection-setSelectionRange.html
+++ b/testing/web-platform/tests/html/semantics/forms/textfieldselection/textfieldselection-setSelectionRange.html
@@ -133,32 +133,16 @@ test(function() {
     assert_equals(input.selectionEnd, 1, "element.selectionEnd should be 1");
   },'input setSelectionRange(null,1)');
 
   test(function() {
     input.setSelectionRange(undefined,1);
     assert_equals(input.selectionStart, 0, "element.selectionStart should be 0");
     assert_equals(input.selectionEnd, 1, "element.selectionEnd should be 1");
   },'input setSelectionRange(undefined,1)');
-
-  test(function() {
-    input.setSelectionRange(Math.pow(2,32) - 2, Math.pow(2,32) - 1);
-    assert_equals(input.selectionStart, input.value.length,
-                 "element.selectionStart should be value.length");
-    assert_equals(input.selectionEnd, input.value.length,
-                  "element.selectionEnd should be value.length");
-  }, 'input setSelectionRange(Math.pow(2,32) - 2, Math.pow(2,32) - 1)');
-
-  test(function() {
-    input.setSelectionRange(Math.pow(2,31), Math.pow(2,32) - 1);
-    assert_equals(input.selectionStart, input.value.length,
-                 "element.selectionStart should be value.length");
-    assert_equals(input.selectionEnd, input.value.length,
-                  "element.selectionEnd should be value.length");
-  }, 'input setSelectionRange(Math.pow(2,31), Math.pow(2,32) - 1)');
 },"test of input.setSelectionRange");
 
 async_test(function() {
   var q = false;
   var input = document.getElementById("a");
   input.addEventListener("select", this.step_func_done(function(e) {
     assert_true(q, "event should be queued");
     assert_true(e.isTrusted, "event is trusted");
@@ -268,32 +252,16 @@ test(function() {
     assert_equals(textarea.selectionEnd, 1, "element.selectionStart should be 1");
   },'textarea setSelectionRange(null,1)');
 
   test(function() {
     textarea.setSelectionRange(undefined,1);
     assert_equals(textarea.selectionStart, 0, "element.selectionStart should be 0");
     assert_equals(textarea.selectionEnd, 1, "element.selectionStart should be 1");
   },'textarea setSelectionRange(undefined,1)');
-
-  test(function() {
-    textarea.setSelectionRange(Math.pow(2,32) - 2, Math.pow(2,32) - 1);
-    assert_equals(textarea.selectionStart, textarea.value.length,
-                 "element.selectionStart should be value.length");
-    assert_equals(textarea.selectionEnd, textarea.value.length,
-                  "element.selectionEnd should be value.length");
-  }, 'textarea setSelectionRange(Math.pow(2,32) - 2, Math.pow(2,32) - 1)');
-
-  test(function() {
-    textarea.setSelectionRange(Math.pow(2,31), Math.pow(2,32) - 1);
-    assert_equals(textarea.selectionStart, textarea.value.length,
-                 "element.selectionStart should be value.length");
-    assert_equals(textarea.selectionEnd, textarea.value.length,
-                  "element.selectionEnd should be value.length");
-  }, 'textarea setSelectionRange(Math.pow(2,31), Math.pow(2,32) - 1)');
 },"test of textarea.setSelectionRange");
 
 async_test(function() {
   var q = false;
   var textarea = document.getElementById("b");
   textarea.addEventListener("select", this.step_func_done(function(e) {
     assert_true(q, "event should be queued");
     assert_true(e.isTrusted, "event is trusted");