Skip to content

Commit

Permalink
matchall test case added
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Nov 27, 2024
1 parent 414c672 commit fc456b1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@

<body>
<release version="4.7.0" date="November xx, 2024" description="Bugfixes, Chrome/Edge 131">
<action type="add" dev="RhinoTeam">
core-js: String.prototype.matchAll, Symbol.matchAll, and RegExp.prototype[Symbol.matchAll] added.
</action>
<action type="fix" dev="rbri">
neko: BOM header detection fixed
</action>
<action type="update" dev="rbri">
neko: bunch of micro optimizations
</action>
<action type="add" dev="rbri">
Property navigator pdfViewerEnabled added.
</action>
Expand Down
33 changes: 33 additions & 0 deletions src/test/java/org/htmlunit/javascript/JavaScriptEngine2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -1175,4 +1175,37 @@ public void ensureOrder() throws Exception {
Thread.sleep(DEFAULT_WAIT_TIME);
verifyTitle2(driver, getExpectedAlerts());
}

/**
* @throws Exception if the test fails
*/
@Test
@Alerts({"false", "aa", "0", "aabbc", "false", "bb", "2", "aabbc", "true", "undefined"})
public void matchAll() throws Exception {
final String html = "<html><body>"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ "const s = 'aabbc';\n"
+ "const re = /([a-z])\\1/g;\n"
+ "const matches = s.matchAll(re);\n"

+ "var match = matches.next();\n"
+ "log(match.done);\n"
+ "log(match.value[0]);\n"
+ "log(match.value.index);\n"
+ "log(match.value.input);\n"

+ "match = matches.next();\n"
+ "log(match.done);\n"
+ "log(match.value[0]);\n"
+ "log(match.value.index);\n"
+ "log(match.value.input);\n"

+ "match = matches.next();\n"
+ "log(match.done);\n"
+ "log(match.value);\n"
+ "</script></body></html>";

loadPageVerifyTitle2(html);
}
}

0 comments on commit fc456b1

Please sign in to comment.