2011-10-19 51 views
1

上的http請求撞毀我想這個代碼:Firefox是使用插件

// This is an active module of the goelvivek (10) Add-on 
// This is an active module of the goelvivek (9) Add-on 

var pageMod = require("page-mod"); 
var request = require('request'); 
pageMod.PageMod({ 
    include: "*", 
    contentScriptWhen: "end", 
    contentScript: 'var doc_c=document.title;console.log(doc_c);var body_uri=document.URI;self.postMessage(body_uri);', 
    onAttach:function(body_c){ 
     console.log("onattach"); 
     var req = request.Request({ 
      url:"http://google.com", 
      content:{ 
       v:"1", 
       body:body_c    
       }, 
       oncomplete: function (response){ 
        console.log(response); 
        } 
     }); 
     req.get(); 
     } 
}); 

但Firefox崩潰。爲什麼?

你可以在https://builder.addons.mozilla.org/addon/1021520/latest/

+0

您是否發送了崩潰報告?請參閱http://support.mozilla.com/zh-CN/kb/Firefox%20crashes#w_get-help-fixing-this-crash –

+0

https://crash-stats.mozilla.com/report/index/bp-1f78c671 -cc54-4fc9-86f8-b80022111019 –

+0

但我得到錯誤 我們無法找到您之後的OOID。如果您最近提交了此次崩潰,它可能仍然在隊列中。 如果您認爲此消息有誤,請提交說明發生了什麼的Bugzilla憑單,並請包含此頁面的網址。 –

回答

2

測試插件它沒有崩潰,我在最近的一個每晚。相反,它會消耗大量內存並掛起,直到出現Unresponsive腳本對話框。

的原因掛的是你期待的onAttachbody_c參數是從內容腳本的消息,但它是一個worker object有很多subreferences的,甚至可能是圓形的。

SDK的Request有此code在發送請求之前將作爲content傳遞的對象轉換爲字符串。它應該遞歸地走動對象,顯然它會阻塞您通過的工作對象。

+0

只有一件事要補充:不是試圖發送'onAttach'參數,這個擴展名應該調用'worker.on(「message」,function(數據){...})'在第二個「與內容腳本通信」示例中指出的那個回調實際上將從內容腳本接收消息。 –