2010-09-14 18:35:37 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=592802
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 592802</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=592802">Mozilla Bug 592802</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content">
|
|
|
|
<input id='a' type='file'>
|
|
|
|
<input id='a2' type='file'>
|
|
|
|
</div>
|
|
|
|
<button id='b' onclick="document.getElementById('a').click();">Show Filepicker</button>
|
|
|
|
<button id='b2' onclick="document.getElementById('a2').click();">Show Filepicker</button>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 592802 **/
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2011-10-21 23:39:30 +00:00
|
|
|
var MockFilePicker = SpecialPowers.MockFilePicker;
|
2012-10-16 21:39:32 +00:00
|
|
|
MockFilePicker.init(window);
|
2010-09-14 18:35:37 +00:00
|
|
|
|
|
|
|
var testData = [
|
|
|
|
/* visibility | display | multiple */
|
|
|
|
[ "", "", false ],
|
|
|
|
[ "hidden", "", false ],
|
|
|
|
[ "", "none", false ],
|
|
|
|
[ "", "", true ],
|
|
|
|
[ "hidden", "", true ],
|
|
|
|
[ "", "none", true ],
|
|
|
|
];
|
|
|
|
|
|
|
|
var testCounter = 0;
|
|
|
|
var testNb = testData.length;
|
|
|
|
|
|
|
|
function finished()
|
|
|
|
{
|
2011-12-22 22:10:52 +00:00
|
|
|
MockFilePicker.cleanup();
|
2010-09-14 18:35:37 +00:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForFocus(function() {
|
|
|
|
// mockFilePicker will simulate a cancel for the first time the file picker will be shown.
|
2011-10-21 23:39:30 +00:00
|
|
|
MockFilePicker.returnValue = MockFilePicker.returnCancel;
|
|
|
|
|
2010-09-14 18:35:37 +00:00
|
|
|
var b2 = document.getElementById('b2');
|
|
|
|
b2.focus(); // Be sure the element is visible.
|
|
|
|
document.getElementById('b2').addEventListener("change", function(aEvent) {
|
|
|
|
aEvent.target.removeEventListener("change", arguments.callee, false);
|
|
|
|
ok(false, "When cancel is received, change should not fire");
|
|
|
|
}, false);
|
2011-10-21 23:39:30 +00:00
|
|
|
b2.click();
|
2010-09-14 18:35:37 +00:00
|
|
|
|
|
|
|
// Now, we can launch tests when file picker isn't canceled.
|
2014-09-09 01:48:50 +00:00
|
|
|
MockFilePicker.useBlobFile();
|
2011-10-21 23:39:30 +00:00
|
|
|
MockFilePicker.returnValue = MockFilePicker.returnOK;
|
|
|
|
|
2010-09-14 18:35:37 +00:00
|
|
|
var b = document.getElementById('b');
|
|
|
|
b.focus(); // Be sure the element is visible.
|
|
|
|
|
|
|
|
document.getElementById('a').addEventListener("change", function(aEvent) {
|
|
|
|
ok(true, "change event correctly sent");
|
2010-12-03 14:20:07 +00:00
|
|
|
ok(aEvent.bubbles, "change event should bubble");
|
2010-12-17 17:45:46 +00:00
|
|
|
ok(!aEvent.cancelable, "change event should not be cancelable");
|
2010-09-14 18:35:37 +00:00
|
|
|
testCounter++;
|
|
|
|
|
|
|
|
if (testCounter >= testNb) {
|
|
|
|
aEvent.target.removeEventListener("change", arguments.callee, false);
|
|
|
|
SimpleTest.executeSoon(finished);
|
|
|
|
} else {
|
|
|
|
var data = testData[testCounter];
|
|
|
|
var a = document.getElementById('a');
|
|
|
|
a.style.visibility = data[0];
|
|
|
|
a.style.display = data[1];
|
|
|
|
a.multiple = data[2];
|
|
|
|
|
|
|
|
SimpleTest.executeSoon(function() {
|
2011-10-21 23:39:30 +00:00
|
|
|
b.click();
|
2010-09-14 18:35:37 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}, false);
|
|
|
|
|
2011-10-21 23:39:30 +00:00
|
|
|
b.click();
|
2010-09-14 18:35:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|