Revision: 6249 Author: [email protected] Date: Tue Sep 29 12:15:40 2009 Log: Fixing a failing test because FF3.5 allows cross-site XHR requests.
Patch by: jlabanca Review by: rjrjr http://code.google.com/p/google-web-toolkit/source/detail?r=6249 Modified: /trunk/user/test/com/google/gwt/http/client/RequestBuilderTest.java ======================================= --- /trunk/user/test/com/google/gwt/http/client/RequestBuilderTest.java Thu Jul 30 13:47:31 2009 +++ /trunk/user/test/com/google/gwt/http/client/RequestBuilderTest.java Tue Sep 29 12:15:40 2009 @@ -45,6 +45,25 @@ return ua.indexOf("webkit") != -1; }-*/; + /** + * HACK: Part of a work around for FF 3.5's failure to throw an exception when + * an XmlHttpRequest that violates the same origin policy is made. + */ + private static native boolean isFirefox35() /*-{ + var ua = navigator.userAgent.toLowerCase(); + if (ua.indexOf("gecko") == -1) { + return false; + } + var result = /firefox\/([0-9]+\.[0-9]+)/.exec(ua.toLowerCase()); + if (result && result.length == 2) { + var version = parseFloat(result[1]); + if (version >= 3.5) { + return true; + } + } + return false; + }-*/; + @Override public String getModuleName() { return "com.google.gwt.http.RequestBuilderTest"; @@ -109,13 +128,17 @@ } }); - if (isSafari()) { + if (isSafari() || isFirefox35()) { /* * HACK: Safari 2.0.4 will not throw an exception for XHR's that violate * the same-origin policy. It appears to silently ignore them so we do * not fail this test if we are on Safari and the * RequestPermissionException is not thrown. Even though Safari 3.0.4 * does throw an exception in this case, we exclude it anyway. + * + * FF3.5 allows XHR's to violate the same-origin policy and offers no + * way to disable the feature from the client. Only the server can block + * the same origin policy. */ } else { /* --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
