Revision: 9567
Author: p...@google.com
Date: Wed Jan 19 05:47:41 2011
Log: 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
http://code.google.com/p/google-web-toolkit/source/detail?r=9567
Added:
/trunk/user/test/com/google/gwt/dom/public-test/iframetest.html
Modified:
/trunk/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java
/trunk/user/test/com/google/gwt/dom/client/FrameTests.java
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/dom/public-test/iframetest.html Wed Jan
19 05:47:41 2011
@@ -0,0 +1,5 @@
+<html>
+<body>
+IFRAME TEST
+</body>
+</html>
=======================================
--- /trunk/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java Tue
Jun 22 06:26:45 2010
+++ /trunk/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java Wed
Jan 19 05:47:41 2011
@@ -30,6 +30,9 @@
@SuppressWarnings("unused")
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) ?
=======================================
--- /trunk/user/test/com/google/gwt/dom/client/FrameTests.java Wed Oct 28
09:10:53 2009
+++ /trunk/user/test/com/google/gwt/dom/client/FrameTests.java Wed Jan 19
05:47:41 2011
@@ -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);
+ }
+}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors