From: <rb...@us...> - 2017-11-15 21:29:56
|
Revision: 14960 http://sourceforge.net/p/htmlunit/code/14960 Author: rbri Date: 2017-11-15 21:29:53 +0000 (Wed, 15 Nov 2017) Log Message: ----------- URL constuctor and origin property added. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URL.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-11-15 21:03:02 UTC (rev 14959) +++ trunk/htmlunit/src/changes/changes.xml 2017-11-15 21:29:53 UTC (rev 14960) @@ -10,6 +10,9 @@ <release version="2.29" date="xx, 2017" description=""> </release> <release version="2.28" date="November 12, 2017" description="Bugfixes, Chrome 62, improved Promise"> + <action type="add" dev="rbri"> + JavaScript: URL constuctor and origin property added. + </action> <action type="fix" dev="rbri" issue="1927"> The link tag now supports the onLoad and the onError handler. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URL.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URL.java 2017-11-15 21:03:02 UTC (rev 14959) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URL.java 2017-11-15 21:29:53 UTC (rev 14960) @@ -18,12 +18,22 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; +import java.net.MalformedURLException; + +import org.apache.commons.lang3.StringUtils; + import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxStaticFunction; import com.gargoylesoftware.htmlunit.javascript.host.file.File; +import com.gargoylesoftware.htmlunit.util.UrlUtils; +import net.sourceforge.htmlunit.corejs.javascript.Context; +import net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime; +import net.sourceforge.htmlunit.corejs.javascript.Undefined; + /** * A JavaScript object for {@code URL}. * @@ -33,14 +43,44 @@ @JsxClass public class URL extends SimpleScriptable { + private java.net.URL url_; + /** * Creates an instance. */ - @JsxConstructor({CHROME, FF, EDGE}) public URL() { } /** + * Creates an instance. + * @param url a string representing an absolute or relative URL. + * If url is a relative URL, base is required, and will be used + * as the base URL. If url is an absolute URL, a given base will be ignored. + * @param base a string representing the base URL to use in case url + * is a relative URL. If not specified, it defaults to ''. + */ + @JsxConstructor({CHROME, FF, EDGE}) + public URL(final String url, final Object base) { + String baseStr = null; + if (Undefined.instance != base) { + baseStr = Context.toString(base); + } + + try { + if (StringUtils.isBlank(baseStr)) { + url_ = UrlUtils.toUrlUnsafe(url); + } + else { + final java.net.URL baseUrl = UrlUtils.toUrlUnsafe(baseStr); + url_ = new java.net.URL(baseUrl, url); + } + } + catch (final MalformedURLException e) { + throw ScriptRuntime.typeError(e.toString()); + } + } + + /** * The URL.createObjectURL() static method creates a DOMString containing a URL * representing the object given in parameter. * The URL lifetime is tied to the document in the window on which it was created. @@ -66,4 +106,34 @@ @JsxStaticFunction public static void revokeObjectURL(final Object objectURL) { } + + /** + * @return the origin + */ + @JsxGetter + public Object getOrigin() { + if (url_ == null) { + return null; + } + + return url_.getProtocol() + "://" + url_.getHost(); + } + + /** + * Calls for instance for implicit conversion to string. + * @see com.gargoylesoftware.htmlunit.javascript.SimpleScriptable#getDefaultValue(java.lang.Class) + * @param hint the type hint + * @return the default value + */ + @Override + public Object getDefaultValue(final Class<?> hint) { + if (url_ == null) { + return super.getDefaultValue(hint); + } + + if (StringUtils.isEmpty(url_.getPath())) { + return url_.toExternalForm() + "/"; + } + return url_.toExternalForm(); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLTest.java 2017-11-15 21:03:02 UTC (rev 14959) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLTest.java 2017-11-15 21:29:53 UTC (rev 14960) @@ -63,6 +63,74 @@ } /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = { "https://developer.mozilla.org/", "https://developer.mozilla.org/", + "https://developer.mozilla.org/en-US/docs", "https://developer.mozilla.org/en-US/docs", + "https://developer.mozilla.org/en-US/docs", "https://developer.mozilla.org/en-US/docs", + "http://www.example.com/", "type error", "type error" }, + IE = {}) + // @NotYetImplemented({FF, CHROME}) + public void ctor() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (typeof window.URL === 'function') {\n" + + " alert(new URL('/', 'https://developer.mozilla.org'));\n" + + " var b = new URL('https://developer.mozilla.org');\n" + + " alert(b);\n" + + " alert(new URL('en-US/docs', b));\n" + + " var d = new URL('/en-US/docs', b);\n" + + " alert(d);\n" + + " alert(new URL('/en-US/docs', d));\n" + + " alert(new URL('/en-US/docs', 'https://developer.mozilla.org/fr-FR/toto'));\n" + + " alert(new URL('http://www.example.com', 'https://developers.mozilla.com'));\n" + + " try {\n" + + " new URL('/en-US/docs', '');\n" + + " } catch(e) { alert('type error'); }\n" + + " try {\n" + + " new URL('/en-US/docs');\n" + + " } catch(e) { alert('type error'); }\n" + + " }\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = "http://developer.mozilla.org", + IE = {}) + // @NotYetImplemented({FF, CHROME}) + public void origin() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (typeof window.URL === 'function') {\n" + + " var u = new URL('http://developer.mozilla.org/en-US/docs');\n" + + " alert(u.origin);\n" + + " }\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + + /** * @throws Exception if the test fails */ @Test |
From: <rb...@us...> - 2017-11-18 15:44:48
|
Revision: 14965 http://sourceforge.net/p/htmlunit/code/14965 Author: rbri Date: 2017-11-18 15:44:45 +0000 (Sat, 18 Nov 2017) Log Message: ----------- URLSearchParams append/delete/get Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java 2017-11-18 15:25:50 UTC (rev 14964) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java 2017-11-18 15:44:45 UTC (rev 14965) @@ -18,7 +18,8 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; import java.util.AbstractMap; -import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; import java.util.Map.Entry; import org.apache.commons.lang3.StringUtils; @@ -26,6 +27,7 @@ import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; import net.sourceforge.htmlunit.corejs.javascript.Context; import net.sourceforge.htmlunit.corejs.javascript.Undefined; @@ -40,7 +42,7 @@ @JsxClass({CHROME, FF}) public class URLSearchParams extends SimpleScriptable { - private final LinkedHashSet<Entry<String, String>> params_ = new LinkedHashSet<>(); + private final List<Entry<String, String>> params_ = new LinkedList<>(); /** * Constructs a new instance. @@ -96,6 +98,50 @@ } /** + * The append() method of the URLSearchParams interface appends a specified + * key/value pair as a new search parameter. + * + * @param name The name of the parameter to append. + * @param value The value of the parameter to append. + */ + @JsxFunction + public void append(final String name, final String value) { + params_.add(new AbstractMap.SimpleEntry<>(name, value)); + } + + /** + * The delete() method of the URLSearchParams interface deletes the given search + * parameter and its associated value, from the list of all search parameters. + * + * @param name The name of the parameter to be deleted. + */ + @JsxFunction + public void delete(final String name) { + for (Entry<String, String> param : params_) { + if (param.getKey().equals(name)) { + params_.remove(param); + } + } + } + + /** + * The get() method of the URLSearchParams interface returns the + * first value associated to the given search parameter. + * + * @param name The name of the parameter to return. + * @return An array of USVStrings. + */ + @JsxFunction + public String get(final String name) { + for (Entry<String, String> param : params_) { + if (param.getKey().equals(name)) { + return param.getValue(); + } + } + return null; + } + + /** * Calls for instance for implicit conversion to string. * @see com.gargoylesoftware.htmlunit.javascript.SimpleScriptable#getDefaultValue(java.lang.Class) * @param hint the type hint Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java 2017-11-18 15:25:50 UTC (rev 14964) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java 2017-11-18 15:44:45 UTC (rev 14965) @@ -58,4 +58,92 @@ + "</html>"; loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = { "key=value", "key=value&empty-key=undefined", + "key=value&empty-key=undefined&key=overwrite"}, + IE = {}) + public void append() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (self.URLSearchParams) {\n" + + " var param = new URLSearchParams();\n" + + " param.append('key', 'value');\n" + + " alert(param);\n" + + " param.append('empty-key', undefined);\n" + + " alert(param);\n" + + " param.append('key', 'overwrite');\n" + + " alert(param);\n" + + " }\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = { "key2=val2", "key2=val2", "key2=val2"}, + IE = {}) + public void delete() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (self.URLSearchParams) {\n" + + " var param = new URLSearchParams('key1=val1&key2=val2');\n" + + " param.delete('key1');\n" + + " alert(param);\n" + + " param.delete('key3');\n" + + " alert(param);\n" + + " param.delete('key1');\n" + + " alert(param);\n" + + " }\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = { "val1", "val2", "null"}, + IE = {}) + public void get() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (self.URLSearchParams) {\n" + + " var param = new URLSearchParams('key1=val1&key2=val2&key1=val3');\n" + + " alert(param.get('key1'));\n" + + " alert(param.get('key2'));\n" + + " alert(param.get('key3'));\n" + + " }\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2017-11-18 15:57:36
|
Revision: 14966 http://sourceforge.net/p/htmlunit/code/14966 Author: rbri Date: 2017-11-18 15:57:33 +0000 (Sat, 18 Nov 2017) Log Message: ----------- URLSearchParams getAll/has Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java 2017-11-18 15:44:45 UTC (rev 14965) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java 2017-11-18 15:57:33 UTC (rev 14966) @@ -30,6 +30,9 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; import net.sourceforge.htmlunit.corejs.javascript.Context; +import net.sourceforge.htmlunit.corejs.javascript.NativeArray; +import net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime; +import net.sourceforge.htmlunit.corejs.javascript.TopLevel; import net.sourceforge.htmlunit.corejs.javascript.Undefined; /** @@ -142,6 +145,44 @@ } /** + * The getAll() method of the URLSearchParams interface returns all the values + * associated with a given search parameter as an array. + * + * @param name The name of the parameter to return. + * @return An array of USVStrings. + */ + @JsxFunction + public NativeArray getAll(final String name) { + final List<String> result = new LinkedList<>(); + for (Entry<String, String> param : params_) { + if (param.getKey().equals(name)) { + result.add(param.getValue()); + } + } + + final NativeArray jsValues = new NativeArray(result.toArray()); + ScriptRuntime.setBuiltinProtoAndParent(jsValues, getWindow(this), TopLevel.Builtins.Array); + return jsValues; + } + + /** + * The has() method of the URLSearchParams interface returns a Boolean that + * indicates whether a parameter with the specified name exists. + * + * @param name The name of the parameter to find. + * @return A Boolean. + */ + @JsxFunction + public boolean has(final String name) { + for (Entry<String, String> param : params_) { + if (param.getKey().equals(name)) { + return true; + } + } + return false; + } + + /** * Calls for instance for implicit conversion to string. * @see com.gargoylesoftware.htmlunit.javascript.SimpleScriptable#getDefaultValue(java.lang.Class) * @param hint the type hint Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java 2017-11-18 15:44:45 UTC (rev 14965) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java 2017-11-18 15:57:33 UTC (rev 14966) @@ -146,4 +146,58 @@ + "</html>"; loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = { "true", "true", "false"}, + IE = {}) + public void has() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (self.URLSearchParams) {\n" + + " var param = new URLSearchParams('key1=val1&key2=val2&key1=val3');\n" + + " alert(param.has('key1'));\n" + + " alert(param.has('key2'));\n" + + " alert(param.has('key3'));\n" + + " }\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = { "val1,val3", "val2", ""}, + IE = {}) + public void getAll() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (self.URLSearchParams) {\n" + + " var param = new URLSearchParams('key1=val1&key2=val2&key1=val3');\n" + + " alert(param.getAll('key1'));\n" + + " alert(param.getAll('key2'));\n" + + " alert(param.getAll('key3'));\n" + + " }\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2017-11-18 16:59:50
|
Revision: 14967 http://sourceforge.net/p/htmlunit/code/14967 Author: rbri Date: 2017-11-18 16:59:47 +0000 (Sat, 18 Nov 2017) Log Message: ----------- URLSearchParams set Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java 2017-11-18 15:57:33 UTC (rev 14966) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java 2017-11-18 16:59:47 UTC (rev 14967) @@ -18,6 +18,7 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; import java.util.AbstractMap; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map.Entry; @@ -120,9 +121,11 @@ */ @JsxFunction public void delete(final String name) { - for (Entry<String, String> param : params_) { - if (param.getKey().equals(name)) { - params_.remove(param); + final Iterator<Entry<String, String>> iter = params_.iterator(); + while (iter.hasNext()) { + final Entry<String, String> entry = iter.next(); + if (entry.getKey().equals(name)) { + iter.remove(); } } } @@ -166,6 +169,37 @@ } /** + * The set() method of the URLSearchParams interface sets the value associated with a + * given search parameter to the given value. If there were several matching values, + * this method deletes the others. If the search parameter doesn't exist, this method + * creates it. + * + * @param name The name of the parameter to set. + * @param value The value of the parameter to set. + */ + @JsxFunction + public void set(final String name, final String value) { + final Iterator<Entry<String, String>> iter = params_.iterator(); + boolean change = true; + while (iter.hasNext()) { + final Entry<String, String> entry = iter.next(); + if (entry.getKey().equals(name)) { + if (change) { + entry.setValue(value); + change = false; + } + else { + iter.remove(); + } + } + } + + if (change) { + append(name, value); + } + } + + /** * The has() method of the URLSearchParams interface returns a Boolean that * indicates whether a parameter with the specified name exists. * Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java 2017-11-18 15:57:33 UTC (rev 14966) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParamsTest.java 2017-11-18 16:59:47 UTC (rev 14967) @@ -36,8 +36,8 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = { "foo=1&bar=2", ""}, - FF45 = { "%3Ffoo=1&bar=2", ""}, + @Alerts(DEFAULT = {"foo=1&bar=2", ""}, + FF45 = {"%3Ffoo=1&bar=2", ""}, IE = {}) @NotYetImplemented(FF45) public void ctor() throws Exception { @@ -63,7 +63,7 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = { "key=value", "key=value&empty-key=undefined", + @Alerts(DEFAULT = {"key=value", "key=value&empty-key=undefined", "key=value&empty-key=undefined&key=overwrite"}, IE = {}) public void append() throws Exception { @@ -94,7 +94,7 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = { "key2=val2", "key2=val2", "key2=val2"}, + @Alerts(DEFAULT = {"key2=val2&key2=val3", "", ""}, IE = {}) public void delete() throws Exception { final String html = @@ -103,13 +103,13 @@ + " <script>\n" + " function test() {\n" + " if (self.URLSearchParams) {\n" - + " var param = new URLSearchParams('key1=val1&key2=val2');\n" + + " var param = new URLSearchParams('key1=val1&key2=val2&key2=val3');\n" + " param.delete('key1');\n" + " alert(param);\n" + + " param.delete('key2');\n" + + " alert(param);\n" + " param.delete('key3');\n" + " alert(param);\n" - + " param.delete('key1');\n" - + " alert(param);\n" + " }\n" + " }\n" + " </script>\n" @@ -124,7 +124,7 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = { "val1", "val2", "null"}, + @Alerts(DEFAULT = {"val1", "val2", "null"}, IE = {}) public void get() throws Exception { final String html = @@ -151,7 +151,7 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = { "true", "true", "false"}, + @Alerts(DEFAULT = {"true", "true", "false"}, IE = {}) public void has() throws Exception { final String html = @@ -178,7 +178,7 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = { "val1,val3", "val2", ""}, + @Alerts(DEFAULT = {"val1,val3", "val2", ""}, IE = {}) public void getAll() throws Exception { final String html = @@ -200,4 +200,36 @@ + "</html>"; loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = {"key1=val1&key2=val2&key2=val3&key4=val4", + "key1=new1&key2=val2&key2=val3&key4=val4", + "key1=new1&key2=new2&key4=val4"}, + IE = {}) + public void set() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (self.URLSearchParams) {\n" + + " var param = new URLSearchParams('key1=val1&key2=val2&key2=val3');\n" + + " param.set('key4', 'val4');\n" + + " alert(param);\n" + + " param.set('key1', 'new1');\n" + + " alert(param);\n" + + " param.set('key2', 'new2');\n" + + " alert(param);\n" + + " }\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2017-11-21 17:16:23
|
Revision: 14972 http://sourceforge.net/p/htmlunit/code/14972 Author: rbri Date: 2017-11-21 17:16:21 +0000 (Tue, 21 Nov 2017) Log Message: ----------- New configuration settings webSocketMaxTextMessageSize, webSocketMaxTextMessageBufferSize, webSocketMaxBinaryMessageSize, and webSocketMaxBinaryMessageBufferSize. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClientOptions.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-11-20 19:40:14 UTC (rev 14971) +++ trunk/htmlunit/src/changes/changes.xml 2017-11-21 17:16:21 UTC (rev 14972) @@ -9,6 +9,10 @@ <body> <release version="2.29" date="xx, 2017" description=""> <action type="add" dev="rbri"> + New configuration settings webSocketMaxTextMessageSize, webSocketMaxTextMessageBufferSize, + webSocketMaxBinaryMessageSize, and webSocketMaxBinaryMessageBufferSize. + </action> + <action type="add" dev="rbri"> JavaScript: URL constuctor and origin property added. </action> </release> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClientOptions.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClientOptions.java 2017-11-20 19:40:14 UTC (rev 14971) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClientOptions.java 2017-11-21 17:16:21 UTC (rev 14972) @@ -59,6 +59,11 @@ private int screenWidth_ = 1024; private int screenHeight_ = 768; + private int webSocketMaxTextMessageSize_ = -1; + private int webSocketMaxTextMessageBufferSize_ = -1; + private int webSocketMaxBinaryMessageSize_ = -1; + private int webSocketMaxBinaryMessageBufferSize_ = -1; + /** * If set to {@code true}, the client will accept connections to any host, regardless of * whether they have valid certificates or not. This is especially useful when you are trying to @@ -662,4 +667,68 @@ public int getScreenHeight() { return screenHeight_; } + + /** + * @return the WebSocket maxTextMessageSize + */ + public int getWebSocketMaxTextMessageSize() { + return webSocketMaxTextMessageSize_; + } + + /** + * Sets the WebSocket maxTextMessageSize. + * + * @param webSocketMaxTextMessageSize the new value + */ + public void setWebSocketMaxTextMessageSize(final int webSocketMaxTextMessageSize) { + webSocketMaxTextMessageSize_ = webSocketMaxTextMessageSize; + } + + /** + * @return the WebSocket maxTextMessageBufferSize + */ + public int getWebSocketMaxTextMessageBufferSize() { + return webSocketMaxTextMessageBufferSize_; + } + + /** + * Sets the WebSocket maxTextMessageBufferSize. + * + * @param webSocketMaxTextMessageBufferSize the new value + */ + public void setWebSocketMaxTextMessageBufferSize(final int webSocketMaxTextMessageBufferSize) { + webSocketMaxTextMessageBufferSize_ = webSocketMaxTextMessageBufferSize; + } + + /** + * @return the WebSocket maxTextMessageSize + */ + public int getWebSocketMaxBinaryMessageSize() { + return webSocketMaxBinaryMessageSize_; + } + + /** + * Sets the WebSocket maxBinaryMessageSize. + * + * @param webSocketMaxBinaryMessageSize the new value + */ + public void setWebSocketMaxBinaryMessageSize(final int webSocketMaxBinaryMessageSize) { + webSocketMaxBinaryMessageSize_ = webSocketMaxBinaryMessageSize; + } + + /** + * @return the WebSocket maxBinaryMessageBufferSize + */ + public int getWebSocketMaxBinaryMessageBufferSize() { + return webSocketMaxBinaryMessageBufferSize_; + } + + /** + * Sets the WebSocket maxBinaryMessageBufferSize. + * + * @param webSocketMaxBinaryMessageBufferSize the new value + */ + public void setWebSocketMaxBinaryMessageBufferSize(final int webSocketMaxBinaryMessageBufferSize) { + webSocketMaxBinaryMessageBufferSize_ = webSocketMaxBinaryMessageBufferSize; + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java 2017-11-20 19:40:14 UTC (rev 14971) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java 2017-11-21 17:16:21 UTC (rev 14972) @@ -28,6 +28,7 @@ import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketListener; +import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.client.WebSocketClient; import com.gargoylesoftware.htmlunit.ScriptResult; @@ -137,6 +138,25 @@ client_ = new WebSocketClient(); } client_.setCookieStore(new WebSocketCookieStore(webClient)); + + final WebSocketPolicy policy = client_.getPolicy(); + int size = webClient.getOptions().getWebSocketMaxBinaryMessageSize(); + if (size > 0) { + policy.setMaxBinaryMessageSize(size); + } + size = webClient.getOptions().getWebSocketMaxBinaryMessageBufferSize(); + if (size > 0) { + policy.setMaxBinaryMessageBufferSize(size); + } + size = webClient.getOptions().getWebSocketMaxTextMessageSize(); + if (size > 0) { + policy.setMaxTextMessageSize(size); + } + size = webClient.getOptions().getWebSocketMaxTextMessageBufferSize(); + if (size > 0) { + policy.setMaxTextMessageBufferSize(size); + } + client_.start(); containingPage_.addAutoCloseable(this); url_ = new URI(url); |
From: <rb...@us...> - 2017-11-26 10:39:34
|
Revision: 14978 http://sourceforge.net/p/htmlunit/code/14978 Author: rbri Date: 2017-11-26 10:39:31 +0000 (Sun, 26 Nov 2017) Log Message: ----------- JavaScript: URL.searchParams added Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URL.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-11-26 10:37:57 UTC (rev 14977) +++ trunk/htmlunit/src/changes/changes.xml 2017-11-26 10:39:31 UTC (rev 14978) @@ -9,11 +9,14 @@ <body> <release version="2.29" date="xx, 2017" description=""> <action type="add" dev="rbri"> + JavaScript: URL.searchParams added. + </action> + <action type="add" dev="rbri"> New configuration settings webSocketMaxTextMessageSize, webSocketMaxTextMessageBufferSize, webSocketMaxBinaryMessageSize, and webSocketMaxBinaryMessageBufferSize. </action> <action type="add" dev="rbri"> - JavaScript: URL constuctor and origin property added. + JavaScript: URL constructor and origin property added. </action> </release> <release version="2.28" date="November 12, 2017" description="Bugfixes, Chrome 62, improved Promise"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URL.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URL.java 2017-11-26 10:37:57 UTC (rev 14977) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URL.java 2017-11-26 10:39:31 UTC (rev 14978) @@ -120,6 +120,18 @@ } /** + * @return the origin + */ + @JsxGetter + public URLSearchParams getSearchParams() { + if (url_ == null) { + return null; + } + + return new URLSearchParams(url_.getQuery()); + } + + /** * Calls for instance for implicit conversion to string. * @see com.gargoylesoftware.htmlunit.javascript.SimpleScriptable#getDefaultValue(java.lang.Class) * @param hint the type hint Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java 2017-11-26 10:37:57 UTC (rev 14977) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java 2017-11-26 10:39:31 UTC (rev 14978) @@ -66,7 +66,7 @@ // TODO: Pass in a record // new URLSearchParams({"foo" : 1 , "bar" : 2}); - if (Undefined.instance == params) { + if (Undefined.instance == params || null == params) { return; } @@ -232,7 +232,10 @@ paramStr.append(param.getKey()); paramStr.append("="); // TODO: need to encode value - paramStr.append(param.getValue()); + final String value = param.getValue(); + if (value != null) { + paramStr.append(param.getValue()); + } } return paramStr.toString(); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLTest.java 2017-11-26 10:37:57 UTC (rev 14977) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/URLTest.java 2017-11-26 10:39:31 UTC (rev 14978) @@ -176,4 +176,31 @@ FileUtils.deleteQuietly(tstFile); } } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = {"", "a=u&x="}, + IE = {}) + public void searchParams() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (typeof window.URL === 'function') {\n" + + " var u = new URL('http://developer.mozilla.org/en-US/docs');\n" + + " alert(u.searchParams);\n" + + " u = new URL('http://developer.mozilla.org/en-US/docs?a=u&x');\n" + + " alert(u.searchParams);\n" + + " }\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2017-11-29 18:54:56
|
Revision: 14981 http://sourceforge.net/p/htmlunit/code/14981 Author: rbri Date: 2017-11-29 18:54:53 +0000 (Wed, 29 Nov 2017) Log Message: ----------- JavaScript: performance.navigation.toJSON() added Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/performance/PerformanceNavigation.java Added Paths: ----------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/performance/PerformanceNavigationTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-11-27 20:16:26 UTC (rev 14980) +++ trunk/htmlunit/src/changes/changes.xml 2017-11-29 18:54:53 UTC (rev 14981) @@ -9,6 +9,9 @@ <body> <release version="2.29" date="xx, 2017" description=""> <action type="add" dev="rbri"> + JavaScript: performance.navigation.toJSON() added. + </action> + <action type="add" dev="rbri"> JavaScript: URL.searchParams added. </action> <action type="add" dev="rbri"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/performance/PerformanceNavigation.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/performance/PerformanceNavigation.java 2017-11-27 20:16:26 UTC (rev 14980) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/performance/PerformanceNavigation.java 2017-11-29 18:54:53 UTC (rev 14981) @@ -17,8 +17,10 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; -import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.IE; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstant; @@ -26,14 +28,21 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; +import net.sourceforge.htmlunit.corejs.javascript.Context; +import net.sourceforge.htmlunit.corejs.javascript.json.JsonParser; +import net.sourceforge.htmlunit.corejs.javascript.json.JsonParser.ParseException; + /** * A JavaScript object for {@code PerformanceNavigation}. * * @author Ahmed Ashour + * @author Ronald Brill */ @JsxClass public class PerformanceNavigation extends SimpleScriptable { + private static final Log LOG = LogFactory.getLog(PerformanceNavigation.class); + /** Navigate. */ @JsxConstant public static final int TYPE_NAVIGATE = 0; @@ -79,9 +88,21 @@ * The {@code toJSON} function. * @return the {@code toJSON} object */ - @JsxFunction({FF, IE}) + @JsxFunction public Object toJSON() { - throw new UnsupportedOperationException(); + final String jsonString = new StringBuilder() + .append("{\"type\":") + .append(Integer.toString(getType())) + .append(", \"redirectCount\":") + .append(Integer.toString(getRedirectCount())) + .append("}").toString(); + try { + return new JsonParser(Context.getCurrentContext(), getParentScope()).parseValue(jsonString); + } + catch (final ParseException e) { + LOG.warn("Failed parsingJSON '" + jsonString + "' reason: " + e.getMessage()); + } + return null; } } Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/performance/PerformanceNavigationTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/performance/PerformanceNavigationTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/performance/PerformanceNavigationTest.java 2017-11-29 18:54:53 UTC (rev 14981) @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2002-2017 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.javascript.host.performance; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openqa.selenium.WebDriver; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; +import com.gargoylesoftware.htmlunit.html.HtmlPageTest; + +/** + * Tests for {@link Performance}. + * + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class PerformanceNavigationTest extends WebDriverTestCase { + + /** + * @throws Exception if the test fails + */ + @Test + public void toJSON() throws Exception { + final String html = + HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html>\n" + + "<head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(JSON.stringify(performance.navigation.toJSON()));\n" + + " }\n" + + " test();\n" + + "</script>\n" + + "</head>\n" + + "<body></body>\n" + + "</html>"; + + final WebDriver driver = loadPage2(html); + final String json = getCollectedAlerts(driver, 1).get(0); + assertTrue(json, json.contains("\"type\":0")); + assertTrue(json, json.contains("\"redirectCount\":0")); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void redirectCount() throws Exception { + final String html = + HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html>\n" + + "<head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(performance.navigation.redirectCount);\n" + + " }\n" + + " test();\n" + + "</script>\n" + + "</head>\n" + + "<body></body>\n" + + "</html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("0") + public void type() throws Exception { + final String html = + HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html>\n" + + "<head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(performance.navigation.type);\n" + + " }\n" + + " test();\n" + + "</script>\n" + + "</head>\n" + + "<body></body>\n" + + "</html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"number", "function"}) + public void methods() throws Exception { + final String html + = "<html>\n" + + "<body>\n" + + "<script>\n" + + " alert(typeof performance.navigation.redirectCount);\n" + + " alert(typeof performance.navigation.toJSON);\n" + + "</script>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/performance/PerformanceNavigationTest.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property |
From: <rb...@us...> - 2017-11-29 20:13:22
|
Revision: 14982 http://sourceforge.net/p/htmlunit/code/14982 Author: rbri Date: 2017-11-29 20:13:19 +0000 (Wed, 29 Nov 2017) Log Message: ----------- fix Number.toLocaleString() to be able to support locale strings like 'en-US' Issue 1932 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/NumberCustom.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeNumberTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-11-29 18:54:53 UTC (rev 14981) +++ trunk/htmlunit/src/changes/changes.xml 2017-11-29 20:13:19 UTC (rev 14982) @@ -8,6 +8,9 @@ <body> <release version="2.29" date="xx, 2017" description=""> + <action type="fix" dev="rbri" issue="1932"> + JavaScript: fix Number.toLocaleString() to be able to support locale strings like 'en-US'. + </action> <action type="add" dev="rbri"> JavaScript: performance.navigation.toJSON() added. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/NumberCustom.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/NumberCustom.java 2017-11-29 18:54:53 UTC (rev 14981) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/NumberCustom.java 2017-11-29 20:13:19 UTC (rev 14982) @@ -15,10 +15,9 @@ package com.gargoylesoftware.htmlunit.javascript.host; import java.text.NumberFormat; +import java.util.IllformedLocaleException; import java.util.Locale; -import org.apache.commons.lang3.LocaleUtils; - import com.gargoylesoftware.htmlunit.BrowserVersion; import net.sourceforge.htmlunit.corejs.javascript.Context; @@ -49,10 +48,10 @@ if (args.length != 0 && args[0] instanceof String) { final String localeStr = (String) args[0]; try { - final Locale locale = LocaleUtils.toLocale(localeStr); + final Locale locale = new Locale.Builder().setLanguageTag(localeStr).build(); return NumberFormat.getInstance(locale).format(Double.parseDouble(thisObj.toString())); } - catch (final IllegalArgumentException e) { + catch (final IllformedLocaleException e) { throw ScriptRuntime.rangeError("Invalid language tag: " + localeStr); } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeNumberTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeNumberTest.java 2017-11-29 18:54:53 UTC (rev 14981) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeNumberTest.java 2017-11-29 20:13:19 UTC (rev 14982) @@ -101,6 +101,19 @@ */ @Test @Alerts("12,345") + public void toLocaleStringEnUS() throws Exception { + final String html = "<html><head><script>\n" + + " alert((12345).toLocaleString('en-US'));\n" + + "</script></head><body>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("12,345") public void toLocaleStringNoParam() throws Exception { final String html = "<html><head><script>\n" + " try {\n" |
From: <rb...@us...> - 2017-12-01 07:16:34
|
Revision: 14983 http://sourceforge.net/p/htmlunit/code/14983 Author: rbri Date: 2017-12-01 07:16:31 +0000 (Fri, 01 Dec 2017) Log Message: ----------- WebSocket constructor call failed with a NPE when called during page construction Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocketTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-11-29 20:13:19 UTC (rev 14982) +++ trunk/htmlunit/src/changes/changes.xml 2017-12-01 07:16:31 UTC (rev 14983) @@ -9,6 +9,9 @@ <body> <release version="2.29" date="xx, 2017" description=""> <action type="fix" dev="rbri" issue="1932"> + JavaScript: WebSocket constructor call failed with a NPE when called during page construction. + </action> + <action type="fix" dev="rbri" issue="1932"> JavaScript: fix Number.toLocaleString() to be able to support locale strings like 'en-US'. </action> <action type="add" dev="rbri"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java 2017-11-29 20:13:19 UTC (rev 14982) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java 2017-12-01 07:16:31 UTC (rev 14983) @@ -128,7 +128,7 @@ try { containingPage_ = (HtmlPage) window.getWebWindow().getEnclosedPage(); setParentScope(window); - setDomNode(containingPage_.getBody(), false); + setDomNode(containingPage_.getDocumentElement(), false); final WebClient webClient = window.getWebWindow().getWebClient(); if (webClient.getOptions().isUseInsecureSSL()) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocketTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocketTest.java 2017-11-29 20:13:19 UTC (rev 14982) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocketTest.java 2017-12-01 07:16:31 UTC (rev 14983) @@ -90,6 +90,27 @@ * @throws Exception if the test fails */ @Test + @Alerts({"[object WebSocket]", "ws://localhost:12345/"}) + public void earlyConstruction() throws Exception { + final String html = "<html><head><script>\n" + + " function test() {\n" + + " var location = 'ws://localhost:" + PORT + "/';\n" + + " var ws = new WebSocket(location);\n" + + " alert(ws);\n" + + " alert(ws.url);\n" + + " }\n" + + " test();\n" + + "</script>\n" + + "</head>\n" + + "<body>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts({"exception undefined", "exception null", "exception empty", "exception invalid"}) public void initialWithoutUrl() throws Exception { final String html = "<html><head><script>\n" |
From: <rb...@us...> - 2017-12-01 08:40:05
|
Revision: 14984 http://sourceforge.net/p/htmlunit/code/14984 Author: rbri Date: 2017-12-01 08:40:03 +0000 (Fri, 01 Dec 2017) Log Message: ----------- location.reload uses the same request method like the original request Issue 1840 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-12-01 07:16:31 UTC (rev 14983) +++ trunk/htmlunit/src/changes/changes.xml 2017-12-01 08:40:03 UTC (rev 14984) @@ -8,7 +8,10 @@ <body> <release version="2.29" date="xx, 2017" description=""> - <action type="fix" dev="rbri" issue="1932"> + <action type="fix" dev="rbri" issue="1840"> + JavaScript: location.reload uses the same request method like the original request. + </action> + <action type="fix" dev="rbri"> JavaScript: WebSocket constructor call failed with a NPE when called during page construction. </action> <action type="fix" dev="rbri" issue="1932"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java 2017-12-01 07:16:31 UTC (rev 14983) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java 2017-12-01 08:40:03 UTC (rev 14984) @@ -134,13 +134,18 @@ */ @JsxFunction public void reload(final boolean force) throws IOException { - final String url = getHref(); - if (UNKNOWN.equals(url)) { - LOG.error("Unable to reload location: current URL is unknown."); - } - else { - setHref(url); - } + final HtmlPage htmlPage = (HtmlPage) getWindow(getStartingScope()).getWebWindow().getEnclosedPage(); + final WebRequest request = htmlPage.getWebResponse().getWebRequest(); + + String referer = htmlPage.getUrl().toExternalForm(); + request.setAdditionalHeader(HttpHeader.REFERER, referer); + + referer = UrlUtils.getUrlWithNewQuery(htmlPage.getUrl(), null).toExternalForm(); + referer = StringUtils.stripEnd(referer, "/"); + request.setAdditionalHeader(HttpHeader.ORIGIN, referer); + + final WebWindow webWindow = window_.getWebWindow(); + webWindow.getWebClient().download(webWindow, "", request, true, false, "JS reload"); } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java 2017-12-01 07:16:31 UTC (rev 14983) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java 2017-12-01 08:40:03 UTC (rev 14984) @@ -18,6 +18,7 @@ import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; import java.net.URL; +import java.util.List; import java.util.Map; import org.junit.Test; @@ -26,11 +27,14 @@ import org.openqa.selenium.WebDriver; import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.HttpHeader; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; import com.gargoylesoftware.htmlunit.BrowserRunner.BuggyWebDriver; import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; +import com.gargoylesoftware.htmlunit.HttpMethod; import com.gargoylesoftware.htmlunit.MockWebConnection; import com.gargoylesoftware.htmlunit.WebDriverTestCase; +import com.gargoylesoftware.htmlunit.util.NameValuePair; /** * Tests for {@link Location}. @@ -769,7 +773,7 @@ assertEquals(2, conn.getRequestCount()); Map<String, String> lastAdditionalHeaders = conn.getLastAdditionalHeaders(); - assertEquals(getExpectedAlerts()[0], lastAdditionalHeaders.get("Referer")); + assertEquals(getExpectedAlerts()[0], lastAdditionalHeaders.get(HttpHeader.REFERER)); loadPage2(html); assertEquals(3, conn.getRequestCount()); @@ -777,7 +781,7 @@ driver.findElement(By.id("jsLink")).click(); assertEquals(4, conn.getRequestCount()); lastAdditionalHeaders = conn.getLastAdditionalHeaders(); - assertEquals(getExpectedAlerts()[0], lastAdditionalHeaders.get("Referer")); + assertEquals(getExpectedAlerts()[0], lastAdditionalHeaders.get(HttpHeader.REFERER)); } /** @@ -814,13 +818,13 @@ driver.findElement(By.id("link")).click(); assertEquals(3, conn.getRequestCount()); Map<String, String> lastAdditionalHeaders = conn.getLastAdditionalHeaders(); - assertEquals(getExpectedAlerts()[0], lastAdditionalHeaders.get("Referer")); + assertEquals(getExpectedAlerts()[0], lastAdditionalHeaders.get(HttpHeader.REFERER)); // click an anchor with onclick which sets frame.location driver.findElement(By.id("jsLink")).click(); assertEquals(4, conn.getRequestCount()); lastAdditionalHeaders = conn.getLastAdditionalHeaders(); - assertEquals(getExpectedAlerts()[0], lastAdditionalHeaders.get("Referer")); + assertEquals(getExpectedAlerts()[0], lastAdditionalHeaders.get(HttpHeader.REFERER)); } /** @@ -844,4 +848,92 @@ final WebDriver driver = loadPage2(html); verifyAlerts(driver, expectedAlerts); } + + /** + * @throws Exception if the test fails + */ + @Test + public void reloadGet() throws Exception { + final String html = + "<html>\n" + + " <head></head>\n" + + " <body>\n" + + " <a href='javascript:window.location.reload(true);' id='link'>reload</a>\n" + + " </body>\n" + + "</html>"; + + getMockWebConnection().setDefaultResponse(html); + final WebDriver driver = loadPage2(html, new URL(URL_FIRST + "a.html?p1=sieben&p2")); + assertEquals(1, getMockWebConnection().getRequestCount()); + + driver.findElement(By.id("link")).click(); + assertEquals(2, getMockWebConnection().getRequestCount()); + + assertEquals(HttpMethod.GET, getMockWebConnection().getLastWebRequest().getHttpMethod()); + assertEquals(URL_FIRST + "a.html", getMockWebConnection().getLastWebRequest().getUrl()); + + final List<NameValuePair> params = getMockWebConnection().getLastWebRequest().getRequestParameters(); + assertEquals(2, params.size()); + assertEquals("p1", params.get(0).getName()); + assertEquals("sieben", params.get(0).getValue()); + assertEquals("p2", params.get(1).getName()); + assertEquals("", params.get(1).getValue()); + } + + /** + * @throws Exception if the test fails + */ + @Test + @BuggyWebDriver(FF) + public void reloadPost() throws Exception { + final String form = + "<html>\n" + + " <head></head>\n" + + " <body>\n" + + " <form method='POST' name='form' action='" + URL_SECOND + "a.html?urlParam=urlVal'>\n" + + " <input type='hidden' name='p1' value='seven'>\n" + + " <input type='hidden' name='p2' value=''>\n" + + " <input type='submit' id='enter' name='sub' value='ok'>\n" + + " </form>\n" + + " </body>\n" + + "</html>"; + + final String html = + "<html>\n" + + " <head></head>\n" + + " <body>\n" + + " <a href='javascript:window.location.reload(true);' id='link'>reload</a>\n" + + " </body>\n" + + "</html>"; + + getMockWebConnection().setDefaultResponse(html); + + final WebDriver driver = loadPage2(form, URL_FIRST); + assertEquals(1, getMockWebConnection().getRequestCount()); + driver.findElement(By.id("enter")).click(); + + assertEquals(2, getMockWebConnection().getRequestCount()); + + driver.findElement(By.id("link")).click(); + assertEquals(3, getMockWebConnection().getRequestCount()); + + assertEquals(HttpMethod.POST, getMockWebConnection().getLastWebRequest().getHttpMethod()); + assertEquals(URL_SECOND + "a.html", getMockWebConnection().getLastWebRequest().getUrl()); + + final List<NameValuePair> params = getMockWebConnection().getLastWebRequest().getRequestParameters(); + assertEquals(4, params.size()); + assertEquals("p1", params.get(0).getName()); + assertEquals("seven", params.get(0).getValue()); + assertEquals("sub", params.get(1).getName()); + assertEquals("ok", params.get(1).getValue()); + assertEquals("p2", params.get(2).getName()); + assertEquals("", params.get(2).getValue()); + assertEquals("urlParam", params.get(3).getName()); + assertEquals("urlVal", params.get(3).getValue()); + + final Map<String, String> additionalHeaders = getMockWebConnection().getLastAdditionalHeaders(); + // assertEquals("http://localhost:" + PORT, additionalHeaders.get(HttpHeader.ORIGIN)); + assertEquals(URL_SECOND + "a.html?urlParam=urlVal", additionalHeaders.get(HttpHeader.REFERER)); + assertEquals("localhost:" + PORT, additionalHeaders.get(HttpHeader.HOST)); + } } |
From: <rb...@us...> - 2017-12-01 08:42:54
|
Revision: 14985 http://sourceforge.net/p/htmlunit/code/14985 Author: rbri Date: 2017-12-01 08:42:51 +0000 (Fri, 01 Dec 2017) Log Message: ----------- cleanup Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpHeader.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/activex/javascript/msxml/XMLHTTPRequest.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAnchorElement2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpHeader.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpHeader.java 2017-12-01 08:40:03 UTC (rev 14984) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpHeader.java 2017-12-01 08:42:51 UTC (rev 14985) @@ -88,6 +88,23 @@ /** Upgrade-Insecure-Requests. */ public static final String UPGRADE_INSECURE_REQUESTS = "Upgrade-Insecure-Requests"; + /** Access-Control-Request-Method. */ + public static final String ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method"; + /** Access-Control-Request-Headers. */ + public static final String ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers"; + /** Access-Control-Allow-Origin. */ + public static final String ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"; + /** Access-Control-Allow-Credentials. */ + public static final String ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials"; + /** Access-Control-Allow-Headers. */ + public static final String ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers"; + + /** Ping-From. */ + public static final String PING_FROM = "Ping-From"; + + /** Ping-From. */ + public static final String PING_TO = "Ping-To"; + private HttpHeader() { } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/activex/javascript/msxml/XMLHTTPRequest.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/activex/javascript/msxml/XMLHTTPRequest.java 2017-12-01 08:40:03 UTC (rev 14984) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/activex/javascript/msxml/XMLHTTPRequest.java 2017-12-01 08:42:51 UTC (rev 14985) @@ -96,11 +96,6 @@ private static final char REQUEST_HEADERS_SEPARATOR = ','; - private static final String HEADER_ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method"; - private static final String HEADER_ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers"; - private static final String HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"; - private static final String HEADER_ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers"; - private static final String ALLOW_ORIGIN_ALL = "*"; private static final String[] ALL_PROPERTIES_ = {"onreadystatechange", "readyState", "responseText", "responseXML", @@ -541,7 +536,7 @@ // header request-method preflightRequest.setAdditionalHeader( - HEADER_ACCESS_CONTROL_REQUEST_METHOD, + HttpHeader.ACCESS_CONTROL_REQUEST_METHOD, webRequest_.getHttpMethod().name()); // header request-headers @@ -555,7 +550,7 @@ builder.append(name); } } - preflightRequest.setAdditionalHeader(HEADER_ACCESS_CONTROL_REQUEST_HEADERS, builder.toString()); + preflightRequest.setAdditionalHeader(HttpHeader.ACCESS_CONTROL_REQUEST_HEADERS, builder.toString()); // do the preflight request final WebResponse preflightResponse = wc.loadWebResponse(preflightRequest); @@ -577,7 +572,7 @@ } boolean allowOriginResponse = true; if (originHeaderValue != null) { - final String value = webResponse.getResponseHeaderValue(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN); + final String value = webResponse.getResponseHeaderValue(HttpHeader.ACCESS_CONTROL_ALLOW_ORIGIN); allowOriginResponse = originHeaderValue.equals(value); allowOriginResponse = allowOriginResponse || ALLOW_ORIGIN_ALL.equals(value); } @@ -624,12 +619,12 @@ } private boolean isPreflightAuthorized(final WebResponse preflightResponse) { - final String originHeader = preflightResponse.getResponseHeaderValue(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN); + final String originHeader = preflightResponse.getResponseHeaderValue(HttpHeader.ACCESS_CONTROL_ALLOW_ORIGIN); if (!ALLOW_ORIGIN_ALL.equals(originHeader) && !webRequest_.getAdditionalHeaders().get(HttpHeader.ORIGIN).equals(originHeader)) { return false; } - String headersHeader = preflightResponse.getResponseHeaderValue(HEADER_ACCESS_CONTROL_ALLOW_HEADERS); + String headersHeader = preflightResponse.getResponseHeaderValue(HttpHeader.ACCESS_CONTROL_ALLOW_HEADERS); if (headersHeader == null) { headersHeader = ""; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java 2017-12-01 08:40:03 UTC (rev 14984) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java 2017-12-01 08:42:51 UTC (rev 14985) @@ -156,8 +156,8 @@ if (ATTRIBUTE_NOT_DEFINED != getPingAttribute() && browser.hasFeature(ANCHOR_IGNORE_TARGET_FOR_JS_HREF)) { final URL pingUrl = getTargetUrl(getPingAttribute(), page); final WebRequest pingRequest = new WebRequest(pingUrl, HttpMethod.POST); - pingRequest.setAdditionalHeader("Ping-From", page.getUrl().toExternalForm()); - pingRequest.setAdditionalHeader("Ping-To", url.toExternalForm()); + pingRequest.setAdditionalHeader(HttpHeader.PING_FROM, page.getUrl().toExternalForm()); + pingRequest.setAdditionalHeader(HttpHeader.PING_TO, url.toExternalForm()); pingRequest.setRequestBody("PING"); page.getWebClient().loadWebResponse(pingRequest); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java 2017-12-01 08:40:03 UTC (rev 14984) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java 2017-12-01 08:42:51 UTC (rev 14985) @@ -120,12 +120,6 @@ @JsxConstant public static final int DONE = 4; - private static final String HEADER_ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method"; - private static final String HEADER_ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers"; - private static final String HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"; - private static final String HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials"; - private static final String HEADER_ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers"; - private static final String ALLOW_ORIGIN_ALL = "*"; private static final String[] ALL_PROPERTIES_ = {"onreadystatechange", "readyState", "responseText", "responseXML", @@ -718,7 +712,7 @@ // header request-method preflightRequest.setAdditionalHeader( - HEADER_ACCESS_CONTROL_REQUEST_METHOD, + HttpHeader.ACCESS_CONTROL_REQUEST_METHOD, webRequest_.getHttpMethod().name()); // header request-headers @@ -733,7 +727,7 @@ builder.append(name); } } - preflightRequest.setAdditionalHeader(HEADER_ACCESS_CONTROL_REQUEST_HEADERS, builder.toString()); + preflightRequest.setAdditionalHeader(HttpHeader.ACCESS_CONTROL_REQUEST_HEADERS, builder.toString()); // do the preflight request final WebResponse preflightResponse = wc.loadWebResponse(preflightRequest); @@ -755,7 +749,7 @@ } boolean allowOriginResponse = true; if (originHeaderValue != null) { - String value = webResponse.getResponseHeaderValue(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN); + String value = webResponse.getResponseHeaderValue(HttpHeader.ACCESS_CONTROL_ALLOW_ORIGIN); allowOriginResponse = originHeaderValue.equals(value); if (isWithCredentials()) { allowOriginResponse = allowOriginResponse @@ -763,7 +757,7 @@ && ALLOW_ORIGIN_ALL.equals(value)); // second step: check the allow-credentials header for true - value = webResponse.getResponseHeaderValue(HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS); + value = webResponse.getResponseHeaderValue(HttpHeader.ACCESS_CONTROL_ALLOW_CREDENTIALS); allowOriginResponse = allowOriginResponse && Boolean.parseBoolean(value); } else { @@ -847,12 +841,12 @@ } private boolean isPreflightAuthorized(final WebResponse preflightResponse) { - final String originHeader = preflightResponse.getResponseHeaderValue(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN); + final String originHeader = preflightResponse.getResponseHeaderValue(HttpHeader.ACCESS_CONTROL_ALLOW_ORIGIN); if (!ALLOW_ORIGIN_ALL.equals(originHeader) && !webRequest_.getAdditionalHeaders().get(HttpHeader.ORIGIN).equals(originHeader)) { return false; } - String headersHeader = preflightResponse.getResponseHeaderValue(HEADER_ACCESS_CONTROL_ALLOW_HEADERS); + String headersHeader = preflightResponse.getResponseHeaderValue(HttpHeader.ACCESS_CONTROL_ALLOW_HEADERS); if (headersHeader == null) { headersHeader = ""; } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAnchorElement2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAnchorElement2Test.java 2017-12-01 08:40:03 UTC (rev 14984) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAnchorElement2Test.java 2017-12-01 08:42:51 UTC (rev 14985) @@ -977,8 +977,8 @@ secondString = null; body = null; } - assertEquals(firstString, PingServlet.HEADERS_.get("Ping-From")); - assertEquals(secondString, PingServlet.HEADERS_.get("Ping-To")); + assertEquals(firstString, PingServlet.HEADERS_.get(HttpHeader.PING_FROM)); + assertEquals(secondString, PingServlet.HEADERS_.get(HttpHeader.PING_TO)); assertEquals(body, PingServlet.BODY_); } |
From: <rb...@us...> - 2017-12-02 11:44:03
|
Revision: 14987 http://sourceforge.net/p/htmlunit/code/14987 Author: rbri Date: 2017-12-02 11:44:00 +0000 (Sat, 02 Dec 2017) Log Message: ----------- Error.captureStackTrace is not available in FF and IE Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeErrorTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-12-01 08:43:28 UTC (rev 14986) +++ trunk/htmlunit/src/changes/changes.xml 2017-12-02 11:44:00 UTC (rev 14987) @@ -9,6 +9,9 @@ <body> <release version="2.29" date="xx, 2017" description=""> <action type="fix" dev="rbri" issue="1840"> + JavaScript: Error.captureStackTrace is not available in FF and IE. + </action> + <action type="fix" dev="rbri" issue="1840"> JavaScript: location.reload uses the same request method like the original request. </action> <action type="fix" dev="rbri"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-12-01 08:43:28 UTC (rev 14986) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-12-02 11:44:00 UTC (rev 14987) @@ -872,6 +872,10 @@ IE}) JS_ENUM_NUMBERS_FIRST, + /** Javascript {@code Error.captureStackTrace}. */ + @BrowserFeature(CHROME) + JS_ERROR_CAPTURE_STACK_TRACE, + /** Javascript {@code Error.stack}. */ @BrowserFeature({CHROME, FF}) JS_ERROR_STACK, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java 2017-12-01 08:43:28 UTC (rev 14986) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java 2017-12-02 11:44:00 UTC (rev 14987) @@ -15,6 +15,7 @@ package com.gargoylesoftware.htmlunit.javascript; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ARRAY_FROM; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ERROR_CAPTURE_STACK_TRACE; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ERROR_STACK_TRACE_LIMIT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_FUNCTION_TOSOURCE; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_IMAGE_PROTOTYPE_SAME_AS_HTML_IMAGE; @@ -237,6 +238,9 @@ else { ScriptableObject.deleteProperty(errorObject, "stackTraceLimit"); } + if (!browserVersion.hasFeature(JS_ERROR_CAPTURE_STACK_TRACE)) { + ScriptableObject.deleteProperty(errorObject, "captureStackTrace"); + } final Intl intl = new Intl(); intl.setParentScope(window); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeErrorTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeErrorTest.java 2017-12-01 08:43:28 UTC (rev 14986) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeErrorTest.java 2017-12-02 11:44:00 UTC (rev 14987) @@ -250,4 +250,22 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "undefined", + CHROME = "function captureStackTrace() { [native code] }") + public void captureStackTrace() throws Exception { + final String html + = "<html><head><script>\n" + + "function test() {\n" + + " alert(Error.captureStackTrace);\n" + + "}\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2017-12-07 17:06:24
|
Revision: 14993 http://sourceforge.net/p/htmlunit/code/14993 Author: rbri Date: 2017-12-07 17:06:21 +0000 (Thu, 07 Dec 2017) Log Message: ----------- check option cssEnabled before downloading a css file Issue 1935 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClientOptions.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/StyleSheetList.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlLinkTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-12-07 16:34:47 UTC (rev 14992) +++ trunk/htmlunit/src/changes/changes.xml 2017-12-07 17:06:21 UTC (rev 14993) @@ -8,6 +8,9 @@ <body> <release version="2.29" date="xx, 2017" description=""> + <action type="fix" dev="rbri" issue="1935"> + Check option cssEnabled before downloading a css file (regression from 1927). + </action> <action type="fix" dev="rbri" issue="1840"> JavaScript: Error.captureStackTrace is not available in FF and IE. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClientOptions.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClientOptions.java 2017-12-07 16:34:47 UTC (rev 14992) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClientOptions.java 2017-12-07 17:06:21 UTC (rev 14993) @@ -230,6 +230,8 @@ /** * Enables/disables CSS support. By default, this property is enabled. + * If disabled HtmlUnit will not download the linked css files and also + * not triggered the associated onload/onerror events. * * @param enabled {@code true} to enable CSS support */ Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java 2017-12-07 16:34:47 UTC (rev 14992) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java 2017-12-07 17:06:21 UTC (rev 14993) @@ -274,7 +274,8 @@ LOG.debug("Link node added: " + asXml()); } - if (!StyleSheetList.isStyleSheetLink(this)) { + if (!getPage().getWebClient().getOptions().isCssEnabled() + || !StyleSheetList.isStyleSheetLink(this)) { return; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/StyleSheetList.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/StyleSheetList.java 2017-12-07 16:34:47 UTC (rev 14992) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/StyleSheetList.java 2017-12-07 17:06:21 UTC (rev 14993) @@ -128,10 +128,9 @@ setPrototype(getPrototype(getClass())); final WebClient webClient = getWindow().getWebWindow().getWebClient(); - final boolean cssEnabled = webClient.getOptions().isCssEnabled(); - final boolean onlyActive = webClient.getBrowserVersion().hasFeature(JS_STYLESHEETLIST_ACTIVE_ONLY); - if (cssEnabled) { + if (webClient.getOptions().isCssEnabled()) { + final boolean onlyActive = webClient.getBrowserVersion().hasFeature(JS_STYLESHEETLIST_ACTIVE_ONLY); nodes_ = new HTMLCollection(document.getDomNodeOrDie(), true) { @Override protected boolean isMatching(final DomNode node) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlLinkTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlLinkTest.java 2017-12-07 16:34:47 UTC (rev 14992) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlLinkTest.java 2017-12-07 17:06:21 UTC (rev 14993) @@ -14,10 +14,13 @@ */ package com.gargoylesoftware.htmlunit.html; +import java.net.URL; + import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; import com.gargoylesoftware.htmlunit.HttpHeader; import com.gargoylesoftware.htmlunit.SimpleWebTestCase; import com.gargoylesoftware.htmlunit.WebResponse; @@ -48,4 +51,74 @@ assertEquals(page.getUrl().toExternalForm(), respCss.getWebRequest().getAdditionalHeaders().get(HttpHeader.REFERER)); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts("body onLoad") + public void onLoad() throws Exception { + getWebClientWithMockWebConnection().getOptions().setCssEnabled(false); + getMockWebConnection().setResponse(new URL(URL_FIRST, "simple.css"), ""); + + final String html + = "<html>\n" + + "<head>\n" + + " <link rel='stylesheet' href='simple.css' " + + "onload='alert(\"onLoad\")' onerror='alert(\"onError\")'>\n" + + "</head>\n" + + "<body onload='alert(\"body onLoad\")'>\n" + + "</body>\n" + + "</html>"; + + loadPageWithAlerts(html); + assertEquals(1, getMockWebConnection().getRequestCount()); + } + + /** + * @throws Exception if an error occurs + */ + @Test + public void onLoadDynamic() throws Exception { + getWebClientWithMockWebConnection().getOptions().setCssEnabled(false); + getMockWebConnection().setResponse(new URL(URL_FIRST, "simple.css"), ""); + + final String html + = "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " var dynLink = document.createElement('link');\n" + + " dynLink.rel = 'stylesheet';\n" + + " dynLink.type = 'text/css';\n" + + " dynLink.href = 'simple.css';" + + " dynLink.onload = function (e) { log(\"onLoad \" + e) };\n" + + " dynLink.onerror = function (e) { log(\"onError \" + e) };\n" + + " document.head.appendChild(dynLink);\n" + + + " var dynLink = document.createElement('link');\n" + + " dynLink.rel = 'stylesheet';\n" + + " dynLink.type = 'text/css';\n" + + " dynLink.href = 'unknown.css';" + + " dynLink.onload = function (e) { log(\"onLoad \" + e) };\n" + + " dynLink.onerror = function (e) { log(\"onError \" + e) };\n" + + " document.head.appendChild(dynLink);\n" + + " }\n" + + + " function log(x) {\n" + + " document.getElementById('log').value += x + '\\n';\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'></body>\n" + + " <textarea id='log' cols='80' rows='40'></textarea>\n" + + "</body>\n" + + "</html>"; + + final HtmlPage page = loadPageWithAlerts(html); + final String text = page.getElementById("log").getAttribute("value").trim().replaceAll("\r", ""); + assertEquals(String.join("\n", getExpectedAlerts()), text); + + assertEquals(1, getMockWebConnection().getRequestCount()); + } } |
From: <rb...@us...> - 2017-12-11 18:02:01
|
Revision: 14994 http://sourceforge.net/p/htmlunit/code/14994 Author: rbri Date: 2017-12-11 18:01:58 +0000 (Mon, 11 Dec 2017) Log Message: ----------- CanvasGradient.addColorStop() added CanvasRenderingContext2D.createRadialGradient() now returns an CanvasGradient CanvasRenderingContext2D.createLinearGradient() now returns an CanvasGradient Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasGradient.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java Added Paths: ----------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasGradientTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-12-07 17:06:21 UTC (rev 14993) +++ trunk/htmlunit/src/changes/changes.xml 2017-12-11 18:01:58 UTC (rev 14994) @@ -8,6 +8,15 @@ <body> <release version="2.29" date="xx, 2017" description=""> + <action type="add" dev="rbri"> + JavaScript: CanvasGradient.addColorStop() added + </action> + <action type="fix" dev="rbri"> + JavaScript: CanvasRenderingContext2D.createRadialGradient() now returns an CanvasGradient + </action> + <action type="fix" dev="rbri"> + JavaScript: CanvasRenderingContext2D.createLinearGradient() now returns an CanvasGradient + </action> <action type="fix" dev="rbri" issue="1935"> Check option cssEnabled before downloading a css file (regression from 1927). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasGradient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasGradient.java 2017-12-07 17:06:21 UTC (rev 14993) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasGradient.java 2017-12-11 18:01:58 UTC (rev 14994) @@ -21,11 +21,13 @@ import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; /** * A JavaScript object for {@code CanvasGradient}. * * @author Ahmed Ashour + * @author Ronald Brill */ @JsxClass public class CanvasGradient extends SimpleScriptable { @@ -36,4 +38,16 @@ @JsxConstructor({CHROME, FF, EDGE}) public CanvasGradient() { } + + /** + * Adds a new stop, defined by an offset and a color, to the gradient. + * @param offset A number between 0 and 1. An INDEX_SIZE_ERR is raised, + * if the number is not in that range. + * @param color A CSS <color>. A SYNTAX_ERR is raised, if the value + * can not be parsed as a CSS <color> value. + */ + @JsxFunction + public void addColorStop(final double offset, final String color) { + // empty + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java 2017-12-07 17:06:21 UTC (rev 14993) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java 2017-12-11 18:01:58 UTC (rev 14994) @@ -257,11 +257,15 @@ * @param x1 the x1 * @param y1 the y1 * @param r1 the r1 + * @return the new CanvasGradient */ @JsxFunction - public void createLinearGradient(final double x0, final double y0, final double r0, final double x1, + public CanvasGradient createLinearGradient(final double x0, final double y0, final double r0, final double x1, final Object y1, final Object r1) { - //empty + final CanvasGradient canvasGradient = new CanvasGradient(); + canvasGradient.setParentScope(getParentScope()); + canvasGradient.setPrototype(getPrototype(canvasGradient.getClass())); + return canvasGradient; } /** @@ -274,10 +278,21 @@ /** * Creates a gradient. + * @param x0 the x axis of the coordinate of the start circle + * @param y0 the y axis of the coordinate of the start circle + * @param r0 the radius of the start circle + * @param x1 the x axis of the coordinate of the end circle + * @param y1 the y axis of the coordinate of the end circle + * @param r1 the radius of the end circle + * @return the new CanvasGradient */ @JsxFunction - public void createRadialGradient() { - //empty + public CanvasGradient createRadialGradient(final double x0, final double y0, + final double r0, final double x1, final double y1, final double r1) { + final CanvasGradient canvasGradient = new CanvasGradient(); + canvasGradient.setParentScope(getParentScope()); + canvasGradient.setPrototype(getPrototype(canvasGradient.getClass())); + return canvasGradient; } /** Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasGradientTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasGradientTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasGradientTest.java 2017-12-11 18:01:58 UTC (rev 14994) @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2002-2017 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.javascript.host.canvas; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; + +/** + * Unit tests for {@link CanvasGradient}. + * + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class CanvasGradientTest extends WebDriverTestCase { + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts("function") + public void functions() throws Exception { + final String html = + "<html><head><script>\n" + + "function test() {\n" + + " var canvas = document.getElementById('myCanvas');\n" + + " var ctx = canvas.getContext('2d');\n" + + " var gradient = ctx.createRadialGradient(100, 100, 100, 100, 100, 0);\n" + + " alert(typeof gradient.addColorStop);\n" + + "}\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'><canvas id='myCanvas'></canvas></body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts("[object CanvasGradient]") + public void addColorStop() throws Exception { + final String html = + "<html><head><script>\n" + + "function test() {\n" + + " var canvas = document.getElementById('myCanvas');\n" + + " var ctx = canvas.getContext('2d');\n" + + " var gradient = ctx.createRadialGradient(100, 100, 100, 100, 100, 0);\n" + + " gradient.addColorStop(0, 'green');\n" + + " gradient.addColorStop(1, 'white');\n" + + " alert(gradient);\n" + + "}\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'><canvas id='myCanvas'></canvas></body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasGradientTest.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java 2017-12-07 17:06:21 UTC (rev 14993) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java 2017-12-11 18:01:58 UTC (rev 14994) @@ -34,6 +34,7 @@ * @author Ahmed Ashour * @author Marc Guillemot * @author Frank Danek + * @author Ronald Brill */ @RunWith(BrowserRunner.class) public class CanvasRenderingContext2DTest extends WebDriverTestCase { @@ -403,4 +404,46 @@ + "</html>"; loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts("[object CanvasGradient]") + public void createLinearGradient() throws Exception { + final String html = + "<html><head><script>\n" + + "function test() {\n" + + " var canvas = document.getElementById('myCanvas');\n" + + " var ctx = canvas.getContext('2d');\n" + + " var gradient = ctx.createLinearGradient(0, 0, 200, 0);\n" + + " alert(gradient);\n" + + "}\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'><canvas id='myCanvas'></canvas></body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts("[object CanvasGradient]") + public void createRadialGradient() throws Exception { + final String html = + "<html><head><script>\n" + + "function test() {\n" + + " var canvas = document.getElementById('myCanvas');\n" + + " var ctx = canvas.getContext('2d');\n" + + " var gradient = ctx.createRadialGradient(100, 100, 100, 100, 100, 0);\n" + + " alert(gradient);\n" + + "}\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'><canvas id='myCanvas'></canvas></body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2017-12-11 18:07:14
|
Revision: 14995 http://sourceforge.net/p/htmlunit/code/14995 Author: rbri Date: 2017-12-11 18:07:11 +0000 (Mon, 11 Dec 2017) Log Message: ----------- WebClient.setWebStartHandler() and the interface WebStartHandler added. Create your implementation of this interface to support WebStart links. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java Added Paths: ----------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/webstart/ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/webstart/WebStartHandler.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/webstart/package-info.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-12-11 18:01:58 UTC (rev 14994) +++ trunk/htmlunit/src/changes/changes.xml 2017-12-11 18:07:11 UTC (rev 14995) @@ -7,8 +7,12 @@ </properties> <body> - <release version="2.29" date="xx, 2017" description=""> + <release version="2.29" date="xx, 2017" description="Bugfixes, WebStart support"> <action type="add" dev="rbri"> + WebClient.setWebStartHandler() and the interface WebStartHandler added. Create your implementation + of this interface to support WebStart links. + </action> + <action type="add" dev="rbri"> JavaScript: CanvasGradient.addColorStop() added </action> <action type="fix" dev="rbri"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2017-12-11 18:01:58 UTC (rev 14994) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2017-12-11 18:07:11 UTC (rev 14995) @@ -94,6 +94,7 @@ import com.gargoylesoftware.htmlunit.util.Cookie; import com.gargoylesoftware.htmlunit.util.NameValuePair; import com.gargoylesoftware.htmlunit.util.UrlUtils; +import com.gargoylesoftware.htmlunit.webstart.WebStartHandler; import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; @@ -159,6 +160,7 @@ private PromptHandler promptHandler_; private StatusHandler statusHandler_; private AttachmentHandler attachmentHandler_; + private WebStartHandler webStartHandler_; private AppletConfirmHandler appletConfirmHandler_; private AjaxController ajaxController_ = new AjaxController(); @@ -507,6 +509,11 @@ return webWindow.getEnclosedPage(); } + if (webStartHandler_ != null && "application/x-java-jnlp-file".equals(webResponse.getContentType())) { + webStartHandler_.handleJnlpResponse(webResponse); + return webWindow.getEnclosedPage(); + } + if (attachmentHandler_ != null && Attachment.isAttachment(webResponse)) { final WebWindow w = openWindow(null, null, webWindow); final Page page = pageCreator_.createPage(webResponse, w); @@ -1700,6 +1707,22 @@ } /** + * Sets the WebStart handler. + * @param handler the new WebStart handler + */ + public void setWebStartHandler(final WebStartHandler handler) { + webStartHandler_ = handler; + } + + /** + * Returns the current WebStart handler. + * @return the current WebStart handler + */ + public WebStartHandler getWebStartHandler() { + return webStartHandler_; + } + + /** * Sets the applet confirm handler. * @param handler the new applet confirm handler handler */ Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/webstart/WebStartHandler.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/webstart/WebStartHandler.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/webstart/WebStartHandler.java 2017-12-11 18:07:11 UTC (rev 14995) @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2002-2017 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.webstart; + +import com.gargoylesoftware.htmlunit.WebResponse; + +/** + * WebStart support. + * + * @author Ronald Brill + */ +public interface WebStartHandler { + + /** + * Handles the jnlp file response. + * @param webResponse the response to get the jnlp content from + */ + void handleJnlpResponse(WebResponse webResponse); +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/webstart/WebStartHandler.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/webstart/package-info.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/webstart/package-info.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/webstart/package-info.java 2017-12-11 18:07:11 UTC (rev 14995) @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2002-2017 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Miscellaneous utilities. + */ +package com.gargoylesoftware.htmlunit.webstart; Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/webstart/package-info.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property |
From: <rb...@us...> - 2017-12-13 20:47:54
|
Revision: 15004 http://sourceforge.net/p/htmlunit/code/15004 Author: rbri Date: 2017-12-13 20:47:51 +0000 (Wed, 13 Dec 2017) Log Message: ----------- fixes for chrome 63 (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/StyleAttributes.java trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.properties.Chrome.txt trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.properties2.Chrome.txt trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.Chrome.txt trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.notAttached.Chrome.txt Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/StyleAttributes.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/StyleAttributes.java 2017-12-13 20:22:54 UTC (rev 15003) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/StyleAttributes.java 2017-12-13 20:47:51 UTC (rev 15004) @@ -864,7 +864,7 @@ FLOOD_OPACITY_("flood-opacity", "flood-opacity", ff("1")), /** The style property {@code font}. */ - FONT("font", "font", chrome("normal normal normal normal 16px / normal \"Times New Roman\""), ff(""), ie("")), + FONT("font", "font", chrome("normal normal 400 normal 16px / normal \"Times New Roman\""), ff(""), ie("")), /** The style property {@code fontDisplay}. */ FONT_DISPLAY("fontDisplay", "font-display", chrome("")), @@ -907,7 +907,7 @@ FONT_SIZE_ADJUST_("font-size-adjust", "font-size-adjust", ff("none")), /** The style property {@code fontStretch}. */ - FONT_STRETCH("fontStretch", "font-stretch", chrome("normal"), ff("normal"), ie("normal")), + FONT_STRETCH("fontStretch", "font-stretch", chrome("100%"), ff("normal"), ie("normal")), /** The style property {@code font-stretch}. */ FONT_STRETCH_("font-stretch", "font-stretch", ff("normal")), @@ -966,8 +966,11 @@ /** The style property {@code font-variant-position}. */ FONT_VARIANT_POSITION_("font-variant-position", "font-variant-position", ff("normal")), + /** The style property {@code fontVariationSettings}. */ + FONT_VARIATION_SETTING("fontVariationSettings", "font-variation-settings", chrome("normal")), + /** The style property {@code fontWeight}. */ - FONT_WEIGHT("fontWeight", "font-weight", chrome("normal"), ff("400"), ie("400")), + FONT_WEIGHT("fontWeight", "font-weight", chrome("400"), ff("400"), ie("400")), /** The style property {@code font-weight}. */ FONT_WEIGHT_("font-weight", "font-weight", ff("400")), @@ -981,7 +984,7 @@ ie("auto")), /** The style property {@code grid}. */ - GRID("grid", "grid", chrome("none / none / none / row / auto / auto / 0px / 0px"), + GRID("grid", "grid", chrome("none / none / none / row / auto / auto"), ff52up("")), /** The style property {@code gridArea}. */ @@ -2273,6 +2276,15 @@ /** The style property {@code overflow-y}. */ OVERFLOW_Y_("overflow-y", "overflow-y", ff("visible")), + /** The style property {@code overscrollBehavior}. */ + OVERSCROLL_BEHAVIOR("overscrollBehavior", "overscroll-behavior", chrome("auto auto")), + + /** The style property {@code overscrollBehaviorX}. */ + OVERSCROLL_BEHAVIOR_X("overscrollBehaviorX", "overscroll-behavior_x", chrome("auto")), + + /** The style property {@code overscrollBehaviorY}. */ + OVERSCROLL_BEHAVIOR_Y("overscrollBehaviorY", "overscroll-behavior_y", chrome("auto")), + /** The style property {@code padding}. */ PADDING("padding", "padding", chrome("0px"), ff(""), ie("")), @@ -2875,7 +2887,7 @@ UNICODE_RANGE("unicodeRange", "unicode-range", chrome("")), /** The style property {@code userSelect}. */ - USER_SELECT("userSelect", "user-select", chrome("text")), + USER_SELECT("userSelect", "user-select", chrome("auto")), /** The style property {@code userZoom}. */ USER_ZOOM("userZoom", "user-zoom", chrome("")), @@ -3553,7 +3565,7 @@ /** The style property {@code webkitTextEmphasisPosition}. */ WEBKIT_TEXT_EMPHASIS_POSITION("webkitTextEmphasisPosition", "webkit-text-emphasis-position", - chrome("over")), + chrome("over right")), /** The style property {@code webkitTextEmphasisStyle}. */ WEBKIT_TEXT_EMPHASIS_STYLE("webkitTextEmphasisStyle", "webkit-text-emphasis-style", Modified: trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.properties.Chrome.txt =================================================================== --- trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.properties.Chrome.txt 2017-12-13 20:22:54 UTC (rev 15003) +++ trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.properties.Chrome.txt 2017-12-13 20:47:51 UTC (rev 15004) @@ -127,8 +127,10 @@ fontStyle fontVariant fontVariantCaps +fontVariantEastAsian fontVariantLigatures fontVariantNumeric +fontVariationSettings fontWeight grid gridArea @@ -208,6 +210,9 @@ overflowWrap overflowX overflowY +overscrollBehavior +overscrollBehaviorX +overscrollBehaviorY padding paddingBottom paddingLeft Modified: trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.properties2.Chrome.txt =================================================================== --- trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.properties2.Chrome.txt 2017-12-13 20:22:54 UTC (rev 15003) +++ trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration2Test.properties2.Chrome.txt 2017-12-13 20:47:51 UTC (rev 15004) @@ -127,8 +127,10 @@ fontStyle fontVariant fontVariantCaps +fontVariantEastAsian fontVariantLigatures fontVariantNumeric +fontVariationSettings fontWeight grid gridArea @@ -207,6 +209,9 @@ overflowWrap overflowX overflowY +overscrollBehavior +overscrollBehaviorX +overscrollBehaviorY padding paddingBottom paddingLeft Modified: trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.Chrome.txt =================================================================== --- trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.Chrome.txt 2017-12-13 20:22:54 UTC (rev 15003) +++ trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.Chrome.txt 2017-12-13 20:47:51 UTC (rev 15004) @@ -117,20 +117,22 @@ float=:none floodColor=:rgb(0, 0, 0) floodOpacity=:1 -font=:normal normal normal normal 16px / normal "Times New Roman" +font=:normal normal 400 normal 16px / normal "Times New Roman" fontDisplay=: fontFamily=:"Times New Roman" fontFeatureSettings=:normal fontKerning=:auto fontSize=:16px -fontStretch=:normal +fontStretch=:100% fontStyle=:normal fontVariant=:normal fontVariantCaps=:normal +fontVariantEastAsian=:normal fontVariantLigatures=:normal fontVariantNumeric=:normal -fontWeight=:normal -grid=:none / none / none / row / auto / auto / 0px / 0px +fontVariationSettings=:normal +fontWeight=:400 +grid=:none / none / none / row / auto / auto gridArea=:auto / auto / auto / auto gridAutoColumns=:auto gridAutoFlow=:row @@ -207,6 +209,9 @@ overflowWrap=:normal overflowX=:visible overflowY=:visible +overscrollBehavior=:auto auto +overscrollBehaviorX=:auto +overscrollBehaviorY=:auto padding=:0px paddingBottom=:0px paddingLeft=:0px @@ -279,7 +284,7 @@ transitionTimingFunction=:ease unicodeBidi=:normal unicodeRange=: -userSelect=:text +userSelect=:auto userZoom=: vectorEffect=:none verticalAlign=:baseline @@ -374,7 +379,7 @@ webkitTextDecorationsInEffect=:none webkitTextEmphasis=: webkitTextEmphasisColor=:rgb(0, 0, 0) -webkitTextEmphasisPosition=:over +webkitTextEmphasisPosition=:over right webkitTextEmphasisStyle=:none webkitTextFillColor=:rgb(0, 0, 0) webkitTextOrientation=:vertical-right Modified: trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.notAttached.Chrome.txt =================================================================== --- trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.notAttached.Chrome.txt 2017-12-13 20:22:54 UTC (rev 15003) +++ trunk/htmlunit/src/test/resources/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.notAttached.Chrome.txt 2017-12-13 20:47:51 UTC (rev 15004) @@ -127,8 +127,10 @@ fontStyle=: fontVariant=: fontVariantCaps=: +fontVariantEastAsian=: fontVariantLigatures=: fontVariantNumeric=: +fontVariationSettings=: fontWeight=: grid=: gridArea=: @@ -207,6 +209,9 @@ overflowWrap=: overflowX=: overflowY=: +overscrollBehavior=: +overscrollBehaviorX=: +overscrollBehaviorY=: padding=: paddingBottom=: paddingLeft=: |
From: <rb...@us...> - 2017-12-13 21:11:30
|
Revision: 15005 http://sourceforge.net/p/htmlunit/code/15005 Author: rbri Date: 2017-12-13 21:11:28 +0000 (Wed, 13 Dec 2017) Log Message: ----------- fixes for chrome 63 (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-12-13 20:47:51 UTC (rev 15004) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-12-13 21:11:28 UTC (rev 15005) @@ -967,11 +967,11 @@ JS_IMAGE_PROTOTYPE_SAME_AS_HTML_IMAGE, /** - * Getting the width and height of an image tag without a source returns 18x20; - * for invalid values returns 1. + * Getting the width and height of an image tag without a source returns 16x16; + * for invalid values returns 0. */ @BrowserFeature(CHROME) - JS_IMAGE_WIDTH_HEIGHT_RETURNS_0x0_0x0, + JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0, /** * Getting the width and height of an image tag without a source returns 18x20; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java 2017-12-13 20:47:51 UTC (rev 15004) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java 2017-12-13 21:11:28 UTC (rev 15005) @@ -16,7 +16,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ALIGN_ACCEPTS_ARBITRARY_VALUES; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_IMAGE_WIDTH_HEIGHT_RETURNS_24x24_0x0; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_IMAGE_WIDTH_HEIGHT_RETURNS_0x0_0x0; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_IMAGE_WIDTH_HEIGHT_RETURNS_28x30_28x30; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE; @@ -28,6 +28,7 @@ import java.util.Locale; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.xml.sax.helpers.AttributesImpl; import com.gargoylesoftware.htmlunit.BrowserVersion; @@ -239,31 +240,37 @@ } final String src = img.getSrcAttribute(); - if (DomElement.ATTRIBUTE_NOT_DEFINED != src) { - try { - return img.getWidth(); + if (DomElement.ATTRIBUTE_NOT_DEFINED == src) { + final BrowserVersion browserVersion = getBrowserVersion(); + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_28x30_28x30)) { + return 28; } - catch (final IOException e) { - final BrowserVersion browserVersion = getBrowserVersion(); - if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_28x30_28x30)) { - return 28; - } - if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_0x0_0x0)) { - return 0; - } - return 24; + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0) + || browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_24x24_0x0)) { + return 0; } + return 24; } final BrowserVersion browserVersion = getBrowserVersion(); - if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_28x30_28x30)) { - return 28; - } - if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_0x0_0x0) - || browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_24x24_0x0)) { + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0) + && !StringUtils.isEmpty(src) + && StringUtils.isBlank(src)) { return 0; } - return 24; + + try { + return img.getWidth(); + } + catch (final IOException e) { + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_28x30_28x30)) { + return 28; + } + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0)) { + return 16; + } + return 24; + } } /** @@ -295,31 +302,37 @@ } final String src = img.getSrcAttribute(); - if (DomElement.ATTRIBUTE_NOT_DEFINED != src) { - try { - return img.getHeight(); + if (DomElement.ATTRIBUTE_NOT_DEFINED == src) { + final BrowserVersion browserVersion = getBrowserVersion(); + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_28x30_28x30)) { + return 30; } - catch (final IOException e) { - final BrowserVersion browserVersion = getBrowserVersion(); - if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_28x30_28x30)) { - return 30; - } - if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_0x0_0x0)) { - return 0; - } - return 24; + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0) + || browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_24x24_0x0)) { + return 0; } + return 24; } final BrowserVersion browserVersion = getBrowserVersion(); - if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_28x30_28x30)) { - return 30; - } - if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_0x0_0x0) - || browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_24x24_0x0)) { + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0) + && !StringUtils.isEmpty(src) + && StringUtils.isBlank(src)) { return 0; } - return 24; + + try { + return img.getHeight(); + } + catch (final IOException e) { + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_28x30_28x30)) { + return 30; + } + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0)) { + return 16; + } + return 24; + } } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java 2017-12-13 20:47:51 UTC (rev 15004) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java 2017-12-13 21:11:28 UTC (rev 15005) @@ -547,7 +547,7 @@ webConnection.setResponse(URL_SECOND, directBytes, 200, "ok", "image/jpg", emptyList); } - loadPageWithAlerts2(html); + loadPageWithAlerts2(html, 70000); } /** |
From: <rb...@us...> - 2017-12-13 21:19:03
|
Revision: 15006 http://sourceforge.net/p/htmlunit/code/15006 Author: rbri Date: 2017-12-13 21:19:00 +0000 (Wed, 13 Dec 2017) Log Message: ----------- fixes for chrome 63 (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-12-13 21:11:28 UTC (rev 15005) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-12-13 21:19:00 UTC (rev 15006) @@ -1101,7 +1101,7 @@ JS_NODE_INSERT_BEFORE_REF_OPTIONAL, /** Children are enumerated. */ - @BrowserFeature({CHROME, IE}) + @BrowserFeature(IE) JS_NODE_LIST_ENUMERATE_CHILDREN, /** Functions are enumerated. */ Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java 2017-12-13 21:11:28 UTC (rev 15005) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java 2017-12-13 21:19:00 UTC (rev 15006) @@ -547,7 +547,7 @@ webConnection.setResponse(URL_SECOND, directBytes, 200, "ok", "image/jpg", emptyList); } - loadPageWithAlerts2(html, 70000); + loadPageWithAlerts2(html); } /** |
From: <rb...@us...> - 2017-12-14 07:21:59
|
Revision: 15008 http://sourceforge.net/p/htmlunit/code/15008 Author: rbri Date: 2017-12-14 07:21:56 +0000 (Thu, 14 Dec 2017) Log Message: ----------- Crypto.subtle added Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/Crypto.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/SubtleCrypto.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/CryptoTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-12-13 21:33:09 UTC (rev 15007) +++ trunk/htmlunit/src/changes/changes.xml 2017-12-14 07:21:56 UTC (rev 15008) @@ -8,6 +8,9 @@ <body> <release version="2.29" date="xx, 2017" description="Bugfixes, WebStart support"> + <action type="add" dev="rbri" issue="1936"> + JavaScript: Crypto.subtle added + </action> <action type="add" dev="rbri"> WebClient.setWebStartHandler() and the interface WebStartHandler added. Create your implementation of this interface to support WebStart links. Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/Crypto.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/Crypto.java 2017-12-13 21:33:09 UTC (rev 15007) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/Crypto.java 2017-12-14 07:21:56 UTC (rev 15008) @@ -24,6 +24,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.host.Window; import com.gargoylesoftware.htmlunit.javascript.host.arrays.ArrayBufferViewBase; @@ -34,6 +35,7 @@ * * @author Ahmed Ashour * @author Marc Guillemot + * @author Ronald Brill */ @JsxClass public class Crypto extends SimpleScriptable { @@ -70,4 +72,17 @@ array.put(i, array, random.nextInt()); } } + + /** + * Returns the {@code subtle} property. + * @return the {@code stuble} property + */ + @JsxGetter({CHROME, FF}) + public SubtleCrypto getSubtle() { + final SubtleCrypto stuble = new SubtleCrypto(); + final Window window = getWindow(); + stuble.setParentScope(window); + stuble.setPrototype(window.getPrototype(SubtleCrypto.class)); + return stuble; + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/SubtleCrypto.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/SubtleCrypto.java 2017-12-13 21:33:09 UTC (rev 15007) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/SubtleCrypto.java 2017-12-14 07:21:56 UTC (rev 15008) @@ -26,6 +26,7 @@ * A JavaScript object for {@code SubtleCrypto}. * * @author Ahmed Ashour + * @author Ronald Brill */ @JsxClass public class SubtleCrypto extends SimpleScriptable { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/CryptoTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/CryptoTest.java 2017-12-13 21:33:09 UTC (rev 15007) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/crypto/CryptoTest.java 2017-12-14 07:21:56 UTC (rev 15008) @@ -25,6 +25,7 @@ * Tests for {@link Crypto}. * * @author Marc Guillemot + * @author Ronald Brill */ @RunWith(BrowserRunner.class) public class CryptoTest extends WebDriverTestCase { @@ -48,4 +49,21 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "[object SubtleCrypto]", + IE = "exception") + public void subtle() throws Exception { + final String html = "<html><head><script>\n" + + "try {\n" + + " alert(window.crypto.subtle);\n" + + "}\n" + + "catch(e) { alert('exception'); }\n" + + "</script></head></html>"; + + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2017-12-14 09:58:36
|
Revision: 15009 http://sourceforge.net/p/htmlunit/code/15009 Author: rbri Date: 2017-12-14 09:58:33 +0000 (Thu, 14 Dec 2017) Log Message: ----------- fixes for chrome 63 (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-12-14 07:21:56 UTC (rev 15008) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-12-14 09:58:33 UTC (rev 15009) @@ -186,7 +186,7 @@ // FF52 FIREFOX_52.applicationVersion_ = "5.0 (Windows)"; FIREFOX_52.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0"; - FIREFOX_52.buildId_ = "20170921064520"; + FIREFOX_52.buildId_ = "20171206101620"; FIREFOX_52.productSub_ = "20100101"; FIREFOX_52.headerNamesOrdered_ = new String[] { HttpHeader.HOST, @@ -382,25 +382,19 @@ // flush plugin (windows version) PluginConfiguration flash = new PluginConfiguration("Shockwave Flash", - "Shockwave Flash 24.0 r0", "undefined", "internal-not-yet-present"); + "Shockwave Flash 28.0 r0", "28.0.0.126", "NPSWF32_28_0_0_126.dll"); flash.getMimeTypes().add(new PluginConfiguration.MimeType("application/x-shockwave-flash", "Shockwave Flash", "swf")); - CHROME.plugins_.add(flash); - - flash = new PluginConfiguration("Shockwave Flash", - "Shockwave Flash 27.0 r0", "27.0.0.183", "NPSWF32_27_0_0_183.dll"); - flash.getMimeTypes().add(new PluginConfiguration.MimeType("application/x-shockwave-flash", - "Shockwave Flash", "swf")); FIREFOX_45.plugins_.add(flash); flash = new PluginConfiguration("Shockwave Flash", - "Shockwave Flash 27.0 r0", "27.0.0.183", "NPSWF64_27_0_0_183.dll"); + "Shockwave Flash 28.0 r0", "28.0.0.126", "NPSWF64_28_0_0_126.dll"); flash.getMimeTypes().add(new PluginConfiguration.MimeType("application/x-shockwave-flash", "Shockwave Flash", "swf")); FIREFOX_52.plugins_.add(flash); flash = new PluginConfiguration("Shockwave Flash", - "Shockwave Flash 27.0 r0", "27.0.0.183", "Flash32_27_0_0_183.ocx"); + "Shockwave Flash 28.0 r0", "28.0.0.126", "Flash32_28_0_0_126.ocx"); flash.getMimeTypes().add(new PluginConfiguration.MimeType("application/x-shockwave-flash", "Shockwave Flash", "swf")); INTERNET_EXPLORER.plugins_.add(flash); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java 2017-12-14 07:21:56 UTC (rev 15008) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java 2017-12-14 09:58:33 UTC (rev 15009) @@ -216,10 +216,10 @@ * @throws Exception on test failure */ @Test - @Alerts(FF45 = {"Shockwave Flash", "Shockwave Flash 27.0 r0", "27.0.0.183", "NPSWF32_27_0_0_183.dll"}, - FF52 = {"Shockwave Flash", "Shockwave Flash 27.0 r0", "27.0.0.183", "NPSWF64_27_0_0_183.dll"}, - CHROME = {"Shockwave Flash", "Shockwave Flash 24.0 r0", "undefined", "internal-not-yet-present"}, - IE = {"Shockwave Flash", "Shockwave Flash 27.0 r0", "27.0.0.183", "Flash32_27_0_0_183.ocx"}, + @Alerts(FF45 = {"Shockwave Flash", "Shockwave Flash 28.0 r0", "28.0.0.126", "NPSWF32_28_0_0_126.dll"}, + FF52 = {"Shockwave Flash", "Shockwave Flash 28.0 r0", "28.0.0.126", "NPSWF64_28_0_0_126.dll"}, + CHROME = "Shockwave Flash not available", + IE = {"Shockwave Flash", "Shockwave Flash 28.0 r0", "28.0.0.126", "Flash32_28_0_0_126.ocx"}, EDGE = {"Shockwave Flash", "Shockwave Flash 18.0 r0", "18.0.0.232", "Flash.ocx"}) public void pluginsShockwaveFlash() throws Exception { final String html = "<html>\n" @@ -227,9 +227,11 @@ + " <title>test</title>\n" + " <script>\n" + " function doTest() {\n" + + " var flash = false;\n" + " for (var i = 0; i < window.navigator.plugins.length; i++) {\n" + " var plugin = window.navigator.plugins[i];\n" + " if ('Shockwave Flash' == window.navigator.plugins[i].name) {\n" + + " flash = true;\n" + " alert(plugin.name);\n" + " alert(plugin.description);\n" + " alert(plugin.version);\n" @@ -236,6 +238,9 @@ + " alert(plugin.filename);\n" + " }\n" + " }\n" + + " if (!flash) {\n" + + " alert('Shockwave Flash not available');\n" + + " }\n" + " }\n" + " </script>\n" + "</head>\n" @@ -382,7 +387,7 @@ @Test @Alerts(DEFAULT = "undefined", FF45 = "20170411115307", - FF52 = "20170921064520") + FF52 = "20171206101620") public void buildID() throws Exception { final String html = "<html><head><title>First</title>\n" |
From: <rb...@us...> - 2017-12-15 20:14:47
|
Revision: 15015 http://sourceforge.net/p/htmlunit/code/15015 Author: rbri Date: 2017-12-15 20:14:44 +0000 (Fri, 15 Dec 2017) Log Message: ----------- fixes for chrome 63 (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFrameSetElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java 2017-12-15 18:49:58 UTC (rev 15014) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java 2017-12-15 20:14:44 UTC (rev 15015) @@ -475,7 +475,7 @@ * Returns the {@code onafterprint} event handler for this element. * @return the {@code onafterprint} event handler for this element */ - @JsxGetter({FF, IE}) + @JsxGetter public Function getOnafterprint() { return getEventHandler("afterprint"); } @@ -484,7 +484,7 @@ * Sets the {@code onafterprint} event handler for this element. * @param onafterprint the {@code onafterprint} event handler for this element */ - @JsxSetter({FF, IE}) + @JsxSetter public void setOnafterprint(final Object onafterprint) { setEventHandler("afterprint", onafterprint); } @@ -493,7 +493,7 @@ * Returns the {@code onbeforeprint} event handler for this element. * @return the {@code onbeforeprint} event handler for this element */ - @JsxGetter({FF, IE}) + @JsxGetter public Function getOnbeforeprint() { return getEventHandler("beforeprint"); } @@ -502,7 +502,7 @@ * Sets the {@code onbeforeprint} event handler for this element. * @param onbeforeprint the {@code onbeforeprint} event handler for this element */ - @JsxSetter({FF, IE}) + @JsxSetter public void setOnbeforeprint(final Object onbeforeprint) { setEventHandler("beforeprint", onbeforeprint); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFrameSetElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFrameSetElement.java 2017-12-15 18:49:58 UTC (rev 15014) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFrameSetElement.java 2017-12-15 20:14:44 UTC (rev 15015) @@ -388,7 +388,7 @@ * Returns the {@code onafterprint} event handler. * @return the {@code onafterprint} event handler */ - @JsxGetter({FF, IE}) + @JsxGetter public Function getOnafterprint() { return getEventHandler("afterprint"); } @@ -397,7 +397,7 @@ * Sets the {@code onafterprint} event handler. * @param afterprint the {@code onafterprint} event handler */ - @JsxSetter({FF, IE}) + @JsxSetter public void setOnafterprint(final Object afterprint) { setEventHandler("afterprint", afterprint); } @@ -406,7 +406,7 @@ * Returns the {@code onbeforeprint} event handler. * @return the {@code onbeforeprint} event handler */ - @JsxGetter({FF, IE}) + @JsxGetter public Function getOnbeforeprint() { return getEventHandler("beforeprint"); } @@ -415,7 +415,7 @@ * Sets the {@code onbeforeprint} event handler. * @param beforeprint the {@code onbeforeprint} event handler */ - @JsxSetter({FF, IE}) + @JsxSetter public void setOnbeforeprint(final Object beforeprint) { setEventHandler("beforeprint", beforeprint); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java 2017-12-15 18:49:58 UTC (rev 15014) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java 2017-12-15 20:14:44 UTC (rev 15015) @@ -712,7 +712,7 @@ + "createImageBitmap(),crypto,devicePixelRatio,dispatchEvent(),document,dump()," + "external,fetch(),find()," + "focus(),frameElement,frames,fullScreen,getComputedStyle(),getDefaultComputedStyle()," - + "getSelection(),history,ieMethods,indexedDB,innerHeight,innerWidth," + + "getSelection(),history,indexedDB,innerHeight,innerWidth," + "InstallTrigger,length,localStorage,location,locationbar,matchMedia(),menubar,moveBy(),moveTo()," + "mozInnerScreenX,mozInnerScreenY,mozPaintCount,name,navigator,onabort," + "onafterprint,onbeforeprint,onbeforeunload,onblur," |
From: <rb...@us...> - 2017-12-16 10:39:14
|
Revision: 15016 http://sourceforge.net/p/htmlunit/code/15016 Author: rbri Date: 2017-12-16 10:39:12 +0000 (Sat, 16 Dec 2017) Log Message: ----------- fixes for chrome 63 (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAudioElementTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-12-15 20:14:44 UTC (rev 15015) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-12-16 10:39:12 UTC (rev 15016) @@ -401,7 +401,7 @@ HTMLIMAGE_BLANK_SRC_AS_EMPTY, /** Empty src attribute sets display to false. */ - @BrowserFeature(FF52) + @BrowserFeature({IE, FF52}) HTMLIMAGE_EMPTY_SRC_DISPLAY_FALSE, /** Is document.cretaeElement('image') an HTMLElement. */ Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2017-12-15 20:14:44 UTC (rev 15015) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2017-12-16 10:39:12 UTC (rev 15016) @@ -663,11 +663,19 @@ @Override public boolean isDisplayed() { final String src = getSrcAttribute(); - if (hasFeature(HTMLIMAGE_INVISIBLE_NO_SRC) - && (ATTRIBUTE_NOT_DEFINED == src - || (hasFeature(HTMLIMAGE_BLANK_SRC_AS_EMPTY) && StringUtils.isBlank(src)) - || (hasFeature(HTMLIMAGE_EMPTY_SRC_DISPLAY_FALSE) && StringUtils.isEmpty(src)))) { - return false; + if (hasFeature(HTMLIMAGE_INVISIBLE_NO_SRC)) { + if (ATTRIBUTE_NOT_DEFINED == src) { + return false; + } + if (StringUtils.isEmpty(src)) { + if (hasFeature(HTMLIMAGE_EMPTY_SRC_DISPLAY_FALSE)) { + return false; + } + return true; + } + if (hasFeature(HTMLIMAGE_BLANK_SRC_AS_EMPTY) && StringUtils.isBlank(src)) { + return false; + } } return super.isDisplayed(); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAudioElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAudioElementTest.java 2017-12-15 20:14:44 UTC (rev 15015) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAudioElementTest.java 2017-12-16 10:39:12 UTC (rev 15016) @@ -326,10 +326,9 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "probably", - FF45 = "", - FF = "maybe", - IE = "") + @Alerts(DEFAULT = "", + CHROME = "probably", + FF52 = "maybe") @NotYetImplemented({CHROME, FF52}) public void canPlayType_AudioFlac() throws Exception { canPlayType("audio/flac"); |
From: <rb...@us...> - 2017-12-16 10:50:34
|
Revision: 15017 http://sourceforge.net/p/htmlunit/code/15017 Author: rbri Date: 2017-12-16 10:50:32 +0000 (Sat, 16 Dec 2017) Log Message: ----------- fixes for chrome 63 (wip) Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-12-16 10:39:12 UTC (rev 15016) +++ trunk/htmlunit/src/changes/changes.xml 2017-12-16 10:50:32 UTC (rev 15017) @@ -7,7 +7,7 @@ </properties> <body> - <release version="2.29" date="xx, 2017" description="Bugfixes, WebStart support"> + <release version="2.29" date="xx, 2017" description="Bugfixes, Chrome 63, WebStart support"> <action type="add" dev="rbri" issue="1936"> JavaScript: Crypto.subtle added </action> Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java 2017-12-16 10:39:12 UTC (rev 15016) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java 2017-12-16 10:50:32 UTC (rev 15017) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF; import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; @@ -27,10 +28,10 @@ import org.openqa.selenium.WebDriver; import com.gargoylesoftware.htmlunit.BrowserRunner; -import com.gargoylesoftware.htmlunit.HttpHeader; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; import com.gargoylesoftware.htmlunit.BrowserRunner.BuggyWebDriver; import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; +import com.gargoylesoftware.htmlunit.HttpHeader; import com.gargoylesoftware.htmlunit.HttpMethod; import com.gargoylesoftware.htmlunit.MockWebConnection; import com.gargoylesoftware.htmlunit.WebDriverTestCase; @@ -195,6 +196,7 @@ @Test @Alerts(DEFAULT = {"#%C3%BC%C3%B6%C3%A4", "§§URL§§#%C3%BC%C3%B6%C3%A4"}, IE = {"#üöä", "§§URL§§#üöä"}) + @NotYetImplemented(CHROME) public void hashEncoding3() throws Exception { final String html = "<html><body><script>\n" + "window.location.hash = 'üöä';\n" |
From: <rb...@us...> - 2017-12-18 16:54:33
|
Revision: 15019 http://sourceforge.net/p/htmlunit/code/15019 Author: rbri Date: 2017-12-18 16:54:30 +0000 (Mon, 18 Dec 2017) Log Message: ----------- fixes for chrome 63 (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfWTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImage2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2017-12-17 14:46:58 UTC (rev 15018) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2017-12-18 16:54:30 UTC (rev 15019) @@ -667,15 +667,10 @@ if (ATTRIBUTE_NOT_DEFINED == src) { return false; } - if (StringUtils.isEmpty(src)) { - if (hasFeature(HTMLIMAGE_EMPTY_SRC_DISPLAY_FALSE)) { - return false; - } - return true; - } if (hasFeature(HTMLIMAGE_BLANK_SRC_AS_EMPTY) && StringUtils.isBlank(src)) { return false; } + return !(hasFeature(HTMLIMAGE_EMPTY_SRC_DISPLAY_FALSE) && StringUtils.isEmpty(src)); } return super.isDisplayed(); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java 2017-12-17 14:46:58 UTC (rev 15018) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java 2017-12-18 16:54:30 UTC (rev 15019) @@ -253,9 +253,7 @@ } final BrowserVersion browserVersion = getBrowserVersion(); - if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0) - && !StringUtils.isEmpty(src) - && StringUtils.isBlank(src)) { + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0) && StringUtils.isBlank(src)) { return 0; } @@ -315,9 +313,7 @@ } final BrowserVersion browserVersion = getBrowserVersion(); - if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0) - && !StringUtils.isEmpty(src) - && StringUtils.isBlank(src)) { + if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0) && StringUtils.isBlank(src)) { return 0; } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfWTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfWTest.java 2017-12-17 14:46:58 UTC (rev 15018) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfWTest.java 2017-12-18 16:54:30 UTC (rev 15019) @@ -289,6 +289,16 @@ * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = "false", + CHROME = "true") + public void _WebKitCSSMatrix_DOMMatrix() throws Exception { + test("WebKitCSSMatrix", "DOMMatrix"); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(DEFAULT = "true", IE = "false", FF45 = "false") Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImage2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImage2Test.java 2017-12-17 14:46:58 UTC (rev 15018) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImage2Test.java 2017-12-18 16:54:30 UTC (rev 15019) @@ -151,6 +151,7 @@ */ @Test @Alerts(DEFAULT = "true", + CHROME = "false", FF52 = "false") public void isDisplayedEmptySource() throws Exception { isDisplayed("src=''"); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java 2017-12-17 14:46:58 UTC (rev 15018) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java 2017-12-18 16:54:30 UTC (rev 15019) @@ -472,7 +472,6 @@ */ @Test @Alerts(DEFAULT = {"number: 300", "number: 200", "number: 0", "number: 0", "number: 0", "number: 0"}, - CHROME = {"number: 300", "number: 200", "number: 16", "number: 16", "number: 16", "number: 16"}, FF45 = {"number: 300", "number: 200", "number: 24", "number: 24", "number: 24", "number: 24"}, IE = {"number: 300", "number: 200", "number: 28", "number: 30", "number: 28", "number: 30"}) @NotYetImplemented(FF52) @@ -506,7 +505,7 @@ webConnection.setResponse(URL_SECOND, directBytes, 200, "ok", "image/jpg", emptyList); } - loadPageWithAlerts2(html); + loadPageWithAlerts2(html, 70000); } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java 2017-12-17 14:46:58 UTC (rev 15018) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java 2017-12-18 16:54:30 UTC (rev 15019) @@ -244,6 +244,7 @@ */ @Test @Alerts(DEFAULT = "Thursday, December 20, 2012, GMT", + CHROME = "Thursday, December 20, 2012, UTC", IE = "\u200EThursday\u200E, \u200EDecember\u200E \u200E20\u200E, \u200E2012") @NotYetImplemented public void format_utc_short() throws Exception { |
From: <rb...@us...> - 2017-12-18 19:34:50
|
Revision: 15020 http://sourceforge.net/p/htmlunit/code/15020 Author: rbri Date: 2017-12-18 19:34:48 +0000 (Mon, 18 Dec 2017) Log Message: ----------- fixes for chrome 63 (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfWTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImage2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-12-18 16:54:30 UTC (rev 15019) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-12-18 19:34:48 UTC (rev 15020) @@ -239,8 +239,8 @@ EDGE.userAgent_ = "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"; // CHROME - CHROME.applicationVersion_ = "5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"; - CHROME.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"; + CHROME.applicationVersion_ = "5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36"; + CHROME.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36"; CHROME.applicationCodeName_ = "Mozilla"; CHROME.vendor_ = "Google Inc."; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2017-12-18 16:54:30 UTC (rev 15019) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2017-12-18 19:34:48 UTC (rev 15020) @@ -670,7 +670,9 @@ if (hasFeature(HTMLIMAGE_BLANK_SRC_AS_EMPTY) && StringUtils.isBlank(src)) { return false; } - return !(hasFeature(HTMLIMAGE_EMPTY_SRC_DISPLAY_FALSE) && StringUtils.isEmpty(src)); + if (hasFeature(HTMLIMAGE_EMPTY_SRC_DISPLAY_FALSE) && StringUtils.isEmpty(src)) { + return false; + } } return super.isDisplayed(); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfWTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfWTest.java 2017-12-18 16:54:30 UTC (rev 15019) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfWTest.java 2017-12-18 19:34:48 UTC (rev 15020) @@ -291,6 +291,7 @@ @Test @Alerts(DEFAULT = "false", CHROME = "true") + @NotYetImplemented(CHROME) public void _WebKitCSSMatrix_DOMMatrix() throws Exception { test("WebKitCSSMatrix", "DOMMatrix"); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImage2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImage2Test.java 2017-12-18 16:54:30 UTC (rev 15019) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImage2Test.java 2017-12-18 19:34:48 UTC (rev 15020) @@ -185,6 +185,15 @@ isDisplayed("src='" + URL_FIRST + "'"); } + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts("false") + public void isDisplayedDisplayNone() throws Exception { + isDisplayed("src='img.jpg' style='display: none'"); + } + private void isDisplayed(final String src) throws Exception { try (InputStream is = getClass().getClassLoader().getResourceAsStream("testfiles/tiny-jpg.img")) { final byte[] directBytes = IOUtils.toByteArray(is); |