Package org.mozilla.javascript.tools.shell

Examples of org.mozilla.javascript.tools.shell.Global


      URL engine = classLoader.getResource("META-INF/engine.js");
      URL cssmin = classLoader.getResource("META-INF/cssmin.js");
      Context cx = Context.enter();
      logger.debug("Using implementation version: " + cx.getImplementationVersion());
      cx.setOptimizationLevel(9);
      Global global = new Global();
      global.init(cx);
      scope = cx.initStandardObjects(global);
      cx.evaluateReader(scope, new InputStreamReader(env.openConnection().getInputStream()), env.getFile(), 1, null);
      cx.evaluateString(scope, "lessenv.charset = '" + options.getCharset() + "';", "charset", 1, null);
      cx.evaluateString(scope, "lessenv.css = " + options.isCss() + ";", "css", 1, null);
      cx.evaluateReader(scope, new InputStreamReader(less.openConnection().getInputStream()), less.getFile(), 1, null);
View Full Code Here


            URL env = classLoader.getResource(JS_ROOT + "env.js");
            URL engine = classLoader.getResource(JS_ROOT + "engine.js");
            Context cx = Context.enter();
            logger.debug("Using implementation version: " + cx.getImplementationVersion());
            cx.setOptimizationLevel(9);
            Global global = new Global();
            global.init(cx);
            scope = cx.initStandardObjects(global);
            cx.evaluateReader(scope, new InputStreamReader(env.openConnection().getInputStream()), env.getFile(), 1, null);
            cx.evaluateString(scope, "lessenv.charset = '" + CHARSET + "';", "charset", 1, null);
            cx.evaluateString(scope, "lessenv.css = " + "true" + ";", "css", 1, null);
            cx.evaluateReader(scope, new InputStreamReader(less.openConnection().getInputStream()), less.getFile(), 1, null);
View Full Code Here

        JXPathIntrospector.registerDynamicClass(org.mozilla.javascript.Scriptable.class,
                                                ScriptablePropertyHandler.class);
        JXPathContextReferenceImpl.addNodePointerFactory(new ScriptablePointerFactory());

        try {
            scope = new Global(context);
            // Access to Cocoon internal objects
            FOM_Cocoon.init(scope);
            errorReporter = new JSErrorReporter(getLogger());
        } catch (Exception e) {
            Context.exit();
View Full Code Here

        JXPathIntrospector.registerDynamicClass(org.mozilla.javascript.Scriptable.class,
                                                ScriptablePropertyHandler.class);
        JXPathContextReferenceImpl.addNodePointerFactory(new ScriptablePointerFactory());

        try {
            scope = new Global(context);
            // Access to Cocoon internal objects
            AO_FOM_Cocoon.init(scope);
            errorReporter = new JSErrorReporter(getLogger());
        }
        catch (Exception e) {
View Full Code Here

     * @return  Returns true IFF initialization was successful.
     */
    private boolean initializeJavascriptEnvironment(List<String> supportingScripts) {
        Context jsContext = Context.enter();
        try {
            scope = new Global(jsContext);
            for (Iterator<String> iter = supportingScripts.iterator(); iter.hasNext();) {
                String script = iter.next();
                try {
                    this.loadJsLib(script);
                }
View Full Code Here

    }

    public static void run(final ShellContextFactory shellContextFactory,
            final File jsFile, final Parameters parameters,
            final Status status) throws Exception {
        final Global global = new Global();
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        final PrintStream p = new PrintStream(out);
        global.setOut(p);
        global.setErr(p);
        global.defineFunctionProperties(
                new String[] { "options" }, ShellTest.class,
                ScriptableObject.DONTENUM | ScriptableObject.PERMANENT |
                  ScriptableObject.READONLY);
        // test suite expects keywords to be disallowed as identifiers
        shellContextFactory.setAllowReservedKeywords(false);
        final TestState testState = new TestState();
        if (jsFile.getName().endsWith("-n.js")) {
            status.setNegative();
        }
        final Throwable thrown[] = {null};

        Thread t = new Thread(new Runnable()
        {
            public void run()
            {
                try
                {
                    shellContextFactory.call(new ContextAction()
                    {
                        public Object run(Context cx)
                        {
                            status.running(jsFile);
                            testState.errors = new ErrorReporterWrapper(cx.getErrorReporter());
                            cx.setErrorReporter( testState.errors );
                            global.init(cx);
                            try {
                                runFileIfExists(cx, global, new File(jsFile.getParentFile().getParentFile().getParentFile(), "shell.js"));
                                runFileIfExists(cx, global, new File(jsFile.getParentFile().getParentFile(), "shell.js"));
                                runFileIfExists(cx, global, new File(jsFile.getParentFile(), "shell.js"));
                                runFileIfExists(cx, global, jsFile);
View Full Code Here

            URL env = classLoader.getResource(JS_ROOT + "env.js");
            URL engine = classLoader.getResource(JS_ROOT + "engine.js");
            Context cx = Context.enter();
            logger.debug("Using implementation version: " + cx.getImplementationVersion());
            cx.setOptimizationLevel(9);
            Global global = new Global();
            global.init(cx);
            scope = cx.initStandardObjects(global);
            cx.evaluateReader(scope, new InputStreamReader(env.openConnection().getInputStream()), env.getFile(), 1, null);
            cx.evaluateString(scope, "lessenv.charset = '" + CHARSET + "';", "charset", 1, null);
            cx.evaluateString(scope, "lessenv.css = " + "false" + ";", "css", 1, null);
            cx.evaluateReader(scope, new InputStreamReader(less.openConnection().getInputStream()), less.getFile(), 1, null);
View Full Code Here

        }

        @Override
        public void run() {
            ContextFactory contextFactory = new ContextFactory();
            RhinoInterpreter.this.global = new Global();
            RhinoInterpreter.this.global.init(contextFactory);
            RhinoInterpreter.this.cx = contextFactory.enterContext();
            while (!finished) {
                try {
                    ICommand cmd = queue.take();
View Full Code Here

    }

    public static void run(final ShellContextFactory shellContextFactory,
            final File jsFile, final Parameters parameters,
            final Status status) throws Exception {
        final Global global = new Global();
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        final PrintStream p = new PrintStream(out);
        global.setOut(p);
        global.setErr(p);
        global.defineFunctionProperties(
                new String[] { "options" }, ShellTest.class,
                ScriptableObject.DONTENUM | ScriptableObject.PERMANENT |
                  ScriptableObject.READONLY);
        // test suite expects keywords to be disallowed as identifiers
        shellContextFactory.setAllowReservedKeywords(false);
        final TestState testState = new TestState();
        if (jsFile.getName().endsWith("-n.js")) {
            status.setNegative();
        }
        final Throwable thrown[] = {null};

        Thread t = new Thread(new Runnable()
        {
            public void run()
            {
                try
                {
                    shellContextFactory.call(new ContextAction()
                    {
                        public Object run(Context cx)
                        {
                            status.running(jsFile);
                            testState.errors = new ErrorReporterWrapper(cx.getErrorReporter());
                            cx.setErrorReporter( testState.errors );
                            global.init(cx);
                            try {
                                runFileIfExists(cx, global, new File(jsFile.getParentFile().getParentFile().getParentFile(), "shell.js"));
                                runFileIfExists(cx, global, new File(jsFile.getParentFile().getParentFile(), "shell.js"));
                                runFileIfExists(cx, global, new File(jsFile.getParentFile(), "shell.js"));
                                runFileIfExists(cx, global, jsFile);
View Full Code Here

    public void runDoctest() throws Exception {
        ContextFactory factory = ContextFactory.getGlobal();
        Context cx = factory.enterContext();
        try {
            cx.setOptimizationLevel(optimizationLevel);
            Global global = new Global(cx);
            // global.runDoctest throws an exception on any failure
            int testsPassed = global.runDoctest(cx, global, source, name, 1);
            System.out.println(name + "(" + optimizationLevel + "): " +
                    testsPassed + " passed.");
            assertTrue(testsPassed > 0);
        } catch (Exception ex) {
          System.out.println(name + "(" + optimizationLevel + "): FAILED due to "+ex);
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.tools.shell.Global

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.