2010-05-19 19:28:08 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=377624
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 377624</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>
|
2011-10-21 16:39:30 -07:00
|
|
|
<body>
|
2010-05-19 19:28:08 -07:00
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=377624">Mozilla Bug 377624</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content">
|
2010-07-17 00:00:28 -07:00
|
|
|
<input id='a' type='file' accept="image/*">
|
|
|
|
<input id='b' type='file' accept="audio/*">
|
|
|
|
<input id='c' type='file' accept="video/*">
|
2010-07-21 09:07:55 -07:00
|
|
|
<input id='d' type='file' accept="image/*, audio/* ">
|
|
|
|
<input id='e' type='file' accept=" image/*,video/*">
|
|
|
|
<input id='f' type='file' accept="audio/*,video/*">
|
|
|
|
<input id='g' type='file' accept="image/*, audio/* ,video/*">
|
|
|
|
<input id='h' type='file' accept="foo/baz,image/*,bogus/duh">
|
|
|
|
<input id='i' type='file' accept="mime/type;parameter,video/*">
|
2010-10-08 03:13:08 -07:00
|
|
|
<input id='j' type='file' accept="audio/*, audio/*, audio/*">
|
2010-07-21 09:07:55 -07:00
|
|
|
<input id='z' type='file' accept="i/am,a,pathological,;,,,,test/case">
|
2010-05-19 19:28:08 -07:00
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 377624 **/
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2011-10-21 16:39:30 -07:00
|
|
|
var MockFilePicker = SpecialPowers.MockFilePicker;
|
2011-12-22 14:10:52 -08:00
|
|
|
MockFilePicker.init();
|
2011-07-11 17:49:03 -07:00
|
|
|
|
2011-10-21 16:39:30 -07:00
|
|
|
var testData = [["a", MockFilePicker.filterImages, 1],
|
|
|
|
["b", MockFilePicker.filterAudio, 1],
|
|
|
|
["c", MockFilePicker.filterVideo, 1],
|
2010-10-08 03:13:08 -07:00
|
|
|
["d", 0, 0],
|
|
|
|
["e", 0, 0],
|
|
|
|
["f", 0, 0],
|
|
|
|
["g", 0, 0],
|
2011-10-21 16:39:30 -07:00
|
|
|
["h", MockFilePicker.filterImages, 1],
|
|
|
|
["i", MockFilePicker.filterVideo, 1],
|
|
|
|
["j", MockFilePicker.filterAudio, 1],
|
2010-07-21 09:07:55 -07:00
|
|
|
["z", 0, 0]];
|
|
|
|
|
2010-07-17 00:00:28 -07:00
|
|
|
var currentTest = 0;
|
2011-10-21 16:39:30 -07:00
|
|
|
var appendFilterCalled;
|
|
|
|
var filters;
|
|
|
|
var filterIndex;
|
2010-07-17 00:00:28 -07:00
|
|
|
|
2011-10-21 16:39:30 -07:00
|
|
|
// disable popups to make sure that the popup blocker does not interfere
|
|
|
|
// with manually opened file pickers.
|
|
|
|
SpecialPowers.pushPrefEnv({'set': [["dom.disable_open_during_load", false]]}, runTests);
|
2011-07-11 17:49:03 -07:00
|
|
|
|
2011-10-21 16:39:30 -07:00
|
|
|
function launchNextTest() {
|
|
|
|
MockFilePicker.shown = false;
|
|
|
|
appendFilterCalled = false;
|
|
|
|
filters = [];
|
|
|
|
filterIndex = 0;
|
2011-07-11 17:49:03 -07:00
|
|
|
|
2011-10-21 16:39:30 -07:00
|
|
|
document.getElementById(testData[currentTest][0]).click();
|
|
|
|
}
|
2011-07-11 17:49:03 -07:00
|
|
|
|
2011-10-21 16:39:30 -07:00
|
|
|
function runTests() {
|
|
|
|
MockFilePicker.appendFilterCallback = function(filepicker, title, val) {
|
|
|
|
this.appendFilterCalled = true;
|
|
|
|
};
|
|
|
|
MockFilePicker.appendFiltersCallback = function(filepicker, val) {
|
|
|
|
filters.push(val);
|
|
|
|
};
|
|
|
|
MockFilePicker.showCallback = function(filepicker) {
|
|
|
|
filterIndex = filepicker.filterIndex;
|
|
|
|
SimpleTest.executeSoon(function () {
|
|
|
|
ok(MockFilePicker.shown,
|
|
|
|
"File picker show method should have been called");
|
|
|
|
ok(!appendFilterCalled,
|
|
|
|
"appendFilter should not have been called");
|
|
|
|
is(filters.length, 1,
|
|
|
|
"appendFilters should have been called once");
|
|
|
|
is(filters[0], MockFilePicker.filterAll +
|
|
|
|
testData[currentTest][1],
|
|
|
|
"Correct filters should have been added");
|
|
|
|
is(filterIndex, testData[currentTest][2],
|
|
|
|
"File picker should show the correct filter index");
|
|
|
|
|
|
|
|
if (++currentTest == testData.length) {
|
2011-12-22 14:10:52 -08:00
|
|
|
MockFilePicker.cleanup();
|
2011-10-21 16:39:30 -07:00
|
|
|
SimpleTest.finish();
|
|
|
|
} else {
|
|
|
|
launchNextTest();
|
2010-05-19 19:28:08 -07:00
|
|
|
}
|
2011-10-21 16:39:30 -07:00
|
|
|
});
|
2010-05-19 19:28:08 -07:00
|
|
|
};
|
|
|
|
|
2011-10-21 16:39:30 -07:00
|
|
|
launchNextTest();
|
2010-05-19 19:28:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|