-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgremlins.js.javascript.txt
62 lines (56 loc) · 4.59 KB
/
gremlins.js.javascript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
┏━━━━━━━━━━━━━━━━━┓
┃ GREMLINS.JS ┃
┗━━━━━━━━━━━━━━━━━┛
VERSION ==> #Node module (0.1.0), web script or bookmarklet
#As Node module, DOM must be available under window.* (e.g. with JSDOM)
#Fires several random DOM actions/events (stress testing)
GREMLINS.createHorde() #Returns HORDE
HORDE.unleash([OBJ]) #Starts stress testing, using native DOM events/actions
#Actions performed can be seen on the GUI (red spots) and on console.log
#OBJ members are:
# - nb NUM (def: 1000): number of actions before stopping
# - delay NUM (def: 10 ms): time betweeb two actions
# - distribution DOUBLE_ARR: percentage of GREMLINS.species.* (must add up to 100%)
# (def: uniform)
HORDE.stop() #Otherwise stops after all actions are executed or when changing URL
HORDER.before|after([FUNC()]) #Executes code before|after unleash()
HORDE.gremlin(FUNC()) #Add only a specific stress testing action.
#FUNC() returns a FUNC2() that performs an action.
#By default, all default GREMLINS.species.* are included. They can be chained with some
#CONFIGFUNC(...) for configuration
GREMLINS.species.clicker() #MouseEvent. CONFIGFUNC:
# - clickTypes EVENT_STR_ARR (def: [ 6 'click', 2 'dblclick', 'mousedown', 'mouseup',
# 3 'mouseover', 'mousemove', 'mouseout'])
# - positionSelector FUNC() -> [ X, Y ]
# - showAction FUNC(X,Y): visual indicator (def: show red outlines).
# Also available for other GREMLINS.
# - canClick FUNC(ELEM): returns false if should not click here.
# - maxNbTries NUM (def: 10). Also available for other GREMLINS
GREMLINS.species.toucher() #Touch events. CONFIGFUNC:
# - touchTypes EVENT_STR_ARR (def: [3 'tap', 'doubletap', 3 'gesture', 2 'multitouch'])
# - positionSelector: cf clicker()
# - canTouch: same as canClick above
# - maxTouches UINT (def: 2): when multitouch
GREMLINS.species.formFiller() #Changes forms values and click on forms. CONFIGFUNC:
# - elementMapTypes { SELECTOR: FUNC(ELEM) ... }: action to perform
# - canFillElement FUNC(ELEM): same as canClick above
GREMLINS.species.scroller() #Uses WINDOW.scrollTo(). CONFIGFUNC:
# - positionSelector FUNC(X,Y)
GREMLINS.species.typer() #keypress|up|down events. CONFIGFUNC:
# - eventTypes EVENT_STR_ARR (def: ['keypress', 'keyup', 'keydown'])
# - keyGenerator FUNC(): returns KEYBOARDEVENT.which|keyCode
HORDE.allGremlins() #HORDE.gremlin(HORDE.allGremlins()) is same as doing HORDE.gremlin(FUNC()) on all
#GREMLINS.species.* (in previous order)
HORDE.mogwai(FUNC()) #Like HORDER.gremlin() for a logging/helper action. By def, include:
GREMLINS.mogwais.alert() #Replace popups functions with console.log messages functions. CONFIGFUNC:
# - watchEvents FUNC_STR_ARR (def: ['alert', 'confirm', 'prompt'])
GREMLINS.mogwais.fps(VAL) #console.*() the FPS. CONFIGFUNC:
# - delay (def: 500): between FPS check
# - levelSelector FUNC(NUM): returns the FUNC2_STR according to NUM fps, to execute
# console[FUNC2_STR]() (def: <10 console.error, <20 console.warn, otherwise console.log)
GREMLINS.mogwais.gizmo() #Executes HORDE.stop() if there are more than NUM error events
#(window.onerror and console.onerror). CONFIGFUNC:
# - maxErrors NUM (def: 10)
HORDE.allMogwais() #Same as HORDE.allGremlins() but for Mogwais
HORDE.logger(
{log|info|warn|error FUNC(STR)})#Change the logging method