In my background script:
var collection = Backbone.Collection.extend({});
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
sendResponse(new collection());
}
In my browser_action's javascript:
chrome.tabs.getSelected(null, function(tab) {
chrome.extension.sendRequest({
action: "someAction",
tab: tab
},
function(collection) {
// collection is now a JS array, rather than Backbone.Collection
});
});
As mentioned in the comment above the 'collection' argument in the sendRequest callback turns out to be a regular JS array, rather than Backbone.Collection.
Is this a sanitisation artefact / security measure taken by chromium? Is there any way to pass a Backbone.Collection via sendRequest?