gecko/layout/forms/test/test_bug36619.html

78 lines
2.5 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=36619
-->
<head>
<title>Test for Bug 36619</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.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=36619">Mozilla Bug 36619</a>
<p id="display"></p>
<div id="content" style="display:none;">
<input id='a' type='file'>
</div>
<button id='b' onclick="document.getElementById('a').click();">Show Filepicker</button>
<button id='c' onmousedown="document.getElementById('a').click();">Show Filepicker</button>
<button id='d' onmouseup="document.getElementById('a').click();">Show Filepicker</button>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 36619 **/
SimpleTest.waitForExplicitFinish();
var MockFilePicker = SpecialPowers.MockFilePicker;
MockFilePicker.init();
// enable popups the first time
SpecialPowers.pushPrefEnv({'set': [
["dom.disable_open_during_load", true],
["privacy.popups.showBrowserMessage", false]
]}, function() {
SimpleTest.waitForFocus(function() {
// Tests that a click on 'b' calls the show method.
var b = document.getElementById('b');
b.focus(); // Be sure the element is visible.
synthesizeMouseAtCenter(b, {});
SimpleTest.executeSoon(function() {
ok(MockFilePicker.showing,
"File picker showAsync method should have been called");
MockFilePicker.reset();
// Tests that a click on 'a' doesn't call the show method, because it is hidden.
document.getElementById("a").click();
SimpleTest.executeSoon(function() {
ok(!MockFilePicker.showing,
"File picker showAsync method should not have been called");
MockFilePicker.reset();
synthesizeMouseAtCenter(document.getElementById('c'), {});
SimpleTest.executeSoon(function() {
ok(!MockFilePicker.showing,
"File picker showAsync method should have been called");
MockFilePicker.reset();
synthesizeMouseAtCenter(document.getElementById('d'), {});
SimpleTest.executeSoon(function() {
ok(MockFilePicker.showing,
"File picker showAsync method should have been called");
MockFilePicker.cleanup();
SimpleTest.finish();
});
});
});
});
});
});
</script>
</pre>
</body>
</html>