Package net.sourceforge.htmlunit.corejs.javascript

Examples of net.sourceforge.htmlunit.corejs.javascript.Context


        + ", methodName: " + methodName + ", args: " + args);
    /*
     * 1. lookup functions by name. 2. Find context and scope. 3. Convert
     * thisObject to ScriptableObject 4. Convert args 5. Get return value
     */
    Context jsContext = Context.getCurrentContext();
    ScriptableObject jsThis;
    if (thisObj.getType() == ValueType.NULL) {
      jsThis = window;
    } else {
      jsThis = (ScriptableObject) makeJsvalFromValue(jsContext, thisObj);
View Full Code Here


        + ", methodName: " + methodName + ", args: " + args);
    /*
     * 1. lookup functions by name. 2. Find context and scope. 3. Convert
     * thisObject to ScriptableObject 4. Convert args 5. Get return value
     */
    Context jsContext = Context.getCurrentContext();
    ScriptableObject jsThis;
    if (thisObj.getType() == ValueType.NULL) {
      jsThis = window;
    } else {
      jsThis = (ScriptableObject) makeJsvalFromValue(jsContext, thisObj);
View Full Code Here

    }
    /*
     * 1. lookup functions by name. 2. Find context and scope. 3. Convert
     * thisObject to ScriptableObject 4. Convert args 5. Get return value
     */
    Context jsContext = Context.getCurrentContext();
    ScriptableObject jsThis = null;
    if (thisObj.getType() == ValueType.NULL) {
      jsThis = window;
    } else {
      Object obj = makeJsvalFromValue(jsContext, thisObj);
View Full Code Here

       Object[] args = { arg1, arg2 };
       return getMessage(messageId, args);
   }

   public static String getMessage(String messageId, Object[] args) {
       Context cx = Context.getCurrentContext();
       Locale locale = cx == null ? Locale.getDefault() : cx.getLocale();

       // ResourceBundle does cacheing.
       ResourceBundle rb = ResourceBundle.getBundle
           ("org.moyrax.javascript.tool.Messages", locale);
View Full Code Here

    }
    /*
     * 1. lookup functions by name. 2. Find context and scope. 3. Convert
     * thisObject to ScriptableObject 4. Convert args 5. Get return value
     */
    Context jsContext = Context.getCurrentContext();
    ScriptableObject jsThis = null;
    if (thisObj.getType() == ValueType.NULL) {
      jsThis = window;
    } else {
      Object obj = makeJsvalFromValue(jsContext, thisObj);
View Full Code Here

     * @param content the JavaScript content
     * @param url the URL to be retrieved
     * @return semicolon-separated result
     */
    public static String evaluate(final String content, final URL url) {
        final Context cx = ContextFactory.getGlobal().enterContext();
        try {
            final ProxyAutoConfig config = new ProxyAutoConfig();
            final Scriptable scope = cx.initStandardObjects();

            config.defineMethod("isPlainHostName", scope);
            config.defineMethod("dnsDomainIs", scope);
            config.defineMethod("localHostOrDomainIs", scope);
            config.defineMethod("isResolvable", scope);
            config.defineMethod("isInNet", scope);
            config.defineMethod("dnsResolve", scope);
            config.defineMethod("myIpAddress", scope);
            config.defineMethod("dnsDomainLevels", scope);
            config.defineMethod("shExpMatch", scope);
            config.defineMethod("weekdayRange", scope);
            config.defineMethod("dateRange", scope);
            config.defineMethod("timeRange", scope);

            cx.evaluateString(scope, "var ProxyConfig = function() {}; ProxyConfig.bindings = {}", "<init>", 1, null);
            cx.evaluateString(scope, content, "<Proxy Auto-Config>", 1, null);
            final Object functionArgs[] = {url.toExternalForm(), url.getHost()};
            final Object fObj = scope.get("FindProxyForURL", scope);

            final NativeFunction f = (NativeFunction) fObj;
            final Object result = f.call(cx, scope, scope, functionArgs);
View Full Code Here

        applicationCache_ = new OfflineResourceList();
        applicationCache_.setParentScope(this);
        applicationCache_.setPrototype(getPrototype(OfflineResourceList.class));

        // like a JS new Object()
        final Context ctx = Context.getCurrentContext();
        controllers_ = ctx.newObject(this);

        if (webWindow_ instanceof TopLevelWindow) {
            final WebWindow opener = ((TopLevelWindow) webWindow_).getOpener();
            if (opener != null) {
                opener_ = opener.getScriptObject();
View Full Code Here

     * This is used only when eval() is called on a Window other than the starting scope
     * @param scriptCode some JavaScript code
     * @return the evaluation result
     */
    public Object custom_eval(final String scriptCode) {
        final Context context = Context.getCurrentContext();
        final Script script = context.compileString(scriptCode, "eval body", 0, null);
        return script.exec(context, this);
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.htmlunit.corejs.javascript.Context

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.