You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by li...@apache.org on 2010/09/15 03:40:15 UTC

svn commit: r997163 [35/37] - in /shindig/trunk/features/src/main/javascript/features: caja/ com.google.gadgets.analytics/ container/ core.config/ core.io/ core.json/ core.legacy/ core.log/ core.prefs/ core.util/ dynamic-height.util/ dynamic-height/ fl...

Modified: shindig/trunk/features/src/main/javascript/features/osapi/batch.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi/batch.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi/batch.js (original)
+++ shindig/trunk/features/src/main/javascript/features/osapi/batch.js Wed Sep 15 01:39:49 2010
@@ -42,16 +42,16 @@
 
     /**
      * Create a new request in the batch
-     * @param {string} key id for the request
+     * @param {string} key id for the request.
      * @param {Object} request the opensocial request object which is of the form
      * { method : <service-method>
      *   rpc  : <request>
      *   transport : <rpc dispatcher>
-     * }
+     * }.
      */
     var add = function(key, request) {
       if (request && key) {
-        keyedRequests.push({"key" : key, "request" : request});
+        keyedRequests.push({'key' : key, 'request' : request});
       }
       return that;
     };
@@ -61,7 +61,7 @@
      * @param {Object} request
      */
     var toJsonRpc = function(request) {
-      var jsonRpc = {method : request.request.method, id : request.key};
+      var jsonRpc = {method: request.request.method, id: request.key};
       if (request.request.rpc) {
         jsonRpc.params = request.request.rpc;
       }
@@ -75,7 +75,7 @@
      *
      * @param {function(Object)} userCallback the callback to the gadget where results are passed.
      */
-    var execute =  function(userCallback) {
+    var execute = function(userCallback) {
       var batchResult = {};
 
       var perTransportBatch = {};
@@ -133,7 +133,7 @@
 
       // Force the callback to occur asynchronously even if there were no actual calls
       if (latchCount == 0) {
-        window.setTimeout(function(){userCallback(batchResult)}, 0);
+        window.setTimeout(function() {userCallback(batchResult)}, 0);
       }
     };
 

Modified: shindig/trunk/features/src/main/javascript/features/osapi/gadgetsrpctransport.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi/gadgetsrpctransport.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi/gadgetsrpctransport.js (original)
+++ shindig/trunk/features/src/main/javascript/features/osapi/gadgetsrpctransport.js Wed Sep 15 01:39:49 2010
@@ -28,15 +28,15 @@ if (gadgets && gadgets.rpc) { //Dont bin
      * Execute the JSON-RPC batch of gadgets.rpc. The container is expected to implement
      * the method osapi._handleGadgetRpcMethod(<JSON-RPC batch>)
      *
-     * @param {Object} requests the opensocial JSON-RPC request batch
+     * @param {Object} requests the opensocial JSON-RPC request batch.
      * @param {function(Object)} callback to the osapi batch with either an error response or
-     * a JSON-RPC batch result
+     * a JSON-RPC batch result.
      * @private
      */
     function execute(requests, callback) {
-        var rpcCallback = function(response) {
+      var rpcCallback = function(response) {
         if (!response) {
-          callback({ code : 500, message : 'Container refused the request' });
+          callback({ code: 500, message: 'Container refused the request' });
         } else if (response.error) {
           callback(response);
         } else {
@@ -52,15 +52,15 @@ if (gadgets && gadgets.rpc) { //Dont bin
     }
 
     function init(config) {
-      var transport = { name : "gadgets.rpc", "execute" : execute };
-      var services = config["osapi.services"];
+      var transport = { name: 'gadgets.rpc', 'execute' : execute };
+      var services = config['osapi.services'];
       if (services) {
         // Iterate over the defined services, extract the gadget.rpc endpoint and
         // bind to it
         for (var endpointName in services) if (services.hasOwnProperty(endpointName)) {
-          if (endpointName === "gadgets.rpc") {
+          if (endpointName === 'gadgets.rpc') {
             var methods = services[endpointName];
-            for (var i=0; i < methods.length; i++) {
+            for (var i = 0; i < methods.length; i++) {
               osapi._registerMethod(methods[i], transport);
             }
           }
@@ -96,7 +96,7 @@ if (gadgets && gadgets.rpc) { //Dont bin
           if (!response.error) {
             for (var i = 0; i < response.length; i++) {
               // do not rebind container.listMethods implementation
-              if (response[i] != "container.listMethods") {
+              if (response[i] != 'container.listMethods') {
                 osapi._registerMethod(response[i], transport);
               }
             }
@@ -114,7 +114,7 @@ if (gadgets && gadgets.rpc) { //Dont bin
 
     // Do not run this in container mode.
     if (gadgets.config && gadgets.config.isGadget) {
-      gadgets.config.register("osapi.services", null, init);
+      gadgets.config.register('osapi.services', null, init);
     }
   })();
 }

Modified: shindig/trunk/features/src/main/javascript/features/osapi/jsonrpctransport.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi/jsonrpctransport.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi/jsonrpctransport.js (original)
+++ shindig/trunk/features/src/main/javascript/features/osapi/jsonrpctransport.js Wed Sep 15 01:39:49 2010
@@ -33,9 +33,9 @@
       // Convert an XHR failure to a JSON-RPC error
       if (response.errors[0]) {
         callback({
-          error : {
-            code : response.rc,
-            message : response.text
+          error: {
+            code: response.rc,
+            message: response.text
           }
         });
       } else {
@@ -53,34 +53,34 @@
     }
 
     var request = {
-      "POST_DATA" : gadgets.json.stringify(requests),
-      "CONTENT_TYPE" : "JSON",
-      "METHOD" : "POST",
-      "AUTHORIZATION" : "SIGNED"
+      'POST_DATA' : gadgets.json.stringify(requests),
+      'CONTENT_TYPE' : 'JSON',
+      'METHOD' : 'POST',
+      'AUTHORIZATION' : 'SIGNED'
     };
 
     var url = this.name;
     var token = shindig.auth.getSecurityToken();
     if (token) {
-      url += "?st=";
+      url += '?st=';
       url += encodeURIComponent(token);
     }
-    gadgets.io.makeNonProxiedRequest(url, processResponse, request, "application/json");
+    gadgets.io.makeNonProxiedRequest(url, processResponse, request, 'application/json');
   }
 
   function init(config) {
-    var services = config["osapi.services"];
+    var services = config['osapi.services'];
     if (services) {
       // Iterate over the defined services, extract the http endpoints and
       // create a transport per-endpoint
       for (var endpointName in services) if (services.hasOwnProperty(endpointName)) {
-        if (endpointName.indexOf("http") == 0 ||
-            endpointName.indexOf("//") == 0) {
+        if (endpointName.indexOf('http') == 0 ||
+            endpointName.indexOf('//') == 0) {
           // Expand the host & append the security token
-          var endpointUrl = endpointName.replace("%host%", document.location.host);
-          var transport = { name : endpointUrl, "execute" : execute };
+          var endpointUrl = endpointName.replace('%host%', document.location.host);
+          var transport = { name: endpointUrl, 'execute' : execute };
           var methods = services[endpointName];
-          for (var i=0; i < methods.length; i++) {
+          for (var i = 0; i < methods.length; i++) {
             osapi._registerMethod(methods[i], transport);
           }
         }
@@ -90,7 +90,7 @@
 
   // We do run this in the container mode in the new common container
   if (gadgets.config) {
-    gadgets.config.register("osapi.services", null, init);
+    gadgets.config.register('osapi.services', null, init);
   }
 
 })();

Modified: shindig/trunk/features/src/main/javascript/features/osapi/osapi.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi/osapi.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi/osapi.js (original)
+++ shindig/trunk/features/src/main/javascript/features/osapi/osapi.js Wed Sep 15 01:39:49 2010
@@ -19,19 +19,19 @@
 (function() {
   /**
    * Called by the transports for each service method that they expose
-   * @param {string} method  The method to expose e.g. "people.get"
-   * @param {Object.<string,Object>} transport The transport used to execute a call for the method
+   * @param {string} method  The method to expose e.g. "people.get".
+   * @param {Object.<string,Object>} transport The transport used to execute a call for the method.
    */
-  osapi._registerMethod = function (method, transport) {
+  osapi._registerMethod = function(method, transport) {
     var has___ = typeof ___ !== 'undefined';
 
     // Skip registration of local newBatch implementation.
-    if (method == "newBatch") {
-        return;
+    if (method == 'newBatch') {
+      return;
     }
 
     // Lookup last method value.
-    var parts = method.split(".");
+    var parts = method.split('.');
     var last = osapi;
     for (var i = 0; i < parts.length - 1; i++) {
       last[parts[i]] = last[parts[i]] || {};
@@ -55,13 +55,13 @@
         });
       }
       if (has___) {
-          ___.markInnocent(boundCall.execute, 'execute');
+        ___.markInnocent(boundCall.execute, 'execute');
       }
       // TODO: This shouldnt really be necessary. The spec should be clear enough about
       // defaults that we dont have to populate this.
       rpc = rpc || {};
-      rpc.userId = rpc.userId || "@viewer";
-      rpc.groupId = rpc.groupId || "@self";
+      rpc.userId = rpc.userId || '@viewer';
+      rpc.groupId = rpc.groupId || '@self';
 
       // Decorate the execute method with the information necessary for batching
       boundCall.method = method;
@@ -75,7 +75,7 @@
     }
 
     if (last[parts[parts.length - 1]]) {
-      gadgets.warn("Skipping duplicate osapi method definition " + method + " on transport " + transport.name);
+      gadgets.warn('Skipping duplicate osapi method definition ' + method + ' on transport ' + transport.name);
     } else {
       last[parts[parts.length - 1]] = apiMethod;
     }

Modified: shindig/trunk/features/src/main/javascript/features/osapi/peoplehelpers.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi/peoplehelpers.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi/peoplehelpers.js (original)
+++ shindig/trunk/features/src/main/javascript/features/osapi/peoplehelpers.js Wed Sep 15 01:39:49 2010
@@ -30,62 +30,62 @@ gadgets.util.registerOnLoadHandler(funct
     * Options specifies parameters to the call as outlined in the
     * JSON RPC Opensocial Spec
     * http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
-    * @param {object.<JSON>} The JSON object of parameters for the specific request
+    * @param {object.<JSON>} The JSON object of parameters for the specific request.
     */
-       /**
+    /**
       * Function to get Viewer profile.
       * Options specifies parameters to the call as outlined in the
       * JSON RPC Opensocial Spec
       * http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
-      * @param {object.<JSON>} The JSON object of parameters for the specific request
+      * @param {object.<JSON>} The JSON object of parameters for the specific request.
       */
-      osapi.people.getViewer = function(options) {
-        options = options || {};
-        options.userId = "@viewer";
-        options.groupId = "@self";
-        return osapi.people.get(options);
-      };
+    osapi.people.getViewer = function(options) {
+      options = options || {};
+      options.userId = '@viewer';
+      options.groupId = '@self';
+      return osapi.people.get(options);
+    };
 
-      /**
+    /**
       * Function to get Viewer's friends'  profiles.
       * Options specifies parameters to the call as outlined in the
       * JSON RPC Opensocial Spec
       * http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
-      * @param {object.<JSON>} The JSON object of parameters for the specific request
+      * @param {object.<JSON>} The JSON object of parameters for the specific request.
       */
-      osapi.people.getViewerFriends = function(options) {
-        options = options || {};
-        options.userId = "@viewer";
-        options.groupId = "@friends";
-        return osapi.people.get(options);
-      };
+    osapi.people.getViewerFriends = function(options) {
+      options = options || {};
+      options.userId = '@viewer';
+      options.groupId = '@friends';
+      return osapi.people.get(options);
+    };
 
-      /**
+    /**
       * Function to get Owner profile.
       * Options specifies parameters to the call as outlined in the
       * JSON RPC Opensocial Spec
       * http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
-      * @param {object.<JSON>} The JSON object of parameters for the specific request
+      * @param {object.<JSON>} The JSON object of parameters for the specific request.
       */
-      osapi.people.getOwner = function(options) {
-        options = options || {};
-        options.userId = "@owner";
-        options.groupId = "@self";
-        return osapi.people.get(options);
-      };
+    osapi.people.getOwner = function(options) {
+      options = options || {};
+      options.userId = '@owner';
+      options.groupId = '@self';
+      return osapi.people.get(options);
+    };
 
-      /**
+    /**
       * Function to get Owner's friends' profiles.
       * Options specifies parameters to the call as outlined in the
       * JSON RPC Opensocial Spec
       * http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
-      * @param {object.<JSON>} The JSON object of parameters for the specific request
+      * @param {object.<JSON>} The JSON object of parameters for the specific request.
       */
-      osapi.people.getOwnerFriends = function(options) {
-        options = options || {};
-        options.userId = "@owner";
-        options.groupId = "@friends";
-        return osapi.people.get(options);
-      };
+    osapi.people.getOwnerFriends = function(options) {
+      options = options || {};
+      options.userId = '@owner';
+      options.groupId = '@friends';
+      return osapi.people.get(options);
+    };
   }
 });

Modified: shindig/trunk/features/src/main/javascript/features/osapi/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi/taming.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi/taming.js (original)
+++ shindig/trunk/features/src/main/javascript/features/osapi/taming.js Wed Sep 15 01:39:49 2010
@@ -24,7 +24,7 @@
 var tamings___ = tamings___ || [];
 tamings___.push(function(imports) {
 
-  ___.tamesTo(osapi.newBatch, ___.markFuncFreeze(function () {
+  ___.tamesTo(osapi.newBatch, ___.markFuncFreeze(function() {
     var result = osapi.newBatch();
     ___.markInnocent(result['add'], 'add');
     ___.markInnocent(result['execute'], 'execute');

Modified: shindig/trunk/features/src/main/javascript/features/pubsub/pubsub-router.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/pubsub/pubsub-router.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/pubsub/pubsub-router.js (original)
+++ shindig/trunk/features/src/main/javascript/features/pubsub/pubsub-router.js Wed Sep 15 01:39:49 2010
@@ -38,38 +38,38 @@ gadgets.pubsubrouter = function() {
     var sender = gadgetId === '..' ? 'container' : gadgetIdToSpecUrl(gadgetId);
     if (sender) {
       switch (command) {
-      case 'subscribe':
-        if (onSubscribe && onSubscribe(gadgetId, channel)) {
-          break;
-        }
-        if (!subscribers[channel]) {
-          subscribers[channel] = {};
-        }
-        subscribers[channel][gadgetId] = true;
-        break;
-      case 'unsubscribe':
-        if (onUnsubscribe && onUnsubscribe(gadgetId, channel)) {
+        case 'subscribe':
+          if (onSubscribe && onSubscribe(gadgetId, channel)) {
+            break;
+          }
+          if (!subscribers[channel]) {
+            subscribers[channel] = {};
+          }
+          subscribers[channel][gadgetId] = true;
           break;
-        }
-        if (subscribers[channel]) {
-          delete subscribers[channel][gadgetId];
-        }
-        break;
-      case 'publish':
-        if (onPublish && onPublish(gadgetId, channel, message)) {
+        case 'unsubscribe':
+          if (onUnsubscribe && onUnsubscribe(gadgetId, channel)) {
+            break;
+          }
+          if (subscribers[channel]) {
+            delete subscribers[channel][gadgetId];
+          }
           break;
-        }
-        var channelSubscribers = subscribers[channel];
-        if (channelSubscribers) {
-          for (var subscriber in channelSubscribers) {
-            if (channelSubscribers.hasOwnProperty(subscriber)) {
-              gadgets.rpc.call(subscriber, 'pubsub', null, channel, sender, message);
+        case 'publish':
+          if (onPublish && onPublish(gadgetId, channel, message)) {
+            break;
+          }
+          var channelSubscribers = subscribers[channel];
+          if (channelSubscribers) {
+            for (var subscriber in channelSubscribers) {
+              if (channelSubscribers.hasOwnProperty(subscriber)) {
+                gadgets.rpc.call(subscriber, 'pubsub', null, channel, sender, message);
+              }
             }
           }
-        }
-        break;
-      default:
-        throw new Error('Unknown pubsub command');
+          break;
+        default:
+          throw new Error('Unknown pubsub command');
       }
     }
   }
@@ -79,7 +79,7 @@ gadgets.pubsubrouter = function() {
      * Initializes the PubSub message router.
      * @param {function(number)} gadgetIdToSpecUrlHandler Function that returns the full
      *                   gadget spec URL of a given gadget id. For example:
-     *                   function(id) { return idToUrlMap[id]; }
+     *                   function(id) { return idToUrlMap[id]; }.
      * @param {Object=} opt_callbacks Optional event handlers. Supported handlers:
      *                 opt_callbacks.onSubscribe: function(gadgetId, channel)
      *                   Called when a gadget tries to subscribe to a channel.

Modified: shindig/trunk/features/src/main/javascript/features/pubsub/pubsub.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/pubsub/pubsub.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/pubsub/pubsub.js (original)
+++ shindig/trunk/features/src/main/javascript/features/pubsub/pubsub.js Wed Sep 15 01:39:49 2010
@@ -54,7 +54,7 @@ gadgets.pubsub = function() {
      *                     if (isTrustedGadgetSpecUrl(sender)) {
      *                       processMessage(message);
      *                     }
-     *                   }
+     *                   }.
      */
     subscribe: function(channel, callback) {
       listeners[channel] = callback;

Modified: shindig/trunk/features/src/main/javascript/features/rpc/fe.transport.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/rpc/fe.transport.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/rpc/fe.transport.js (original)
+++ shindig/trunk/features/src/main/javascript/features/rpc/fe.transport.js Wed Sep 15 01:39:49 2010
@@ -42,96 +42,96 @@ gadgets.rpctx = gadgets.rpctx || {};
  */
 if (!gadgets.rpctx.frameElement) {  // make lib resilient to double-inclusion
 
-gadgets.rpctx.frameElement = function() {
-  // Consts for FrameElement.
-  var FE_G2C_CHANNEL = '__g2c_rpc';
-  var FE_C2G_CHANNEL = '__c2g_rpc';
-  var process;
-  var ready;
-
-  function callFrameElement(targetId, from, rpc) {
-    try {
-      if (from !== '..') {
-        // Call from gadget to the container.
-        var fe = window.frameElement;
-
-        if (typeof fe[FE_G2C_CHANNEL] === 'function') {
-          // Complete the setup of the FE channel if need be.
-          if (typeof fe[FE_G2C_CHANNEL][FE_C2G_CHANNEL] !== 'function') {
-            fe[FE_G2C_CHANNEL][FE_C2G_CHANNEL] = function(args) {
-              process(gadgets.json.parse(args));
-            };
+  gadgets.rpctx.frameElement = function() {
+    // Consts for FrameElement.
+    var FE_G2C_CHANNEL = '__g2c_rpc';
+    var FE_C2G_CHANNEL = '__c2g_rpc';
+    var process;
+    var ready;
+
+    function callFrameElement(targetId, from, rpc) {
+      try {
+        if (from !== '..') {
+          // Call from gadget to the container.
+          var fe = window.frameElement;
+
+          if (typeof fe[FE_G2C_CHANNEL] === 'function') {
+            // Complete the setup of the FE channel if need be.
+            if (typeof fe[FE_G2C_CHANNEL][FE_C2G_CHANNEL] !== 'function') {
+              fe[FE_G2C_CHANNEL][FE_C2G_CHANNEL] = function(args) {
+                process(gadgets.json.parse(args));
+              };
+            }
+
+            // Conduct the RPC call.
+            fe[FE_G2C_CHANNEL](gadgets.json.stringify(rpc));
+            return true;
+          }
+        } else {
+          // Call from container to gadget[targetId].
+          var frame = document.getElementById(targetId);
+
+          if (typeof frame[FE_G2C_CHANNEL] === 'function' &&
+              typeof frame[FE_G2C_CHANNEL][FE_C2G_CHANNEL] === 'function') {
+
+            // Conduct the RPC call.
+            frame[FE_G2C_CHANNEL][FE_C2G_CHANNEL](gadgets.json.stringify(rpc));
+            return true;
           }
-
-          // Conduct the RPC call.
-          fe[FE_G2C_CHANNEL](gadgets.json.stringify(rpc));
-          return true;
-        }
-      } else {
-        // Call from container to gadget[targetId].
-        var frame = document.getElementById(targetId);
-
-        if (typeof frame[FE_G2C_CHANNEL] === 'function' &&
-            typeof frame[FE_G2C_CHANNEL][FE_C2G_CHANNEL] === 'function') {
-
-          // Conduct the RPC call.
-          frame[FE_G2C_CHANNEL][FE_C2G_CHANNEL](gadgets.json.stringify(rpc));
-          return true;
         }
+      } catch (e) {
       }
-    } catch (e) {
+      return false;
     }
-    return false;
-  }
 
-  return {
-    getCode: function() {
-      return 'fe';
-    },
-
-    isParentVerifiable: function() {
-      return false;
-    },
-  
-    init: function(processFn, readyFn) {
-      // No global setup.
-      process = processFn;
-      ready = readyFn;
-      return true;
-    },
-
-    setup: function(receiverId, token) {
-      // Indicate OK to call to container. This will be true
-      // by the end of this method.
-      if (receiverId !== '..') {
-        try {
-          var frame = document.getElementById(receiverId);
-          frame[FE_G2C_CHANNEL] = function(args) {
-            process(gadgets.json.parse(args));
+    return {
+      getCode: function() {
+        return 'fe';
+      },
+
+      isParentVerifiable: function() {
+        return false;
+      },
+
+      init: function(processFn, readyFn) {
+        // No global setup.
+        process = processFn;
+        ready = readyFn;
+        return true;
+      },
+
+      setup: function(receiverId, token) {
+        // Indicate OK to call to container. This will be true
+        // by the end of this method.
+        if (receiverId !== '..') {
+          try {
+            var frame = document.getElementById(receiverId);
+            frame[FE_G2C_CHANNEL] = function(args) {
+              process(gadgets.json.parse(args));
+            };
+          } catch (e) {
+            return false;
+          }
+        }
+        if (receiverId === '..') {
+          ready('..', true);
+          var ackFn = function() {
+            window.setTimeout(function() {
+              gadgets.rpc.call(receiverId, gadgets.rpc.ACK);
+            }, 500);
           };
-        } catch (e) {
-          return false;
+          // Setup to container always happens before onload.
+          // If it didn't, the correct fix would be in gadgets.util.
+          gadgets.util.registerOnLoadHandler(ackFn);
         }
-      }
-      if (receiverId === '..') {
-        ready('..', true);
-        var ackFn = function() {
-          window.setTimeout(function() {
-            gadgets.rpc.call(receiverId, gadgets.rpc.ACK);
-          }, 500);
-        };
-        // Setup to container always happens before onload.
-        // If it didn't, the correct fix would be in gadgets.util.
-        gadgets.util.registerOnLoadHandler(ackFn);
-      }
-      return true;
-    },
+        return true;
+      },
 
-    call: function(targetId, from, rpc) {
-      return callFrameElement(targetId, from, rpc);
-    } 
+      call: function(targetId, from, rpc) {
+        return callFrameElement(targetId, from, rpc);
+      }
 
-  };
-}();
+    };
+  }();
 
 } // !end of double-inclusion guard

Modified: shindig/trunk/features/src/main/javascript/features/rpc/ifpc.transport.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/rpc/ifpc.transport.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/rpc/ifpc.transport.js (original)
+++ shindig/trunk/features/src/main/javascript/features/rpc/ifpc.transport.js Wed Sep 15 01:39:49 2010
@@ -36,124 +36,124 @@ gadgets.rpctx = gadgets.rpctx || {};
  */
 if (!gadgets.rpctx.ifpc) {  // make lib resilient to double-inclusion
 
-gadgets.rpctx.ifpc = function() {
-  var iframePool = [];
-  var callId = 0;
-  var ready;
+  gadgets.rpctx.ifpc = function() {
+    var iframePool = [];
+    var callId = 0;
+    var ready;
 
-  /**
+    /**
    * Encodes arguments for the legacy IFPC wire format.
    *
    * @param {Object} args
-   * @return {string} the encoded args
+   * @return {string} the encoded args.
    */
-  function encodeLegacyData(args) {
-    var argsEscaped = [];
-    for(var i = 0, j = args.length; i < j; ++i) {
-      argsEscaped.push(encodeURIComponent(gadgets.json.stringify(args[i])));
+    function encodeLegacyData(args) {
+      var argsEscaped = [];
+      for (var i = 0, j = args.length; i < j; ++i) {
+        argsEscaped.push(encodeURIComponent(gadgets.json.stringify(args[i])));
+      }
+      return argsEscaped.join('&');
     }
-    return argsEscaped.join('&');
-  }
 
-  /**
+    /**
    * Helper function to emit an invisible IFrame.
    * @param {string} src SRC attribute of the IFrame to emit.
    * @private
    */
-  function emitInvisibleIframe(src) {
-    var iframe;
-    // Recycle IFrames
-    for (var i = iframePool.length - 1; i >=0; --i) {
-      var ifr = iframePool[i];
-      try {
-        if (ifr && (ifr.recyclable || ifr.readyState === 'complete')) {
-          ifr.parentNode.removeChild(ifr);
-          if (window.ActiveXObject) {
-            // For MSIE, delete any iframes that are no longer being used. MSIE
-            // cannot reuse the IFRAME because a navigational click sound will
-            // be triggered when we set the SRC attribute.
-            // Other browsers scan the pool for a free iframe to reuse.
-            iframePool[i] = ifr = null;
-            iframePool.splice(i, 1);
-          } else {
-            ifr.recyclable = false;
-            iframe = ifr;
-            break;
+    function emitInvisibleIframe(src) {
+      var iframe;
+      // Recycle IFrames
+      for (var i = iframePool.length - 1; i >= 0; --i) {
+        var ifr = iframePool[i];
+        try {
+          if (ifr && (ifr.recyclable || ifr.readyState === 'complete')) {
+            ifr.parentNode.removeChild(ifr);
+            if (window.ActiveXObject) {
+              // For MSIE, delete any iframes that are no longer being used. MSIE
+              // cannot reuse the IFRAME because a navigational click sound will
+              // be triggered when we set the SRC attribute.
+              // Other browsers scan the pool for a free iframe to reuse.
+              iframePool[i] = ifr = null;
+              iframePool.splice(i, 1);
+            } else {
+              ifr.recyclable = false;
+              iframe = ifr;
+              break;
+            }
           }
+        } catch (e) {
+          // Ignore; IE7 throws an exception when trying to read readyState and
+          // readyState isn't set.
         }
-      } catch (e) {
-        // Ignore; IE7 throws an exception when trying to read readyState and
-        // readyState isn't set.
       }
-    }
-    // Create IFrame if necessary
-    if (!iframe) {
-      iframe = document.createElement('iframe');
-      iframe.style.border = iframe.style.width = iframe.style.height = '0px';
-      iframe.style.visibility = 'hidden';
-      iframe.style.position = 'absolute';
-      iframe.onload = function() { this.recyclable = true; };
-      iframePool.push(iframe);
-    }
-    iframe.src = src;
-    window.setTimeout(function() { document.body.appendChild(iframe); }, 0);
-  }
-
-  return {
-    getCode: function() {
-      return 'ifpc';
-    },
-
-    isParentVerifiable: function() {
-      return true;
-    },
-
-    init: function(processFn, readyFn) {
-      // No global setup.
-      ready = readyFn;
-      ready('..', true);  // Ready immediately.
-      return true;
-    },
-
-    setup: function(receiverId, token) {
-      // Indicate readiness to send to receiver.
-      ready(receiverId, true);
-      return true;
-    },
-
-    call: function(targetId, from, rpc) {
-      // Retrieve the relay file used by IFPC. Note that
-      // this must be set before the call, and so we conduct
-      // an extra check to ensure it is not blank.
-      var relay = gadgets.rpc.getRelayUrl(targetId);
-      ++callId;
-
-      if (!relay) {
-        gadgets.warn('No relay file assigned for IFPC');
-        return false;
+      // Create IFrame if necessary
+      if (!iframe) {
+        iframe = document.createElement('iframe');
+        iframe.style.border = iframe.style.width = iframe.style.height = '0px';
+        iframe.style.visibility = 'hidden';
+        iframe.style.position = 'absolute';
+        iframe.onload = function() { this.recyclable = true; };
+        iframePool.push(iframe);
       }
+      iframe.src = src;
+      window.setTimeout(function() { document.body.appendChild(iframe); }, 0);
+    }
 
-      // The RPC mechanism supports two formats for IFPC (legacy and current).
-      var src = null;
-      if (rpc.l) {
-        // Use legacy protocol.
-        // Format: #iframe_id&callId&num_packets&packet_num&block_of_data
-        var callArgs = rpc.a;
-        src = [relay, '#', encodeLegacyData([from, callId, 1, 0,
-               encodeLegacyData([from, rpc.s, '', '', from].concat(
-                 callArgs))])].join('');
-      } else {
-        // Format: #targetId & sourceId@callId & packetNum & packetId & packetData
-        src = [relay, '#', targetId, '&', from, '@', callId,
-               '&1&0&', encodeURIComponent(gadgets.json.stringify(rpc))].join('');
-      }
+    return {
+      getCode: function() {
+        return 'ifpc';
+      },
+
+      isParentVerifiable: function() {
+        return true;
+      },
+
+      init: function(processFn, readyFn) {
+        // No global setup.
+        ready = readyFn;
+        ready('..', true);  // Ready immediately.
+        return true;
+      },
+
+      setup: function(receiverId, token) {
+        // Indicate readiness to send to receiver.
+        ready(receiverId, true);
+        return true;
+      },
+
+      call: function(targetId, from, rpc) {
+        // Retrieve the relay file used by IFPC. Note that
+        // this must be set before the call, and so we conduct
+        // an extra check to ensure it is not blank.
+        var relay = gadgets.rpc.getRelayUrl(targetId);
+        ++callId;
+
+        if (!relay) {
+          gadgets.warn('No relay file assigned for IFPC');
+          return false;
+        }
 
-      // Conduct the IFPC call by creating the Iframe with
-      // the relay URL and appended message.
-      emitInvisibleIframe(src);
-      return true;
-    }
-  };
-}();
+        // The RPC mechanism supports two formats for IFPC (legacy and current).
+        var src = null;
+        if (rpc.l) {
+          // Use legacy protocol.
+          // Format: #iframe_id&callId&num_packets&packet_num&block_of_data
+          var callArgs = rpc.a;
+          src = [relay, '#', encodeLegacyData([from, callId, 1, 0,
+            encodeLegacyData([from, rpc.s, '', '', from].concat(
+                callArgs))])].join('');
+        } else {
+          // Format: #targetId & sourceId@callId & packetNum & packetId & packetData
+          src = [relay, '#', targetId, '&', from, '@', callId,
+            '&1&0&', encodeURIComponent(gadgets.json.stringify(rpc))].join('');
+        }
+
+        // Conduct the IFPC call by creating the Iframe with
+        // the relay URL and appended message.
+        emitInvisibleIframe(src);
+        return true;
+      }
+    };
+  }();
 
 } // !end of double inclusion guard

Modified: shindig/trunk/features/src/main/javascript/features/rpc/nix.transport.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/rpc/nix.transport.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/rpc/nix.transport.js (original)
+++ shindig/trunk/features/src/main/javascript/features/rpc/nix.transport.js Wed Sep 15 01:39:49 2010
@@ -64,222 +64,222 @@ gadgets.rpctx = gadgets.rpctx || {};
  */
 if (!gadgets.rpctx.nix) {  // make lib resilient to double-inclusion
 
-gadgets.rpctx.nix = function() {
-  // Consts for NIX. VBScript doesn't
-  // allow items to start with _ for some reason,
-  // so we need to make these names quite unique, as
-  // they will go into the global namespace.
-  var NIX_WRAPPER = 'GRPC____NIXVBS_wrapper';
-  var NIX_GET_WRAPPER = 'GRPC____NIXVBS_get_wrapper';
-  var NIX_HANDLE_MESSAGE = 'GRPC____NIXVBS_handle_message';
-  var NIX_CREATE_CHANNEL = 'GRPC____NIXVBS_create_channel';
-  var MAX_NIX_SEARCHES = 10;
-  var NIX_SEARCH_PERIOD = 500;
-
-  // JavaScript reference to the NIX VBScript wrappers.
-  // Gadgets will have but a single channel under
-  // nix_channels['..'] while containers will have a channel
-  // per gadget stored under the gadget's ID.
-  var nix_channels = {};
-  var isForceSecure = {};
-
-  // Store the ready signal method for use on handshake complete.
-  var ready;
-  var numHandlerSearches = 0;
-
-  // Search for NIX handler to parent. Tries MAX_NIX_SEARCHES times every
-  // NIX_SEARCH_PERIOD milliseconds.
-  function conductHandlerSearch() {
-    // Call from gadget to the container.
-    var handler = nix_channels['..'];
-    if (handler) {
-      return;
-    }
-
-    if (++numHandlerSearches > MAX_NIX_SEARCHES) {
-      // Handshake failed. Will fall back.
-      gadgets.warn('Nix transport setup failed, falling back...');
-      ready('..', false);
-      return;
-    }
-
-    // If the gadget has yet to retrieve a reference to
-    // the NIX handler, try to do so now. We don't do a
-    // typeof(window.opener.GetAuthToken) check here
-    // because it means accessing that field on the COM object, which,
-    // being an internal function reference, is not allowed.
-    // "in" works because it merely checks for the prescence of
-    // the key, rather than actually accessing the object's property.
-    // This is just a sanity check, not a validity check.
-    if (!handler && window.opener && "GetAuthToken" in window.opener) {
-      handler = window.opener;
-
-      // Create the channel to the parent/container.
-      // First verify that it knows our auth token to ensure it's not
-      // an impostor.
-      if (handler.GetAuthToken() == gadgets.rpc.getAuthToken('..')) {
-        // Auth match - pass it back along with our wrapper to finish.
-        // own wrapper and our authentication token for co-verification.
-        var token = gadgets.rpc.getAuthToken('..');
-        handler.CreateChannel(window[NIX_GET_WRAPPER]('..', token),
-                              token);
-        // Set channel handler
-        nix_channels['..'] = handler;
-        window.opener = null;
-
-        // Signal success and readiness to send to parent.
-        // Container-to-gadget bit flipped in CreateChannel.
-        ready('..', true);
+  gadgets.rpctx.nix = function() {
+    // Consts for NIX. VBScript doesn't
+    // allow items to start with _ for some reason,
+    // so we need to make these names quite unique, as
+    // they will go into the global namespace.
+    var NIX_WRAPPER = 'GRPC____NIXVBS_wrapper';
+    var NIX_GET_WRAPPER = 'GRPC____NIXVBS_get_wrapper';
+    var NIX_HANDLE_MESSAGE = 'GRPC____NIXVBS_handle_message';
+    var NIX_CREATE_CHANNEL = 'GRPC____NIXVBS_create_channel';
+    var MAX_NIX_SEARCHES = 10;
+    var NIX_SEARCH_PERIOD = 500;
+
+    // JavaScript reference to the NIX VBScript wrappers.
+    // Gadgets will have but a single channel under
+    // nix_channels['..'] while containers will have a channel
+    // per gadget stored under the gadget's ID.
+    var nix_channels = {};
+    var isForceSecure = {};
+
+    // Store the ready signal method for use on handshake complete.
+    var ready;
+    var numHandlerSearches = 0;
+
+    // Search for NIX handler to parent. Tries MAX_NIX_SEARCHES times every
+    // NIX_SEARCH_PERIOD milliseconds.
+    function conductHandlerSearch() {
+      // Call from gadget to the container.
+      var handler = nix_channels['..'];
+      if (handler) {
         return;
       }
-    }
 
-    // Try again.
-    window.setTimeout(function() { conductHandlerSearch(); },
-                      NIX_SEARCH_PERIOD);
-  }
-
-  // Returns current window location, without hash values
-  function getLocationNoHash() {
-    var loc = window.location.href;
-    var idx = loc.indexOf('#');
-    if (idx == -1) {
-      return loc;
-    }
-    return loc.substring(0, idx);
-  }
+      if (++numHandlerSearches > MAX_NIX_SEARCHES) {
+        // Handshake failed. Will fall back.
+        gadgets.warn('Nix transport setup failed, falling back...');
+        ready('..', false);
+        return;
+      }
 
-  // When "forcesecure" is set to true, use the relay file and a simple variant of IFPC to first
-  // authenticate the container and gadget with each other.  Once that is done, then initialize
-  // the NIX protocol. 
-  function setupSecureRelayToParent(rpctoken) {
-    // To the parent, transmit the child's URL, the passed in auth
-    // token, and another token generated by the child.
-    var childToken = (0x7FFFFFFF * Math.random()) | 0;    // TODO expose way to have child set this value
-    var data = [
-      getLocationNoHash(),
-      childToken
-    ];
-    gadgets.rpc._createRelayIframe(rpctoken, data);
-    
-    // listen for response from parent
-    var hash = window.location.href.split('#')[1] || '';
-  
-    function relayTimer() {
-      var newHash = window.location.href.split('#')[1] || '';
-      if (newHash !== hash) {
-        clearInterval(relayTimerId);
-        var params = gadgets.util.getUrlParameters(window.location.href);
-        if (params.childtoken == childToken) {
-          // parent has been authenticated; now init NIX
-          conductHandlerSearch();
+      // If the gadget has yet to retrieve a reference to
+      // the NIX handler, try to do so now. We don't do a
+      // typeof(window.opener.GetAuthToken) check here
+      // because it means accessing that field on the COM object, which,
+      // being an internal function reference, is not allowed.
+      // "in" works because it merely checks for the prescence of
+      // the key, rather than actually accessing the object's property.
+      // This is just a sanity check, not a validity check.
+      if (!handler && window.opener && 'GetAuthToken' in window.opener) {
+        handler = window.opener;
+
+        // Create the channel to the parent/container.
+        // First verify that it knows our auth token to ensure it's not
+        // an impostor.
+        if (handler.GetAuthToken() == gadgets.rpc.getAuthToken('..')) {
+          // Auth match - pass it back along with our wrapper to finish.
+          // own wrapper and our authentication token for co-verification.
+          var token = gadgets.rpc.getAuthToken('..');
+          handler.CreateChannel(window[NIX_GET_WRAPPER]('..', token),
+              token);
+          // Set channel handler
+          nix_channels['..'] = handler;
+          window.opener = null;
+
+          // Signal success and readiness to send to parent.
+          // Container-to-gadget bit flipped in CreateChannel.
+          ready('..', true);
           return;
         }
-        // security error -- token didn't match
-        ready('..', false);
       }
+
+      // Try again.
+      window.setTimeout(function() { conductHandlerSearch(); },
+          NIX_SEARCH_PERIOD);
     }
-    var relayTimerId = setInterval( relayTimer, 100 );
-  }
 
-  return {
-    getCode: function() {
-      return 'nix';
-    },
-
-    isParentVerifiable: function(opt_receiverId) {
-      // NIX is only parent verifiable if a receiver was setup with "forcesecure" set to TRUE.
-      if (opt_receiverId) {
-        return isForceSecure[opt_receiverId];
+    // Returns current window location, without hash values
+    function getLocationNoHash() {
+      var loc = window.location.href;
+      var idx = loc.indexOf('#');
+      if (idx == -1) {
+        return loc;
       }
-      return false;
-    },
-
-    init: function(processFn, readyFn) {
-      ready = readyFn;
+      return loc.substring(0, idx);
+    }
 
-      // Ensure VBScript wrapper code is in the page and that the
-      // global Javascript handlers have been set.
-      // VBScript methods return a type of 'unknown' when
-      // checked via the typeof operator in IE. Fortunately
-      // for us, this only applies to COM objects, so we
-      // won't see this for a real Javascript object.
-      if (typeof window[NIX_GET_WRAPPER] !== 'unknown') {
-        window[NIX_HANDLE_MESSAGE] = function(data) {
-          window.setTimeout(
-              function() { processFn(gadgets.json.parse(data)); }, 0);
-        };
-
-        window[NIX_CREATE_CHANNEL] = function(name, channel, token) {
-          // Verify the authentication token of the gadget trying
-          // to create a channel for us.
-          if (gadgets.rpc.getAuthToken(name) === token) {
-            nix_channels[name] = channel;
-            ready(name, true);
+    // When "forcesecure" is set to true, use the relay file and a simple variant of IFPC to first
+    // authenticate the container and gadget with each other.  Once that is done, then initialize
+    // the NIX protocol.
+    function setupSecureRelayToParent(rpctoken) {
+      // To the parent, transmit the child's URL, the passed in auth
+      // token, and another token generated by the child.
+      var childToken = (0x7FFFFFFF * Math.random()) | 0;    // TODO expose way to have child set this value
+      var data = [
+        getLocationNoHash(),
+        childToken
+      ];
+      gadgets.rpc._createRelayIframe(rpctoken, data);
+
+      // listen for response from parent
+      var hash = window.location.href.split('#')[1] || '';
+
+      function relayTimer() {
+        var newHash = window.location.href.split('#')[1] || '';
+        if (newHash !== hash) {
+          clearInterval(relayTimerId);
+          var params = gadgets.util.getUrlParameters(window.location.href);
+          if (params.childtoken == childToken) {
+            // parent has been authenticated; now init NIX
+            conductHandlerSearch();
+            return;
           }
-        };
+          // security error -- token didn't match
+          ready('..', false);
+        }
+      }
+      var relayTimerId = setInterval(relayTimer, 100);
+    }
+
+    return {
+      getCode: function() {
+        return 'nix';
+      },
+
+      isParentVerifiable: function(opt_receiverId) {
+        // NIX is only parent verifiable if a receiver was setup with "forcesecure" set to TRUE.
+        if (opt_receiverId) {
+          return isForceSecure[opt_receiverId];
+        }
+        return false;
+      },
 
-        // Inject the VBScript code needed.
-        var vbscript =
-          // We create a class to act as a wrapper for
-          // a Javascript call, to prevent a break in of
-          // the context.
-          'Class ' + NIX_WRAPPER + '\n '
-
-          // An internal member for keeping track of the
-          // name of the document (container or gadget)
-          // for which this wrapper is intended. For
-          // those wrappers created by gadgets, this is not
-          // used (although it is set to "..")
+      init: function(processFn, readyFn) {
+        ready = readyFn;
+
+        // Ensure VBScript wrapper code is in the page and that the
+        // global Javascript handlers have been set.
+        // VBScript methods return a type of 'unknown' when
+        // checked via the typeof operator in IE. Fortunately
+        // for us, this only applies to COM objects, so we
+        // won't see this for a real Javascript object.
+        if (typeof window[NIX_GET_WRAPPER] !== 'unknown') {
+          window[NIX_HANDLE_MESSAGE] = function(data) {
+            window.setTimeout(
+                function() { processFn(gadgets.json.parse(data)); }, 0);
+          };
+
+          window[NIX_CREATE_CHANNEL] = function(name, channel, token) {
+            // Verify the authentication token of the gadget trying
+            // to create a channel for us.
+            if (gadgets.rpc.getAuthToken(name) === token) {
+              nix_channels[name] = channel;
+              ready(name, true);
+            }
+          };
+
+          // Inject the VBScript code needed.
+          var vbscript =
+              // We create a class to act as a wrapper for
+              // a Javascript call, to prevent a break in of
+              // the context.
+              'Class ' + NIX_WRAPPER + '\n '
+
+              // An internal member for keeping track of the
+              // name of the document (container or gadget)
+              // for which this wrapper is intended. For
+              // those wrappers created by gadgets, this is not
+              // used (although it is set to "..")
           + 'Private m_Intended\n'
 
-          // Stores the auth token used to communicate with
-          // the gadget. The GetChannelCreator method returns
-          // an object that returns this auth token. Upon matching
-          // that with its own, the gadget uses the object
-          // to actually establish the communication channel.
+              // Stores the auth token used to communicate with
+              // the gadget. The GetChannelCreator method returns
+              // an object that returns this auth token. Upon matching
+              // that with its own, the gadget uses the object
+              // to actually establish the communication channel.
           + 'Private m_Auth\n'
 
-          // Method for internally setting the value
-          // of the m_Intended property.
+              // Method for internally setting the value
+              // of the m_Intended property.
           + 'Public Sub SetIntendedName(name)\n '
           + 'If isEmpty(m_Intended) Then\n'
           + 'm_Intended = name\n'
           + 'End If\n'
           + 'End Sub\n'
 
-          // Method for internally setting the value of the m_Auth property.
+              // Method for internally setting the value of the m_Auth property.
           + 'Public Sub SetAuth(auth)\n '
           + 'If isEmpty(m_Auth) Then\n'
           + 'm_Auth = auth\n'
           + 'End If\n'
           + 'End Sub\n'
 
-          // A wrapper method which actually causes a
-          // message to be sent to the other context.
+              // A wrapper method which actually causes a
+              // message to be sent to the other context.
           + 'Public Sub SendMessage(data)\n '
           + NIX_HANDLE_MESSAGE + '(data)\n'
           + 'End Sub\n'
 
-          // Returns the auth token to the gadget, so it can
-          // confirm a match before initiating the connection
+              // Returns the auth token to the gadget, so it can
+              // confirm a match before initiating the connection
           + 'Public Function GetAuthToken()\n '
           + 'GetAuthToken = m_Auth\n'
           + 'End Function\n'
 
-          // Method for setting up the container->gadget
-          // channel. Not strictly needed in the gadget's
-          // wrapper, but no reason to get rid of it. Note here
-          // that we pass the intended name to the NIX_CREATE_CHANNEL
-          // method so that it can save the channel in the proper place
-          // *and* verify the channel via the authentication token passed
-          // here.
+              // Method for setting up the container->gadget
+              // channel. Not strictly needed in the gadget's
+              // wrapper, but no reason to get rid of it. Note here
+              // that we pass the intended name to the NIX_CREATE_CHANNEL
+              // method so that it can save the channel in the proper place
+              // *and* verify the channel via the authentication token passed
+              // here.
           + 'Public Sub CreateChannel(channel, auth)\n '
           + 'Call ' + NIX_CREATE_CHANNEL + '(m_Intended, channel, auth)\n'
           + 'End Sub\n'
           + 'End Class\n'
 
-          // Function to get a reference to the wrapper.
+              // Function to get a reference to the wrapper.
           + 'Function ' + NIX_GET_WRAPPER + '(name, auth)\n'
           + 'Dim wrap\n'
           + 'Set wrap = New ' + NIX_WRAPPER + '\n'
@@ -288,55 +288,55 @@ gadgets.rpctx.nix = function() {
           + 'Set ' + NIX_GET_WRAPPER + ' = wrap\n'
           + 'End Function';
 
+          try {
+            window.execScript(vbscript, 'vbscript');
+          } catch (e) {
+            return false;
+          }
+        }
+        return true;
+      },
+
+      setup: function(receiverId, token, forcesecure) {
+        isForceSecure[receiverId] = !!forcesecure;
+        if (receiverId === '..') {
+          if (forcesecure) {
+            setupSecureRelayToParent(token);
+          } else {
+            conductHandlerSearch();
+          }
+          return true;
+        }
         try {
-          window.execScript(vbscript, 'vbscript');
+          var frame = document.getElementById(receiverId);
+          var wrapper = window[NIX_GET_WRAPPER](receiverId, token);
+          frame.contentWindow.opener = wrapper;
         } catch (e) {
           return false;
         }
-      }
-      return true;
-    },
+        return true;
+      },
 
-    setup: function(receiverId, token, forcesecure) {
-      isForceSecure[receiverId] = !!forcesecure;
-      if (receiverId === '..') {
-        if (forcesecure) {
-          setupSecureRelayToParent(token);
-        } else {
-          conductHandlerSearch();
+      call: function(targetId, from, rpc) {
+        try {
+          // If we have a handler, call it.
+          if (nix_channels[targetId]) {
+            nix_channels[targetId].SendMessage(gadgets.json.stringify(rpc));
+          }
+        } catch (e) {
+          return false;
         }
         return true;
-      }
-      try {
-        var frame = document.getElementById(receiverId);
-        var wrapper = window[NIX_GET_WRAPPER](receiverId, token);
-        frame.contentWindow.opener = wrapper;
-      } catch (e) {
-        return false;
-      }
-      return true;
-    },
+      },
 
-    call: function(targetId, from, rpc) {
-      try {
-        // If we have a handler, call it.
-        if (nix_channels[targetId]) {
-          nix_channels[targetId].SendMessage(gadgets.json.stringify(rpc));
-        }
-      } catch (e) {
-        return false;
+      // data = [child URL, child auth token]
+      relayOnload: function(receiverId, data) {
+        // transmit childtoken back to child to complete authentication
+        var src = data[0] + '#childtoken=' + data[1];
+        var childIframe = document.getElementById(receiverId);
+        childIframe.src = src;
       }
-      return true;
-    },
-    
-    // data = [child URL, child auth token]
-    relayOnload: function(receiverId, data) {
-      // transmit childtoken back to child to complete authentication
-      var src = data[0] + '#childtoken=' + data[1];
-      var childIframe = document.getElementById(receiverId);
-      childIframe.src = src;
-    }
-  };
-}();
+    };
+  }();
 
 } // !end of double-inclusion guard

Modified: shindig/trunk/features/src/main/javascript/features/rpc/rmr.transport.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/rpc/rmr.transport.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/rpc/rmr.transport.js (original)
+++ shindig/trunk/features/src/main/javascript/features/rpc/rmr.transport.js Wed Sep 15 01:39:49 2010
@@ -42,22 +42,22 @@ gadgets.rpctx = gadgets.rpctx || {};
  */
 if (!gadgets.rpctx.rmr) {  // make lib resilient to double-inclusion
 
-gadgets.rpctx.rmr = function() {
-  // Consts for RMR, including time in ms RMR uses to poll for
-  // its relay frame to be created, and the max # of polls it does.
-  var RMR_SEARCH_TIMEOUT = 500;
-  var RMR_MAX_POLLS = 10;
-
-  // JavaScript references to the channel objects used by RMR.
-  // Gadgets will have but a single channel under
-  // rmr_channels['..'] while containers will have a channel
-  // per gadget stored under the gadget's ID.
-  var rmr_channels = {};
-  
-  var process;
-  var ready;
+  gadgets.rpctx.rmr = function() {
+    // Consts for RMR, including time in ms RMR uses to poll for
+    // its relay frame to be created, and the max # of polls it does.
+    var RMR_SEARCH_TIMEOUT = 500;
+    var RMR_MAX_POLLS = 10;
+
+    // JavaScript references to the channel objects used by RMR.
+    // Gadgets will have but a single channel under
+    // rmr_channels['..'] while containers will have a channel
+    // per gadget stored under the gadget's ID.
+    var rmr_channels = {};
 
-  /**
+    var process;
+    var ready;
+
+    /**
    * Append an RMR relay frame to the document. This allows the receiver
    * to start receiving messages.
    *
@@ -66,122 +66,122 @@ gadgets.rpctx.rmr = function() {
    * @param {string} data to pass along to the frame.
    * @param {string=} opt_frameId ID of frame for which relay is being appended (optional).
    */
-  function appendRmrFrame(channelFrame, relayUri, data, opt_frameId) {
-    var appendFn = function() {
-      // Append the iframe.
-      document.body.appendChild(channelFrame);
-
-      // Set the src of the iframe to 'about:blank' first and then set it
-      // to the relay URI. This prevents the iframe from maintaining a src
-      // to the 'old' relay URI if the page is returned to from another.
-      // In other words, this fixes the bfcache issue that causes the iframe's
-      // src property to not be updated despite us assigning it a new value here.
-      channelFrame.src = 'about:blank';
-      if (opt_frameId) {
-        // Process the initial sent payload (typically sent by container to
-        // child/gadget) only when the relay frame has finished loading. We
-        // do this to ensure that, in processRmrData(...), the ACK sent due
-        // to processing can actually be sent. Before this time, the frame's
-        // contentWindow is null, making it impossible to do so.
-        channelFrame.onload = function() {
-          processRmrData(opt_frameId);
-        };
-      }
-      channelFrame.src = relayUri + '#' + data;
-    };
+    function appendRmrFrame(channelFrame, relayUri, data, opt_frameId) {
+      var appendFn = function() {
+        // Append the iframe.
+        document.body.appendChild(channelFrame);
+
+        // Set the src of the iframe to 'about:blank' first and then set it
+        // to the relay URI. This prevents the iframe from maintaining a src
+        // to the 'old' relay URI if the page is returned to from another.
+        // In other words, this fixes the bfcache issue that causes the iframe's
+        // src property to not be updated despite us assigning it a new value here.
+        channelFrame.src = 'about:blank';
+        if (opt_frameId) {
+          // Process the initial sent payload (typically sent by container to
+          // child/gadget) only when the relay frame has finished loading. We
+          // do this to ensure that, in processRmrData(...), the ACK sent due
+          // to processing can actually be sent. Before this time, the frame's
+          // contentWindow is null, making it impossible to do so.
+          channelFrame.onload = function() {
+            processRmrData(opt_frameId);
+          };
+        }
+        channelFrame.src = relayUri + '#' + data;
+      };
 
-    if (document.body) {
-      appendFn();
-    } else {
-      // Common gadget case: attaching header during in-gadget handshake,
-      // when we may still be in script in head. Attach onload.
-      gadgets.util.registerOnLoadHandler(function() { appendFn(); });
+      if (document.body) {
+        appendFn();
+      } else {
+        // Common gadget case: attaching header during in-gadget handshake,
+        // when we may still be in script in head. Attach onload.
+        gadgets.util.registerOnLoadHandler(function() { appendFn(); });
+      }
     }
-  }
 
-  /**
+    /**
    * Sets up the RMR transport frame for the given frameId. For gadgets
    * calling containers, the frameId should be '..'.
    *
    * @param {string} frameId The ID of the frame.
    */
-  function setupRmr(frameId) {
-    if (typeof rmr_channels[frameId] === "object") {
-      // Sanity check. Already done.
-      return;
-    }
-
-    var channelFrame = document.createElement('iframe');
-    var frameStyle = channelFrame.style;
-    frameStyle.position = 'absolute';
-    frameStyle.top = '0px';
-    frameStyle.border = '0';
-    frameStyle.opacity = '0';
-
-    // The width here is important as RMR
-    // makes use of the resize handler for the frame.
-    // Do not modify unless you test thoroughly!
-    frameStyle.width = '10px';
-    frameStyle.height = '1px';
-    channelFrame.id = 'rmrtransport-' + frameId;
-    channelFrame.name = channelFrame.id;
-
-    // Use the explicitly set relay, if one exists. Otherwise,
-    // Construct one using the parent parameter plus robots.txt
-    // as a synthetic relay. This works since browsers using RMR
-    // treat 404s as legitimate for the purposes of cross domain
-    // communication.
-    var relayUri = gadgets.rpc.getRelayUrl(frameId);
-    if (!relayUri) {
-      relayUri =
-          gadgets.rpc.getOrigin(gadgets.util.getUrlParameters()["parent"]) +
-          '/robots.txt';
-    }
+    function setupRmr(frameId) {
+      if (typeof rmr_channels[frameId] === 'object') {
+        // Sanity check. Already done.
+        return;
+      }
 
-    rmr_channels[frameId] = {
-      frame: channelFrame,
-      receiveWindow: null,
-      relayUri: relayUri,
-      searchCounter : 0,
-      width: 10,
-
-      // Waiting means "waiting for acknowledgement to be received."
-      // Acknowledgement always comes as a special ACK
-      // message having been received. This message is received
-      // during handshake in different ways by the container and
-      // gadget, and by normal RMR message passing once the handshake
-      // is complete.
-      waiting: true,
-      queue: [],
-
-      // Number of non-ACK messages that have been sent to the recipient
-      // and have been acknowledged.
-      sendId: 0,
-
-      // Number of messages received and processed from the sender.
-      // This is the number that accompanies every ACK to tell the
-      // sender to clear its queue.
-      recvId: 0
-    };
+      var channelFrame = document.createElement('iframe');
+      var frameStyle = channelFrame.style;
+      frameStyle.position = 'absolute';
+      frameStyle.top = '0px';
+      frameStyle.border = '0';
+      frameStyle.opacity = '0';
+
+      // The width here is important as RMR
+      // makes use of the resize handler for the frame.
+      // Do not modify unless you test thoroughly!
+      frameStyle.width = '10px';
+      frameStyle.height = '1px';
+      channelFrame.id = 'rmrtransport-' + frameId;
+      channelFrame.name = channelFrame.id;
+
+      // Use the explicitly set relay, if one exists. Otherwise,
+      // Construct one using the parent parameter plus robots.txt
+      // as a synthetic relay. This works since browsers using RMR
+      // treat 404s as legitimate for the purposes of cross domain
+      // communication.
+      var relayUri = gadgets.rpc.getRelayUrl(frameId);
+      if (!relayUri) {
+        relayUri =
+            gadgets.rpc.getOrigin(gadgets.util.getUrlParameters()['parent']) +
+            '/robots.txt';
+      }
+
+      rmr_channels[frameId] = {
+        frame: channelFrame,
+        receiveWindow: null,
+        relayUri: relayUri,
+        searchCounter: 0,
+        width: 10,
+
+        // Waiting means "waiting for acknowledgement to be received."
+        // Acknowledgement always comes as a special ACK
+        // message having been received. This message is received
+        // during handshake in different ways by the container and
+        // gadget, and by normal RMR message passing once the handshake
+        // is complete.
+        waiting: true,
+        queue: [],
+
+        // Number of non-ACK messages that have been sent to the recipient
+        // and have been acknowledged.
+        sendId: 0,
+
+        // Number of messages received and processed from the sender.
+        // This is the number that accompanies every ACK to tell the
+        // sender to clear its queue.
+        recvId: 0
+      };
+
+      if (frameId !== '..') {
+        // Container always appends a relay to the gadget, before
+        // the gadget appends its own relay back to container. The
+        // gadget, in the meantime, refuses to attach the container
+        // relay until it finds this one. Thus, the container knows
+        // for certain that gadget to container communication is set
+        // up by the time it finds its own relay. In addition to
+        // establishing a reliable handshake protocol, this also
+        // makes it possible for the gadget to send an initial batch
+        // of messages to the container ASAP.
+        appendRmrFrame(channelFrame, relayUri, getRmrData(frameId));
+      }
 
-    if (frameId !== '..') {
-      // Container always appends a relay to the gadget, before
-      // the gadget appends its own relay back to container. The
-      // gadget, in the meantime, refuses to attach the container
-      // relay until it finds this one. Thus, the container knows
-      // for certain that gadget to container communication is set
-      // up by the time it finds its own relay. In addition to
-      // establishing a reliable handshake protocol, this also
-      // makes it possible for the gadget to send an initial batch
-      // of messages to the container ASAP.
-      appendRmrFrame(channelFrame, relayUri, getRmrData(frameId));
+      // Start searching for our own frame on the other page.
+      conductRmrSearch(frameId);
     }
-     
-    // Start searching for our own frame on the other page.
-    conductRmrSearch(frameId);
-  }
 
-  /**
+    /**
    * Searches for a relay frame, created by the sender referenced by
    * frameId, with which this context receives messages. Once
    * found with proper permissions, attaches a resize handler which
@@ -189,51 +189,51 @@ gadgets.rpctx.rmr = function() {
    *
    * @param {string} frameId Frame ID of the prospective sender.
    */
-  function conductRmrSearch(frameId) {
-    var channelWindow = null;
-
-    // Increment the search counter.
-    rmr_channels[frameId].searchCounter++;
-
-    try {
-      var targetWin = gadgets.rpc._getTargetWin(frameId);
-      if (frameId === '..') {
-        // We are a gadget.
-        channelWindow = targetWin.frames['rmrtransport-' + gadgets.rpc.RPC_ID];
-      } else {
-        // We are a container.
-        channelWindow = targetWin.frames['rmrtransport-..'];
-      }
-    } catch (e) {
-      // Just in case; may happen when relay is set to about:blank or unset.
-      // Catching exceptions here ensures that the timeout to continue the
-      // search below continues to work.
-    }
+    function conductRmrSearch(frameId) {
+      var channelWindow = null;
 
-    var status = false;
+      // Increment the search counter.
+      rmr_channels[frameId].searchCounter++;
 
-    if (channelWindow) {
-      // We have a valid reference to "our" RMR transport frame.
-      // Register the proper event handlers.
-      status = registerRmrChannel(frameId, channelWindow);
-    }
+      try {
+        var targetWin = gadgets.rpc._getTargetWin(frameId);
+        if (frameId === '..') {
+          // We are a gadget.
+          channelWindow = targetWin.frames['rmrtransport-' + gadgets.rpc.RPC_ID];
+        } else {
+          // We are a container.
+          channelWindow = targetWin.frames['rmrtransport-..'];
+        }
+      } catch (e) {
+        // Just in case; may happen when relay is set to about:blank or unset.
+        // Catching exceptions here ensures that the timeout to continue the
+        // search below continues to work.
+      }
+
+      var status = false;
+
+      if (channelWindow) {
+        // We have a valid reference to "our" RMR transport frame.
+        // Register the proper event handlers.
+        status = registerRmrChannel(frameId, channelWindow);
+      }
+
+      if (!status) {
+        // Not found yet. Continue searching, but only if the counter
+        // has not reached the threshold.
+        if (rmr_channels[frameId].searchCounter > RMR_MAX_POLLS) {
+          // If we reach this point, then RMR has failed and we
+          // fall back to IFPC.
+          return;
+        }
 
-    if (!status) {
-      // Not found yet. Continue searching, but only if the counter
-      // has not reached the threshold.
-      if (rmr_channels[frameId].searchCounter > RMR_MAX_POLLS) {
-        // If we reach this point, then RMR has failed and we
-        // fall back to IFPC.
-        return;
+        window.setTimeout(function() {
+          conductRmrSearch(frameId);
+        }, RMR_SEARCH_TIMEOUT);
       }
-
-      window.setTimeout(function() {
-        conductRmrSearch(frameId);
-      }, RMR_SEARCH_TIMEOUT);
     }
-  }
 
-  /**
+    /**
    * Attempts to conduct an RPC call to the specified
    * target with the specified data via the RMR
    * method. If this method fails, the system attempts again
@@ -244,147 +244,147 @@ gadgets.rpctx.rmr = function() {
    * @param {string} from Module Id of the calling provider.
    * @param {Object} rpc The RPC data for this call.
    */
-  function callRmr(targetId, serviceName, from, rpc) {
-    var handler = null;
+    function callRmr(targetId, serviceName, from, rpc) {
+      var handler = null;
 
-    if (from !== '..') {
-      // Call from gadget to the container.
-      handler = rmr_channels['..'];
-    } else {
-      // Call from container to the gadget.
-      handler = rmr_channels[targetId];
-    }
-
-    if (handler) {
-      // Queue the current message if not ACK.
-      // ACK is always sent through getRmrData(...).
-      if (serviceName !== gadgets.rpc.ACK) {
-        handler.queue.push(rpc);
-      }
-
-      if (handler.waiting ||
-          (handler.queue.length === 0 &&
-           !(serviceName === gadgets.rpc.ACK && rpc && rpc.ackAlone === true))) {
-        // If we are awaiting a response from any previously-sent messages,
-        // or if we don't have anything new to send, just return.
-        // Note that we don't short-return if we're ACKing just-received
-        // messages.
-        return true;
+      if (from !== '..') {
+        // Call from gadget to the container.
+        handler = rmr_channels['..'];
+      } else {
+        // Call from container to the gadget.
+        handler = rmr_channels[targetId];
       }
 
-      if (handler.queue.length > 0) {
-        handler.waiting = true;
-      }
+      if (handler) {
+        // Queue the current message if not ACK.
+        // ACK is always sent through getRmrData(...).
+        if (serviceName !== gadgets.rpc.ACK) {
+          handler.queue.push(rpc);
+        }
 
-      var url = handler.relayUri + "#" + getRmrData(targetId);
+        if (handler.waiting ||
+            (handler.queue.length === 0 &&
+            !(serviceName === gadgets.rpc.ACK && rpc && rpc.ackAlone === true))) {
+          // If we are awaiting a response from any previously-sent messages,
+          // or if we don't have anything new to send, just return.
+          // Note that we don't short-return if we're ACKing just-received
+          // messages.
+          return true;
+        }
 
-      try {
-        // Update the URL with the message.
-        handler.frame.contentWindow.location = url;
+        if (handler.queue.length > 0) {
+          handler.waiting = true;
+        }
 
-        // Resize the frame.
-        var newWidth = handler.width == 10 ? 20 : 10;
-        handler.frame.style.width = newWidth + 'px';
-        handler.width = newWidth;
+        var url = handler.relayUri + '#' + getRmrData(targetId);
 
-        // Done!
-      } catch (e) {
-        // Something about location-setting or resizing failed.
-        // This should never happen, but if it does, fall back to
-        // the default transport.
-        return false;
+        try {
+          // Update the URL with the message.
+          handler.frame.contentWindow.location = url;
+
+          // Resize the frame.
+          var newWidth = handler.width == 10 ? 20 : 10;
+          handler.frame.style.width = newWidth + 'px';
+          handler.width = newWidth;
+
+          // Done!
+        } catch (e) {
+          // Something about location-setting or resizing failed.
+          // This should never happen, but if it does, fall back to
+          // the default transport.
+          return false;
+        }
       }
-    }
 
-    return true;
-  }
+      return true;
+    }
 
-  /**
+    /**
    * Returns as a string the data to be appended to an RMR relay frame,
    * constructed from the current request queue plus an ACK message indicating
    * the currently latest-processed message ID.
    *
    * @param {string} toFrameId Frame whose sendable queued data to retrieve.
    */
-  function getRmrData(toFrameId) {
-    var channel = rmr_channels[toFrameId];
-    var rmrData = {id: channel.sendId};
-    if (channel) {
-      rmrData.d = Array.prototype.slice.call(channel.queue, 0);
-      rmrData.d.push({s:gadgets.rpc.ACK, id:channel.recvId});
+    function getRmrData(toFrameId) {
+      var channel = rmr_channels[toFrameId];
+      var rmrData = {id: channel.sendId};
+      if (channel) {
+        rmrData.d = Array.prototype.slice.call(channel.queue, 0);
+        rmrData.d.push({s: gadgets.rpc.ACK, id: channel.recvId});
+      }
+      return gadgets.json.stringify(rmrData);
     }
-    return gadgets.json.stringify(rmrData);
-  }
 
-  /**
+    /**
    * Retrieve data from the channel keyed by the given frameId,
    * processing it as a batch. All processed data is assumed to have been
    * generated by getRmrData(...), pairing that method with this.
    *
    * @param {string} fromFrameId Frame from which data is being retrieved.
    */
-  function processRmrData(fromFrameId) {
-    var channel = rmr_channels[fromFrameId];
-    var data = channel.receiveWindow.location.hash.substring(1);
-
-    // Decode the RPC object array.
-    var rpcObj = gadgets.json.parse(decodeURIComponent(data)) || {};
-    var rpcArray = rpcObj.d || [];
-
-    var nonAckReceived = false;
-    var noLongerWaiting = false;
-
-    var numBypassed = 0;
-    var numToBypass = (channel.recvId - rpcObj.id);
-    for (var i = 0; i < rpcArray.length; ++i) {
-      var rpc = rpcArray[i];
-
-      // If we receive an ACK message, then mark the current
-      // handler as no longer waiting and send out the next
-      // queued message.
-      if (rpc.s === gadgets.rpc.ACK) {
-        // ACK received - whether this came from a handshake or
-        // an active call, in either case it indicates readiness to
-        // send messages to the from frame.
-        ready(fromFrameId, true);
+    function processRmrData(fromFrameId) {
+      var channel = rmr_channels[fromFrameId];
+      var data = channel.receiveWindow.location.hash.substring(1);
+
+      // Decode the RPC object array.
+      var rpcObj = gadgets.json.parse(decodeURIComponent(data)) || {};
+      var rpcArray = rpcObj.d || [];
+
+      var nonAckReceived = false;
+      var noLongerWaiting = false;
+
+      var numBypassed = 0;
+      var numToBypass = (channel.recvId - rpcObj.id);
+      for (var i = 0; i < rpcArray.length; ++i) {
+        var rpc = rpcArray[i];
+
+        // If we receive an ACK message, then mark the current
+        // handler as no longer waiting and send out the next
+        // queued message.
+        if (rpc.s === gadgets.rpc.ACK) {
+          // ACK received - whether this came from a handshake or
+          // an active call, in either case it indicates readiness to
+          // send messages to the from frame.
+          ready(fromFrameId, true);
+
+          if (channel.waiting) {
+            noLongerWaiting = true;
+          }
+
+          channel.waiting = false;
+          var newlyAcked = Math.max(0, rpc.id - channel.sendId);
+          channel.queue.splice(0, newlyAcked);
+          channel.sendId = Math.max(channel.sendId, rpc.id || 0);
+          continue;
+        }
 
-        if (channel.waiting) {
-          noLongerWaiting = true;
+        // If we get here, we've received > 0 non-ACK messages to
+        // process. Indicate this bit for later.
+        nonAckReceived = true;
+
+        // Bypass any messages already received.
+        if (++numBypassed <= numToBypass) {
+          continue;
         }
 
-        channel.waiting = false;
-        var newlyAcked = Math.max(0, rpc.id - channel.sendId);
-        channel.queue.splice(0, newlyAcked);
-        channel.sendId = Math.max(channel.sendId, rpc.id || 0);
-        continue;
+        ++channel.recvId;
+        process(rpc);  // actually dispatch the message
       }
 
-      // If we get here, we've received > 0 non-ACK messages to
-      // process. Indicate this bit for later.
-      nonAckReceived = true;
-
-      // Bypass any messages already received.
-      if (++numBypassed <= numToBypass) {
-        continue;
+      // Send an ACK indicating that we got/processed the message(s).
+      // Do so if we've received a message to process or if we were waiting
+      // before but a received ACK has cleared our waiting bit, and we have
+      // more messages to send. Performing this operation causes additional
+      // messages to be sent.
+      if (nonAckReceived ||
+          (noLongerWaiting && channel.queue.length > 0)) {
+        var from = (fromFrameId === '..') ? gadgets.rpc.RPC_ID : '..';
+        callRmr(fromFrameId, gadgets.rpc.ACK, from, {ackAlone: nonAckReceived});
       }
-
-      ++channel.recvId;
-      process(rpc);  // actually dispatch the message
-    }
-
-    // Send an ACK indicating that we got/processed the message(s).
-    // Do so if we've received a message to process or if we were waiting
-    // before but a received ACK has cleared our waiting bit, and we have
-    // more messages to send. Performing this operation causes additional
-    // messages to be sent.
-    if (nonAckReceived ||
-        (noLongerWaiting && channel.queue.length > 0)) {
-      var from = (fromFrameId === '..') ? gadgets.rpc.RPC_ID : '..';
-      callRmr(fromFrameId, gadgets.rpc.ACK, from, {ackAlone: nonAckReceived});
     }
-  }
 
-  /**
+    /**
    * Registers the RMR channel handler for the given frameId and associated
    * channel window.
    *
@@ -396,121 +396,121 @@ gadgets.rpctx.rmr = function() {
    * @return {boolean} True if the frame was setup successfully, false
    *   otherwise.
    */
-  function registerRmrChannel(frameId, channelWindow) {
-    var channel = rmr_channels[frameId];
+    function registerRmrChannel(frameId, channelWindow) {
+      var channel = rmr_channels[frameId];
 
-    // Verify that the channel is ready for receiving.
-    try {
-      var canAccess = false;
-
-      // Check to see if the document is in the window. For Chrome, this
-      // will return 'false' if the channelWindow is inaccessible by this
-      // piece of JavaScript code, meaning that the URL of the channelWindow's
-      // parent iframe has not yet changed from 'about:blank'. We do this
-      // check this way because any true *access* on the channelWindow object
-      // will raise a security exception, which, despite the try-catch, still
-      // gets reported to the debugger (it does not break execution, the try
-      // handles that problem, but it is still reported, which is bad form).
-      // This check always succeeds in Safari 3.1 regardless of the state of
-      // the window.
-      canAccess = 'document' in channelWindow;
+      // Verify that the channel is ready for receiving.
+      try {
+        var canAccess = false;
 
-      if (!canAccess) {
-        return false;
-      }
+        // Check to see if the document is in the window. For Chrome, this
+        // will return 'false' if the channelWindow is inaccessible by this
+        // piece of JavaScript code, meaning that the URL of the channelWindow's
+        // parent iframe has not yet changed from 'about:blank'. We do this
+        // check this way because any true *access* on the channelWindow object
+        // will raise a security exception, which, despite the try-catch, still
+        // gets reported to the debugger (it does not break execution, the try
+        // handles that problem, but it is still reported, which is bad form).
+        // This check always succeeds in Safari 3.1 regardless of the state of
+        // the window.
+        canAccess = 'document' in channelWindow;
 
-      // Check to see if the document is an object. For Safari 3.1, this will
-      // return undefined if the page is still inaccessible. Unfortunately, this
-      // *will* raise a security issue in the debugger.
-      // TODO Find a way around this problem.
-      canAccess = typeof channelWindow['document'] == 'object';
+        if (!canAccess) {
+          return false;
+        }
 
-      if (!canAccess) {
-        return false;
-      }
+        // Check to see if the document is an object. For Safari 3.1, this will
+        // return undefined if the page is still inaccessible. Unfortunately, this
+        // *will* raise a security issue in the debugger.
+        // TODO Find a way around this problem.
+        canAccess = typeof channelWindow['document'] == 'object';
 
-      // Once we get here, we know we can access the document (and anything else)
-      // on the window object. Therefore, we check to see if the location is
-      // still about:blank (this takes care of the Safari 3.2 case).
-      var loc = channelWindow.location.href;
+        if (!canAccess) {
+          return false;
+        }
 
-      // Check if this is about:blank for Safari.
-      if (loc === 'about:blank') {
+        // Once we get here, we know we can access the document (and anything else)
+        // on the window object. Therefore, we check to see if the location is
+        // still about:blank (this takes care of the Safari 3.2 case).
+        var loc = channelWindow.location.href;
+
+        // Check if this is about:blank for Safari.
+        if (loc === 'about:blank') {
+          return false;
+        }
+      } catch (ex) {
+        // For some reason, the iframe still points to about:blank. We try
+        // again in a bit.
         return false;
       }
-    } catch (ex) {
-      // For some reason, the iframe still points to about:blank. We try
-      // again in a bit.
-      return false;
-    }
 
-    // Save a reference to the receive window.
-    channel.receiveWindow = channelWindow;
+      // Save a reference to the receive window.
+      channel.receiveWindow = channelWindow;
 
-    // Register the onresize handler.
-    function onresize() {
-      processRmrData(frameId);
-    };
+      // Register the onresize handler.
+      function onresize() {
+        processRmrData(frameId);
+      };
 
-    if (typeof channelWindow.attachEvent === "undefined") {
-      channelWindow.onresize = onresize;
-    } else {
-      channelWindow.attachEvent("onresize", onresize);
-    }
+      if (typeof channelWindow.attachEvent === 'undefined') {
+        channelWindow.onresize = onresize;
+      } else {
+        channelWindow.attachEvent('onresize', onresize);
+      }
 
-    if (frameId === '..') {
-      // Gadget to container. Signal to the container that the gadget
-      // is ready to receive messages by attaching the g -> c relay.
-      // As a nice optimization, pass along any gadget to container
-      // queued messages that have backed up since then. ACK is enqueued in
-      // getRmrData to ensure that the container's waiting flag is set to false
-      // (this happens in the below code run on the container side).
-      appendRmrFrame(channel.frame, channel.relayUri, getRmrData(frameId), frameId);
-    } else {
-      // Process messages that the gadget sent in its initial relay payload.
-      // We can do this immediately because the container has already appended
-      // and loaded a relay frame that can be used to ACK the messages the gadget
-      // sent. In the preceding if-block, however, the processRmrData(...) call
-      // must wait. That's because appendRmrFrame may not actually append the
-      // frame - in the context of a gadget, this code may be running in the
-      // head element, so it cannot be appended to body. As a result, the
-      // gadget cannot ACK the container for messages it received.
-      processRmrData(frameId);
+      if (frameId === '..') {
+        // Gadget to container. Signal to the container that the gadget
+        // is ready to receive messages by attaching the g -> c relay.
+        // As a nice optimization, pass along any gadget to container
+        // queued messages that have backed up since then. ACK is enqueued in
+        // getRmrData to ensure that the container's waiting flag is set to false
+        // (this happens in the below code run on the container side).
+        appendRmrFrame(channel.frame, channel.relayUri, getRmrData(frameId), frameId);
+      } else {
+        // Process messages that the gadget sent in its initial relay payload.
+        // We can do this immediately because the container has already appended
+        // and loaded a relay frame that can be used to ACK the messages the gadget
+        // sent. In the preceding if-block, however, the processRmrData(...) call
+        // must wait. That's because appendRmrFrame may not actually append the
+        // frame - in the context of a gadget, this code may be running in the
+        // head element, so it cannot be appended to body. As a result, the
+        // gadget cannot ACK the container for messages it received.
+        processRmrData(frameId);
+      }
+
+      return true;
     }
 
-    return true;
-  }
+    return {
+      getCode: function() {
+        return 'rmr';
+      },
 
-  return {
-    getCode: function() {
-      return 'rmr';
-    },
+      isParentVerifiable: function() {
+        return true;
+      },
 
-    isParentVerifiable: function() {
-      return true;
-    },
+      init: function(processFn, readyFn) {
+        // No global setup.
+        process = processFn;
+        ready = readyFn;
+        return true;
+      },
 
-    init: function(processFn, readyFn) {
-      // No global setup.
-      process = processFn;
-      ready = readyFn;
-      return true;
-    },
+      setup: function(receiverId, token) {
+        try {
+          setupRmr(receiverId);
+        } catch (e) {
+          gadgets.warn('Caught exception setting up RMR: ' + e);
+          return false;
+        }
+        return true;
+      },
 
-    setup: function(receiverId, token) {
-      try {
-        setupRmr(receiverId);
-      } catch (e) {
-        gadgets.warn('Caught exception setting up RMR: ' + e);
-        return false;
+      call: function(targetId, from, rpc) {
+        return callRmr(targetId, rpc.s, from, rpc);
       }
-      return true;
-    },
-
-    call: function(targetId, from, rpc) {
-      return callRmr(targetId, rpc.s, from, rpc);
-    }
-  };
-}();
+    };
+  }();
 
 } // !end of double-inclusion guard