1/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * The origin of this IDL file is
7 * https://w3c.github.io/FileAPI/#file
8 * https://wicg.github.io/entries-api
9 */
10
11interface nsIFile;
12
13[Exposed=(Window,Worker)]
14interface File : Blob {
15  [Throws]
16  constructor(sequence<BlobPart> fileBits,
17              USVString fileName, optional FilePropertyBag options = {});
18
19  readonly attribute DOMString name;
20
21  [GetterThrows]
22  readonly attribute long long lastModified;
23};
24
25dictionary FilePropertyBag : BlobPropertyBag {
26  long long lastModified;
27};
28
29dictionary ChromeFilePropertyBag : FilePropertyBag {
30  DOMString name = "";
31  boolean existenceCheck = true;
32};
33
34// https://wicg.github.io/entries-api
35partial interface File {
36  [BinaryName="relativePath", Pref="dom.webkitBlink.dirPicker.enabled"]
37  readonly attribute USVString webkitRelativePath;
38};
39
40// Mozilla extensions
41partial interface File {
42  [GetterThrows, ChromeOnly, NeedsCallerType]
43  readonly attribute DOMString mozFullPath;
44};
45
46// Mozilla extensions
47// These 2 methods can be used only in these conditions:
48// - the main-thread
49// - parent process OR file process OR, only for testing, with pref
50//   `dom.file.createInChild' set to true.
51[Exposed=(Window)]
52partial interface File {
53  [ChromeOnly, Throws, NeedsCallerType]
54  static Promise<File> createFromNsIFile(nsIFile file,
55                                         optional ChromeFilePropertyBag options = {});
56
57  [ChromeOnly, Throws, NeedsCallerType]
58  static Promise<File> createFromFileName(USVString fileName,
59                                          optional ChromeFilePropertyBag options = {});
60};
61