marmelab / gremlins.js

Monkey testing library for web apps and Node.js
https://marmelab.com/blog/2020/06/02/gremlins-2.html
MIT License
9.03k stars 426 forks source link

Bug: gremlins.js aborts too early. #187

Open dmbs335 opened 2 years ago

dmbs335 commented 2 years ago

Steps To Reproduce

When executing code below, gremlins.js aborted too early. (function() { function callback() { gremlins.createHorde({ species: [gremlins.species.clicker(),gremlins.species.toucher(),gremlins.species.formFiller(),gremlins.species.scroller(),gremlins.species.typer()], mogwais: [gremlins.mogwais.alert(),gremlins.mogwais.fps(),gremlins.mogwais.gizmo()], strategies: [gremlins.strategies.distribution(),gremlins.strategies.allTogether(),gremlins.strategies.bySpecies()] }).unleash(); } var s = document.createElement("script"); s.src = "https://unpkg.com/gremlins.js"; if (s.addEventListener) { s.addEventListener("load", callback, false); } else if (s.readyState) { s.onreadystatechange = callback; } document.body.appendChild(s); })()

The current behavior

Error occurs, and gremlins.js stops. `Uncaught (in promise) TypeError: m is null La https://unpkg.com/gremlins.js:1 Na https://unpkg.com/gremlins.js:1 promise callbackNa/< https://unpkg.com/gremlins.js:1 Na https://unpkg.com/gremlins.js:1 i https://unpkg.com/gremlins.js:1 n https://unpkg.com/gremlins.js:1 unleash https://unpkg.com/gremlins.js:1 callback debugger eval code:1 EventListener.handleEvent debugger eval code:1

debugger eval code:1 getEvalResult resource://devtools/server/actors/webconsole/eval-with-debugger.js:243 evalWithDebugger resource://devtools/server/actors/webconsole/eval-with-debugger.js:167 evaluateJS resource://devtools/server/actors/webconsole.js:1127 evaluateJSAsync resource://devtools/server/actors/webconsole.js:1019 makeInfallible resource://devtools/shared/ThreadSafeDevToolsUtils.js:103 }` ## The expected behavior gremlins.js should not stop. ### Suggested solution: By auditing and debugging the source code, I found that the reason for the bug is that sometimes `https://github.com/marmelab/gremlins.js/blob/master/src/species/typer.js#L69` returns undefined.