Fix Window.Location.getHash() for Mozilla so that it returns the unescaped hash, consistent with other platforms.

Review by: jlabanca@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10807 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/Window.gwt.xml b/user/src/com/google/gwt/user/Window.gwt.xml
index 1351b1b..21b9abd 100644
--- a/user/src/com/google/gwt/user/Window.gwt.xml
+++ b/user/src/com/google/gwt/user/Window.gwt.xml
@@ -20,6 +20,10 @@
   <inherits name="com.google.gwt.core.Core"/>
   <inherits name="com.google.gwt.user.UserAgent"/>
 
+  <replace-with class="com.google.gwt.user.client.impl.WindowImplMozilla">
+    <when-type-is class="com.google.gwt.user.client.impl.WindowImpl"/>
+    <when-property-is name="user.agent" value="gecko1_8"/>
+  </replace-with>
    <replace-with class="com.google.gwt.user.client.impl.WindowImplIE">
       <when-type-is class="com.google.gwt.user.client.impl.WindowImpl"/>
       <any>
diff --git a/user/src/com/google/gwt/user/client/impl/WindowImplMozilla.java b/user/src/com/google/gwt/user/client/impl/WindowImplMozilla.java
new file mode 100644
index 0000000..f1cd82d
--- /dev/null
+++ b/user/src/com/google/gwt/user/client/impl/WindowImplMozilla.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011 Google 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.google.gwt.user.client.impl;
+
+/**
+ * Mozilla implementation of {@link com.google.gwt.user.client.impl.WindowImpl}.
+ */
+public class WindowImplMozilla extends WindowImpl {
+
+  /**
+   * For Mozilla, reading from $wnd.location.hash decodes the fragment.
+   * https://bugzilla.mozilla.org/show_bug.cgi?id=483304
+   * https://bugzilla.mozilla.org/show_bug.cgi?id=135309
+   * To avoid this bug, we use location.href instead.
+   */
+  @Override
+  public native String getHash() /*-{
+    var href = $wnd.location.href;
+    var hashLoc = href.indexOf("#");
+    return (hashLoc > 0) ? href.substring(hashLoc) : "";
+  }-*/;
+
+}
diff --git a/user/test/com/google/gwt/user/client/WindowTest.java b/user/test/com/google/gwt/user/client/WindowTest.java
index ca21f4d..51c798c 100644
--- a/user/test/com/google/gwt/user/client/WindowTest.java
+++ b/user/test/com/google/gwt/user/client/WindowTest.java
@@ -74,7 +74,7 @@
     // Use History to get the #hash part of the url into a known state (if the
     // url has somehow been set to http://host/#, location.hash returns the
     // empty string, but location.href includes the trailing hash).
-    History.newItem("foo");
+    History.newItem("foo bar");
 
     // As we have no control over these values we cannot assert much about them.
     String hash = Window.Location.getHash();