It turns out that Safari 2.0.4 does not throw an exception when an XHR violates the same-origin policy.  As a matter of fact, it appears to do nothing.  The test will no longer fail if an XHR on a Safari browser fails to generate a same-origin policy violation.

Review by: jgw (desk check)

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2003 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/test/com/google/gwt/http/client/RequestBuilderTest.java b/user/test/com/google/gwt/http/client/RequestBuilderTest.java
index ccfeaec..bedda28 100644
--- a/user/test/com/google/gwt/http/client/RequestBuilderTest.java
+++ b/user/test/com/google/gwt/http/client/RequestBuilderTest.java
@@ -28,6 +28,16 @@
     return GWT.getModuleBaseURL() + "testRequestBuilder/";
   }
 
+  /**
+   * HACK: Part of a work around for Safari 2.0.4's failure to throw an
+   * exception when an XmlHttpRequest that violates the same origin policy is
+   * made.
+   */
+  private static native boolean isSafari() /*-{
+    var ua = navigator.userAgent.toLowerCase();
+    return ua.indexOf("webkit") != -1; 
+  }-*/;
+
   @Override
   public String getModuleName() {
     return "com.google.gwt.http.RequestBuilderTest";
@@ -90,7 +100,22 @@
           // should never get here
         }
       });
-      fail("Expected RequestPermissionException");
+
+      if (isSafari()) {
+        /*
+         * 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.
+         */
+      } else {
+        /*
+         * All other supported browsers throw an exception for XHR's that
+         * violate the same-origin policy; fail the test if we get here.
+         */
+        fail("Expected RequestPermissionException");
+      }
     } catch (IllegalArgumentException ex) {
       // purposely ignored
     } catch (RequestPermissionException ex) {