Package org.mozilla.javascript

Examples of org.mozilla.javascript.NativeObject


        ScriptResult scriptResult = page.executeJavaScript("window.simulationContext.results");
        NativeArray array = (NativeArray) scriptResult.getJavaScriptResult();

        for (int i = 0; i < array.getLength(); i++) {
            NativeObject object = (NativeObject) array.get(i, array);
            String data = null;
            Object dataObject = object.get("data", object);

            if (!(dataObject instanceof Undefined)) {
                data = (String) dataObject;
            }

            Double startTime = (Double) object.get("startTime", object);
            Double endTime = (Double) object.get("endTime", object);
            Object aborted = object.get("aborted", object);
            boolean abortedBoolean = aborted instanceof Boolean && (Boolean) aborted;

            result.addData(new RequestData(data, startTime, endTime, abortedBoolean));
        }
View Full Code Here


    public Annotation[] getAnnots(Object o) {
        Reflect.getMethodName();

        Double page = null;
        if (o instanceof NativeObject) {
            NativeObject x = (NativeObject) o;
            if (x.get(0, x) != UniqueTag.NOT_FOUND && x.get(1, x) != UniqueTag.NOT_FOUND
                    && x.get(2, x) != UniqueTag.NOT_FOUND && x.get(3, x) != UniqueTag.NOT_FOUND) {
                double param1 = Double.parseDouble(x.get(0, x).toString());
                double param2 = Double.parseDouble(x.get(1, x).toString());
                double param3 = Double.parseDouble(x.get(2, x).toString());
                double param4 = Double.parseDouble(x.get(3, x).toString());

                if (param1 < 0 && param2 < 0 && param3 < 0 && param4 < 0) {
                    MethodVulnerability vuln = new MethodVulnerability("CVE-2009-1492", "getAnnots", "buffer overflow");
                    scrutinizer.getAnalysisResult().vulnerabilityUsed(vuln);
                }
View Full Code Here

        if (pagex instanceof Double) {
            Double tmp = (Double) pagex;
            int p = tmp.intValue();
            return Integer.toString(scrutinizer.getDocumentAdapter().getPageNumWords(p));
        } else {
            NativeObject page = (NativeObject) pagex;
            //TODO:
            if (page.get(0, page) != UniqueTag.NOT_FOUND) {
                int p = Integer.parseInt(page.get(0, page).toString());
                return Integer.toString(scrutinizer.getDocumentAdapter().getPageNumWords(p));
            } else {
                return Integer.toString(scrutinizer.getDocumentAdapter().getPageNumWords(0));
            }
        }
View Full Code Here

  }
 
  public ScriptEnv makeEnvFromCodeExecution(Collection<Pair<String,String>> codeFiles, Map<String, Object> globals) {
    Context jsContext = Context.enter();
    try {
      NativeObject scope = (NativeObject)jsContext.initStandardObjects();
      for(Map.Entry<String,Object> entry : globals.entrySet()) {
        ScriptableObject.putProperty(scope, entry.getKey(), Context.javaToJS(entry.getValue(), scope));
      }
      for(Pair<String,String> file : codeFiles) {
        String fileName = file.getLeft();
View Full Code Here

  }

  public Object evaluateExpression(String string, Map<String, Object> globals) {
    Context jsContext = Context.enter();
    try {
      NativeObject scope = (NativeObject)jsContext.initStandardObjects();
      for(Map.Entry<String,Object> entry : globals.entrySet()) {
        ScriptableObject.putProperty(scope, entry.getKey(), Context.javaToJS(entry.getValue(), scope));
      }
      return jsContext.evaluateString(scope, string, "<execute>", 1, null);
    } finally {
View Full Code Here

    private Object javaJsonToJS(Object o) {
      if (o instanceof Scriptable) {
        return o;
      } else if (o instanceof Map) {
        Map map = (Map)o;
        NativeObject nativeObj = new NativeObject();
        for(Object entryObj : map.entrySet()) {
          Map.Entry entry = (Map.Entry) entryObj;
          Object val = javaJsonToJS(entry.getValue());
          nativeObj.put((String)entry.getKey(), scope, val);
        }
        return nativeObj;
      } else if (o instanceof List) {
        List list = (List)o;
        NativeObject nativeObj = new NativeObject();
        int idx = 0;
        for(Object subObj : list) {
          Object val = javaJsonToJS(subObj);
          nativeObj.put(idx++, scope, val);
        }
        return nativeObj;
      } else {
        return Context.javaToJS(o, scope);
      }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.NativeObject

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.