duonglaiquang · GitHub

Problem in brief

Attempts to call the JS method DateTimeFormat.format() in HtmlUnit 2.66 now throws TypeError: Cannot find function format in object [object DateTimeFormat] where as in a much older 2.52 it ran as expected.

This commit released in HtmlUnit 2.64 may have unintentionally removed it by removing the RecursiveFunctionObject.call() override.

Reproducing

Here's an example HTML to reproduce:

<!DOCTYPE html>
<html>
<head>
<script>
let dateFormat = Intl.DateTimeFormat();
console.log(dateFormat.format(new Date(2022, 11, 19))) // throws TypeError
console.log(dateFormat instanceof Intl.DateTimeFormat) // returns false instead of true
</script>
</head>
<body>
</body>
</html>
 

More details

Locally restoring RecursiveFunctionObject.call() had the effect of making the test above run as expected.

Read the original on github.com ↗