GithubHelp home page GithubHelp logo

Comments (8)

fzaninotto avatar fzaninotto commented on May 2, 2024

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?

from gremlins.js.

alexeygolev avatar alexeygolev commented on May 2, 2024

same thing here

from gremlins.js.

fzaninotto avatar fzaninotto commented on May 2, 2024

Same comment: can you help me reproduce the bug?

from gremlins.js.

gabehayes avatar gabehayes commented on May 2, 2024

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.

from gremlins.js.

JaSpr avatar JaSpr commented on May 2, 2024

where is MAX_INT getting defined?

from gremlins.js.

gabehayes avatar gabehayes commented on May 2, 2024

I haven't traced exactly where it is getting defined, yet, but it's value is as the comment indicates: 9007199254740992

image

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:

image

Then, calling pick (with the count argument not defined), it is setting the max value to be -1:

image

Which then leads to this error being called by chance's natural method, because the range is invalid:

image

from gremlins.js.

fzaninotto avatar fzaninotto commented on May 2, 2024

Thanks, you helped me find a bug in case a page contains an empty select. Should be fixed by #52.

from gremlins.js.

gabehayes avatar gabehayes commented on May 2, 2024

👍 awesome work, thanks for taking care of that.

from gremlins.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.