Package org.mozilla.javascript

Examples of org.mozilla.javascript.Context.evaluateReader()


                ScriptableObject
                    .putProperty(scope, "response", wrappedResponse);
                ScriptableObject.putProperty(scope, "loader", wrappedLoader);
                ScriptableObject.putProperty(scope, "catalog", wrappedCatalog);

                cx.evaluateReader(scope, reader, script.getName(), 1, null);
            } catch (IOException e) {
                throw new RestletException(
                    "I/O error while loading script...",
                    Status.SERVER_ERROR_INTERNAL
                );
View Full Code Here


    public void testRelativeId() throws Exception {
        final Context cx = createContext();
        final Scriptable scope = cx.initStandardObjects();
        final Require require = getSandboxedRequire(cx, scope, false);
        require.install(scope);
        cx.evaluateReader(scope, getReader("testRelativeId.js"),
                "testRelativeId.js", 1, null);
    }

    public void testSetMainForAlreadyLoadedModule() throws Exception {
        final Context cx = createContext();
View Full Code Here

    public void testSetMainForAlreadyLoadedModule() throws Exception {
        final Context cx = createContext();
        final Scriptable scope = cx.initStandardObjects();
        final Require require = getSandboxedRequire(cx, scope, false);
        require.install(scope);
        cx.evaluateReader(scope, getReader("testSetMainForAlreadyLoadedModule.js"),
                "testSetMainForAlreadyLoadedModule.js", 1, null);
        try {
            require.requireMain(cx, "assert");
            fail();
        }
View Full Code Here

    public void testRelativeId() throws Exception {
        final Context cx = createContext();
        final Scriptable scope = cx.initStandardObjects();
        final Require require = getSandboxedRequire(cx, scope, false);
        require.install(scope);
        cx.evaluateReader(scope, getReader("testRelativeId.js"),
                "testRelativeId.js", 1, null);
    }

    public void testSetMainForAlreadyLoadedModule() throws Exception {
        final Context cx = createContext();
View Full Code Here

    public void testSetMainForAlreadyLoadedModule() throws Exception {
        final Context cx = createContext();
        final Scriptable scope = cx.initStandardObjects();
        final Require require = getSandboxedRequire(cx, scope, false);
        require.install(scope);
        cx.evaluateReader(scope, getReader("testSetMainForAlreadyLoadedModule.js"),
                "testSetMainForAlreadyLoadedModule.js", 1, null);
        try {
            require.requireMain(cx, "assert");
            fail();
        }
View Full Code Here

    try {
      context.setOptimizationLevel( 9 );
      context.setLanguageVersion( Context.VERSION_1_5 );
      scope = context.initStandardObjects();
      context.evaluateString( scope, createShimCode(), "shim", 1, null );
      context.evaluateReader( scope, reader, "jshint library", 1, null );
      jshint = findJSHintFunction( scope );
    } catch( RhinoException exception ) {
      throw new IllegalArgumentException( "Could not evaluate JavaScript input", exception );
    } finally {
      Context.exit();
View Full Code Here

 
  public static String runScript (String testDir, String test, String engine) throws FileNotFoundException, IOException {
    Context cx = Context.enter();
    Scriptable scope = cx.initStandardObjects();
   
    cx.evaluateReader(scope, new FileReader(new File(testDir + File.separator + "html5" + File.separator + "emulator.js")), "library", 1, null);
    cx.evaluateString(scope, engine, "<engine>", 1, null);
    Object result = cx.evaluateReader(scope, new FileReader(new File(testDir + File.separator + "html5" + File.separator + test)), "test", 1, null);
   
    String res = Context.toString(result);
    Context.exit();
View Full Code Here

    Context cx = Context.enter();
    Scriptable scope = cx.initStandardObjects();
   
    cx.evaluateReader(scope, new FileReader(new File(testDir + File.separator + "html5" + File.separator + "emulator.js")), "library", 1, null);
    cx.evaluateString(scope, engine, "<engine>", 1, null);
    Object result = cx.evaluateReader(scope, new FileReader(new File(testDir + File.separator + "html5" + File.separator + test)), "test", 1, null);
   
    String res = Context.toString(result);
    Context.exit();
    return res;
  }
View Full Code Here

    context.setLanguageVersion(Context.VERSION_1_8);
    InputStream script = null;
    final ScriptableObject scriptCommon = (ScriptableObject) context.initStandardObjects(initialScope);
    try {
      script = getClass().getResourceAsStream("commons.js");
      context.evaluateReader(scriptCommon, new InputStreamReader(script), "commons.js", 1, null);
    } catch (final IOException e) {
      throw new RuntimeException("Problem while evaluationg commons script.", e);
    } finally {
      IOUtils.closeQuietly(script);
    }
View Full Code Here

      jsUrls.addAll(customJs);

      for(final URL url : jsUrls){
        final InputStreamReader inputStreamReader = new InputStreamReader(url.openConnection().getInputStream());
        try{
          cx.evaluateReader(scope, inputStreamReader, url.toString(), 1, null);
        }finally{
          inputStreamReader.close();
        }
      }
      doIt = cx.compileFunction(scope, COMPILE_STRING, "doIt.js", 1, null);
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.