I want to use Reflect.parse in my JavaScript in Firefox.
MDN says to import this into the global object via
Components.utils.import("resource://gre/modules/reflect.jsm")
However, this results in the following error message:
Error: Permission denied for <file://> to get property XPCComponents.utils
I have tried this in Firefox 11 and Aurora.
How can I get access to Reflect.parse?
EDIT:
The error message is due to the following fragment:
Component.utils
There is no real solution to this problem. The documentation on
Reflect.parsein the wiki is misleading, to say the least.If you want a “pure” JavaScript solution in SpiderMonkey/Firefox, don’t rely on
Reflect.parse.I see a lot of projects using the parser from Narcissus and I should have done the same.
EDIT: The Esprima project is an excellent implementation of the Mozilla Parser API. After replacing
Reflect.parsewithesprima.parseall my 150+ test cases were still green, except for 5 or so dealing with non-standard SpiderMonkey extensions likeletexpressions (which I find pretty impressive).