Fix bug on IE where onload events don't fire for IFrames.
This is a bugfix for http://code.google.com/p/google-web-toolkit/issues/detail?id=1720
Review at http://gwt-code-reviews.appspot.com/1294801
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9567 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java b/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java
index 7bed0d0..ae763d6 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java
@@ -31,6 +31,9 @@
private static JavaScriptObject callDispatchDblClickEvent;
@SuppressWarnings("unused")
+ private static JavaScriptObject callDispatchOnLoadEvent;
+
+ @SuppressWarnings("unused")
private static JavaScriptObject callDispatchUnhandledEvent;
/**
@@ -168,11 +171,14 @@
$wnd['__gwt_dispatchEvent_' + moduleName] = dispatchEvent;
@com.google.gwt.user.client.impl.DOMImplTrident::callDispatchEvent = new Function('w',
'return function() { w.__gwt_dispatchEvent_' + moduleName + '.call(this) }')($wnd);
-
+
+ @com.google.gwt.user.client.impl.DOMImplTrident::callDispatchOnLoadEvent = new Function('w',
+ 'return function() { w.__gwt_dispatchEvent_' + moduleName + '.call(w.event.srcElement) }')($wnd);
+
$wnd['__gwt_dispatchDblClickEvent_' + moduleName] = dispatchDblClickEvent;
@com.google.gwt.user.client.impl.DOMImplTrident::callDispatchDblClickEvent = new Function('w',
'return function() { w.__gwt_dispatchDblClickEvent_' + moduleName + '.call(this)}')($wnd);
-
+
$wnd['__gwt_dispatchUnhandledEvent_' + moduleName] = dispatchUnhandledEvent;
@com.google.gwt.user.client.impl.DOMImplTrident::callDispatchUnhandledEvent = new Function('w',
'return function() { w.__gwt_dispatchUnhandledEvent_' + moduleName + '.call(this)}')($wnd);
@@ -268,8 +274,13 @@
@com.google.gwt.user.client.impl.DOMImplTrident::callDispatchEvent : null;
if (chMask & 0x04000) elem.onscroll = (bits & 0x04000) ?
@com.google.gwt.user.client.impl.DOMImplTrident::callDispatchEvent : null;
- if (chMask & 0x08000) elem.onload = (bits & 0x08000) ?
- @com.google.gwt.user.client.impl.DOMImplTrident::callDispatchUnhandledEvent : null;
+ if (chMask & 0x08000) {
+ if (bits & 0x08000) {
+ elem.attachEvent('onload', @com.google.gwt.user.client.impl.DOMImplTrident::callDispatchOnLoadEvent);
+ } else {
+ elem.detachEvent('onload', @com.google.gwt.user.client.impl.DOMImplTrident::callDispatchOnLoadEvent);
+ }
+ }
if (chMask & 0x10000) elem.onerror = (bits & 0x10000) ?
@com.google.gwt.user.client.impl.DOMImplTrident::callDispatchEvent : null;
if (chMask & 0x20000) elem.onmousewheel = (bits & 0x20000) ?
diff --git a/user/test/com/google/gwt/dom/client/FrameTests.java b/user/test/com/google/gwt/dom/client/FrameTests.java
index 183ea9d..76d93d6 100644
--- a/user/test/com/google/gwt/dom/client/FrameTests.java
+++ b/user/test/com/google/gwt/dom/client/FrameTests.java
@@ -16,12 +16,14 @@
package com.google.gwt.dom.client;
import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.ui.Frame;
+import com.google.gwt.user.client.ui.RootPanel;
/**
* Tests for the FrameElement and IFrameElement classes.
*/
public class FrameTests extends GWTTestCase {
-
@Override
public String getModuleName() {
return "com.google.gwt.dom.DOMTest";
@@ -34,4 +36,23 @@
doc.getBody().appendChild(iframe);
assertNotNull(iframe.getContentDocument());
}
+
+ public void testOnloadEventFires() {
+ int delayMillis = 3000;
+ delayTestFinish(delayMillis);
+
+ Frame frame = new Frame() {
+ @Override
+ public void onBrowserEvent(Event event) {
+ if (event.getTypeInt() == Event.ONLOAD) {
+ super.onBrowserEvent(event);
+ finishTest();
+ }
+ }
+ };
+
+ frame.sinkEvents(Event.ONLOAD);
+ frame.setUrl("iframetest.html");
+ RootPanel.get().add(frame);
+ }
}
diff --git a/user/test/com/google/gwt/dom/public-test/iframetest.html b/user/test/com/google/gwt/dom/public-test/iframetest.html
new file mode 100644
index 0000000..4eb5342
--- /dev/null
+++ b/user/test/com/google/gwt/dom/public-test/iframetest.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+IFRAME TEST
+</body>
+</html>
\ No newline at end of file