diff options
Diffstat (limited to 'dom/filesystem/compat/tests/test_no_dnd.html')
-rw-r--r-- | dom/filesystem/compat/tests/test_no_dnd.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/dom/filesystem/compat/tests/test_no_dnd.html b/dom/filesystem/compat/tests/test_no_dnd.html new file mode 100644 index 0000000000..c49dd5d40f --- /dev/null +++ b/dom/filesystem/compat/tests/test_no_dnd.html @@ -0,0 +1,84 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test for Blink FileSystem API - no DND == no webkitEntries</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> + +<body> +<script type="application/javascript"> +var fileEntry; +var directoryEntry; +var script; +var entries; + +function setup_tests() { + SpecialPowers.pushPrefEnv({"set": [["dom.webkitBlink.dirPicker.enabled", true], + ["dom.filesystem.pathcheck.disabled", true], + ["dom.webkitBlink.filesystem.enabled", true]]}, next); +} + +function populate_entries() { + entries = document.createElement("input"); + entries.setAttribute("type", "file"); + document.body.appendChild(entries); + + var url = SimpleTest.getTestFileURL("script_entries.js"); + script = SpecialPowers.loadChromeScript(url); + + function onOpened(message) { + for (var i = 0 ; i < message.data.length; ++i) { + if (message.data[i] instanceof File) { + SpecialPowers.wrap(entries).mozSetFileArray([message.data[i]]); + next(); + } + } + } + + script.addMessageListener("entries.opened", onOpened); + script.sendAsyncMessage("entries.open"); +} + +function test_entries() { + ok("webkitEntries" in entries, "HTMLInputElement.webkitEntries"); + is(entries.webkitEntries.length, 0, "HTMLInputElement.webkitEntries.length == 0"); + is(entries.files.length, 1, "HTMLInputElement.files is still populated"); + + next(); +} + +function cleanUpTestingFiles() { + script.addMessageListener("entries.deleted", function onDeleted() { + script.removeMessageListener("entries.deleted"); + script.destroy(); + next(); + }); + + script.sendAsyncMessage("entries.delete"); +} + +var tests = [ + setup_tests, + populate_entries, + + test_entries, + + cleanUpTestingFiles, +]; + +function next() { + if (!tests.length) { + SimpleTest.finish(); + return; + } + + var test = tests.shift(); + test(); +} + +SimpleTest.waitForExplicitFinish(); +next(); +</script> +</body> +</html> |