mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
79701a2085
--HG-- extra : rebase_source : 93d446c1c94512be8cc0dc208c0bf8f1cd3cc936
145 lines
5.2 KiB
HTML
145 lines
5.2 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=448602
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 448602</title>
|
|
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=448602">Mozilla Bug 448602</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
<script type="application/javascript">
|
|
|
|
/** Test for Bug 448602 **/
|
|
|
|
|
|
function runTests() {
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
var jsdIDebuggerService = Components.interfaces.jsdIDebuggerService;
|
|
var jsd = Components.classes['@mozilla.org/js/jsd/debugger-service;1']
|
|
.getService(jsdIDebuggerService);
|
|
var els = Components.classes["@mozilla.org/eventlistenerservice;1"]
|
|
.getService(Components.interfaces.nsIEventListenerService);
|
|
|
|
// Event listener info tests
|
|
var root = document.getElementById("testroot");
|
|
var infos = els.getListenerInfoFor(root, {});
|
|
is(infos.length, 0, "Element shouldn't have listeners (1)");
|
|
|
|
var listenerSource = 'alert(event);';
|
|
root.setAttribute("onclick", listenerSource);
|
|
infos = els.getListenerInfoFor(root, {});
|
|
is(infos.length, 1, "Element should have listeners (1)");
|
|
is(infos[0].toSource(), 'function onclick(event) {' + listenerSource + '}',
|
|
"Unexpected serialization (1)");
|
|
is(infos[0].type, "click", "Wrong type (1)");
|
|
is(infos[0].capturing, false, "Wrong phase (1)");
|
|
is(infos[0].allowsUntrusted, true, "Should allow untrusted events (1)");
|
|
|
|
var jsdOn = jsd.isOn;
|
|
if (!jsdOn) {
|
|
is(infos[0].getDebugObject(), null,
|
|
"If JSD isn't running, getDebugObject() should return null.")
|
|
jsd.on();
|
|
ok(jsd.isOn, "JSD should be running.");
|
|
}
|
|
var jsdvalue = infos[0].getDebugObject().QueryInterface(Components.interfaces.jsdIValue);
|
|
is(jsdvalue.jsType, 3, "Event listener should be a function! (1)");
|
|
|
|
root.removeAttribute("onclick");
|
|
infos = els.getListenerInfoFor(root, {});
|
|
is(infos.length, 0, "Element shouldn't have listeners (2)");
|
|
|
|
var l = function (e) { alert(e); };
|
|
root.addEventListener("foo", l, true, true);
|
|
root.addEventListener("foo", l, false, false);
|
|
infos = els.getListenerInfoFor(root, {});
|
|
is(infos.length, 2, "Element should have listeners (2)");
|
|
is(infos[0].toSource(), "(function (e) {alert(e);})",
|
|
"Unexpected serialization (2)");
|
|
is(infos[0].type, "foo", "Wrong type (2)");
|
|
is(infos[0].capturing, true, "Wrong phase (2)");
|
|
is(infos[0].allowsUntrusted, true, "Should allow untrusted events (2)");
|
|
jsdvalue = infos[0].getDebugObject().QueryInterface(Components.interfaces.jsdIValue);
|
|
is(jsdvalue.jsType, 3, "Event listener should be a function!(2)");
|
|
is(jsdvalue.getWrappedValue(), l, "Wrong JS value! (1)");
|
|
|
|
is(infos[1].toSource(), "(function (e) {alert(e);})",
|
|
"Unexpected serialization (3)");
|
|
is(infos[1].type, "foo", "Wrong type (3)");
|
|
is(infos[1].capturing, false, "Wrong phase (3)");
|
|
is(infos[1].allowsUntrusted, false, "Shouldn't allow untrusted events (1)");
|
|
|
|
jsdvalue2 = infos[1].getDebugObject().QueryInterface(Components.interfaces.jsdIValue);
|
|
is(jsdvalue2.jsType, 3, "Event listener should be a function! (3)");
|
|
is(jsdvalue2.getWrappedValue(), l, "Wrong JS value! (2)");
|
|
root.removeEventListener("foo", l, true);
|
|
root.removeEventListener("foo", l, false);
|
|
infos = els.getListenerInfoFor(root, {});
|
|
is(infos.length, 0, "Element shouldn't have listeners (3)");
|
|
|
|
root.onclick = l;
|
|
infos = els.getListenerInfoFor(root, {});
|
|
is(infos.length, 1, "Element should have listeners (3)");
|
|
is(infos[0].toSource(), '(function (e) {alert(e);})',
|
|
"Unexpected serialization (4)");
|
|
is(infos[0].type, "click", "Wrong type (4)");
|
|
is(infos[0].capturing, false, "Wrong phase (4)");
|
|
is(infos[0].allowsUntrusted, true, "Should allow untrusted events (3)");
|
|
|
|
// Event target chain tests
|
|
var l2 = document.getElementById("testlevel2");
|
|
var l3 = document.getElementById("testlevel3");
|
|
var textnode = l3.firstChild;
|
|
var chain = els.getEventTargetChainFor(textnode, {});
|
|
ok(chain.length > 3, "Too short event target chain.");
|
|
is(chain[0], textnode, "Wrong chain item (1)");
|
|
is(chain[1], l3, "Wrong chain item (2)");
|
|
is(chain[2], l2, "Wrong chain item (3)");
|
|
is(chain[3], root, "Wrong chain item (4)");
|
|
|
|
var hasDocumentInChain = false;
|
|
var hasWindowInChain = false;
|
|
for (var i = 0; i < chain.length; ++i) {
|
|
if (chain[i] == document) {
|
|
hasDocumentInChain = true;
|
|
} else if (chain[i] == window) {
|
|
hasWindowInChain = true;
|
|
}
|
|
}
|
|
|
|
ok(hasDocumentInChain, "Should have document in event target chain!");
|
|
ok(hasWindowInChain, "Should have window in event target chain!");
|
|
|
|
if (!jsdOn) {
|
|
jsd.off();
|
|
ok(!jsd.isOn, "JSD shouldn't be running anymore.");
|
|
}
|
|
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
addLoadEvent(runTests);
|
|
</script>
|
|
</pre>
|
|
<div id="testroot">
|
|
<div id="testlevel2">
|
|
<div id="testlevel3">
|
|
Test
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|