Source code
Revision control
Copy as Markdown
Other Tools
<?xml version="1.0"?>
type="text/css"?>
<!--
-->
onload="start();">
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
function ok(val, msg) {
window.arguments[0].ok(val, msg);
}
var elems =
[
"input",
"textarea",
"select",
"button",
];
var chromeDidGetEvent = false;
function chromeListener() {
chromeDidGetEvent = true;
}
function testElement(el, disabled, contentShouldGetEvent) {
chromeDidGetEvent = false;
var b = document.getElementById("browser");
b.contentDocument.body.innerHTML = null;
var e = b.contentDocument.createElement(el);
if (disabled) {
e.setAttribute("disabled", "true");
}
b.contentDocument.body.appendChild(e);
var contentDidGetEvent = false;
b.contentDocument.body.addEventListener("foo",
function() { contentDidGetEvent = true }, true);
b.addEventListener("foo", chromeListener, true);
e.dispatchEvent(new Event("foo"));
b.removeEventListener("foo", chromeListener, true);
ok(contentDidGetEvent == contentShouldGetEvent, "content: " + el + (disabled ? " disabled" : ""));
ok(chromeDidGetEvent, "chrome: " + el + (disabled ? " disabled" : ""));
}
function start() {
// Test common element.
testElement("div", false, true);
testElement("div", true, true);
for (var i = 0; i < elems.length; ++i) {
testElement(elems[i], false, true);
testElement(elems[i], true, false);
}
ok(true, "done");
window.arguments[0].setTimeout(function() { this.done(); }, 0);
window.close();
}
]]></script>
<browser id="browser" type="content" src="about:blank"/>
</window>