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 2011/05/17 03:14:02 UTC
svn commit: r1103973 - in /shindig/trunk/features/src:
main/javascript/features/caja/ main/javascript/features/core.json/
main/javascript/features/opensocial-reference/
main/javascript/features/osapi.base/ test/javascript/features/
test/javascript/feat...
Author: lindner
Date: Tue May 17 01:14:02 2011
New Revision: 1103973
URL: http://svn.apache.org/viewvc?rev=1103973&view=rev
Log:
Patch from felix lee | fix osapi taming for caja es53
Modified:
shindig/trunk/features/src/main/javascript/features/caja/feature.xml
shindig/trunk/features/src/main/javascript/features/caja/taming.js
shindig/trunk/features/src/main/javascript/features/core.json/json-jsimpl.js
shindig/trunk/features/src/main/javascript/features/core.json/json-native.js
shindig/trunk/features/src/main/javascript/features/opensocial-reference/taming.js
shindig/trunk/features/src/main/javascript/features/osapi.base/feature.xml
shindig/trunk/features/src/main/javascript/features/osapi.base/osapi.js
shindig/trunk/features/src/main/javascript/features/osapi.base/taming.js
shindig/trunk/features/src/test/javascript/features/alltests.js
shindig/trunk/features/src/test/javascript/features/mocks/env.js
Modified: shindig/trunk/features/src/main/javascript/features/caja/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/caja/feature.xml?rev=1103973&r1=1103972&r2=1103973&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/caja/feature.xml (original)
+++ shindig/trunk/features/src/main/javascript/features/caja/feature.xml Tue May 17 01:14:02 2011
@@ -23,18 +23,21 @@ specific language governing permissions
<dependency>taming</dependency>
<gadget>
<script src="taming.js"/>
- <exports type="js">caja___.getPendingScript</exports>
- <exports type="js">caja___.getTameGlobal</exports>
- <exports type="js">caja___.grantTameAsRead</exports>
- <exports type="js">caja___.loadedGuestFrame</exports>
- <exports type="js">caja___.loadedTamingFrame</exports>
- <exports type="js">caja___.markTameAsFunction</exports>
- <exports type="js">caja___.start</exports>
- <exports type="js">caja___.tame</exports>
- <exports type="js">caja___.tamesTo</exports>
- <exports type="js">caja___.whitelistCtors</exports>
- <exports type="js">caja___.whitelistFuncs</exports>
- <exports type="js">caja___.whitelistMeths</exports>
- <exports type="js">caja___.whitelistProps</exports>
+ <api>
+ <exports type="js">caja___.getPendingScript</exports>
+ <exports type="js">caja___.getTameGlobal</exports>
+ <exports type="js">caja___.getUseless</exports>
+ <exports type="js">caja___.loadedGuestFrame</exports>
+ <exports type="js">caja___.loadedTamingFrame</exports>
+ <exports type="js">caja___.markTameAsFunction</exports>
+ <exports type="js">caja___.start</exports>
+ <exports type="js">caja___.tame</exports>
+ <exports type="js">caja___.tamesTo</exports>
+ <exports type="js">caja___.untame</exports>
+ <exports type="js">caja___.whitelistCtors</exports>
+ <exports type="js">caja___.whitelistFuncs</exports>
+ <exports type="js">caja___.whitelistMeths</exports>
+ <exports type="js">caja___.whitelistProps</exports>
+ </api>
</gadget>
</feature>
Modified: shindig/trunk/features/src/main/javascript/features/caja/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/caja/taming.js?rev=1103973&r1=1103972&r2=1103973&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/caja/taming.js (original)
+++ shindig/trunk/features/src/main/javascript/features/caja/taming.js Tue May 17 01:14:02 2011
@@ -58,8 +58,12 @@ caja___ = (function() {
return tamingFrame.contentWindow;
}
- function grantTameAsRead(obj, propName) {
- tame___.grantTameAsRead(obj, propName);
+ function getUseless() {
+ return tame___ && tame___.USELESS;
+ }
+
+ function markTameAsFunction(func, name) {
+ return tame___.markTameAsFunction(func, name);
}
function tame(obj) {
@@ -70,8 +74,8 @@ caja___ = (function() {
tame___.tamesTo(feral, tame);
}
- function markTameAsFunction(f, name) {
- return tame___.markTameAsFunction(f, name);
+ function untame(obj) {
+ return tame___.untame(obj);
}
function whitelistCtors(schemas) {
@@ -209,13 +213,14 @@ caja___ = (function() {
return {
getPendingScript: getPendingScript,
getTameGlobal: getTameGlobal,
- grantTameAsRead: grantTameAsRead,
+ getUseless: getUseless,
loadedGuestFrame: loadedGuestFrame,
loadedTamingFrame: loadedTamingFrame,
markTameAsFunction: markTameAsFunction,
start: start,
tame: tame,
tamesTo: tamesTo,
+ untame: untame,
whitelistCtors: whitelistCtors,
whitelistFuncs: whitelistFuncs,
whitelistMeths: whitelistMeths,
Modified: shindig/trunk/features/src/main/javascript/features/core.json/json-jsimpl.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.json/json-jsimpl.js?rev=1103973&r1=1103972&r2=1103973&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.json/json-jsimpl.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.json/json-jsimpl.js Tue May 17 01:14:02 2011
@@ -90,7 +90,7 @@ if (!(window.JSON && window.JSON.parse &
i, // The loop counter.
k, // The member key.
l, // Length.
- r = /["\\\x00-\x1f\x7f-\x9f]/g,
+ r = /[\"\\\x00-\x1f\x7f-\x9f]/g,
v; // The member value.
switch (typeof value) {
@@ -135,7 +135,7 @@ if (!(window.JSON && window.JSON.parse &
}
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
- if (k.match('___$'))
+ if (/___$/.test(k))
continue;
if (value.hasOwnProperty(k)) {
if (typeof k === 'string') {
Modified: shindig/trunk/features/src/main/javascript/features/core.json/json-native.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.json/json-native.js?rev=1103973&r1=1103972&r2=1103973&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.json/json-native.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.json/json-native.js Tue May 17 01:14:02 2011
@@ -68,7 +68,7 @@ if (window.JSON && window.JSON.parse &&
patchedStringify : orig;
try {
return stringifyFn(obj, function(k,v) {
- return !endsWith___.test(k) ? v : null;
+ return !endsWith___.test(k) ? v : void 0;
});
} catch (e) {
return null;
Modified: shindig/trunk/features/src/main/javascript/features/opensocial-reference/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-reference/taming.js?rev=1103973&r1=1103972&r2=1103973&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-reference/taming.js (original)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-reference/taming.js Tue May 17 01:14:02 2011
@@ -205,9 +205,10 @@ tamings___.push(function(imports) {
// TODO(jasvir): The following object *is* exposed to gadget
// code because its returned by opensocial.DataRequest.*
// but isn't documented in gadget API.
- caja___.grantTameAsRead(JsonRpcRequestItem, 'rpc');
- caja___.grantTameAsRead(JsonRpcRequestItem, 'processData');
- caja___.grantTameAsRead(JsonRpcRequestItem, 'processResponse');
- caja___.grantTameAsRead(JsonRpcRequestItem, 'errors');
-
+ caja___.whitelistProps([
+ [JsonRpcRequestItem, 'rpc'],
+ [JsonRpcRequestItem, 'processData'],
+ [JsonRpcRequestItem, 'processResponse'],
+ [JsonRpcRequestItem, 'errors']
+ ]);
});
Modified: shindig/trunk/features/src/main/javascript/features/osapi.base/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi.base/feature.xml?rev=1103973&r1=1103972&r2=1103973&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi.base/feature.xml (original)
+++ shindig/trunk/features/src/main/javascript/features/osapi.base/feature.xml Tue May 17 01:14:02 2011
@@ -30,6 +30,8 @@
<exports type="js">osapi.newBatch.add</exports>
<exports type="js">osapi.newBatch.execute</exports>
<exports type="js">osapi._registerMethod</exports>
+ <exports type="js">osapi._BoundCall</exports>
+ <exports type="js">osapi._BoundCall.prototype.execute</exports>
</api>
</all>
</feature>
Modified: shindig/trunk/features/src/main/javascript/features/osapi.base/osapi.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi.base/osapi.js?rev=1103973&r1=1103972&r2=1103973&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi.base/osapi.js (original)
+++ shindig/trunk/features/src/main/javascript/features/osapi.base/osapi.js Tue May 17 01:14:02 2011
@@ -19,13 +19,12 @@
/**
* 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 {Object.<string,Object>} transport The transport used to
+ * execute a call for the method.
*/
osapi._registerMethod = function(method, transport) {
- var has___ = typeof ___ !== 'undefined';
-
// Skip registration of local newBatch implementation.
- if (method == 'newBatch') {
+ if (method === 'newBatch') {
return;
}
@@ -36,46 +35,53 @@ osapi._registerMethod = function(method,
last[parts[i]] = last[parts[i]] || {};
last = last[parts[i]];
}
+ var basename = parts[parts.length - 1];
+ if (last[basename]) {
+ gadgets.warn('Skipping duplicate osapi method definition '
+ + method + ' on transport ' + transport['name']);
+ return;
+ }
- // Use the batch as the actual executor of calls.
- var apiMethod = function(rpc) {
- var batch = osapi.newBatch();
- var boundCall = {};
- boundCall.execute = function(callback) {
- var feralCallback = has___ ? ___.untame(callback) : callback;
- var that = has___ ? ___.USELESS : this;
- batch.add(method, this);
- batch.execute(function(batchResult) {
- if (batchResult.error) {
- feralCallback.call(that, batchResult.error);
- } else {
- feralCallback.call(that, batchResult[method]);
- }
- });
- };
- if (has___) {
- ___.markFunc(boundCall.execute, 'execute');
- }
- // TODO: This shouldnt really be necessary. The spec should be clear enough about
- // defaults that we dont have to populate this.
+ last[basename] = function(rpc) {
+ // TODO: This shouldn't 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';
-
- // Decorate the execute method with the information necessary for batching
- boundCall['method'] = method;
- boundCall['transport'] = transport;
- boundCall['rpc'] = rpc;
-
+ var boundCall = new osapi._BoundCall(method, transport, rpc);
return boundCall;
};
- if (has___ && typeof ___.markFunc !== 'undefined') {
- ___.markFunc(apiMethod, method);
- }
- if (last[parts[parts.length - 1]]) {
- gadgets.warn('Skipping duplicate osapi method definition ' + method + ' on transport ' + transport['name']);
- } else {
- last[parts[parts.length - 1]] = apiMethod;
+ if (typeof tamings___ !== 'undefined') {
+ tamings___.push(function() {
+ caja___.markTameAsFunction(last[basename], method);
+ });
}
};
+
+// This was formerly an anonymous ad-hoc object, but that triggers a caja
+// bug: http://code.google.com/p/google-caja/issues/detail?id=1355
+// Workaround is to make it a class.
+osapi._BoundCall = function(method, transport, rpc) {
+ this.method = method;
+ this.transport = transport;
+ this.rpc = rpc;
+};
+
+osapi._BoundCall.prototype.execute = function(callback) {
+ var cajaReady = (typeof caja___ !== 'undefined'
+ && caja___.getUseless
+ && caja___.getUseless());
+ var that = cajaReady ? caja___.getUseless() : this;
+ var feralCallback = cajaReady ? caja___.untame(callback) : callback;
+ var batch = osapi.newBatch();
+ batch.add(this.method, this);
+ batch.execute(function(batchResult) {
+ if (batchResult.error) {
+ feralCallback.call(that, batchResult.error);
+ } else {
+ feralCallback.call(that, batchResult[that.method]);
+ }
+ });
+};
+
Modified: shindig/trunk/features/src/main/javascript/features/osapi.base/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi.base/taming.js?rev=1103973&r1=1103972&r2=1103973&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi.base/taming.js (original)
+++ shindig/trunk/features/src/main/javascript/features/osapi.base/taming.js Tue May 17 01:14:02 2011
@@ -22,13 +22,20 @@
* Tame and expose core osapi.* API to cajoled gadgets
*/
tamings___.push(function(imports) {
- caja___.tamesTo(osapi.newBatch, caja___.markTameAsFunction(function() {
+ function newBatch() {
var batch = osapi.newBatch();
caja___.whitelistFuncs([
[batch, 'add'],
[batch, 'execute']
]);
- var t = caja___.tame(batch);
- return t;
- }, 'newBatch'));
+ return caja___.tame(batch);
+ }
+ caja___.markTameAsFunction(newBatch, 'newBatch');
+ caja___.tamesTo(osapi.newBatch, newBatch);
+ caja___.whitelistCtors([
+ [osapi, '_BoundCall', Object]
+ ]);
+ caja___.whitelistMeths([
+ [osapi._BoundCall, 'execute']
+ ]);
});
Modified: shindig/trunk/features/src/test/javascript/features/alltests.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/alltests.js?rev=1103973&r1=1103972&r2=1103973&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/alltests.js (original)
+++ shindig/trunk/features/src/test/javascript/features/alltests.js Tue May 17 01:14:02 2011
@@ -34,11 +34,18 @@ if (!this.JsUtil) {
}
eval(JsUtil.prototype.include(testSrcDir + '/mocks/env.js'));
+ eval(JsUtil.prototype.include(testSrcDir + '/mocks/window.js'));
eval(JsUtil.prototype.include(testSrcDir + '/mocks/xhr.js'));
+ eval(JsUtil.prototype.include(srcDir + '/globals/globals.js'));
+ eval(JsUtil.prototype.include(srcDir + '/cloo/cloo.js'));
eval(JsUtil.prototype.include(srcDir + '/core.config.base/config.js'));
+ eval(JsUtil.prototype.include(srcDir + '/core.config.base/configcontainer.js'));
+ eval(JsUtil.prototype.include(srcDir + '/core.config.base/configgadget.js'));
+ eval(JsUtil.prototype.include(srcDir + '/core.config/validators.js'));
eval(JsUtil.prototype.include(srcDir + '/core.json/json-native.js'));
eval(JsUtil.prototype.include(srcDir + '/core.json/json-jsimpl.js'));
eval(JsUtil.prototype.include(srcDir + '/core.json/json-flatten.js'));
+ eval(JsUtil.prototype.include(srcDir + '/shindig.auth/auth.js'));
eval(JsUtil.prototype.include(srcDir + '/core.util.dom/dom.js'));
eval(JsUtil.prototype.include(srcDir + '/core.util.string/string.js'));
eval(JsUtil.prototype.include(srcDir + '/core.util.urlparams/urlparams.js'));
@@ -46,12 +53,28 @@ if (!this.JsUtil) {
eval(JsUtil.prototype.include(srcDir + '/core.prefs/prefs.js'));
eval(JsUtil.prototype.include(srcDir + '/core.log/log.js'));
eval(JsUtil.prototype.include(srcDir + '/core.io/io.js'));
+ eval(JsUtil.prototype.include(srcDir + '/container/constant.js'));
+ eval(JsUtil.prototype.include(srcDir + '/container/util.js'));
+ eval(JsUtil.prototype.include(srcDir + '/container/service.js'));
+ eval(JsUtil.prototype.include(srcDir + '/container/gadget_holder.js'));
+ eval(JsUtil.prototype.include(srcDir + '/container/gadget_site.js'));
+ eval(JsUtil.prototype.include(srcDir + '/container/container.js'));
+ eval(JsUtil.prototype.include(srcDir + '/i18n/currencycodemap.js'));
+ eval(JsUtil.prototype.include(srcDir + '/i18n/datetimeformat.js'));
+ eval(JsUtil.prototype.include(srcDir + '/i18n/datetimeparse.js'));
+ eval(JsUtil.prototype.include(srcDir + '/i18n/formatting.js'));
+ eval(JsUtil.prototype.include(srcDir + '/i18n/numberformat.js'));
+ eval(JsUtil.prototype.include(srcDir + '/setprefs/setprefs.js'));
eval(JsUtil.prototype.include(srcDir + '/views/views.js'));
- eval(JsUtil.prototype.include(srcDir + '/xhrwrapper/xhrwrapper.js'));
+ eval(JsUtil.prototype.include(srcDir + '/shindig.uri/uri.js'));
+ eval(JsUtil.prototype.include(srcDir + '/shindig.xhrwrapper/xhrwrapper.js'));
+ eval(JsUtil.prototype.include(srcDir + '/xmlutil/xmlutil.js'));
+ eval(JsUtil.prototype.include(srcDir + '/opensocial-data-context/datacontext.js'));
+ eval(JsUtil.prototype.include(srcDir + '/opensocial-data/data.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/opensocial.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/activity.js'));
- eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/album.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/address.js'));
+ eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/album.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/bodytype.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/collection.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/container.js'));
@@ -70,6 +93,7 @@ if (!this.JsUtil) {
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/phone.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/responseitem.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/url.js'));
+ eval(JsUtil.prototype.include(srcDir + '/opensocial-base/fieldtranslations.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-base/jsonactivity.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-base/jsonalbum.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-base/jsonmediaitem.js'));
@@ -78,17 +102,9 @@ if (!this.JsUtil) {
eval(JsUtil.prototype.include(srcDir + '/osapi.base/osapi.js'));
eval(JsUtil.prototype.include(srcDir + '/osapi.base/batch.js'));
eval(JsUtil.prototype.include(srcDir + '/osapi/jsonrpctransport.js'));
- eval(JsUtil.prototype.include(srcDir + '/osapi/gadgetsrpctransport.js'));
eval(JsUtil.prototype.include(srcDir + '/osapi/peoplehelpers.js'));
- eval(JsUtil.prototype.include(srcDir + '/shindig.auth/auth.js'));
- eval(JsUtil.prototype.include(srcDir + '/shindig.uri/uri.js'));
- eval(JsUtil.prototype.include(srcDir + '/container/constant.js'));
- eval(JsUtil.prototype.include(srcDir + '/container/util.js'));
- eval(JsUtil.prototype.include(srcDir + '/container/service.js'));
- eval(JsUtil.prototype.include(srcDir + '/container/gadget_holder.js'));
- eval(JsUtil.prototype.include(srcDir + '/container/gadget_site.js'));
- eval(JsUtil.prototype.include(srcDir + '/container/container.js'));
eval(JsUtil.prototype.include(testToolsDir + "/JsUnit.js"));
+ eval(JsUtil.prototype.include(testToolsDir + '/testutils.js'));
eval(JsUtil.prototype.include(testSrcDir + "/core/authtest.js"));
eval(JsUtil.prototype.include(testSrcDir + "/core/config-test.js"));
eval(JsUtil.prototype.include(testSrcDir + "/core/prefstest.js"));
@@ -103,7 +119,6 @@ if (!this.JsUtil) {
eval(JsUtil.prototype.include(testSrcDir + "/opensocial-templates/os_test.js"));
eval(JsUtil.prototype.include(testSrcDir + "/opensocial-templates/template_test.js"));
eval(JsUtil.prototype.include(testSrcDir + "/opensocial-templates/util_test.js"));
- eval(JsUtil.prototype.include(testToolsDir + '/testutils.js'));
eval(JsUtil.prototype.include(testSrcDir + "/osapi/osapitest.js"));
eval(JsUtil.prototype.include(testSrcDir + "/osapi/batchtest.js"));
eval(JsUtil.prototype.include(testSrcDir + "/osapi/jsonrpctransporttest.js"));
Modified: shindig/trunk/features/src/test/javascript/features/mocks/env.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/mocks/env.js?rev=1103973&r1=1103972&r2=1103973&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/mocks/env.js (original)
+++ shindig/trunk/features/src/test/javascript/features/mocks/env.js Tue May 17 01:14:02 2011
@@ -27,7 +27,8 @@
var document = {
location: {
href: "http://localhost"
- }
+ },
+ getElementsByTagName: function (name) { return []; }
};
// See mocks.FakeWindow if you need something more full featured.