Exemplo n.º 1
0
  /**
   * Create a new com.netscape.javascript.Context.
   *
   * @return the newly instantiated Context
   */
  public Object createContext() {
    // this is stolen from Main.java
    cx = new Context();
    ((Context) cx).enter();

    global = new Global();
    ((Context) cx).initStandardObjects(global);

    String[] names = {"print", "quit", "version", "load", "help", "loadClass"};
    try {
      global.defineFunctionProperties(names, Main.class, ScriptableObject.DONTENUM);
    } catch (PropertyException e) {

      throw new Error(e.getMessage());
    }

    return cx;
  }
Exemplo n.º 2
0
 /** Close the context. */
 public void close() {
   try {
     ((Context) cx).exit();
   } catch (Exception e) {
     suite.passed = false;
     file.passed = false;
     file.exception = "file failed with exception:  " + e;
   }
 }
Exemplo n.º 3
0
  /**
   * Creates the JavaScript Context, which evaluates the contents of a RhinoFile and returns a
   * result. The RhinoEnv parses the test result, and sets values of the RhinoFile test result
   * properties.
   *
   * @see com.netscape.javascript.Context#setOptimizationLevel
   * @see com.netscape.javascript.Context#setDebugLevel
   */
  public synchronized void runTest() {
    this.driver.p(file.name);
    try {
      cx = createContext();
      ((Context) cx).setOptimizationLevel(driver.OPT_LEVEL);
      ((Context) cx).setDebugLevel(driver.DEBUG_LEVEL);
      Object loadFn = executeTestFile(driver.HELPER_FUNCTIONS.getAbsolutePath());

      file.startTime = driver.getCurrentTime();
      result = executeTestFile(file.filePath);
      file.endTime = driver.getCurrentTime();
      parseResult();

    } catch (Exception e) {
      suite.passed = false;
      file.passed = false;
      file.exception += "file failed with exception:  " + e;
    }
  }