From 4fbcc9b1f20e6190126ebfd40b17f186b86e84c7 Mon Sep 17 00:00:00 2001 From: "edburns%acm.org" Date: Fri, 31 Aug 2007 15:05:19 +0000 Subject: [PATCH] M dist/mcp-test/src/test/java/immosearch/ImmoSearchTest.java - Be more resiliant to changes in what the server sends back via ajax M dist/netbeans/build.xml M dist/netbeans/webclient.properties M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java Added copyProxySettingsIfNecessary() to copy the proxy settings from the java system properties into the firefox properties format documented at http://developer.mozilla.org/en/docs/Mozilla_Embedding_FAQ:How_do_I...#How_do_I_set_the_network_proxy.3F git-svn-id: svn://10.0.0.236/trunk@233489 18797224-902f-48f8-a5cc-f745e15eee43 --- .../test/java/immosearch/ImmoSearchTest.java | 56 +++++----- mozilla/java/dist/netbeans/build.xml | 19 ++++ .../java/dist/netbeans/webclient.properties | 3 + .../wrapper_native/WrapperFactoryImpl.java | 105 +++++++++++++++++- 4 files changed, 157 insertions(+), 26 deletions(-) diff --git a/mozilla/java/dist/mcp-test/src/test/java/immosearch/ImmoSearchTest.java b/mozilla/java/dist/mcp-test/src/test/java/immosearch/ImmoSearchTest.java index ddeb424f2c8..c7597177965 100644 --- a/mozilla/java/dist/mcp-test/src/test/java/immosearch/ImmoSearchTest.java +++ b/mozilla/java/dist/mcp-test/src/test/java/immosearch/ImmoSearchTest.java @@ -1,5 +1,5 @@ /* - * $Id: ImmoSearchTest.java,v 1.3 2007-06-26 12:39:01 edburns%acm.org Exp $ + * $Id: ImmoSearchTest.java,v 1.4 2007-08-31 15:05:18 edburns%acm.org Exp $ */ /* @@ -93,32 +93,38 @@ public class ImmoSearchTest extends WebclientTestCase { String responseText = (String) eventMap.get("responseText"); - // Test the first autocomplete response: - if (-1 != responseText.indexOf("8400 Winterthur") && - -1 != responseText.indexOf("8200 Schaffhausen") && - -1 != responseText.indexOf("8500 Frauenfeld") && - -1 != responseText.indexOf("8610 Uster") && - -1 != responseText.indexOf("8280 Kreuzlingen") && - -1 != responseText.indexOf("8050 Z\u00fcrich") && - -1 != responseText.indexOf("8645 Jona") && - -1 != responseText.indexOf("8600 D\u00fcbendorf") && - -1 != responseText.indexOf("8810 Horgen") && - -1 != responseText.indexOf("8700 K\u00fcsnacht ZH")) { + // Test the first autocomplete response. + + // Score the response. The response must have at least 5 + // of the following ten Postleitzahls. + int plzScore = 0; + plzScore += (-1 != responseText.indexOf("8400 Winterthur")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8200 Schaffhausen")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8500 Frauenfeld")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8610 Uster")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8280 Kreuzlingen")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8050 Z\\u00fcrich")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8645 Jona")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8600 D\\u00fcbendorf")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8810 Horgen")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8700 K\\u00fcsnacht ZH")) ? 1 : 0; + if (5 < plzScore) { bitSet.flip(TestFeature.HAS_VALID_FIRST_AUTOCOMPLETE_RESPONSE.ordinal()); } - if (-1 != responseText.indexOf("8050 Z\u00fcrich") && - -1 != responseText.indexOf("8032 Z\u00fcrich") && - -1 != responseText.indexOf("8049 Z\u00fcrich") && - -1 != responseText.indexOf("8048 Z\u00fcrich") && - -1 != responseText.indexOf("8006 Z\u00fcrich") && - -1 != responseText.indexOf("8057 Z\u00fcrich") && - -1 != responseText.indexOf("8004 Z\u00fcrich") && - -1 != responseText.indexOf("8008 Z\u00fcrich") && - -1 != responseText.indexOf("8046 Z\u00fcrich") && - -1 != responseText.indexOf("8051 Z\u00fcrich")) { + plzScore = 0; + plzScore += (-1 != responseText.indexOf("8050 Z\\u00fcrich")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8032 Z\\u00fcrich")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8049 Z\\u00fcrich")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8048 Z\\u00fcrich")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8006 Z\\u00fcrich")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8057 Z\\u00fcrich")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8004 Z\\u00fcrich")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8008 Z\\u00fcrich")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8046 Z\\u00fcrich")) ? 1 : 0; + plzScore += (-1 != responseText.indexOf("8051 Z\\u00fcrich")) ? 1 : 0; + + if (5 < plzScore) { bitSet.flip(TestFeature.HAS_VALID_SECOND_AUTOCOMPLETE_RESPONSE.ordinal()); - - } if (bitSet.get(TestFeature.HAS_VALID_FIRST_AUTOCOMPLETE_RESPONSE.ordinal()) || bitSet.get(TestFeature.HAS_VALID_SECOND_AUTOCOMPLETE_RESPONSE.ordinal())) { @@ -192,7 +198,7 @@ public class ImmoSearchTest extends WebclientTestCase { null != readyState && readyState.equals("4")); String responseText = (String) eventMap.get("responseText"); - if (-1 != responseText.indexOf("8050 Z\u00fcrich")) { + if (-1 != responseText.indexOf("8050 Z\\u00fcrich")) { bitSet.set(TestFeature.STOP_WAITING.ordinal(), true); } diff --git a/mozilla/java/dist/netbeans/build.xml b/mozilla/java/dist/netbeans/build.xml index 75a62f1cd81..59132b31dbf 100755 --- a/mozilla/java/dist/netbeans/build.xml +++ b/mozilla/java/dist/netbeans/build.xml @@ -216,6 +216,9 @@ ${so.prefix}xul.${so.extension}. + + + @@ -226,6 +229,9 @@ ${so.prefix}xul.${so.extension}. + + + @@ -276,6 +282,9 @@ ${so.prefix}xul.${so.extension}. + + + @@ -288,6 +297,9 @@ ${so.prefix}xul.${so.extension}. + + + @@ -312,6 +324,10 @@ ${so.prefix}xul.${so.extension}. + + + + @@ -327,6 +343,9 @@ ${so.prefix}xul.${so.extension}. + + + diff --git a/mozilla/java/dist/netbeans/webclient.properties b/mozilla/java/dist/netbeans/webclient.properties index d6768adaa02..747d43338ae 100755 --- a/mozilla/java/dist/netbeans/webclient.properties +++ b/mozilla/java/dist/netbeans/webclient.properties @@ -13,6 +13,9 @@ #debug.jvm.args=-Xdebug -Xrunjdwp:transport=dt_shmem,address=jdbconn,server=y,suspend=y # test.browser.url=http://jazoon.com/ +# http.proxyHost=webcache.east.sun.com +# http.proxyPort=8080 +# http.nonProxyHosts=".sfbay.sun.com|.east.sun.com|.central.sun.com" # END optional modifications diff --git a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java index 9d71dbb4d1f..056a5ee256e 100644 --- a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java +++ b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java @@ -23,6 +23,9 @@ package org.mozilla.webclient.impl.wrapper_native; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import org.mozilla.util.Assert; @@ -107,7 +110,6 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory { protected boolean terminated = false; protected CountDownLatch oneCountLatch = null; - // Relationship Instance Variables private NativeEventThread eventThread = null; // OWNER @@ -180,6 +182,9 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory { }); browserControls.put(result, new Integer(nativeBrowserControl)); + if (1 == browserControls.size()) { + copyProxySettingsIfNecessary(); + } return result; } @@ -421,6 +426,104 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory { } + private enum ProxyEnum { + httpProxyHost, + httpProxyPort, + httpNonProxyHosts, + ftpProxyHost, + ftpProxyPort, + ftpNonProxyHosts, + socksProxyHost, + socksProxyPort, + sslProxyHost, + sslProxyPort, + gopherProxyHost, + gopherProxyPort + } + + private static final List ProxyPropNames; + + static { ProxyPropNames = new ArrayList(); + ProxyPropNames.add(new String [] { "http.proxyHost", "network.proxy.http"}); + ProxyPropNames.add(new String [] { "http.proxyPort", "network.proxy.http_port"}); + ProxyPropNames.add(new String [] { "http.nonProxyHosts", "network.proxy.no_proxies_on"}); + ProxyPropNames.add(new String [] { "ftp.proxyHost", "network.proxy.ftp"}); + ProxyPropNames.add(new String [] { "ftp.proxyPort", "network.proxy.ftp_port"}); + ProxyPropNames.add(new String [] { "ftp.nonProxyHosts", ""}); + ProxyPropNames.add(new String [] { "socksProxyHost", "network.proxy.socks"}); + ProxyPropNames.add(new String [] { "socksProxyPort", "network.proxy.socks_port"}); + ProxyPropNames.add(new String [] { "ssl.proxyHost", "network.proxy.ssl" }); + ProxyPropNames.add(new String [] { "ssl.proxyPort", "network.proxy.ssl_port" }); + ProxyPropNames.add(new String [] { "gopher.proxyHost", "network.proxy.gopher" }); + ProxyPropNames.add(new String [] { "gopher.proxyPort", "network.proxy.gopher_port" }); + } + + private static final int Java = 0; + private static final int Mozilla = 1; + + private static final String [] JavaProxyPropertyValues = new String[ProxyPropNames.size()]; + + public void copyProxySettingsIfNecessary() { + assert(ProxyEnum.values().length == ProxyPropNames.size()); + + Properties props = System.getProperties(); + int i = 0, len = ProxyPropNames.size(); + // get proxy related property values from the System Properties + for (i = 0; i < len; i++) { + JavaProxyPropertyValues[i] = props.getProperty(ProxyPropNames.get(i)[Java]); + } + // If there are any network related properties in the System Properties... + if (null != JavaProxyPropertyValues[ProxyEnum.httpProxyHost.ordinal()] || + null != JavaProxyPropertyValues[ProxyEnum.ftpProxyHost.ordinal()] || + null != JavaProxyPropertyValues[ProxyEnum.socksProxyHost.ordinal()] || + null != JavaProxyPropertyValues[ProxyEnum.sslProxyHost.ordinal()] || + null != JavaProxyPropertyValues[ProxyEnum.gopherProxyHost.ordinal()]) { + // turn on manual property configuration. + prefs.setPref("network.proxy.type", "1"); + } + + // If the only proxy related property that is set is the http proxy host... + if (null != JavaProxyPropertyValues[ProxyEnum.httpProxyHost.ordinal()] && + null == JavaProxyPropertyValues[ProxyEnum.ftpProxyHost.ordinal()] && + null == JavaProxyPropertyValues[ProxyEnum.socksProxyHost.ordinal()] && + null == JavaProxyPropertyValues[ProxyEnum.sslProxyHost.ordinal()] && + null == JavaProxyPropertyValues[ProxyEnum.gopherProxyHost.ordinal()]) { + // make sure the rest of the protocols share the http proxy settings + prefs.setPref("network.proxy.share_proxy_settings", "true"); + } + + String val = null; + ProxyEnum proxyType; + len = ProxyEnum.values().length; + for (i = 0; i < len; i++) { + proxyType = ProxyEnum.values()[i]; + // If the current proxy property is a hostname property... + if (proxyType.toString().endsWith("Host")) { + // If there is a value for this hostname property, (ie http.proxyHost) + if (null != (val = JavaProxyPropertyValues[proxyType.ordinal()])) { + prefs.setPref(ProxyPropNames.get(proxyType.ordinal())[Mozilla], val); + // If there is no port specified for this host... + if (null == (val = JavaProxyPropertyValues[proxyType.ordinal() + 1])) { + // Use 80, per the Sun Documentation + val = "80"; + } + prefs.setPref(ProxyPropNames.get(proxyType.ordinal() + 1)[Mozilla], val); + } + // If this is the http proxy host... + if (proxyType.toString().equals("httpProxyHost")) { + // and there is a "no proxy for these http hosts" + if (null != + (val = JavaProxyPropertyValues[ProxyEnum.httpNonProxyHosts.ordinal()])) { + val = val.replaceAll("[|]", ","); + // Set the appropriate mozilla pref. + prefs.setPref(ProxyPropNames.get(ProxyEnum.httpNonProxyHosts.ordinal())[Mozilla], + val); + } + } + } + } + } + public void verifyInitialized() throws IllegalStateException { if (!initialized) {