Bug 1394490 - Handle NSVO like Global for js::ComputeImplicitThis draft
authorTed Campbell <tcampbell@mozilla.com>
Thu, 31 Aug 2017 16:30:28 -0400
changeset 657509 67e2d58a689d477be2c6e969ce451d6cb2d67ddb
parent 657508 b2619f543a38779b87494bc46812418ae15ef74b
child 657510 11e69aea0a32f34009db302f30e463342f66c2a4
push id77543
push userbmo:tcampbell@mozilla.com
push dateFri, 01 Sep 2017 15:47:07 +0000
bugs1394490
milestone57.0a1
Bug 1394490 - Handle NSVO like Global for js::ComputeImplicitThis ComputeImplicitThis is used when invoking a function in a |with| block. An NSVO should behave like a GlobalObject and return |undefined|. MozReview-Commit-ID: InjojinxPuF
js/src/vm/Interpreter.cpp
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -1487,16 +1487,19 @@ JS_STATIC_ASSERT(JSOP_IFNE == JSOP_IFEQ 
  * global.
  */
 static inline Value
 ComputeImplicitThis(JSObject* obj)
 {
     if (obj->is<GlobalObject>())
         return UndefinedValue();
 
+    if (obj->is<NonSyntacticVariablesObject>())
+        return UndefinedValue();
+
     if (IsCacheableEnvironment(obj))
         return UndefinedValue();
 
     // Debugger environments need special casing, as despite being
     // non-syntactic, they wrap syntactic environments and should not be
     // treated like other embedding-specific non-syntactic environments.
     if (obj->is<DebugEnvironmentProxy>())
         return ComputeImplicitThis(&obj->as<DebugEnvironmentProxy>().environment());