Reviewers: jat,

Description:
Description:
============
In hosted.html, getTopWindow() reaches up to the very top opener, which
is sometimes too far.  For example, when running selenium tests, the top
window is the selenium host page (a local file).  The window we actually
want is the child that selenium creates, which has our hosted url.

Fix:
===
We now check that we can access location.href of the opener before
walking up each level.  If we cannot access location.href, then the
opener is outside of the scope of the GWT app and we stop walking.

Testing:
=======
I verified that this allows me to run hosted selenium tests with FF3.5.

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

Affected files:
   dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html


Index: dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html
===================================================================
--- dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html        
(revision  
6380)
+++ dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html        
(working  
copy)
@@ -30,7 +30,16 @@
  function getTopWindow() {
    var topWin = window.top;
    while (topWin.opener) {
-    topWin = topWin.opener.top;
+    // Check that we can access the url of the opener. If we can't, then  
return
+    // the window up to the current point. This happens with selenium  
because
+    // the parent window is a file, but the child window is the hosted URL.
+    var nextTopWin = topWin.opener.top;
+    try {
+      nextTopWin.location.href;
+    } catch (e) {
+      return topWin;
+    }
+    topWin = nextTopWin;
    }
    return topWin;
  }



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

Reply via email to