Created attachment 732513 [details] [diff] [review] Make XPCShellEnvironment a singleton, rather than finding it via the JSContext's private pointer. Patch. I still need to integrate the test (some light hacking required, since 'quit' is also broken).
Created attachment 732622 [details] [diff] [review] Make XPCShellEnvironment a singleton, rather than finding it via the JSContext's private pointer. Complete patch, including test case. Try: https://tbpl.mozilla.org/?tree=Try&rev=27836ef67e89
Comment on attachment 732622 [details] [diff] [review] Make XPCShellEnvironment a singleton, rather than finding it via the JSContext's private pointer. Try push looks okay.
Comment on attachment 732622 [details] [diff] [review] Make XPCShellEnvironment a singleton, rather than finding it via the JSContext's private pointer. Removing review request, as there's a B2G xpcshell failure I'd failed to notice in the Try push which definitely looks related. I'll sort that out before asking for review again.
Added some diagnostics, trying that failing test alone: https://tbpl.mozilla.org/?tree=Try&rev=c5fe8079226f
With the patch in bug 874755, we may not need TestShell and XPCShellEnvironment at all any more, so working on XPCShellEnvironment is probably not worth it.