私のバックグラウンドスクリプトでは:
var collection = Backbone.Collection.extend({});
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
sendResponse(new collection());
}
私の browser_action の 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
});
});
上記のコメントで述べたように、sendRequest コールバックの「コレクション」引数は、Backbone.Collection ではなく、通常の JS 配列であることが判明しました。
これは、クロムによるサニタイズ アーティファクト / セキュリティ対策ですか? sendRequest 経由で Backbone.Collection を渡す方法はありますか?