-
-
Notifications
You must be signed in to change notification settings - Fork 184
Closed
Description
Problem in brief
HtmlUnit/Rhino throws ScriptException: null when a "bound function" is given as the callback function of Promise.then(). This error is caused by cx.topCallScope being null when passed to BoundFunction.call().
More details
This problem was introduced after the implementation of Promise was changed to Rhino's native implementation in HtmlUnit version 2.56.
Testing
Here are some tests to show the behavior of HtmlUnit 2.66 and Chrome.
<!DOCTYPE html>
<html>
<head>
<script>
let f = function () { console.log(this) }
Promise.resolve().then(f.bind(null)); // Chrome prints Window {...}, HtmlUnit throws ScriptException -- bad
Promise.resolve().then(f.bind("")); // Chrome and HtmlUnit prints String {''} -- good
Promise.resolve().then(() => f.bind(null).call()); // Chrome and HtmlUnit prints Window {...} -- good
Promise.resolve().then(() => f.bind('').call()); // Chrome and HtmlUnit prints String {''} -- good
</script>
</head>
<body>
</body>
</html>
atnak
Metadata
Metadata
Assignees
Labels
No labels