Package org.mozilla.javascript

Examples of org.mozilla.javascript.ContextAction


      @Override
      public double combine(final double a, final double b)
      {
        final Object res = contextFactory.call(
            new ContextAction()
            {
              @Override
              public Object run(final Context cx)
              {
                return fnCombine.call(cx, scope, scope, new Object[]{a, b});
              }
            }
        );
        return Context.toNumber(res);
      }

      @Override
      public double reset()
      {
        final Object res = contextFactory.call(
            new ContextAction()
            {
              @Override
              public Object run(final Context cx)
              {
                return fnReset.call(cx, scope, scope, new Object[]{});
View Full Code Here


    runScript(importClass + "new PrivateAccessClass(5)");
    runScript(importClass + "new PrivateAccessClass(5, \"foo\")");
  }
 
  private Object runScript(final String scriptSourceText) {
    return this.contextFactory.call(new ContextAction() {
      public Object run(Context context) {
        Script script = context.compileString(scriptSourceText, "", 1, null);
        return script.exec(context, global);
      }
    });
View Full Code Here

    }

    private void testWithTwoScopes(final String scriptScope1,
                                   final String scriptScope2)
    {
      final ContextAction action = new ContextAction()
      {
        public Object run(final Context cx)
        {
              final Scriptable scope1 = cx.initStandardObjects(
                  new MySimpleScriptableObject("scope1"));
View Full Code Here

      myObject.defineFunctionProperties(functionNames, MyObject.class,
          ScriptableObject.EMPTY);

      final String scriptScope1 = "String.prototype.foo = 'from 1'; scope2.f()";

      final ContextAction action = new ContextAction()
      {
          public Object run(final Context cx)
          {
              final Scriptable scope1 = cx.initStandardObjects(
                  new MySimpleScriptableObject("scope1"));
View Full Code Here

              Object[] _args)
          {
            return _args[0].getClass().getName();
          }
        };
    final ContextAction action = new ContextAction()
    {
      public Object run(final Context context)
      {
        final Scriptable scope = context.initStandardObjects();
        scope.put("myObj", scope, f);
View Full Code Here

    doTest("function", action);
  }

  private void testCustomizeTypeOf(final String expected, final Scriptable obj)
  {
    final ContextAction action = new ContextAction()
    {
      public Object run(final Context context)
      {
        final Scriptable scope = context.initStandardObjects();
        scope.put("myObj", scope, obj);
View Full Code Here

    doTest("object", "typeof /foo/;");
  }

  private void doTest(String expected, final String script)
  {
    final ContextAction action = new ContextAction()
    {
      public Object run(final Context context)
      {
        final Scriptable scope = context.initStandardObjects();
        return context.evaluateString(scope, script, "test script", 1, null);
View Full Code Here

    doTest(1, expected, action);
  }

  private void doTest(final int optimizationLevel, final String expected, final ContextAction action)
  {
    Object o = new ContextFactory().call(new ContextAction()
      {
        public Object run(final Context context)
        {
          context.setOptimizationLevel(optimizationLevel);
          return Context.toString(action.run(context));
View Full Code Here

        Context.exit();
    }
  }

  private Object runScript(final String scriptSourceText) {
    return this.contextFactory.call(new ContextAction() {
      public Object run(Context context) {
          return context.evaluateString(global, scriptSourceText,
                  "test source", 1, null);
      }
    });
View Full Code Here

        assertEvaluates("hello", "var x = String.toLowerCase; x.apply('HELLO')");
        assertEvaluates("hello", "String.toLowerCase('HELLO')"); // first patch proposed to #492359 was breaking this
    }

    private void assertEvaluates(final Object expected, final String source) {
        final ContextAction action = new ContextAction() {
            public Object run(Context cx) {
                final Scriptable scope = cx.initStandardObjects();
                final Object rep = cx.evaluateString(scope, source, "test.js",
                        0, null);
                assertEquals(expected, rep);
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.ContextAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.