Created attachment 531225 [details] [diff] [review]
Right now Function creates the function it'll return (minus its script), then it does CSP checks to see whether to reject the attempt to create dynamic code. And it does this by unconditionally calling the security callback, when it really should use GlobalObject::isEvalAllowed to take advantage of its cache of the eval-prohibited setting. It should check for prohibition first, then proceed to creating an object to return, and it should do so using the is-prohibited fast path.
This builds atop bug 655192 and bug 655907 for no particular reason beyond adding a new explicit-global NewFunction overload, which is the direction we need to start heading for all APIs that can create an object, in order to eventually fully fix bug 631135. I trust the minimal reliance on those patches (for the obviously-named GlobalObject::getOrCreateFunctionPrototype) won't present a difficulty.
It was tempting to rename isEvalAllowed, but that made the overlap with the other two bugs a bit more than I wanted, before those bugs land. That can be a followup or something, probably touches enough code to deserve it.
Comment on attachment 531225 [details] [diff] [review]
I was just going to suggest changing the function name when I saw comment 1!
Comment 1 is now bug 658069; I'll try to get to it shortly.
cdleary-bot mozilla-central merge info: