IE8 issues with wpm RPC mechanism
---------------------------------
Key: SHINDIG-1108
URL: https://issues.apache.org/jira/browse/SHINDIG-1108
Project: Shindig
Issue Type: Bug
Components: Javascript
Affects Versions: trunk
Environment: IE8 build 6001
Reporter: Paul Lindner
Assignee: Paul Lindner
Fix For: trunk
Testing the latest rpc code we found that IE8 was having big problems.
Specifically:
window.postMessage is an object, not a function and
window.attachEvent needs to be used instead of window.addEventListener
A simple patch is as follows:
===================================================================
--- features/src/main/javascript/features/rpc/rpc.js (revision 790359)
+++ features/src/main/javascript/features/rpc/rpc.js (working copy)
@@ -119,6 +119,7 @@
*/
function getTransport() {
return typeof window.postMessage === 'function' ? gadgets.rpctx.wpm :
+ typeof window.postMessage === 'object' ? gadgets.rpctx.wpm :
window.ActiveXObject ? gadgets.rpctx.nix :
navigator.userAgent.indexOf('WebKit') > 0 ? gadgets.rpctx.rmr :
navigator.product === 'Gecko' ? gadgets.rpctx.frameElement :
Index: features/src/main/javascript/features/rpc/wpm.transport.js
===================================================================
--- features/src/main/javascript/features/rpc/wpm.transport.js (revision
790359)
+++ features/src/main/javascript/features/rpc/wpm.transport.js (working copy)
@@ -56,11 +56,17 @@
init: function(processFn, readyFn) {
ready = readyFn;
- // Set up native postMessage handler.
- window.addEventListener('message', function(packet) {
+ var onmessage = function(packet) {
// TODO validate packet.domain for security reasons
processFn(gadgets.json.parse(packet.data));
- }, false);
+ };
+
+ // Set up native postMessage handler.
+ if (typeof window.addEventListener != 'undefined') {
+ window.addEventListener('message', onmessage, false);
+ } else if (typeof window.attachEvent != 'undefined') {
+ window.attachEvent('onmessage', onmessage);
+ }
ready('..', true); // Immediately ready to send to parent.
return true;
},
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.