Fixes Issue #1235.
Refreshing after a change and recompile would cause an app to not load as
the GWT app would not properly start. This fixes that issue by avoiding
some iframe behavioral oddities on Safari and IE.
Review by: jgw, scottb
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1237 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/util/SelectionScriptTemplate-xs.js b/dev/core/src/com/google/gwt/dev/util/SelectionScriptTemplate-xs.js
index 8a1ab4d..2820309 100644
--- a/dev/core/src/com/google/gwt/dev/util/SelectionScriptTemplate-xs.js
+++ b/dev/core/src/com/google/gwt/dev/util/SelectionScriptTemplate-xs.js
@@ -276,7 +276,7 @@
$doc.removeEventListener("DOMContentLoaded", onBodyDone, false);
}
if (onBodyDoneTimerId) {
- clearInterval(onBodyDoneTimerId);
+ clearInterval(onBodyDoneTimerId);
}
}
}
@@ -328,28 +328,31 @@
;
$wnd.onresize = function(evt) {
- resize();
- if (oldOnResize)
- oldOnResize(evt);
+ try {
+ resize();
+ } finally {
+ oldOnResize && oldOnResize(evt);
+ }
};
$wnd.onbeforeunload = function(evt) {
- var ret = beforeunload();
-
- var oldRet;
- if (oldOnBeforeUnload)
- oldRet = oldOnBeforeUnload(evt);
-
- if (ret !== null)
- return ret;
- return oldRet;
+ var ret, oldRet;
+ try {
+ ret = beforeunload();
+ } finally {
+ oldRet = oldOnBeforeUnload && oldOnBeforeUnload(evt);
+ }
+ // We should never return null as IE6 will coerce it into a string.
+ return ret || oldRet || undefined;
};
$wnd.onunload = function(evt) {
- unload();
- if (oldOnUnload)
- oldOnUnload(evt);
+ try {
+ unload();
+ } finally {
+ oldOnUnload && oldOnUnload(evt);
+ }
};
-}
+};
__MODULE_FUNC__();
diff --git a/dev/core/src/com/google/gwt/dev/util/SelectionScriptTemplate.js b/dev/core/src/com/google/gwt/dev/util/SelectionScriptTemplate.js
index 86fa6df..0d1570d 100644
--- a/dev/core/src/com/google/gwt/dev/util/SelectionScriptTemplate.js
+++ b/dev/core/src/com/google/gwt/dev/util/SelectionScriptTemplate.js
@@ -317,7 +317,7 @@
$doc.removeEventListener("DOMContentLoaded", onBodyDone, false);
}
if (onBodyDoneTimerId) {
- clearInterval(onBodyDoneTimerId);
+ clearInterval(onBodyDoneTimerId);
}
}
}
@@ -350,7 +350,14 @@
strongName += '.cache.html';
}
- $doc.write('<iframe id="__MODULE_NAME__" style="width:0;height:0;border:0" src="' + base + strongName + '"></iframe>');
+ $doc.write('<iframe id="__MODULE_NAME__" style="width:0;height:0;border:0" src="javascript:\'\'"></iframe>');
+ var iframe = $doc.getElementById('__MODULE_NAME__');
+
+ // The true src cannot be included in the tag that is emitted with $doc.write,
+ // because Safari and IE will reload outdated cache.html files and fail to
+ // load.
+ iframe.src = base + strongName;
+
// __MODULE_DEPS_BEGIN__
// Module dependencies, such as scripts and css
// __MODULE_DEPS_END__
@@ -376,28 +383,31 @@
;
$wnd.onresize = function(evt) {
- resize();
- if (oldOnResize)
- oldOnResize(evt);
+ try {
+ resize();
+ } finally {
+ oldOnResize && oldOnResize(evt);
+ }
};
$wnd.onbeforeunload = function(evt) {
- var ret = beforeunload();
-
- var oldRet;
- if (oldOnBeforeUnload)
- oldRet = oldOnBeforeUnload(evt);
-
- if (ret !== null)
- return ret;
- return oldRet;
+ var ret, oldRet;
+ try {
+ ret = beforeunload();
+ } finally {
+ oldRet = oldOnBeforeUnload && oldOnBeforeUnload(evt);
+ }
+ // We should never return null as IE6 will coerce it into a string.
+ return ret || oldRet || undefined;
};
$wnd.onunload = function(evt) {
- unload();
- if (oldOnUnload)
- oldOnUnload(evt);
+ try {
+ unload();
+ } finally {
+ oldOnUnload && oldOnUnload(evt);
+ }
};
-}
+};
__MODULE_FUNC__();