use of com.gargoylesoftware.htmlunit.javascript.host.ActiveXObjectImpl in project htmlunit by HtmlUnit.
the class HTMLObjectElement method setClassid.
/**
* Sets the {@code classid} attribute.
* @param classid the {@code classid} attribute
*/
@JsxSetter(IE)
public void setClassid(final String classid) {
getDomNodeOrDie().setAttribute("classid", classid);
if (classid.indexOf(':') != -1 && getBrowserVersion().hasFeature(HTML_OBJECT_CLASSID)) {
final WebClient webClient = getWindow().getWebWindow().getWebClient();
final Map<String, String> map = webClient.getActiveXObjectMap();
if (map != null) {
final String xClassString = map.get(classid);
if (xClassString != null) {
try {
final Class<?> xClass = Class.forName(xClassString);
final Object object = xClass.newInstance();
boolean contextCreated = false;
if (Context.getCurrentContext() == null) {
new HtmlUnitContextFactory(webClient).enterContext();
contextCreated = true;
}
wrappedActiveX_ = Context.toObject(object, getParentScope());
if (contextCreated) {
Context.exit();
}
} catch (final Exception e) {
throw Context.reportRuntimeError("ActiveXObject Error: failed instantiating class " + xClassString + " because " + e.getMessage() + ".");
}
return;
}
}
if (webClient.getOptions().isActiveXNative() && System.getProperty("os.name").contains("Windows")) {
try {
wrappedActiveX_ = new ActiveXObjectImpl(classid);
wrappedActiveX_.setParentScope(getParentScope());
} catch (final Exception e) {
Context.throwAsScriptRuntimeEx(e);
}
}
}
}
Aggregations