use of com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration.ConstantInfo in project htmlunit by HtmlUnit.
the class HostConstantsTest method getExpectedString.
private String getExpectedString() throws Exception {
if (host_.endsWith("Array") || "Image".equals(host_) || "Option".equals(host_)) {
return "";
}
if ("Error".equals(host_) && getBrowserVersion().hasFeature(JS_ERROR_STACK_TRACE_LIMIT)) {
return "stackTraceLimit:10";
}
final JavaScriptConfiguration javaScriptConfig = JavaScriptConfiguration.getInstance(getBrowserVersion());
final List<String> constants = new ArrayList<>();
ClassConfiguration classConfig = javaScriptConfig.getClassConfiguration(host_);
boolean first = true;
while (classConfig != null) {
if (first && !classConfig.isJsObject()) {
break;
}
if (first || classConfig.getJsConstructor() != null) {
final List<ConstantInfo> constantInfos = classConfig.getConstants();
if (constantInfos != null) {
for (final ConstantInfo constantInfo : constantInfos) {
constants.add(constantInfo.getName() + ":" + constantInfo.getValue());
}
}
}
classConfig = javaScriptConfig.getClassConfiguration(classConfig.getExtendedClassName());
first = false;
}
Collections.sort(constants, new Comparator<String>() {
@Override
public int compare(final String o1, final String o2) {
return o1.substring(0, o1.indexOf(':')).compareTo(o2.substring(0, o2.indexOf(':')));
}
});
final StringBuilder builder = new StringBuilder();
for (final String key : constants) {
builder.append(key).append(' ');
}
return builder.toString().trim();
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration.ConstantInfo 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;
}
Aggregations