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

rbri--- via HtmlUnit-develop <[email protected]>
Newsgroups gmane.comp.java.htmlunit.devel
Message-ID <[email protected]>
Revision: 15413
          http://sourceforge.net/p/htmlunit/code/15413
Author:   rbri
Date:     2018-06-29 14:01:31 +0000 (Fri, 29 Jun 2018)
Log Message:
-----------
ff60 support (wip)

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/NativeFunctionToStringFunction.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementChildNodesTest.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElementTest.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java	2018-06-29 13:28:37 UTC (rev 15412)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java	2018-06-29 14:01:31 UTC (rev 15413)
@@ -1093,6 +1093,10 @@
     @BrowserFeature(IE)
     JS_NATIVE_FUNCTION_TOSTRING_NEW_LINE,
 
+    /** Indicates if the String representation of a native function has a newline for empty parameter list. */
+    @BrowserFeature(FF60)
+    JS_NATIVE_FUNCTION_TOSTRING_NL,
+
     /** Navigator.doNotTrack returns unspecified if not set. */
     @BrowserFeature(FF)
     JS_NAVIGATOR_DO_NOT_TRACK_UNSPECIFIED,

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/NativeFunctionToStringFunction.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/NativeFunctionToStringFunction.java	2018-06-29 13:28:37 UTC (rev 15412)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/NativeFunctionToStringFunction.java	2018-06-29 14:01:31 UTC (rev 15413)
@@ -16,6 +16,7 @@
 
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_NATIVE_FUNCTION_TOSTRING_COMPACT;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_NATIVE_FUNCTION_TOSTRING_NEW_LINE;
+import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_NATIVE_FUNCTION_TOSTRING_NL;
 
 import com.gargoylesoftware.htmlunit.BrowserVersion;
 
@@ -55,6 +56,13 @@
             final Function newToString = new NativeFunctionToStringFunctionChrome(originalToString);
             ScriptableObject.putProperty(fnPrototype, "toString", newToString);
         }
+        else if (browserVersion.hasFeature(JS_NATIVE_FUNCTION_TOSTRING_NL)) {
+            final ScriptableObject fnPrototype =
+                    (ScriptableObject) ScriptableObject.getClassPrototype(window, "Function");
+            final Function originalToString = (Function) ScriptableObject.getProperty(fnPrototype, "toString");
+            final Function newToString = new NativeFunctionToStringFunctionFF(originalToString);
+            ScriptableObject.putProperty(fnPrototype, "toString", newToString);
+        }
     }
 
     NativeFunctionToStringFunction(final Function wrapped) {
@@ -92,7 +100,22 @@
                 final String functionName = ((BaseFunction) thisObj).getFunctionName();
                 return "function " + functionName + "() { [native code] }";
             }
-            return s;
+            return s.replace("function anonymous() {", "function anonymous(\n) {");
         }
     }
+    static class NativeFunctionToStringFunctionFF extends FunctionWrapper {
+
+        NativeFunctionToStringFunctionFF(final Function wrapped) {
+            super(wrapped);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) {
+            final String s = (String) super.call(cx, scope, thisObj, args);
+            return s.replace("function anonymous() {", "function anonymous(\n) {");
+        }
+    }
 }

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementChildNodesTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementChildNodesTest.java	2018-06-29 13:28:37 UTC (rev 15412)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementChildNodesTest.java	2018-06-29 14:01:31 UTC (rev 15413)
@@ -14,11 +14,14 @@
  */
 package com.gargoylesoftware.htmlunit.general;
 
+import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF60;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import com.gargoylesoftware.htmlunit.BrowserRunner;
 import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts;
+import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented;
 import com.gargoylesoftware.htmlunit.WebDriverTestCase;
 
 /**
@@ -415,6 +418,7 @@
     @Test
     @Alerts(DEFAULT = {"3", "2", "2", "3", "2", "2"},
             FF60 = {"1", "0", "1", "1", "0", "1"})
+    @NotYetImplemented(FF60)
     public void dialog() throws Exception {
         loadPageWithAlerts2(test("dialog"));
     }

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElementTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElementTest.java	2018-06-29 13:28:37 UTC (rev 15412)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElementTest.java	2018-06-29 14:01:31 UTC (rev 15413)
@@ -267,7 +267,7 @@
             + "</form>\n"
             + "</body></html>";
 
-        loadPageWithAlerts2(html, 7777777);
+        loadPageWithAlerts2(html, 2 * DEFAULT_WAIT_TIME);
     }
 
     /**


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.