Closed danb235 closed 10 years ago
Can't reproduce. Could you share the test page you run gremlins on? Could you paste the detailed error stack when using the non-minified version of gremlins?
same thing here
Same comment: can you help me reproduce the bug?
After rebuilding the js file with the optimize
property set to none
, then running the test, here is the stack for the error:
Uncaught RangeError: Chance: Min cannot be greater than Max. gremlins.min.js?bust=1395780871173:481
testRange gremlins.min.js?bust=1395780871173:481
Chance.natural gremlins.min.js?bust=1395780871173:603
Chance.pick gremlins.min.js?bust=1395780871173:662
fillSelect gremlins.min.js?bust=1395780871173:2002
formFillerGremlin gremlins.min.js?bust=1395780871173:1975
iterator gremlins.min.js?bust=1395780871173:2564
executeInSeries gremlins.min.js?bust=1395780871173:2576
executeNext gremlins.min.js?bust=1395780871173:2789
(anonymous function) gremlins.min.js?bust=1395780871173:2791
Looks like the error is being thrown by this method in chancejs:
function testRange(test, errorMessage) {
if (test) {
throw new RangeError(errorMessage);
}
}
Which means that the passed options here are invalid?
// NOTE the max and min are INCLUDED in the range. So:
//
// chance.natural({min: 1, max: 3});
//
// would return either 1, 2, or 3.
Chance.prototype.natural = function (options) {
// 9007199254740992 (2^53) is the max integer number in JavaScript
// See: http://vq.io/132sa2j
options = initOptions(options, {min: 0, max: MAX_INT});
testRange(options.min > options.max, "Chance: Min cannot be greater than Max.");
return Math.floor(this.random() * (options.max - options.min + 1) + options.min);
};
Happens every time we launch. Loading the module via requirejs and launching with gremlins.createHorde().unleash()
.
After looking at the stack, please let me know if there are any specific variables you care for us to log.
where is MAX_INT getting defined?
I haven't traced exactly where it is getting defined, yet, but it's value is as the comment indicates: 9007199254740992
The issue definitely seems to be with chance's handling of picking a random item. For some reason at a given moment, element.querySelectorAll('option')
returns no items:
Then, calling pick (with the count argument not defined), it is setting the max value to be -1:
Which then leads to this error being called by chance's natural method, because the range is invalid:
Thanks, you helped me find a bug in case a page contains an empty select. Should be fixed by #52.
:+1: awesome work, thanks for taking care of that.
We got gremlins up and running (neat project, btw) but are encountering an error after a second or two of testing. I was hoping for some insight.
Here is a screenshot of my chrome dev console with the error:
Any suggestions?