blob: 64a9c8508b376877a75391f20980430c8214ca70 [file] [log] [blame]
Zhiqiang Zhanga57fb452013-08-18 07:58:521<!DOCTYPE html>
2<html>
3 <head>
4 <meta charset="utf-8">
Ms2gerd12f7992014-02-01 12:01:265 <title>File API automated IDL tests</title>
Zhiqiang Zhanga57fb452013-08-18 07:58:526 <link rel="author" title="Intel" href="http://www.intel.com">
Zhiqiang Zhangb5084452013-09-02 07:07:067 <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#conformance">
Zhiqiang Zhanga57fb452013-08-18 07:58:528 <script src="/resources/testharness.js"></script>
9 <script src="/resources/testharnessreport.js"></script>
Zhiqiang Zhang7c354dc2013-12-05 07:04:4410 <script src="/resources/WebIDLParser.js"></script>
Zhiqiang Zhanga57fb452013-08-18 07:58:5211 <script src="/resources/idlharness.js"></script>
12 </head>
13 <body>
Ms2gerd12f7992014-02-01 12:01:2614 <h1>File API automated IDL tests</h1>
Zhiqiang Zhang7c354dc2013-12-05 07:04:4415
16 <div id="log"></div>
Zhiqiang Zhanga57fb452013-08-18 07:58:5217
18 <pre id="untested_idl" style="display: none">
19 interface ArrayBuffer {
20 };
21
22 interface ArrayBufferView {
23 };
24
Zhiqiang Zhangb5084452013-09-02 07:07:0625 interface URL {
Zhiqiang Zhanga57fb452013-08-18 07:58:5226 };
27
28 interface EventTarget {
29 };
30
Zhiqiang Zhangb5084452013-09-02 07:07:0631 interface Event {
Zhiqiang Zhanga57fb452013-08-18 07:58:5232 };
33
Zhiqiang Zhangb5084452013-09-02 07:07:0634 [TreatNonCallableAsNull]
35 callback EventHandlerNonNull = any (Event event);
36 typedef EventHandlerNonNull? EventHandler;
Zhiqiang Zhanga57fb452013-08-18 07:58:5237 </pre>
38
39 <pre id="idl" style="display: none">
plehegar4e53aeb2014-08-26 19:01:4340[Constructor,
41 Constructor(sequence<(ArrayBuffer or ArrayBufferView or Blob or DOMString)> blobParts, optional BlobPropertyBag options), Exposed=Window,Worker]
42interface Blob {
Zhiqiang Zhanga57fb452013-08-18 07:58:5243
plehegar4e53aeb2014-08-26 19:01:4344 readonly attribute unsigned long long size;
45 readonly attribute DOMString type;
46 readonly attribute boolean isClosed;
Zhiqiang Zhanga57fb452013-08-18 07:58:5247
plehegar4e53aeb2014-08-26 19:01:4348 //slice Blob into byte-ranged chunks
Zhiqiang Zhanga57fb452013-08-18 07:58:5249
plehegar4e53aeb2014-08-26 19:01:4350 Blob slice([Clamp] optional long long start,
51 [Clamp] optional long long end,
52 optional DOMString contentType);
53 void close();
Zhiqiang Zhanga57fb452013-08-18 07:58:5254
plehegar4e53aeb2014-08-26 19:01:4355};
Zhiqiang Zhangb5084452013-09-02 07:07:0656
plehegar4e53aeb2014-08-26 19:01:4357dictionary BlobPropertyBag {
58 DOMString type = "";
59};
Zhiqiang Zhanga57fb452013-08-18 07:58:5260
plehegar4e53aeb2014-08-26 19:01:4361[Constructor(sequence<(Blob or DOMString or ArrayBufferView or ArrayBuffer)> fileBits,
62[EnsureUTF16] DOMString fileName, optional FilePropertyBag options), Exposed=Window,Worker]
63interface File : Blob {
Zhiqiang Zhanga57fb452013-08-18 07:58:5264
plehegar4e53aeb2014-08-26 19:01:4365 readonly attribute DOMString name;
66 readonly attribute long long lastModified;
Zhiqiang Zhanga57fb452013-08-18 07:58:5267
plehegar4e53aeb2014-08-26 19:01:4368};
Zhiqiang Zhanga57fb452013-08-18 07:58:5269
plehegar4e53aeb2014-08-26 19:01:4370dictionary FilePropertyBag {
Zhiqiang Zhanga57fb452013-08-18 07:58:5271
plehegar4e53aeb2014-08-26 19:01:4372 DOMString type = "";
73 long long lastModified;
Zhiqiang Zhanga57fb452013-08-18 07:58:5274
plehegar4e53aeb2014-08-26 19:01:4375};
Zhiqiang Zhanga57fb452013-08-18 07:58:5276
plehegar4e53aeb2014-08-26 19:01:4377[Exposed=Window,Worker] interface FileList {
78 getter File? item(unsigned long index);
79 readonly attribute unsigned long length;
80};
Zhiqiang Zhanga57fb452013-08-18 07:58:5281
plehegar4e53aeb2014-08-26 19:01:4382[Constructor, Exposed=Window,Worker]
83interface FileReader: EventTarget {
84
85 // async read methods
86 void readAsArrayBuffer(Blob blob);
87 void readAsText(Blob blob, optional DOMString label);
88 void readAsDataURL(Blob blob);
89
90 void abort();
91
92 // states
93 const unsigned short EMPTY = 0;
94 const unsigned short LOADING = 1;
95 const unsigned short DONE = 2;
96
97 readonly attribute unsigned short readyState;
98
99 // File or Blob data
100 readonly attribute (DOMString or ArrayBuffer)? result;
101
102 readonly attribute DOMError? error;
103
104 // event handler attributes
105 attribute EventHandler onloadstart;
106 attribute EventHandler onprogress;
107 attribute EventHandler onload;
108 attribute EventHandler onabort;
109 attribute EventHandler onerror;
110 attribute EventHandler onloadend;
111
112};
113
114[Constructor, Exposed=Worker]
115interface FileReaderSync {
116
117 // Synchronously return strings
118
119 ArrayBuffer readAsArrayBuffer(Blob blob);
120 DOMString readAsText(Blob blob, optional DOMString label);
121 DOMString readAsDataURL(Blob blob);
122};
123
124partial interface URL {
125
126 static DOMString createObjectURL(Blob blob);
127 static DOMString createFor(Blob blob);
128 static void revokeObjectURL(DOMString url);
129
130};
131
Zhiqiang Zhanga57fb452013-08-18 07:58:52132 </pre>
133
Ms2gerf6d4d3e2015-01-30 13:40:00134 <form name="uploadData">
135 <input type="file" id="fileChooser">
136 </form>
137
Zhiqiang Zhanga57fb452013-08-18 07:58:52138 <script>
Ms2gerf6d4d3e2015-01-30 13:40:00139 var idl_array, file_input;
Zhiqiang Zhanga57fb452013-08-18 07:58:52140
Zhiqiang Zhangb5084452013-09-02 07:07:06141 setup(function() {
Ms2gerf6d4d3e2015-01-30 13:40:00142 file_input = document.querySelector("#fileChooser");
Ms2gerd12f7992014-02-01 12:01:26143 idl_array = new IdlArray();
Zhiqiang Zhanga57fb452013-08-18 07:58:52144 idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
145 idl_array.add_idls(document.getElementById("idl").textContent);
146
Ms2gerd12f7992014-02-01 12:01:26147 idl_array.add_objects({
James Grahamefc9f062014-08-19 14:36:56148 Blob: ['new Blob(["TEST"])'],
plehegar4e53aeb2014-08-26 19:01:43149 File: ['new File(["myFileBits"], "myFileName")'],
Ms2gerf6d4d3e2015-01-30 13:40:00150 FileList: ['file_input.files'],
James Grahamefc9f062014-08-19 14:36:56151 FileReader: ['new FileReader()']
Ms2gerd12f7992014-02-01 12:01:26152 });
Zhiqiang Zhanga57fb452013-08-18 07:58:52153 });
Ms2gerd12f7992014-02-01 12:01:26154
155 idl_array.test();
Zhiqiang Zhanga57fb452013-08-18 07:58:52156 </script>
157 </body>
158</html>