mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
5af5a73d3d
find /files/mozilla/build/d/_tests/testing/mochitest/tests/ | egrep "\.(xhtml|html|xml|js)$" | grep -v SimpleTest | grep -vi mochikit | grep -v simpleThread | grep -v test_ipc_messagemanager_blob.html | grep -v "indexedDB/test" | xargs grep -l Components | xargs grep -L enablePrivilege | perl -pe 's#.*mochitest/tests/##' | xargs perl -p -i.bakkk -e 's/Components\.interfaces(\s|;|\.|\[)/SpecialPowers\.Ci$1/g, s/SpecialPowers\.wrap\(Components\)\.(.)(lasses|tils|nterfaces|esults)/SpecialPowers.C$1/g, s/(?<![\.a-zA-Z])Components/SpecialPowers\.Components/g, s/window\.Components/window\.SpecialPowers\.Components/g'
159 lines
5.3 KiB
HTML
159 lines
5.3 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="/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() {
|
|
/*
|
|
Disabled due to lack of present support for JSD in JM
|
|
var jsdIDebuggerService = SpecialPowers.Ci.jsdIDebuggerService;
|
|
var jsd = SpecialPowers.Components.classes['@mozilla.org/js/jsd/debugger-service;1']
|
|
.getService(jsdIDebuggerService);
|
|
*/
|
|
var els = SpecialPowers.Cc["@mozilla.org/eventlistenerservice;1"]
|
|
.getService(SpecialPowers.Ci.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) {\n' + listenerSource + '\n}',
|
|
"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(SpecialPowers.Ci.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(SpecialPowers.Ci.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(SpecialPowers.Ci.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 = SpecialPowers.unwrap(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.");
|
|
}
|
|
*/
|
|
|
|
try {
|
|
els.getListenerInfoFor(null, {});
|
|
ok(false, "Should have thrown an exception.");
|
|
} catch (ex) {
|
|
ok(true, "We should be still running.");
|
|
}
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
addLoadEvent(runTests);
|
|
</script>
|
|
</pre>
|
|
<div id="testroot">
|
|
<div id="testlevel2">
|
|
<div id="testlevel3">
|
|
Test
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|