summaryrefslogtreecommitdiffstats
path: root/dom/file/tests/create_file_objects.js
blob: cf016b239da2a93fa75260bc8a2a3c7226a6d003 (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);
  });
});