Reputation: 301
I'm currently developing some tests with HtmlUnit. It's loading a page that contains braintree.js (their form encryption library). I have a bunch running, but I'm stuck where it calls crypto. The JS in question is:
(function() {
try {
var ab = new Uint32Array(32);
crypto.getRandomValues(ab);
sjcl.random.addEntropy(ab, 1024, "crypto.getRandomValues");
} catch (e) {}
})();
HtmlUnit is throwing:
EcmaError, ReferenceError, "'crypto' is not defined."
I suppose HtmlUnit doesn't include crypto. Would it be possible to include a crypto library myself?
Upvotes: 3
Views: 4926
Reputation: 43434
Based on your comment, I have to tell you that HtmlUnit is a pain in the neck when it comes to JavaScript. It will complain a lot about variables not being defined and unknown functions and so on.
Real browsers are more flexible, eg: they accept syntactically incorrect pieces of JavaScript. HtmlUnit expects everything to be perfect without any kind of error. Furthermore, even if you didn't miss a semicolon, HtmlUnit might complain.
My advice:
BrowserVersions
. Internet Explorer (ironically) has proven to provide the best results when it comes to interpreting JavaScriptUpvotes: 4