File.webidl (1926B)
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 11 interface nsIFile; 12 13 [Exposed=(Window,Worker)] 14 interface 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 25 dictionary FilePropertyBag : BlobPropertyBag { 26 long long lastModified; 27 }; 28 29 dictionary ChromeFilePropertyBag : FilePropertyBag { 30 DOMString name = ""; 31 boolean existenceCheck = true; 32 }; 33 34 // https://wicg.github.io/entries-api 35 partial interface File { 36 [BinaryName="relativePath", Pref="dom.webkitBlink.dirPicker.enabled"] 37 readonly attribute USVString webkitRelativePath; 38 }; 39 40 // Mozilla extensions 41 partial interface File { 42 [GetterThrows, ChromeOnly, NeedsCallerType] 43 readonly attribute DOMString mozFullPath; 44 45 [ChromeOnly] 46 undefined setMozRelativePath(DOMString name); 47 }; 48 49 // Mozilla extensions 50 // These 2 methods can be used only in these conditions: 51 // - the main-thread 52 // - parent process OR file process OR, only for testing, with pref 53 // `dom.file.createInChild' set to true. 54 [Exposed=(Window)] 55 partial interface File { 56 [ChromeOnly, NewObject, NeedsCallerType] 57 static Promise<File> createFromNsIFile(nsIFile file, 58 optional ChromeFilePropertyBag options = {}); 59 60 [ChromeOnly, NewObject, NeedsCallerType] 61 static Promise<File> createFromFileName(USVString fileName, 62 optional ChromeFilePropertyBag options = {}); 63 };