diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6db9bbd5d0..aaaa32f842 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -24,7 +24,7 @@ googleGson = "2.9.0" googleProtobuf = "3.21.9" googleProtobufPlugin = "0.9.1" googleTruth = "1.4.2" -graaljs = "22.0.0" # Latest version that supports Java 8 +graaljs = "23.0.5" grpc = "1.50.2" grpcKotlinStub = "1.3.0" imageComparison = "4.4.0" diff --git a/maestro-client/src/main/java/maestro/js/GraalJsEngine.kt b/maestro-client/src/main/java/maestro/js/GraalJsEngine.kt index d23bce860d..662865447b 100644 --- a/maestro-client/src/main/java/maestro/js/GraalJsEngine.kt +++ b/maestro-client/src/main/java/maestro/js/GraalJsEngine.kt @@ -10,6 +10,7 @@ import java.io.ByteArrayOutputStream import java.util.concurrent.TimeUnit import java.util.logging.Handler import java.util.logging.LogRecord +import org.graalvm.polyglot.HostAccess private val NULL_HANDLER = object : Handler() { override fun publish(record: LogRecord?) {} @@ -82,6 +83,8 @@ class GraalJsEngine( val context = Context.newBuilder("js") .option("js.strict", "true") + .allowHostAccess(HostAccess.ALL) + .allowHostClassLookup { true } .logHandler(NULL_HANDLER) .out(outputStream) .build() diff --git a/maestro-test/src/test/kotlin/maestro/test/IntegrationTest.kt b/maestro-test/src/test/kotlin/maestro/test/IntegrationTest.kt index 139ba74767..7b912d442f 100644 --- a/maestro-test/src/test/kotlin/maestro/test/IntegrationTest.kt +++ b/maestro-test/src/test/kotlin/maestro/test/IntegrationTest.kt @@ -2712,10 +2712,16 @@ class IntegrationTest { // given val commands = readCommands("102_graaljs") val driver = driver { } + val receivedLogs = mutableListOf() // when Maestro(driver).use { - orchestra(it).runFlow(commands) + orchestra( + it, + onCommandMetadataUpdate = { _, metadata -> + receivedLogs += metadata.logMessages + } + ).runFlow(commands) } // then @@ -2725,6 +2731,7 @@ class IntegrationTest { Event.InputText("bar"), ) ) + assertThat(receivedLogs).containsExactly("0.2") } @Test diff --git a/maestro-test/src/test/resources/102_graaljs.yaml b/maestro-test/src/test/resources/102_graaljs.yaml index dd0e0bfdcf..11f0892fc5 100644 --- a/maestro-test/src/test/resources/102_graaljs.yaml +++ b/maestro-test/src/test/resources/102_graaljs.yaml @@ -3,4 +3,6 @@ jsEngine: graaljs --- # Note: The ?? operator is an example of an ES2020 feature and is not supported by RhinoJS - inputText: ${null ?? 'foo'} -- runFlow: 102_graaljs_subflow.yaml \ No newline at end of file +- runFlow: 102_graaljs_subflow.yaml +- runScript: + file: 102_graaljs_script.js diff --git a/maestro-test/src/test/resources/102_graaljs_script.js b/maestro-test/src/test/resources/102_graaljs_script.js new file mode 100644 index 0000000000..903abb9507 --- /dev/null +++ b/maestro-test/src/test/resources/102_graaljs_script.js @@ -0,0 +1,3 @@ +var BigDec = Java.type('java.math.BigDecimal'); +var bd = new BigDec("0.1"); +console.log(bd.add(bd).toString());