Hi GWT Team; I implemented the following method described in this
tutorial on cross-site scripting using JSONP in my GWT application:
http://code.google.com/webtoolkit/doc/latest/tutorial/Xsite.html

Unfortunately, I found that the following code from the tutorial has
unexpected consequences on IE8 and the JavaScript function run by the
setTimeout() never completes:

   // [2] Define the callback function on the window object.
   window[callback] = function(jsonObj) {
   // [3]
 
handl...@com.google.gwt.sample.stockwatcher.client.stockwatcher::handleJsonResponse(Lcom/
google/gwt/core/client/JavaScriptObject;)(jsonObj);
     window[callback + "done"] = true;
   }

   // [4] JSON download has 1-second timeout.
   setTimeout(function() {
     if (!window[callback + "done"]) {
 
handl...@com.google.gwt.sample.stockwatcher.client.stockwatcher::handleJsonResponse(Lcom/
google/gwt/core/client/JavaScriptObject;)(null);
     }

     // [5] Cleanup. Remove script and callback elements.
     document.body.removeChild(script);
     delete window[callback];
     delete window[callback + "done"];
   }, 1000);

Calling delete on window[callback], throws an error in IE8, the reason
being that window[callback] is (perhaps mistakenly) treated as a
property of a Global object which can't be deleted. The last line,
delete window[callback+"done"], never gets executed and the window[]
array grows over time. Chrome doesn't seem to have the same problem.
The best description I've found of the problem with the delete
operator and the inconsistencies between browsers is here:
http://perfectionkills.com/understanding-delete/

So I would like to suggest that this tutorial be modified, as in its
current form it causes a rather significant 'memory leak' (i.e. the
size of the window[] array grows the more you use it) in IE - whether
or not the implementation of the delete operator in IE is correct,
it's what's out there. I myself am going to look into re-implementing
my app with JsonpRequestBuilder. Perhaps the tutorial code could be re-
written using the splice() function to remove the objects from the
array, but it seems it would be quite a pain to find the numerical
index.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to