Closed Bug 1396050 Opened 7 years ago Closed 7 years ago

Support IndirectEval with NonSyntacticVariablesScope

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED WONTFIX
Tracking Status
firefox57 --- fix-optional

People

(Reporter: tcampbell, Assigned: tcampbell)

References

Details

(Whiteboard: [js:correctness])

Attachments

(2 obsolete files)

Follow-up to Bug 1394490. If evaluating |(0,eval)("this")| with a NonSyntacticVariblesEnvironment on the chain, we get the global instead of the current lexical this (ie the NonSyntacticVariables itself). This should be fixed by passing the correct environment to IndirectEval. (Once this is fixed, the test in js/src/jsapi-tests/testExecuteInNonSyntacticGlobal should be updated)
Blocks: 1395360
See Also: → 1396145
This also applies to |new Function()|. One difficulty is finding the environment in the callee context. To deal with this, I propose we move the |Function| and |eval| bindings from the global to the NSVO in these cases. We can then use FunctionExtended slots (or other mechanism) to keep track of the NSVO the binding came from. This would give predictable results similar to the non-shared case where the IndirectEval happens in the context that the binding was read from.
Assignee: nobody → tcampbell
Status: NEW → ASSIGNED
Blocks: 1186409
No longer blocks: 1186409
Comment on attachment 8907411 [details] Bug 1396050 - Support IndirectEval per-JSMEnvironment Here is a rough prototype for supporting IndirectEval per-JSMEnvironment/NSVO. Similar would be done for |new Function| constructor. I'm wondering what parts of this worry you the most and if you have ideas of other mechanisms to achieve the same. This could form a stop-gap until we are able to remove eval/new Function usage entirely from JSMs. So this will be a game of balancing risks of this change versus changing all the code/tests that use eval.
Attachment #8907411 - Flags: feedback?(jorendorff)
Priority: -- → P3
Whiteboard: [js:correctness]
Depends on: 1399960
Attachment #8907411 - Flags: feedback?(jorendorff)
I put together this experiment and it seems to work but is hacky. Since Bug 1399997 is on track to unblock this, I'm closing this as WONTFIX and recommending we do Bug 1399997, and then eventually disable eval/Function altogether via CSP.
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
Attachment #8907411 - Attachment is obsolete: true
Attachment #8908341 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: