3 document.getElementById("log").innerHTML = "PASS";
4 if (window.testRunner) {
5 testRunner.notifyDone();
10 if (window.testRunner) {
11 testRunner.dumpAsText();
12 testRunner.waitUntilDone();
15 var doctype = document.implementation.createDocumentType(
17 '-//W3C//DTD XHTML 1.0 Strict//EN',
18 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
21 var evt = document.createEvent("HTMLEvents");
22 evt.initEvent("click", false, false);
24 doctype.addEventListener('click', onClick, false);
26 // Doctype node can only be inserted before <html>.
27 document.insertBefore(doctype, document.getElementsByTagName("html")[0]);
28 doctype.dispatchEvent(evt);
31 <body onload="test()">
32 <p>The test verifies that addEventListener works on EventTargets that do not have ScriptExecutionContext at the moment of call. The event listener should be added, and later invoked when the Context is established. This matches behavior of FF 3.5</p>
33 <p>The only way to simulate this is to use createDocumentType() which creates a Node with NULL Document. Then we insert it into the tree so it gains a pointer to Document and dispatch the event which should fire.</p>
34 <p>We use manually-constructed event instead just watching for DOM mutation event on insert since DOM mutation events are not dispatched on doctype element.</p>
35 <p>Test passes if there is 'PASS' text below.</p>
36 <div id="log">FAIL</div>