This has been annoying me. In general, it's great to use scoping. But sometimes, it unnecessarily complicates the code. For example, sometimes we want to leave the compartment before doing a tail function call. Currently, we have to unnecessarily brace/indent a lot of things to make this happen. Patch coming up.
Created attachment 632171 [details] [diff] [review] Introduce JSAutoEnterCompartment::leave(). v1 Attaching a patch, flagging luke for review.
Created attachment 632209 [details] [diff] [review] Part 1 - Clarify compartment semantics for ExposedPropertiesOnly. v1
Created attachment 632210 [details] [diff] [review] Part 2 - Clarify compartment situation in Xray wrapper. v1 Adding to the mess of the NodePrincipal (et al) check isn't great, but I'm refactoring that in bug 761704.
Created attachment 632211 [details] [diff] [review] Part 1 - Clarify compartment semantics for ExposedPropertiesOnly. v2 Added an updated comment to clarify why two JSAutoEnterCompartments are necessary.
Gah! Wrong bug number for those other patches. Sorry blake. :-(
One thing I realized about this patch is that it allows the consumer to pooch the compartment situation by leaving compartments out of order. I suspect it's not worth worrying about, but maybe we should add some asserts somehow?