-
-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Javascript failing. Multiple engine support? #201
Comments
Can you please give the latest snapshot build a try. |
Sure gimme a min... |
@rbri The download is still failing but now the error messages are different: https://pastebin.com/7QrYLxkj <repositories>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement> |
@rbri |
Looks like the js code uses one of the js features not supported by rhino at the moment. Frome the Rhino sources
|
@rbri Ok so the only option I have is to wait, till support is added? |
@rbri Is there a way I can add support for default values inside destructuring assignments by myself to rhino? |
@rbri Or is there any other program similar to Htmlunit I could use, where default values inside destructuring assignments are supported? |
@rbri How about adding support to change the javascript engine? |
This is a valid point but this is a really huge amount of work. There are many classes providing all the browser specific functionality and the whole work on HtmlUmit is since years done only by me in my spare time. Any help is welcome.
Am 22. August 2020 11:39:11 MESZ schrieb Osiris Team <notifications@github.com>:
…
@rbri How about adding support to change the javascript engine?
There are alternatives like:
https://www.graalvm.org/
or
https://michel-kraemer.github.io/citeproc-java/
or
https://github.com/eclipsesource/J2V8
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#201 (comment)
--
Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.
|
@rbri Ok I would really like to help. I will do some more research on this topic before, and see which of the engines supports default values inside destructuring assignments. |
@rbri Here is the example: package com.osiris.JavaScriptExecutor.javascript;
import de.undercouch.citeproc.script.ScriptRunner;
import de.undercouch.citeproc.script.ScriptRunnerFactory;
import java.io.*;
public class GitHubExample {
private static ScriptRunner scriptRunner = null;
public static void main(String[] args) {
// Loop 3 times to test the same operation on different engines
for (int i = 0; i < 3; i++) {
// Select the engine
setEngine(i);
System.out.println("Testing engine "+i+"...");
// Example to run javascript from a string:
try{
// Test JS code to check if default values inside destructuring assignments are supported
String destruct_test = "const dummy = {" +
" name: undefined" +
"};" +
"const { name = 'Peter' } = dummy;" +
"console.log(name)";
// Get the input stream of the selected string
InputStream in = new ByteArrayInputStream(destruct_test.getBytes());
Reader reader = new InputStreamReader(in);
// Run the javascript
scriptRunner.eval(reader);
System.out.println("Engine "+i+" completed successfully!");
// Result is that only the graal-engine will finish successfully
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* Select the engine:
* 0 = graal_engine (default);
* 1 = java_engine;
* 2 = v8_engine;
* @param engine
*/
public static void setEngine(int engine){
if (engine==0){
//Select graal_engine
ScriptRunnerFactory.setRunnerType(ScriptRunnerFactory.RunnerType.GRAALJS);
scriptRunner = ScriptRunnerFactory.createRunner();
}
else if (engine==1){
//Select java_engine
ScriptRunnerFactory.setRunnerType(ScriptRunnerFactory.RunnerType.JRE);
scriptRunner = ScriptRunnerFactory.createRunner();
}
else {
//Select v8_engine
ScriptRunnerFactory.setRunnerType(ScriptRunnerFactory.RunnerType.V8);
scriptRunner = ScriptRunnerFactory.createRunner();
}
}
} |
@rbri |
@rbri Im back with some news. I think implementing the GraalJS Engine into htmlunit is quite much impossible (at least for me alone) because of its strong dependency and interconnectivity with the rhino engine, like you said. That's why I created this https://github.com/Osiris-Team/JG-Browser which is the same as htmlunit just built with the graal js engine as base. What do you think? |
@Osiris-Team you probably mean @rbri, not @rbi |
Ups! |
@Osiris-Team so it seems the RhinoJS is the one that needs to be updated to make HtmlUnit more robust to handle javascript... |
The issue:
When trying to download a jar file from https://spigotmc.org we get a "default values inside destructuring assignments are not supported" exception.
The root of this problem lays at the javascript engine used by htmlunit (mozilla/rhino#756).
We have two possible fixes:
Status:
The code: #201 (comment)
The text was updated successfully, but these errors were encountered: