GithubHelp home page GithubHelp logo

marmelab / gremlins.js Goto Github PK

View Code? Open in Web Editor NEW
9.0K 157.0 422.0 4.6 MB

Monkey testing library for web apps and Node.js

Home Page: https://marmelab.com/blog/2020/06/02/gremlins-2.html

License: MIT License

JavaScript 89.21% Makefile 1.48% HTML 8.45% CSS 0.86%
test fuzz-testing frontend

gremlins.js's Introduction

gremlins.js

gremlins

A monkey testing library written in JavaScript, for Node.js and the browser. Use it to check the robustness of web applications by unleashing a horde of undisciplined gremlins.


Generate bookmarklet | Install docs



version downloads Build Status

PRs Welcome Code of Conduct MIT License

Tweet

TodoMVC attacked by gremlins

Kate: What are they, Billy?

Billy Peltzer: They're gremlins, Kate, just like Mr. Futterman said.

Table of Contents

Purpose

While developing an HTML5 application, did you anticipate uncommon user interactions? Did you manage to detect and patch all memory leaks? If not, the application may break sooner or later. If n random actions can make an application fail, it's better to acknowledge it during testing, rather than letting users discover it.

Gremlins.js simulates random user actions: gremlins click anywhere in the window, enter random data in forms, or move the mouse over elements that don't expect it. Their goal: triggering JavaScript errors, or making the application fail. If gremlins can't break an application, congrats! The application is robust enough to be released to real users.

This practice, also known as Monkey testing or Fuzz testing, is very common in mobile application development (see for instance the Android Monkey program). Now that frontend (MV*, d3.js, Backbone.js, Angular.js, etc.) and backend (Node.js) development use persistent JavaScript applications, this technique becomes valuable for web applications.

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's dependencies:

npm i gremlins.js

This library has dependencies listings for chance.

gremlins.js is also available as a bookmarklet. Go to this page, grab it, and unleash hordes on any web page.

Basic Usage

A gremlins horde is an army of specialized gremlins ready to mess up your application. unleash the gremlins to start the stress test:

const horde = gremlins.createHorde();
horde.unleash();
// gremlins will act randomly, at 10 ms interval, 1000 times

gremlins.js provides several gremlin species: some click everywhere on the page, others enter data in form inputs, others scroll the window in every possible direction, etc.

You will see traces of the gremlins actions on the screen (they leave red traces) and in the console log:

gremlin formFiller input 5 in <input type=โ€‹"number" name=โ€‹"age">โ€‹
gremlin formFiller input [email protected] in <input type=โ€‹"email" name=โ€‹"email">โ€‹
gremlin clicker    click at 1219 301
gremlin scroller   scroll to 100 25
...

A horde also contains mogwais, which are harmless gremlins (or, you could say that gremlins are harmful mogwais). Mogwais only monitor the activity of the application and record it on the logger. For instance, the "fps" mogwai monitors the number of frame per second, every 500ms:

mogwai  fps  33.21
mogwai  fps  59.45
mogwai  fps  12.67
...

Mogwais also report when gremlins break the application. For instance, if the number of frames per seconds drops below 10, the fps mogwai will log an error:

mogwai  fps  12.67
mogwai  fps  23.56
err > mogwai  fps  7.54 < err
mogwai  fps  15.76
...

After 10 errors, a special mogwai stops the test. He's called Gizmo, and he prevents gremlins from breaking applications bad. After all, once gremlins have found the first 10 errors, you already know what you have to do to make your application more robust.

If not stopped by Gizmo, the default horde stops after roughly 1 minute. You can increase the number of gremlins actions to make the attack last longer:

const horde = gremlins.createHorde({
    strategies: [gremlins.strategies.allTogether({ nb: 10000 })],
});
horde.unleash();
// gremlins will attack at 10 ms interval, 10,000 times

Gremlins, just like mogwais, are simple JavaScript functions. If gremlins.js doesn't provide the gremlin that can break your application, it's very easy to develop it:

// Create a new custom gremlin to blur an input randomly selected
function customGremlin({ logger, randomizer, window }) {
    // Code executed once at initialization
    logger.log('Input blur gremlin initialized');
    // Return a function that will be executed at each attack
    return function attack() {
        var inputs = document.querySelectorAll('input');
        var element = randomizer.pick(element);
        element.blur();
        window.alert('attack done');
    };
}

// Add it to your horde
const horde = gremlins.createHorde({
    species: [customGremlin],
});

Everything in gremlins.js is configurable ; you will find it very easy to extend and adapt to you use cases.

Advanced Usage

Setting Gremlins and Mogwais To Use In A Test

By default, all gremlins and mogwais species are added to the horde.

You can also choose to add only the gremlins species you want, using a custom configuration object:

gremlins
    .createHorde({
        species: [
            gremlins.species.formFiller(),
            gremlins.species.clicker({
                clickTypes: ['click'],
            }),
            gremlins.species.toucher(),
        ],
    })
    .unleash();

If you just want to add your own gremlins in addition to the default ones, use the allSpecies constant:

gremlins
    .createHorde({
        species: [...gremlins.allSpecies, customGremlin],
    })
    .unleash();

To add just the mogwais you want, use the mogwai configuration and allMogwais() constant the same way.

gremlins.js currently provides a few gremlins and mogwais:

  • clickerGremlin clicks anywhere on the visible area of the document
  • toucherGremlin touches anywhere on the visible area of the document
  • formFillerGremlin fills forms by entering data, selecting options, clicking checkboxes, etc
  • scrollerGremlin scrolls the viewport to reveal another part of the document
  • typerGremlin types keys on the keyboard
  • alertMogwai prevents calls to alert() from blocking the test
  • fpsMogwai logs the number of frames per seconds (FPS) of the browser
  • gizmoMogwai can stop the gremlins when they go too far

Configuring Gremlins

All the gremlins and mogwais provided by gremlins.js are configurable, i.e. you can alter the way they work by injecting a custom configuration.

For instance, the clicker gremlin is a function that take an object as custom configuration:

const customClicker = gremlins.species.clicker({
    // which mouse event types will be triggered
    clickTypes: ['click'],
    // Click only if parent is has class test-class
    canClick: (element) => element.parentElement.className === 'test-class',
    // by default, the clicker gremlin shows its action by a red circle
    // overriding showAction() with an empty function makes the gremlin action invisible
    showAction: (x, y) => {},
});
gremlins.createHorde({
    species: [customClicker],
});

Each particular gremlin or mogwai has its own customization methods, check the source for details.

Seeding The Randomizer

If you want the attack to be repeatable, you need to seed the random number generator :

// seed the randomizer
horde.createHorde({
    randomizer: new gremlins.Chance(1234);
});

Executing Code Before or After The Attack

Before starting the attack, you may want to execute custom code. This is especially useful to:

  • Start a profiler
  • Disable some features to better target the test
  • Bootstrap the application

Fortunately, unleashHorde is a Promise. So if you want to execute code before and after the unleash just do:

const horde = gremlins.createHorde();

console.profile('gremlins');
horde.unleash().then(() => {
    console.profileEnd();
});

Setting Up a Strategy

By default, gremlins will attack in random order, in a uniform distribution, separated by a delay of 10ms. This attack strategy is called the distribution strategy. You can customize it using the strategies custom object:

const distributionStrategy = gremlins.strategies.distribution({
    distribution: [0.3, 0.3, 0.3, 0.1], // the first three gremlins have more chances to be executed than the last
    delay: 50, // wait 50 ms between each action
});

Note that if using default gremlins, there are five type of gremlins. The previous example would give a 0 value to last gremlin specie.

You can also use another strategy. A strategy is just a function expecting one parameter: an array of gremlins. Two other strategies are bundled (allTogether and bySpecies), and it should be fairly easy to implement a custom strategy for more sophisticated attack scenarios.

Stopping The Attack

The horde can stop the attack in case of emergency using the horde.stop() method Gizmo uses this method to prevent further damages to the application after 10 errors, and you can use it, too, if you don't want the attack to continue.

Customizing The Logger

By default, gremlins.js logs all gremlin actions and mogwai observations in the console. If you prefer using an alternative logging method (for instance, storing gremlins activity in LocalStorage and sending it in Ajax once every 10 seconds), just provide a logger object with 4 methods (log, info, warn, and error) to the logger() method:

const customLogger = {
    log: function (msg) {
        /* .. */
    },
    info: function (msg) {
        /* .. */
    },
    warn: function (msg) {
        /* .. */
    },
    error: function (msg) {
        /* .. */
    },
};
horde.createHorde({ logger: customLogger });

Cypress

To run gremlins.js inside a cypress test, you need to provide the tested window:

import { createHorde } from 'gremlins.js';

describe('Run gremlins.js inside a cypress test', () => {
    let horde;
    beforeEach(() =>
        cy.window().then((testedWindow) => {
            horde = createHorde({ window: testedWindow });
        })
    );
    it('should run gremlins.js', () => {
        return cy.wrap(horde.unleash()).then(() => {
            /* ... */
        });
    });
});

Playwright

To run gremlin.js with Playwright, you can load it as an init script.

const { test } = require('@playwright/test');

test('run gremlins.js', async ({ page }) => {
    await page.addInitScript({
        path: './node_modules/gremlins.js/dist/gremlins.min.js',
    });
    await page.goto('https://playwright.dev');
    await page.evaluate(() => gremlins.createHorde().unleash());
});

Docs

Issues

Looking to contribute? Look for the Good First Issue label.

๐Ÿ› Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior.

See Bugs

๐Ÿ’ก Feature Requests

Please file an issue to suggest new features. Vote on feature requests by adding a ๐Ÿ‘. This helps maintainers prioritize what to work on.

See Feature Requests

License

gremlins.js is licensed under the MIT Licence, courtesy of marmelab.

gremlins.js's People

Contributors

agutisan avatar bartveneman avatar ckdarby avatar diegorbaquero avatar errorname avatar fzaninotto avatar hallerpierre avatar hong4rc avatar horacepgreeley avatar hppycoder avatar jfgreffier avatar jpetitcolas avatar jtangelder avatar kkirsche avatar luwangel avatar manuquentin avatar onikiienko avatar pborreli avatar sofiboselli avatar thijsvdanker avatar ufo2mstar avatar wdhif avatar zyhou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gremlins.js's Issues

Touch Gremlins

Would be a nice feature. support for touch events, and also pointer events? Also different gestures like swipe, tap, doubletap, hold, drag, rotate and pinch would be awesome.

I wrote a small tool for this a while ago, might be useful to take a look; https://github.com/jtangelder/faketouches.js

How randomizer works ?

Hi all !
I cannot figure out how use a custom randomizer.
I want my typer gremlins just use keyCode 39 when they type, so i write something like

let myHorde = gremlins.createHorde();

let myGremlins = gremlins.species.typer();
myGremlins.eventTypes(['keydown']);
myGremlins.randomizer({
  natural: function() {
    return 39;
  }
});

myHorde.gremlin(myGremlins);
myHorde.unleash();

But it doesn't work and I don't find any doc to help me.

Where I'm wrong ?
Thanks !

window.requestAnimationFrame is missing

It's an experimental technology so not all browsers support it.
Would be nice to have a graceful degradation in this case, especially when I redefine gremlins.species.clicker().showAction or make it an empty function.

Allow execution of closures in series

All _beforeCallbacks, _afterCallbacks, _monkeys, _runners arrays contain a collection of callbacks. these callbacks can be synchronous:

function() {
 // I'm synchronous
}

or asynchronous:

function(done) {
 // I'm asynchronous
}

We should built a generic executor, taking any array of callbacks as parameter, and running them all in series, calling its final callback upon completion:

function series(callbacks, done) {
}

Use mocha as inspiration.

TypeError: Argument 4 of KeyboardEvent.initKeyEvent does not implement interface WindowProxy

Firefox 28.0 on Ubuntu

Appears to be an issue with line 84 of the typer species picking out an element from the page that does not accept events.

I am not sure which element is the problem, since it occurred when using greasemonkey to unleash a horde at an internal website. But it was also a problem when using a bookmarklet to do the same - try using the bookmarklet (in the bookmarklet issue) on stackoverflow.com

Bookmarklet

javascript:(function()%7Bfunction callback()%7Bgremlins.createHorde().unleash()%7Dvar s%3Ddocument.createElement("script")%3Bs.src%3D"https%3A%2F%2Fraw.github.com%2Fmarmelab%2Fgremlins.js%2Fmaster%2Fgremlins.min.js"%3Bif(s.addEventListener)%7Bs.addEventListener("load"%2Ccallback%2Cfalse)%7Delse if(s.readyState)%7Bs.onreadystatechange%3Dcallback%7Ddocument.body.appendChild(s)%3B%7D)()

gremlins don't trigger click handlers?

I can see the gremlins clicking everywhere on my page but click handlers are not called. I have buttons and a that show messages or expend areas of the page and they don't kick-in.

My app is an AngularJS app. I tried giving some time for the app to bootstrap before I unleash but it does not change the result.

    <script src="tests/lib/gremlins.min.js"></script>
    <script>
        $(function () {
            setTimeout(function () {
                gremlins.createHorde().unleash();
            }, 3000)
        })
    </script>

Textareas in form filler

It would be great if text area filling could be added, unless I'm being dumb and have missed out some config.

Uncaught RangeError: Chance: Min cannot be greater than Max.

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.

Uncaught RangeError: Chance: Min cannot be greater than Max. gremlins.min.js?bust=1395340612814:22
f gremlins.min.js?bust=1395340612814:22
u.natural gremlins.min.js?bust=1395340612814:22
u.pick gremlins.min.js?bust=1395340612814:22
l gremlins.min.js?bust=1395340612814:22
u gremlins.min.js?bust=1395340612814:22
s gremlins.min.js?bust=1395340612814:22
t gremlins.min.js?bust=1395340612814:22
p gremlins.min.js?bust=1395340612814:22
(anonymous function)

Here is a screenshot of my chrome dev console with the error:

screen shot 2014-03-20 at 11 37 16 am

Any suggestions?

Can't inject Randomizer into single gremlin

Clicker gremlin has 'randomizer' config, and according to this comment it should be settable
https://github.com/marmelab/gremlins.js/blob/master/src/species/clicker.js#L21

*   clickerGremlin.randomizer(randomizerObject); // inject a randomizer

I want gremlin to do drag'n'drop on the page, so I was going to replace randomizer with something custom, so Clicker will successively call 'mousedown', 'mousemove' and 'mouseup' which is pretty close to what I need.

However, it seems that any custom randomizer (as well as logger) is replaced with the one from the horde object:
https://github.com/marmelab/gremlins.js/blob/master/src/main.js#L449

inject({'logger': this._logger, 'randomizer': this._randomizer}, allCallbacks);

Is this by the design and gremlin can receive randomizer only from horde object (and a comment in clicker.js is innacurate), or it is a bug in the "unleash" method?
Or maybe I'm doing something wrong and there is a way to inject a custom randomizer into gremlin?

The best solution I came so far is to delete setter after I inject my randomizer, although I feel something wrong with it:

gremlin.randomizer({
    ... my fake randomizer
});

delete gremlin.randomizer;

Problems with React.js

gremlins.js seems to have problems with React.js - we can't seem to get it to trigger any event listeners (onChange, onClick, etc.) - any ideas?

Rename the suite to "Gremlins"

target API:

gremlins.createHorde()
    .before(function(suite) {
        console.log('started!');
    })
    .breed(gremlins.types.clicker().clickTypes(['click']))
    .breed(gremlins.types.scroller())
    .breed(gremlins.types.typer())
    .breed(function(suite) {
        console.log('I\'m Gizmo, don\'t kill me!');
    })
    .after(function(suite) {
        console.log('finished!');
    })
    .unleash(100);

Run test in an iframe

To avoid losing script when clicking on an page where the script is not included or in an error page, we can retrieve the current page URL and open it in an full screen iframe.

Any opinion on this ?

Add non-ASCII characters to inputs

non-ascii (utf-8) symbols, in some cases, can be reason of errors in page rendering or/and in business logic. So each app should be ready to handle non-ascii characters.

Custom Logger functions only receive 'gremlin'/'mogwai'-string instead of full msg

Just created an custom logger-object to redirect gremlinJs logging to use native angular logging-module like this:

// Custom gremlinJS Logger for using Angular std. logging
var angularLogger = {
log: function( msg ) { $log.debug( msg ) }
, info: function( msg ) { $log.info( msg ) }
, warn: function( msg ) { $log.warn( msg ) }
, error: function( msg ) { $log.error( msg ) }
} resulting in only 'gremlin'/'mogwai'-logs being written to console.

Verified that passed msg-parameter only contains this information, but couldn't build unminified version for further debugging. What are you using for generating your minified files?

Thank you, great project! All the best!

keyup / keydown should be triggered

Gremlins can type into input fields, but keyup / keydown is never triggered. This causes, f. e. angular apps, to not update the view (update is bound to keyup / keydown). I guess after every typing the event could be manually triggered.

Best
Marc

Make it a jQuery plugin

To allow configuration (like allowed URL pattern, or secure page credentials) the simpler way IMO is to make this library a jQuery plugin.

We have already a dependency to jQuery for click emulation

