         change = doc.createEvent('HTMLEvents')
         change.initEvent('change', false, true)
         textarea.dispatchEvent(change)
-###

                test.equal(count, 3);
                testClient.disconnect();
                test.done();
            });
        ")
        # Once the client registers the event listener for a particular
        # event, we fire it on the client, which should cause it to be
        # sent to the server.

                change.initEvent('change', false, true)
                textarea.dispatchEvent(change)

        client.on 'AddEventListener', (args) ->
            [targetID, type] = args
            eventFirers[type]()

# This test is similar to the one above, except that we make sure the
# listeners are registered before the client is sent its snapshot. We do
# this by putting the script inline at the bottom of the body.  When the
# client fires 'loadFromSnapshot', the listeners should be installed.
exports['event inference via snapshot'] = (test) ->
    b = browsers.create({
            entryPoint : 'http://localhost:3001/test/files/event_inference_snapshot.html'
            remoteBrowsing : true
        }, 'browser5')
    client = b.createTestClient()
    browser = b.browser
    client.once 'PageLoaded', () ->
        browser.window.testClient = client
        # NOTE: The code in the script running on the server DOM will end
        # the test once all 3 events have been received.
        browser.window.test = test
