Search in sources :

Example 6 with ClassConfiguration

use of com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration in project htmlunit by HtmlUnit.

the class RecursiveFunctionObject method get.

/**
 * {@inheritDoc}
 */
@Override
public Object get(final String name, final Scriptable start) {
    final String superFunctionName = super.getFunctionName();
    if ("prototype".equals(name)) {
        if ("Proxy".equals(superFunctionName)) {
            return NOT_FOUND;
        }
    }
    Object value = super.get(name, start);
    if (value == NOT_FOUND && !"Image".equals(superFunctionName) && !"Option".equals(superFunctionName) && (!"WebGLContextEvent".equals(superFunctionName) || getBrowserVersion().hasFeature(JS_WEBGL_CONTEXT_EVENT_CONSTANTS))) {
        Class<?> klass = getPrototypeProperty().getClass();
        final BrowserVersion browserVersion = getBrowserVersion();
        while (value == NOT_FOUND && HtmlUnitScriptable.class.isAssignableFrom(klass)) {
            final ClassConfiguration config = AbstractJavaScriptConfiguration.getClassConfiguration(klass.asSubclass(HtmlUnitScriptable.class), browserVersion);
            if (config != null) {
                final List<ConstantInfo> constants = config.getConstants();
                if (constants != null) {
                    for (final ConstantInfo constantInfo : constants) {
                        if (constantInfo.getName().equals(name)) {
                            value = ScriptableObject.getProperty((Scriptable) getPrototypeProperty(), name);
                            break;
                        }
                    }
                }
            }
            klass = klass.getSuperclass();
        }
    }
    return value;
}
Also used : ConstantInfo(com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration.ConstantInfo) ScriptableObject(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject) FunctionObject(net.sourceforge.htmlunit.corejs.javascript.FunctionObject) Scriptable(net.sourceforge.htmlunit.corejs.javascript.Scriptable) BrowserVersion(com.gargoylesoftware.htmlunit.BrowserVersion) ClassConfiguration(com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration)

Aggregations

ClassConfiguration (com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration)6 BrowserVersion (com.gargoylesoftware.htmlunit.BrowserVersion)4 FunctionObject (net.sourceforge.htmlunit.corejs.javascript.FunctionObject)3 ConstantInfo (com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration.ConstantInfo)2 PropertyInfo (com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration.PropertyInfo)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Scriptable (net.sourceforge.htmlunit.corejs.javascript.Scriptable)2 ScriptableObject (net.sourceforge.htmlunit.corejs.javascript.ScriptableObject)2 Test (org.junit.Test)2 ScriptException (com.gargoylesoftware.htmlunit.ScriptException)1 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 WebWindow (com.gargoylesoftware.htmlunit.WebWindow)1 Definition (com.gargoylesoftware.htmlunit.css.StyleAttributes.Definition)1 HtmlUnitScriptable (com.gargoylesoftware.htmlunit.javascript.HtmlUnitScriptable)1 RecursiveFunctionObject (com.gargoylesoftware.htmlunit.javascript.RecursiveFunctionObject)1 JavaScriptConfiguration (com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration)1 ActiveXObject (com.gargoylesoftware.htmlunit.javascript.host.ActiveXObject)1 Reflect (com.gargoylesoftware.htmlunit.javascript.host.Reflect)1 Window (com.gargoylesoftware.htmlunit.javascript.host.Window)1