4
package org.mozilla.javascript.tests;
6
import junit.framework.TestCase;
8
import org.mozilla.javascript.Context;
9
import org.mozilla.javascript.ContextFactory;
10
import org.mozilla.javascript.Scriptable;
11
import org.mozilla.javascript.RhinoException;
16
public class ContextFactoryTest extends TestCase {
17
static class MyFactory extends ContextFactory {
19
public boolean hasFeature(Context cx, int featureIndex)
21
switch (featureIndex) {
22
case Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME:
25
return super.hasFeature(cx, featureIndex);
29
public void testCustomContextFactory() {
30
ContextFactory factory = new MyFactory();
31
Context cx = factory.enterContext();
33
Scriptable globalScope = cx.initStandardObjects();
34
// Test that FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME is enabled
35
Object result = cx.evaluateString(globalScope,
37
"function obj.foo() { return 'bar'; }" +
39
"test source", 1, null);
40
assertEquals("bar", result);
41
} catch (RhinoException e) {