Package org.mozilla.javascript

Examples of org.mozilla.javascript.ContextAction


   */
  @Test
  public void newObject0Arg()
  {
    final String source = "var x = new Date().getTime();";
    final ContextAction action = new ContextAction() {
      public Object run(final Context cx) {
        final Script script = cx.compileString(source, "my script", 0, null);
        Assert.assertEquals(source, cx.decompileScript(script, 4).trim());
        return null;
      }
View Full Code Here


    private void testParseFloat(final String expected, final String value) {
        assertEvaluates(expected, "String(parseFloat('" + value + "'))");
    }

    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

        runWithExpectedStackTrace(source3, result);
    }

  private void runWithExpectedStackTrace(final String _source, final String _expectedStackTrace)
  {
        final ContextAction action = new ContextAction() {
          public Object run(Context cx) {
            final Scriptable scope = cx.initStandardObjects();
            try {
              cx.evaluateString(scope, _source, "test.js", 0, null);
            }
View Full Code Here

    public void testClassGen() {
        final List<Class<?>> classes = new ArrayList<Class<?>>();
        classes.add(java.lang.Runnable.class);
        classes.add(java.lang.Appendable.class);
        ContextFactory cf = ContextFactory.getGlobal();
        cf.call(new ContextAction() {
            public Object run(Context cx) {
                Class<?> c1 = EventAdapter.getAdapterClass(classes.toArray(), null);
                Class<?> c2 = EventAdapter.getAdapterClass(classes.toArray(), null);
                assertTrue(c1.getSuperclass() == Object.class);
                assertTrue(Runnable.class.isAssignableFrom(c1));
                assertTrue(Appendable.class.isAssignableFrom(c1));
                assertEquals(c1, c2);
                return null;
            }
        });
        cf.call(new ContextAction() {
            public Object run(Context cx) {
                Map<String,String> bindings = new HashMap<String,String>();
                bindings.put("append", "add");
                bindings.put("run", "run");
                Class<?> c1 = EventAdapter.getAdapterClass(classes.toArray(),
View Full Code Here

     */
    @Override
    public ScriptStatus call()
        throws NodeException
    {
        Object ret = env.getContextFactory().call(new ContextAction()
        {
            @Override
            public Object run(Context cx)
            {
                return runScript(cx);
View Full Code Here

        } else {
            fnArgs = ScriptRuntime.emptyArgs;
        }
        return getThreadPool().submit(new Callable<Object>() {
            public Object call() {
                return cxfactory.call(new ContextAction() {
                    public Object run(Context cx) {
                        return function.call(cx, scope, scope, fnArgs);
                    }
                });
            }
View Full Code Here

                }
            });
        }
       
        file = mainScript;
        contextFactory.call(new ContextAction() {
            @Override
            public Object run(Context cx) {
                cx.setErrorReporter(reporter);
                processFile(cx, args);
                return null;
View Full Code Here

        SVGHighchartsHelper.rhinoDebugger.pack();
        SVGHighchartsHelper.rhinoDebugger.setSize(1600, 1000);
        SVGHighchartsHelper.rhinoDebugger.setVisible(true);
      }
     
      call = getContextFactory ().call (new ContextAction() {
        @Override
        public Object run (Context cx) {
          final Initiator initiator = new Initiator (cx).init ();
         
          SVGHighchartsHelper.LOGGER.trace ("call renderSVG method on json");
View Full Code Here

            }
        }
    }

    protected ContextAction generateContextAction(final String viewerVersion, final String pluginVersion, final List<String> codes) {
        ContextAction action = new ContextAction() {
            public Object run(Context cx) {
                log.info("initializing Rhino JavaScript engine...");
                cx.setOptimizationLevel(-1); // Interpreter mode

                Doc doc = document; //global 'this'-object
View Full Code Here

    /**
     * Assemble the {@link JSLintResult} object.
     */
    @NeedsContext
    private JSLintResult buildResults(final String systemId, final long startNanos, final long endNanos) {
        return (JSLintResult) contextFactory.call(new ContextAction() {
            public Object run(Context cx) {
                ResultBuilder b = new JSLintResult.ResultBuilder(systemId);
                b.duration(TimeUnit.NANOSECONDS.toMillis(endNanos - startNanos));
                for (Issue issue : readErrors(systemId)) {
                    b.addIssue(issue);
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.