Examples of CompilerEnvirons


Examples of org.mozilla.javascript.CompilerEnvirons

    @Test
    public void shouldNotRecordInstrumentedURIsForWebServerIfNotFound() throws IOException {
        given(configuration.isIncludeUnloadedJS()).willReturn(true);
        File wwwRoot = new File("wwwRoot");
        ReflectionUtils.setField(webServer, HttpServer.class, "wwwRoot", wwwRoot);
        CompilerEnvirons compilerEnvirons = new CompilerEnvirons();
        given(configuration.getCompilerEnvirons()).willReturn(compilerEnvirons);
        given(configuration.skipInstrumentation("/js/production.js")).willReturn(false);
        given(instrumenterService.instrumentJSForWebServer(configuration, new File("wwwRoot/js/production.js"), "/js/production.js")).willThrow(new UriNotFound("Ouch!", null));

        webServer.handleGet(new HttpRequest("/js/production.js", null, null, 0, null));
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

    @Test
    public void shouldServeInstrumentedJSForProxyServer() throws IOException {
        given(configuration.isProxy()).willReturn(true);
        File wwwRoot = new File("wwwRoot");
        ReflectionUtils.setField(webServer, HttpServer.class, "wwwRoot", wwwRoot);
        CompilerEnvirons compilerEnvirons = new CompilerEnvirons();
        given(configuration.getCompilerEnvirons()).willReturn(compilerEnvirons);
        given(configuration.skipInstrumentation("/js/production.js")).willReturn(false);
        String uri = "http://someserver.org/exclude/js/production.js";
        HttpRequest request = new HttpRequest(uri, null, null, 0, null);
        given(proxyService.getUrl(request)).willReturn("someJavaScript;");
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

    @Test
    public void shouldServeNonInstrumentedJS() throws IOException {
        File wwwRoot = new File("wwwRoot");
        ReflectionUtils.setField(webServer, HttpServer.class, "wwwRoot", wwwRoot);
        CompilerEnvirons compilerEnvirons = new CompilerEnvirons();
        given(configuration.getCompilerEnvirons()).willReturn(compilerEnvirons);
        given(configuration.skipInstrumentation("test/production.js")).willReturn(true);

        webServer.handleGet(new HttpRequest("/test/production.js", null, null, 0, null));
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

    @Test
    public void shouldServeNonInstrumentedJSWhenViewingSource() throws IOException {
        File wwwRoot = new File("wwwRoot");
        ReflectionUtils.setField(webServer, HttpServer.class, "wwwRoot", wwwRoot);
        CompilerEnvirons compilerEnvirons = new CompilerEnvirons();
        given(configuration.getCompilerEnvirons()).willReturn(compilerEnvirons);
        given(configuration.skipInstrumentation("test/production.js")).willReturn(false);

        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        headers.put("NoInstrument", new ArrayList<String>(){{add("true");}});
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

import java.io.StringReader;

//https://bugzilla.mozilla.org/show_bug.cgi?id=788070
public class Bug788070 implements NodeVisitor {
    public static void main(String[] args) throws IOException {
        CompilerEnvirons compilerEnv = new CompilerEnvirons();
        compilerEnv.setLanguageVersion(180);
        compilerEnv.setStrictMode(false);

        Bug788070 visitor = new Bug788070();
        addIncrement(new Parser(compilerEnv), visitor, "switch (x) {\n" +
                "case x:\n" +
                "  y = 0;\n" +
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

    private static IoUtils ioUtils = IoUtils.getInstance();

    public static void main(String args[]) throws Exception {
        String source = ioUtils.loadFromClassPath("/test.js");
//        String source = "let ({x: x0, y: y0} = point) {\n  print(x0);\n  print(y0);\n}";
        CompilerEnvirons compilerEnv = new CompilerEnvirons();
        compilerEnv.setLanguageVersion(180);
        Parser parser = new Parser(compilerEnv);
        AstRoot astRoot = parser.parse(new StringReader(source), null, 1);
        astRoot.visitAll(new InstrumentVisitor());
        System.out.println(astRoot.toSource());
//        System.out.println("****************************");
 
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

//        parseAndPrintSource("/^(\\w+)$/.exec(url);");
        //parseAndPrintSource("if (true)\n  ;\nx++;");
    }

    private static void parseAndPrintSource(String source) throws IOException {
        CompilerEnvirons compilerEnv = new CompilerEnvirons();
        compilerEnv.setLanguageVersion(180);
//        compilerEnv.setStrictMode(false);
        Parser parser = new Parser(compilerEnv);
        AstRoot astRoot = parser.parse(new StringReader(source), null, 1);
        System.out.println(astRoot.toSource());
    }
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

import java.io.StringReader;

//https://bugzilla.mozilla.org/show_bug.cgi?id=784651
public class Bug784651 implements NodeVisitor {
    public static void main(String[] args) throws IOException {
        CompilerEnvirons compilerEnv = new CompilerEnvirons();
        compilerEnv.setLanguageVersion(180);
        compilerEnv.setStrictMode(false);

        Bug784651 visitor = new Bug784651();
        addIncrement(new Parser(compilerEnv), visitor, "while (x)\n{\n  ;\n}");
        System.err.println("*************************");
        addIncrement(new Parser(compilerEnv), visitor, "while (x)\n  ;");
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

        }


        private Class compileClass( final Context pContext, final String pSourceName, final String pClassName, final Class pSuperClass, final Class[] pInterfaces) throws IOException {

            final CompilerEnvirons environments = new CompilerEnvirons();
            environments.initFromContext(pContext);
            final ClassCompiler compiler = new ClassCompiler(environments);

            if (pSuperClass != null) {
                compiler.setTargetExtends(pSuperClass);
            }
View Full Code Here

Examples of org.mozilla.javascript.CompilerEnvirons

    public static final String compressScript(String source, int indent, int lineno, boolean escapeUnicode, String stripConsole) {
      return compressScript(source, indent, lineno, escapeUnicode, stripConsole, null);
    }
       
    public static final String compressScript(String source, int indent, int lineno, boolean escapeUnicode, String stripConsole, StringBuffer debugData) {
        CompilerEnvirons compilerEnv = new CompilerEnvirons();

        Parser parser = new Parser(compilerEnv, compilerEnv.getErrorReporter());
       
        ScriptOrFnNode tree = parser.parse(source, null, lineno);
        String encodedSource = parser.getEncodedSource();
        if (encodedSource.length() == 0) { return ""; }
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.