Fixes a bug in Window where the __gwt_initWindowHandler function was being obfuscated before it was added to the outer window. This patch sets the name after the obfuscation occurs to ensure it is correct.
Patch by: jlabanca
Review by: jgw
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@3556 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/Window.java b/user/src/com/google/gwt/user/client/Window.java
index ee1575c..646d77e 100644
--- a/user/src/com/google/gwt/user/client/Window.java
+++ b/user/src/com/google/gwt/user/client/Window.java
@@ -584,7 +584,7 @@
* string representation of the function that has the syntax of the function.
*/
private static native String getInitHandlerMethodString() /*-{
- return function __gwt_initWindowHandlers(resize, scroll, beforeunload, unload) {
+ return function(resize, scroll, beforeunload, unload) {
var wnd = window
, oldOnResize = wnd.onresize
, oldOnBeforeUnload = wnd.onbeforeunload
@@ -662,9 +662,13 @@
private static void maybeInitializeHandlers() {
if (GWT.isClient() && !handlersAreInitialized) {
+ handlersAreInitialized = true;
+
// Embed the init script on the page
ScriptElement scriptElem = Document.get().createScriptElement();
- scriptElem.setText(getInitHandlerMethodString());
+ String initFunc = getInitHandlerMethodString().replaceFirst("function",
+ "function __gwt_initWindowHandlers");
+ scriptElem.setText(initFunc);
Document.get().getBody().appendChild(scriptElem);
// Initialize the handlers
@@ -672,7 +676,6 @@
// Remove the init script from the page
RootPanel.getBodyElement().removeChild(scriptElem);
- handlersAreInitialized = true;
}
}