Firebreath JavaScript 错误:不受支持:类型函数中没有 toString() 函数

发布于 2025-01-05 01:58:20 字数 1589 浏览 1 评论 0原文

我正在使用 firebreath 框架编写浏览器插件。当我将插件与 javascript 一起使用时,我收到一个奇怪的错误:

unsupported: no toString() function in type function

当我尝试多次调用 Dropbox_pluginAPI 类上返回 JSAPIPtr 的方法时,我收到此错误。

这是代码:

 //JavaScript context
for(var i=0; i<100; i++)
{
//After several times of calling the method I get the error: unsupported: no toString() function in type function
var md = plugin().getMetaDataOfFileOrFolder("dropbox/demotext","null",true,false,"null"); 
}


//API class

FB::JSAPIPtr Dropbox_pluginAPI::getMetaDataOfFileOrFolder(std::string fileOrFolderPath,std::string hash, bool list, bool include_deleted,
std::string rev)
{
MetaData m = client->getMetaDataOfFileOrFolder(fileOrFolderPath,hash,list,include_deleted,rev);

return boost::make_shared<MetaDataAPI>(m_host,m);

}


//MetaDataAPI class
class MetaDataAPI : public FB::JSAPIAuto
{
public:

/**
* Constructor.
* @param host The browser
* @param m The MetaData object
*/
MetaDataAPI(const FB::BrowserHostPtr& host,MetaData m);

.....
.....

}

我希望有人使用 firebreath 并可以帮助我!


我更新了 Firefox 版本并将各个部分分成不同的行,但错误仍然发生。 我做了以下事情:

var plug = plugin();
var fn = plug.getMetaDataOfFileOrFolder;
var md;
for(var i=0; i<100; i++)
{
    md = fn("dropbox/demotext","null",true,false,"null"); 
}   
alert("Finish");

永远不会调用警报!一些调用后仍然出现错误:

    [unsupported: no toString() function in type function]

in line:

    md = fn("dropbox/demotext","null",true,false,"null"); 

I am using the firebreath framework to write a browser plugin. When I use the plugin with javascript I get an weird error:

unsupported: no toString() function in type function

I get this error wheny I try to call several times a method on my Dropbox_pluginAPI class that returns a JSAPIPtr.

Here is the code:

 //JavaScript context
for(var i=0; i<100; i++)
{
//After several times of calling the method I get the error: unsupported: no toString() function in type function
var md = plugin().getMetaDataOfFileOrFolder("dropbox/demotext","null",true,false,"null"); 
}


//API class

FB::JSAPIPtr Dropbox_pluginAPI::getMetaDataOfFileOrFolder(std::string fileOrFolderPath,std::string hash, bool list, bool include_deleted,
std::string rev)
{
MetaData m = client->getMetaDataOfFileOrFolder(fileOrFolderPath,hash,list,include_deleted,rev);

return boost::make_shared<MetaDataAPI>(m_host,m);

}


//MetaDataAPI class
class MetaDataAPI : public FB::JSAPIAuto
{
public:

/**
* Constructor.
* @param host The browser
* @param m The MetaData object
*/
MetaDataAPI(const FB::BrowserHostPtr& host,MetaData m);

.....
.....

}

I hope that someone works with firebreath and can help me !


I updated the firefox version and seperated pieces into different lines but the error still occurs.
I did the following:

var plug = plugin();
var fn = plug.getMetaDataOfFileOrFolder;
var md;
for(var i=0; i<100; i++)
{
    md = fn("dropbox/demotext","null",true,false,"null"); 
}   
alert("Finish");

The alert will never be called! There is still the error after some calls:

    [unsupported: no toString() function in type function]

in line:

    md = fn("dropbox/demotext","null",true,false,"null"); 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白衬杉格子梦 2025-01-12 01:58:20
  1. 首先尝试更新 Firefox;旧版本的 Firefox 中存在一个错误,它有时会交换通过桥发送的两个 NPObject,从而为您提供与应有的对象不同的对象。

  2. 将你的plugin()调用移动到父作用域,这样你就不会每次都调用它

  3. 单独的部分将其分成不同的行,以便您可以准确地看到错误发生的位置

像这样:

var plug = plugin();
for(var i=0; i<100; i++)
{
    var fn = plug.getMetaDataOfFileOrFolder;
    var md = fn("dropbox/demotext","null",true,false,"null"); 
}

假设错误仍然发生,它会告诉我们很多信息,如果它是在 var fn 行或 var MD线。您还可以尝试将 var fn 行移出循环,看看是否有任何作用。

如果问题与 Firefox 错误有关,那么将 var fn 移出可能会产生影响;进行这些测试并报告结果,这可能会帮助我们弄清楚发生了什么。

  1. First try updating Firefox; there was a bug in an older version of firefox where it would sometimes swap two NPObjects sent across the bridge giving you a different object than you should have.

  2. move your plugin() call to a parent scope so you aren't calling it each time

  3. seperate pieces of this into different lines so you can see exactly where the error occurs

Like this:

var plug = plugin();
for(var i=0; i<100; i++)
{
    var fn = plug.getMetaDataOfFileOrFolder;
    var md = fn("dropbox/demotext","null",true,false,"null"); 
}

Assuming the error still occurs, it tells us a lot if it's on the var fn line or the var md line. You could also try moving the var fn line out of the loop and see if that does anything.

If the issue is related to a firefox bug then moving the var fn out will probably make a difference; do those tests and report the results, that may help us figure out what is going on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文