[HtmlUnit] SVN: [14431] trunk/htmlunit/src

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[HtmlUnit] SVN: [14431] trunk/htmlunit/src

rbri
Revision: 14431
          http://sourceforge.net/p/htmlunit/code/14431
Author:   rbri
Date:     2017-05-10 20:13:17 +0000 (Wed, 10 May 2017)
Log Message:
-----------
FF52/CHROME fixed

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlNumberInputTest.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-05-10 19:31:34 UTC (rev 14430)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-05-10 20:13:17 UTC (rev 14431)
@@ -963,9 +963,9 @@
     @BrowserFeature(CHROME)
     JS_INPUT_IGNORE_NEGATIVE_SELECTION_START,
 
-    /** Chrome throws an error if using selectionStart/selectionEnd. */
-    @BrowserFeature(CHROME)
-    JS_INPUT_NUMBER_NO_SELECTION,
+    /** Chrome/FF returns null for selectionStart/selectionEnd. */
+    @BrowserFeature({CHROME, FF52})
+    JS_INPUT_NUMBER_SELECTION_START_END_NULL,
 
     /** Setting the type property of an input converts the type to lowercase. */
     @BrowserFeature(IE)

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java 2017-05-10 19:31:34 UTC (rev 14430)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java 2017-05-10 20:13:17 UTC (rev 14431)
@@ -20,7 +20,7 @@
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_FILE_VALUE_FAKEPATH;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_FILE_VALUE_NO_PATH;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ALIGN_FOR_INPUT_IGNORES_VALUES;
-import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_INPUT_NUMBER_NO_SELECTION;
+import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_INPUT_NUMBER_SELECTION_START_END_NULL;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_INPUT_SET_TYPE_LOWERCASE;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_INPUT_SET_VALUE_DATE_SUPPORTED;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_SELECT_FILE_THROWS;
@@ -318,10 +318,9 @@
     public Object getSelectionStart() {
         final DomNode dom = getDomNodeOrDie();
         if (dom instanceof SelectableTextInput) {
-            if ("number".equalsIgnoreCase(getType()) && getBrowserVersion().hasFeature(JS_INPUT_NUMBER_NO_SELECTION)) {
-                throw Context.reportRuntimeError("Failed to read the 'selectionStart' property"
-                        + "from 'HTMLInputElement': "
-                        + "The input element's type ('number') does not support selection.");
+            if ("number".equalsIgnoreCase(getType())
+                    && getBrowserVersion().hasFeature(JS_INPUT_NUMBER_SELECTION_START_END_NULL)) {
+                return null;
             }
 
             return ((SelectableTextInput) dom).getSelectionStart();
@@ -342,7 +341,8 @@
     public void setSelectionStart(final int start) {
         final DomNode dom = getDomNodeOrDie();
         if (dom instanceof SelectableTextInput) {
-            if ("number".equalsIgnoreCase(getType()) && getBrowserVersion().hasFeature(JS_INPUT_NUMBER_NO_SELECTION)) {
+            if ("number".equalsIgnoreCase(getType())
+                    && getBrowserVersion().hasFeature(JS_INPUT_NUMBER_SELECTION_START_END_NULL)) {
                 throw Context.reportRuntimeError("Failed to set the 'selectionStart' property"
                         + "from 'HTMLInputElement': "
                         + "The input element's type ('number') does not support selection.");
@@ -364,10 +364,9 @@
     public Object getSelectionEnd() {
         final DomNode dom = getDomNodeOrDie();
         if (dom instanceof SelectableTextInput) {
-            if ("number".equalsIgnoreCase(getType()) && getBrowserVersion().hasFeature(JS_INPUT_NUMBER_NO_SELECTION)) {
-                throw Context.reportRuntimeError("Failed to read the 'selectionEnd' property"
-                        + "from 'HTMLInputElement': "
-                        + "The input element's type ('number') does not support selection.");
+            if ("number".equalsIgnoreCase(getType())
+                    && getBrowserVersion().hasFeature(JS_INPUT_NUMBER_SELECTION_START_END_NULL)) {
+                return null;
             }
 
             return ((SelectableTextInput) dom).getSelectionEnd();
@@ -388,7 +387,8 @@
     public void setSelectionEnd(final int end) {
         final DomNode dom = getDomNodeOrDie();
         if (dom instanceof SelectableTextInput) {
-            if ("number".equalsIgnoreCase(getType()) && getBrowserVersion().hasFeature(JS_INPUT_NUMBER_NO_SELECTION)) {
+            if ("number".equalsIgnoreCase(getType())
+                    && getBrowserVersion().hasFeature(JS_INPUT_NUMBER_SELECTION_START_END_NULL)) {
                 throw Context.reportRuntimeError("Failed to set the 'selectionEnd' property"
                         + "from 'HTMLInputElement': "
                         + "The input element's type ('number') does not support selection.");

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlNumberInputTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlNumberInputTest.java 2017-05-10 19:31:34 UTC (rev 14430)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlNumberInputTest.java 2017-05-10 20:13:17 UTC (rev 14431)
@@ -14,8 +14,6 @@
  */
 package com.gargoylesoftware.htmlunit.html;
 
-import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.CHROME;
-import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF52;
 import static org.junit.Assert.fail;
 
 import java.util.Collections;
@@ -30,7 +28,6 @@
 
 import com.gargoylesoftware.htmlunit.BrowserRunner;
 import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts;
-import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented;
 import com.gargoylesoftware.htmlunit.WebDriverTestCase;
 
 /**
@@ -500,7 +497,6 @@
      */
     @Test
     @Alerts("0")
-    @NotYetImplemented(CHROME)
     public void selection() throws Exception {
         final String html =
               "<html><head>\n"
@@ -533,7 +529,6 @@
             FF52 = {"null,null", "null,null", "exception",
                         "null,null", "exception", "null,null"},
             IE = {"0,0", "0,0", "3,3", "3,10"})
-    @NotYetImplemented({CHROME, FF52})
     public void selection2_1() throws Exception {
         selection2(3, 10);
     }
@@ -548,7 +543,6 @@
             FF52 = {"null,null", "null,null", "exception",
                         "null,null", "exception", "null,null"},
             IE = {"0,0", "0,0", "0,0", "0,11"})
-    @NotYetImplemented({CHROME, FF52})
     public void selection2_2() throws Exception {
         selection2(-3, 15);
     }
@@ -563,7 +557,6 @@
             FF52 = {"null,null", "null,null", "exception",
                         "null,null", "exception", "null,null"},
             IE = {"0,0", "0,0", "10,10", "5,5"})
-    @NotYetImplemented({CHROME, FF52})
     public void selection2_3() throws Exception {
         selection2(10, 5);
     }
@@ -611,7 +604,6 @@
             CHROME = {"null,null", "exception"},
             FF52 = {"null,null", "exception"},
             IE = {"0,0", "4,5", "0,0", "0,0", "0,0"})
-    @NotYetImplemented({CHROME, FF52})
     public void selectionOnUpdate() throws Exception {
         final String html = "<html>\n"
             + "<body>\n"


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop