commit d18b6ffcf0f960a7c802ce756b68ca4f1f819b77
parent 1dd67fe8378b0b605397d2f9b9f18a3bef7405f4
Author: Simon Kornblith <simon@simonster.com>
Date: Wed, 10 Oct 2012 15:34:10 -0400
Fix Zotero.selectItems for Firefox 17 sandboxing changes
Diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js
@@ -420,6 +420,10 @@ Zotero.Translate.Sandbox = {
* @param {Object} items An set of id => name pairs in object format
*/
"selectItems":function(translate, items, callback) {
+ function transferObject(obj) {
+ return Zotero.isFx ? translate._sandboxManager.sandbox.JSON.parse(JSON.stringify(obj)) : obj;
+ }
+
if(Zotero.Utilities.isEmpty(items)) {
throw new Error("Translator called select items with no items");
}
@@ -435,7 +439,7 @@ Zotero.Translate.Sandbox = {
if(translate._selectedItems) {
// if we have a set of selected items for this translation, use them
- return translate._selectedItems;
+ return transferObject(translate._selectedItems);
} else if(translate._handlers.select) {
// whether the translator supports asynchronous selectItems
var haveAsyncCallback = !!callback;
@@ -449,7 +453,7 @@ Zotero.Translate.Sandbox = {
// up to pop off the async process
var newCallback = function(selectedItems) {
callbackExecuted = true;
- callback(selectedItems);
+ callback(transferObject(selectedItems));
if(haveAsyncHandler) translate.decrementAsyncProcesses("Zotero.selectItems()");
};
} else {
@@ -461,7 +465,7 @@ Zotero.Translate.Sandbox = {
if(haveAsyncHandler) {
translate.translate(translate._libraryID, translate._saveAttachments, selectedItems);
} else {
- returnedItems = selectedItems;
+ returnedItems = transferObject(selectedItems);
}
};
}
@@ -473,7 +477,7 @@ Zotero.Translate.Sandbox = {
"Please pass items as to the callback provided as the third argument to "+
"the handler.");
- returnedItems = returnValue;
+ returnedItems = transferObject(returnValue);
haveAsyncHandler = false;
} else {
// if we don't have returnedItems set already, the handler is asynchronous
@@ -492,7 +496,7 @@ Zotero.Translate.Sandbox = {
} else {
translate._debug("COMPAT WARNING: No callback was provided for "+
"Zotero.selectItems(). When executed outside of Firefox, a selectItems() call "+
- "will require that this translator to be called multiple times.", 1);
+ "will require this translator to be called multiple times.", 1);
if(haveAsyncHandler) {
// The select handler is asynchronous, but this translator doesn't support