Author: jasvir
Date: Tue Mar  9 02:11:44 2010
New Revision: 920622

URL: http://svn.apache.org/viewvc?rev=920622&view=rev
Log:
Description:
* filters out caja properties from native json.stringify
* tames methods created using osapi.registerMethod_
 - the latter should be reviewed particularly carefully


Modified:
    shindig/trunk/features/src/main/javascript/features/core.json/json.js
    shindig/trunk/features/src/main/javascript/features/osapi/osapi.js
    
shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java

Modified: shindig/trunk/features/src/main/javascript/features/core.json/json.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.json/json.js?rev=920622&r1=920621&r2=920622&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.json/json.js 
(original)
+++ shindig/trunk/features/src/main/javascript/features/core.json/json.js Tue 
Mar  9 02:11:44 2010
@@ -42,22 +42,27 @@ if (window.JSON && window.JSON.parse && 
   // HTML5 implementation, or already defined.
   // Not a direct alias as the opensocial specification disagrees with the 
HTML5 JSON spec.
   // JSON says to throw on parse errors and to support filtering functions. OS 
does not.
-  gadgets['json'] = {
-    'parse': function(str) {
-      try {
-        return window.JSON.parse(str);
-      } catch (e) {
-        return false;
-      }
-    },
-    'stringify': function(obj) {
-      try {
-        return window.JSON.stringify(obj);
-      } catch (e) {
-        return null;
+  gadgets['json'] = (function() {
+    var endsWith___ = /___$/;
+    return {
+      'parse': function(str) {
+        try {
+          return window.JSON.parse(str);
+        } catch (e) {
+          return false;
+        }
+      },
+      'stringify': function(obj) {
+        try {
+          return window.JSON.stringify(obj, function(k,v) {
+            return !endsWith___.test(k) ? v : null;
+          });
+        } catch (e) {
+          return null;
+        }
       }
-    }
-  };
+    };
+  })();
 } else {
   gadgets['json'] = function () {
   

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=920622&r1=920621&r2=920622&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi/osapi.js 
(original)
+++ shindig/trunk/features/src/main/javascript/features/osapi/osapi.js Tue Mar  
9 02:11:44 2010
@@ -17,9 +17,7 @@
  */
 
 var osapi = osapi || {};
-var tamings___ = tamings___ || [];
 (function() {
-
   /**
    * Called by the transports for each service method that they expose
    * @param {string} method  The method to expose e.g. "people.get"
@@ -38,16 +36,20 @@ var tamings___ = tamings___ || [];
       var batch = osapi.newBatch();
       var boundCall = {};
       boundCall.execute = function(callback) {
+        var feralCallback = window.___ ? ___.untame(callback) : callback;
+        var that = window.___ ? ___.USELESS : this;
         batch.add(method, this);
         batch.execute(function(batchResult) {
           if (batchResult.error) {
-            callback(batchResult.error);
+            feralCallback.call(that, batchResult.error);
           } else {
-            callback(batchResult[method]);
+            feralCallback.call(that, batchResult[method]);
           }
         });
       }
-
+      if (window.___) {
+          ___.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 || {};

Modified: 
shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
URL: 
http://svn.apache.org/viewvc/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java?rev=920622&r1=920621&r2=920622&view=diff
==============================================================================
--- 
shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
 (original)
+++ 
shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
 Tue Mar  9 02:11:44 2010
@@ -237,6 +237,16 @@ public class EndToEndTest {
   }
 
   @Test
+  public void testCajaOsapiAppdata() throws Exception {
+    executeAllPageTests("osapi/appdataTest", true /* caja */);
+  }
+
+  @Test
+  public void testCajaOsapiBatch() throws Exception {
+    executeAllPageTests("osapi/batchTest", true /* caja */);
+  }
+  
+  @Test
   public void testTemplateRewrite() throws Exception {
     HtmlPage page = executePageTest("templateRewriter", null);
     


Reply via email to