This is "newObject" method from org.mozilla.javascript.Context class.
....
01 : public final Scriptable newObject(Scriptable scope, String
constructorName, Object[] args)
02 : {
03 : scope = ScriptableObject.getTopLevelScope(scope);
04 : Function ctor = ScriptRuntime.getExistingCtor(this, scope,
05 :
constructorName);
06 : if (args == null) { args = ScriptRuntime.emptyArgs; }
07 : return ctor.construct(this, scope, args);
08 : }
....
Why scope gets reset to point to TopLevelScope (line 03)?