diff --git a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java index bfe19bfdfb2d..dd74827a12ff 100644 --- a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java +++ b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java @@ -124,7 +124,13 @@ public class ScriptRuntime { scope = new NativeObject(); } scope.associateValue(LIBRARY_SCOPE_KEY, scope); - scope.associateValue(CONTEXT_FACTORY_KEY, cx.getFactory()); + ContextFactory factory = cx.getFactory(); + if (factory == null) { + // factory is null for Context asociated with the current thread + // via Context.enter() + factory = ContextFactory.getGlobal(); + } + scope.associateValue(CONTEXT_FACTORY_KEY, factory); (new ClassCache()).associate(scope); BaseFunction.init(cx, scope, sealed);