Package org.mozilla.javascript

Examples of org.mozilla.javascript.ContextAction


    /**
     * To be used by <code>WindowWrapper</code>.
     */
    void callHandler(final Function handler, final ArgumentsBuilder ab) {
        contextFactory.call(new ContextAction() {
            public Object run(Context cx) {
                Object[] args = ab.buildArguments();
                handler.call(cx, handler.getParentScope(), globalObject, args);
                return null;
            }
View Full Code Here


            if (evt instanceof ScriptEventWrapper) {
                array[0] = ((ScriptEventWrapper) evt).getEventObject();
            } else {
                array[0] = evt;
            }
            ContextAction handleEventAction = new ContextAction() {
                public Object run(Context cx) {
                    ScriptableObject.callMethod
                        (scriptable, HANDLE_EVENT, array);
                    return null;
                }
View Full Code Here

        Context cx = Context.getCurrentContext();
        if(cx == null)
        {
            // No context - we're not running within OpenContextInViewInterceptor.
            // Open our own context only for the duration of the controller.
            ContextAction cxa = new ContextAction()
            {
                public Object run(Context cx)
                {
                    try
                    {
View Full Code Here

        this.contextFactory = contextFactory;
    }
   
    public void afterPropertiesSet() throws Exception
    {
        ContextAction ca = new ContextAction() {
            public Object run(Context cx) {
                try {
                    cx.setOptimizationLevel(-1);
                    // Run the built-in library script
                    Script libraryScript = loadScript(new ClassPathResource(
View Full Code Here

      assertEquals("success", result);
  }


  private Object runScript(final String scriptSourceText) {
    return 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

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.