atnak · GitHub

Problem in brief

When HtmlUnit is run in Windows, new Error().stack contains lines are separated by CR LF. However, major browsers separate lines using LF only.

The likely cause is Rhino's use of line.separator when creating the stacktrace string.

Testing

The following JS code was used to test behaviour in Chrome/FF/Edge:

console.log(new Error().stack.replace('\r', '\\r').replace('\n', '\\n'));

The following was used to test behaviour in IE 11:

<html>
<head>
<script>
try {
  throw new Error()
} catch (e) {
  console.log(e.stack.replace('\r', '\\r').replace('\n', '\\n'));
}
</script>
</head>
</html>

Extra

line.separator is used for various reasons in mozilla/rhino with currently four places in total.

Read the original on github.com ↗