What are the differences between Fx 3.x and Fx 4.x that made many userscripts stop working?

夙愿已清 提交于 2019-12-11 04:49:05

问题


I develop scripts for userscripts.org and just upgraded my fx from 3.6.16 to 4.0, but many scripts of mine stopped working with the following message error:

Error: Component returned failure code: 0x8007000e (NS_ERROR_OUT_OF_MEMORY) [nsIXPCComponents_Utils.evalInSandbox]
Source code: file:///xxx.user.js

I know this message means some kind of "infinite" process, but it doesn't appear any line number that can help me to figure it out.

Any help/answer/link is welcome.

Operating System: Windows 7 64-bit
Greasemonkey version: 0.9.1
Example of script that is not working:
Userscripts : Beautifier + Deobfuscator target: http://userscripts.org/scripts/review/58687
(I will add more examples as soon as I get back home from work)

Other sources that made me think about the problem:
Lots of scripts no longer working?


回答1:


The only feature I know of that's been removed in Firefox 4 is the ability to use XUL directly within a web page (ie using the -moz-binding CSS style).

I don't know if that's what's affected your scripts. It has affected one fairly well-known Firefox hack (see text-overflow:ellipsis in Firefox 4? (and FF5)), but I wasn't aware of any other impact of this change.




回答2:


Since Firefox 4, you can't use RegExp as a loop condition because a new instance will be created for each iteration, causing the infinite loop. (lastIndex = 0)

while (/.../g.exec("...")) {  // used to work
    /* your code goes here */
}

To prevent this from happening, create a separate variable with the RegExp:

var re = /.../g;
while (re.exec("...")) {  // works perfectly
    /* your code goes here */
}


来源:https://stackoverflow.com/questions/5413274/what-are-the-differences-between-fx-3-x-and-fx-4-x-that-made-many-userscripts-st

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!