Search in sources :

Example 1 with NativeJavaObject

use of net.sourceforge.htmlunit.corejs.javascript.NativeJavaObject in project htmlunit by HtmlUnit.

the class HTMLObjectElement method get.

/**
 * {@inheritDoc}
 */
@Override
public Object get(final String name, final Scriptable start) {
    // ourself
    if (wrappedActiveX_ instanceof NativeJavaObject) {
        final NativeJavaObject obj = (NativeJavaObject) wrappedActiveX_;
        final Object result = obj.get(name, start);
        if (Scriptable.NOT_FOUND != result) {
            return result;
        }
        return super.get(name, start);
    }
    if (wrappedActiveX_ != null) {
        return wrappedActiveX_.get(name, start);
    }
    return super.get(name, start);
}
Also used : ScriptableObject(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject) HtmlObject(com.gargoylesoftware.htmlunit.html.HtmlObject) NativeJavaObject(net.sourceforge.htmlunit.corejs.javascript.NativeJavaObject) NativeJavaObject(net.sourceforge.htmlunit.corejs.javascript.NativeJavaObject)

Example 2 with NativeJavaObject

use of net.sourceforge.htmlunit.corejs.javascript.NativeJavaObject in project teavm by konsoletyper.

the class HtmlUnitRunStrategy method runTest.

@Override
public void runTest(TestRun run) throws IOException {
    if (++runs == 50) {
        runs = 0;
        cleanUp();
        init();
    }
    try {
        page.set(webClient.get().getPage("about:blank"));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    HtmlPage pageRef = page.get();
    pageRef.executeJavaScript(readFile(new File(run.getBaseDirectory(), run.getFileName())));
    boolean decodeStack = Boolean.parseBoolean(System.getProperty(TeaVMTestRunner.JS_DECODE_STACK, "true"));
    File debugFile = decodeStack ? new File(run.getBaseDirectory(), run.getFileName() + ".teavmdbg") : null;
    RhinoResultParser resultParser = new RhinoResultParser(debugFile);
    AsyncResult asyncResult = new AsyncResult();
    Function function = (Function) page.get().executeJavaScript(readResource("teavm-htmlunit-adapter.js")).getJavaScriptResult();
    Object[] args = new Object[] { run.getArgument(), decodeStack ? createStackDecoderFunction(resultParser) : null, new NativeJavaObject(function, asyncResult, AsyncResult.class) };
    pageRef.executeJavaScriptFunction(function, function, args, page.get());
    resultParser.parseResult((Scriptable) asyncResult.getResult(), run.getCallback());
}
Also used : Function(net.sourceforge.htmlunit.corejs.javascript.Function) BaseFunction(net.sourceforge.htmlunit.corejs.javascript.BaseFunction) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) NativeJavaObject(net.sourceforge.htmlunit.corejs.javascript.NativeJavaObject) IOException(java.io.IOException) NativeJavaObject(net.sourceforge.htmlunit.corejs.javascript.NativeJavaObject) File(java.io.File)

Aggregations

NativeJavaObject (net.sourceforge.htmlunit.corejs.javascript.NativeJavaObject)2 HtmlObject (com.gargoylesoftware.htmlunit.html.HtmlObject)1 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)1 File (java.io.File)1 IOException (java.io.IOException)1 BaseFunction (net.sourceforge.htmlunit.corejs.javascript.BaseFunction)1 Function (net.sourceforge.htmlunit.corejs.javascript.Function)1 ScriptableObject (net.sourceforge.htmlunit.corejs.javascript.ScriptableObject)1