2010-09-01 19:38:54 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test click event on input</title>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p id="display">
|
|
|
|
<input id="input"
|
|
|
|
style="position: absolute; top: 5px; left: 5px; border: solid 15px blue; width: 100px; height: 20px;"
|
|
|
|
onclick="gClickCount++;">
|
|
|
|
</p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
var gClickCount = 0;
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
SimpleTest.waitForFocus(runTests);
|
|
|
|
|
2010-09-08 06:25:21 -07:00
|
|
|
var input = document.getElementById("input");
|
|
|
|
|
2010-09-01 19:38:54 -07:00
|
|
|
function runTests()
|
|
|
|
{
|
2010-09-08 06:25:21 -07:00
|
|
|
for (var i = 0; i < 3; i++) {
|
|
|
|
doTest(i);
|
|
|
|
}
|
2011-05-07 02:42:45 -07:00
|
|
|
|
|
|
|
// Re-test left clicking when the input element has some text.
|
|
|
|
gClickCount = 0;
|
|
|
|
input.value = "Long text Long text Long text Long text Long text Long text";
|
|
|
|
doTest(0);
|
|
|
|
|
2010-09-08 06:25:21 -07:00
|
|
|
input.style.display = "none";
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
2010-09-01 19:38:54 -07:00
|
|
|
|
2010-09-08 06:25:21 -07:00
|
|
|
function isEnabledMiddleClickPaste()
|
|
|
|
{
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
2010-09-01 19:38:54 -07:00
|
|
|
|
2010-09-08 06:25:21 -07:00
|
|
|
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
|
|
|
|
getService(Components.interfaces.nsIPrefBranch2);
|
|
|
|
try {
|
|
|
|
return prefs.getBoolPref("middlemouse.paste");
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2010-09-01 19:38:54 -07:00
|
|
|
|
2010-09-08 06:25:21 -07:00
|
|
|
function doTest(aButton)
|
|
|
|
{
|
|
|
|
// NOTE #1: Right click causes a context menu to popup, then, the click event
|
|
|
|
// isn't generated.
|
|
|
|
// NOTE #2: If middle click causes text to be pasted, then, the click event
|
|
|
|
// isn't generated.
|
|
|
|
if (aButton != 2 && (aButton != 1 || !isEnabledMiddleClickPaste())) {
|
|
|
|
gClickCount = 0;
|
|
|
|
// click on border of input
|
|
|
|
synthesizeMouse(input, 5, 5, { button: aButton });
|
|
|
|
is(gClickCount, 1,
|
|
|
|
"click event doesn't fired on input element (button is " +
|
|
|
|
aButton + ")");
|
2010-09-01 19:38:54 -07:00
|
|
|
|
2010-09-08 06:25:21 -07:00
|
|
|
gClickCount = 0;
|
|
|
|
// down on border
|
|
|
|
synthesizeMouse(input, 5, 5, { type: "mousedown", button: aButton });
|
|
|
|
// up on anonymous div of input
|
|
|
|
synthesizeMouse(input, 20, 20, { type: "mouseup", button: aButton });
|
|
|
|
is(gClickCount, 1,
|
|
|
|
"click event doesn't fired on input element (button is " +
|
|
|
|
aButton + ")");
|
|
|
|
|
|
|
|
gClickCount = 0;
|
|
|
|
// down on anonymous div of input
|
|
|
|
synthesizeMouse(input, 20, 20, { type: "mousedown", button: aButton });
|
|
|
|
// up on border
|
|
|
|
synthesizeMouse(input, 5, 5, { type: "mouseup", button: aButton });
|
|
|
|
is(gClickCount, 1,
|
|
|
|
"click event doesn't fired on input element (button is " +
|
|
|
|
aButton + ")");
|
|
|
|
}
|
|
|
|
|
|
|
|
gClickCount = 0;
|
|
|
|
// down on outside of input
|
|
|
|
synthesizeMouse(input, -3, -3, { type: "mousedown", button: aButton });
|
|
|
|
// up on border
|
|
|
|
synthesizeMouse(input, 5, 5, { type: "mouseup", button: aButton });
|
|
|
|
is(gClickCount, 0,
|
|
|
|
"click event is fired on input element unexpectedly (button is " +
|
|
|
|
aButton + ")");
|
2010-09-01 19:38:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|