<script>
function handleEvent(message) {
    document.getElementById("log").innerHTML = "PASS: " + message + " handled.<br>";
}

function test() {
    if (window.testRunner) {
        testRunner.dumpAsText();
    }

    var doctype = document.implementation.createDocumentType(
        'html',
        '-//W3C//DTD XHTML 1.0 Strict//EN',
        'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
    );

    var evt = document.createEvent("Event");
    evt.initEvent("generic", true, true);
    doctype.addEventListener("generic", function () { handleEvent("generic")}, false);
    doctype.dispatchEvent(evt);
}
</script>
<body onload="test()">
<p>The test verifies that EventTarget with an event listener not inserted into a Document does not crash during an attempt to dispatch an event.</p>
<p>Test passes if there is no crash, and event is dispatched.</p>
<div id="log">FAIL</div>
