chrome 拡張機能のコンテンツ スクリプトで単純なカスタム タイプを使用しています。アイテムの配列は、chrome.extension.sendRequest() を介してバックグラウンド ページに送信されます。bgpage デバッガーでは、私のタイプのインスタンスにこれらのメソッドがないことが示されています。また、未定義の値を持つ型プロパティでも同じことが起こります。どうしたの。
function User(id, holder) {
this.id = id;
var hObj = {};
hObj[holder] = 'undefined'; // this is ok
this.holder = hObj;
this.Result = undefined; // this will be lost
this.Code = undefined; // this will be lost
}
// this will be lost
User.prototype.getFirstHolderType = function() {
for (h in this.holder) {
if (h) return h;
}
return false;
};
// this will be lost
User.prototype.hasHolderType = function(h_type) {
for (h in this.holder) {
if (h_type === h) return true;
}
return false;
};
//...
chrome.extension.sendRequest({id: "users_come", users: users},
function(response) {});