gecko/layout/forms/test/test_bug377624.html

106 lines
3.3 KiB
HTML
Raw Normal View History

<!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>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=377624">Mozilla Bug 377624</a>
<p id="display"></p>
<div id="content">
<input id='a' type='file' accept="image/*">
<input id='b' type='file' accept="audio/*">
<input id='c' type='file' accept="video/*">
<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/*">
<input id='j' type='file' accept="audio/*, audio/*, audio/*">
<input id='z' type='file' accept="i/am,a,pathological,;,,,,test/case">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 377624 **/
SimpleTest.waitForExplicitFinish();
var MockFilePicker = SpecialPowers.MockFilePicker;
MockFilePicker.init();
var testData = [["a", MockFilePicker.filterImages, 1],
["b", MockFilePicker.filterAudio, 1],
["c", MockFilePicker.filterVideo, 1],
["d", 0, 0],
["e", 0, 0],
["f", 0, 0],
["g", 0, 0],
["h", MockFilePicker.filterImages, 1],
["i", MockFilePicker.filterVideo, 1],
["j", MockFilePicker.filterAudio, 1],
["z", 0, 0]];
var currentTest = 0;
var appendFilterCalled;
var filters;
var filterIndex;
// 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);
function launchNextTest() {
MockFilePicker.shown = false;
appendFilterCalled = false;
filters = [];
filterIndex = 0;
document.getElementById(testData[currentTest][0]).click();
}
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) {
MockFilePicker.cleanup();
SimpleTest.finish();
} else {
launchNextTest();
}
});
};
launchNextTest();
}
</script>
</pre>
</body>
</html>