summaryrefslogtreecommitdiffstats
path: root/dom/file/tests/create_file_objects.js
blob: 6243f4b8abae0c4bb94d2730d8d9149a5b23c4a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* eslint-env mozilla/chrome-script */

Cu.importGlobalProperties(["File"]);

addMessageListener("create-file-objects", function(message) {
  let files = [];
  let promises = [];
  for (fileName of message.fileNames) {
    promises.push(
      File.createFromFileName(fileName).then(function(file) {
        files.push(file);
      })
    );
  }

  Promise.all(promises).then(function() {
    sendAsyncMessage("created-file-objects", files);
  });
});