Any cons about that ?

This gremlin requires a randomizer to run. Please call randomizer(randomizerObject) before executing the gremlin

From README.md

"For instance, the clicker gremlin is a function that you can execute it directly:"

var clickerGremlin = gremlins.species.clicker();
clickerGremlin(); // trigger a random mouse even in the screen

The code above raises this error:

This gremlin requires a randomizer to run. 
Please call randomizer(randomizerObject) before executing the gremlin

ENV:
Windows Server 2012 R2
Chrome Version 46.0.2490.86 m
gremlins.min.js from master branch

Clicker does not set event position

Clicker does not set event position

When clicker invokes a mouse event, clientX/clientY properties are always empty:

evt.initMouseEvent(clickType, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);

This can affect the behavior of the tested app (I think not in intended way). Since the event position is known, probably it should be used when event is fired:

evt.initMouseEvent(clickType, true, true, window, 0, 0, 0, posX, posY, false, false, false, false, 0, null);

https://github.com/marmelab/gremlins.js/blob/master/src/species/clicker.js#L121

Create an event stack

Logging:

  • all calls to monkeys
  • all events triggered by the handlers

Store this in the suite, and create an eccessor

Is it possible to playback an attack in slow-motion?

Seeing some strange behavior that I can't reproduce manually. I'm wanting to get a step by step replay of what the horde is doing so that I can replay it up to the point where the problem occurs.

The issue is in a third party piece of code (ng-grid) and it's making columns disappear from the grid (when that should be disabled).

Create a method to intercept errors

using window.onerror

Add to the testsuite using something like testSuite.handler():

var JSErrorHandler = function() {
 return function() {
    //
  }
};

MonkeyTest.createSuite()
  .handler(JSErrorHandler())
  .run(100); // executes all handlers before start

If no handler registered, the JSErrorHandler should be used (just llike defaultRunner).

Uncaught Error (Gremlin suicide)

Ran the library by adding the following:

<script src="/s/gremlins.min.js"></script>
<script>
    gremlins.createHorde().unleash();
</script>

However after the first click (or 10), it throws the following error and stops working:

Uncaught RangeError: Chance: Min cannot be greater than Max. (Line 22)

Let me know if you need anything else

Ben

Issue lauching the script

Hello,
I'm trying to unleash the hord on my website but I get a issue when I launch the script. It tells me ' i is null' (or sometimes 'r is null').
I follow the basic exemple in the README and search in your Git repository but I have not find an answer.
Do you have an idea where the issue could come from ?

Change name of project

Please could you change the name of the project in the bower and package?

"name": "gremlins.js", ==> "name": "gremlinsjs",

Thanks

gremlins not effecting everything

Hi guys, great work, and a very useful concept - thanks!

What I have found though is that the gremlins are only active at low z-indecies, so they do not effect modal popups, or any floating elements sitting on a layer above the main page.

If you load the agent login of our app:
https://dev.ef2f.com/service/1/common/agent.html

And run the following in the console:
releaseTheGremlins(22334);

You should see clearly what I mean - only the page beneath the login popup is effected.

Note you need a webcam plugged in to get to the login screen.

With this issue fixed we can trigger gremlins at any stage in our app, and use it to test all screen states, not only the base layer.

Thanks again for an awesome tool!

Jamie

Untimely Gremlin death?

Greetings,

I am playing around with the fantastic tool, and it appears to stop running after roughly 5 seconds, even though I haven't explicitly halted the siege and there are < 10 errors in the console. Only once in about 10 runs have I see the mogwai gizmo stopped test execution after 10 errors message, so it seems like it's dying before it can complete?

Let me know if you need additional information!

require.js bookmarklet

The current bookmarklet doesn't work with require.js pages.
Can we get a second bookmarklet that will work with require.js?

Alternative to Bookmarklet in mobile browsers

Hi,

Is there a way to use this javascript function other than bookmarklet inorder to make it work on mobile browsers on Android

javascript:(function(){function callback(){gremlins.createHorde().allGremlins().gremlin(function() {window.$ = function() {};}).unleash()} var s=document.createElement("script");s.src="https://rawgithub.com/marmelab/gremlins.js/master/gremlins.min.js";if(s.addEventListener){s.addEventListener("load",callback,false)}else if(s.readyState){s.onreadystatechange=callback}document.body.appendChild(s);})()

Please suggest

Regards,
Madhav Pai

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.