Reviewers: rjrjr,

Description:
If you add a WindowClosingHandler to a GWT app and the user changes the
hash code manually (types a new hash code into URL bar), IE will
continuously prompt the user to leave the page until the user finally
clicks OK.  HistoryImplIE6 uses a timer to continuously check the hash
code for changes.  In the above example, the hash code changes, but
since the user cancels the action, the internal historyToken is never
updated.  As a result, the mismatch between the internal historyToken
and the hash code in the URL bar remains until the user presses OK.

This patch marks a boolean when we catch a change in the hash code.  If
the timer fires again, we check the boolean and assume the user canceled
the page transition, so we reset the hash code back to the last value on
the history stack.  Normally, the page is reloaded, which clears out the
boolean before the timer fires again.

This issue has more detailed and a link to an external example:
http://code.google.com/p/google-web-toolkit/issues/detail?id=3492



Please review this at http://gwt-code-reviews.appspot.com/33810

Affected files:
   user/src/com/google/gwt/user/client/impl/HistoryImplIE6.java


Index: user/src/com/google/gwt/user/client/impl/HistoryImplIE6.java
===================================================================
--- user/src/com/google/gwt/user/client/impl/HistoryImplIE6.java        
(revision  
5348)
+++ user/src/com/google/gwt/user/client/impl/HistoryImplIE6.java        
(working  
copy)
@@ -64,6 +64,9 @@

    protected Element historyFrame;

+  @SuppressWarnings("unused")
+  private boolean reloadedWindow;
+
    @Override
    public boolean init() {
      historyFrame = findHistoryFrame();
@@ -131,6 +134,16 @@
      var historyImplRef = this;
      var urlChecker = function() {
        $wnd.setTimeout(urlChecker, 250);
+
+      // Reset the hash if the user cancels a window reload triggered by  
the
+      // urlChecker.
+      if  
([email protected]::reloadedWindow)
  
{
+         
[email protected]::reloadedWindow  
= false;
+        var historyToken =  
@com.google.gwt.user.client.impl.HistoryImpl::getToken()();
+         
[email protected]::updateHash(Ljava/lang/String;)(historyToken);
+        return;
+      }
+
        var hash =  
@com.google.gwt.user.client.impl.HistoryImplIE6::getLocationHash()();
        if (hash.length > 0) {
          var token = '';
@@ -139,11 +152,13 @@
          } catch (e) {
            // If there's a bad hash, always reload. This could only happen  
if
            // if someone entered or linked to a bad url.
+           
[email protected]::reloadedWindow  
= true;
            $wnd.location.reload();
          }

          var historyToken =  
@com.google.gwt.user.client.impl.HistoryImpl::getToken()();
          if (historyToken && (token != historyToken)) {
+           
[email protected]::reloadedWindow  
= true;
            $wnd.location.reload();
          }
        }



--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to