Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

const not supported in javascript for loop #449

Open
jpschewe opened this issue Feb 22, 2022 · 3 comments
Open

const not supported in javascript for loop #449

jpschewe opened this issue Feb 22, 2022 · 3 comments
Labels
js-engine Issues related to the js engine workaround available There is a workaround available

Comments

@jpschewe
Copy link

When parsing the following javascript htmlunit fails to parse. If "const" is removed from the for loop, then the parsing succeeds.

Minimal code example:
test.js

function checkSomethingToPrint() {
    let arr = new Array();
    for(const e of arr) {
        alert("here");
    }
}

test.html

<html>
  <head>
    <script src="test.js" type="text/javascript"></script>
  </head>
</html>

App.java

import com.gargoylesoftware.htmlunit.*;
import com.gargoylesoftware.htmlunit.html.*;
import java.io.*;

public class App {
  
  public static void main(String[] args) throws Exception {
    try (final WebClient webClient = new WebClient()) {
      File file = new File("test.html");
      final HtmlPage page = webClient.getPage(file.toURI().toURL());
    }
  }
}
jpschewe added a commit to jpschewe/fll-sw that referenced this issue Feb 22, 2022
rbri added a commit to HtmlUnit/htmlunit-rhino-fork that referenced this issue Apr 20, 2022
@rbri
Copy link
Member

rbri commented Apr 20, 2022

made a hack to work around this

HtmlUnit/htmlunit-rhino-fork@691fb57

@rbri
Copy link
Member

rbri commented Apr 20, 2022

see com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine2Test.constInOfLoop() for a test case

@rbri rbri added the workaround available There is a workaround available label Apr 20, 2022
jpschewe added a commit to jpschewe/fll-sw that referenced this issue Nov 1, 2022
@rbri rbri added the js-engine Issues related to the js engine label Mar 27, 2024
@rbri
Copy link
Member

rbri commented Mar 27, 2024

see #755

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
js-engine Issues related to the js engine workaround available There is a workaround available
Projects
None yet
Development

No branches or pull requests

2 participants