blob: 8fb0dfb784ac85b4e56f8974d6889424c1b3994f [file] [log] [blame]
Ms2gerd12f7992014-02-01 12:01:261<!DOCTYPE html>
2<html>
3 <head>
4 <meta charset="utf-8">
5 <title>File API manual IDL tests</title>
6 <link rel="author" title="Intel" href="http://www.intel.com">
7 <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#conformance">
8 <script src="/resources/testharness.js"></script>
9 <script src="/resources/testharnessreport.js"></script>
10 <script src="/resources/WebIDLParser.js"></script>
11 <script src="/resources/idlharness.js"></script>
12 </head>
13 <body>
14 <h1>File API manual IDL tests</h1>
15
16 <div>
17 <p>Test steps:</p>
18 <ol>
19 <li>Download <a href="support/upload.txt">upload.txt</a> to local.</li>
20 <li>Select the local upload.txt file to run the test.</li>
21 </ol>
22 </div>
23
24 <form name="uploadData">
25 <input type="file" id="fileChooser">
26 </form>
27
28 <div id="log"></div>
29
30 <pre id="untested_idl" style="display: none">
31 interface ArrayBuffer {
32 };
33
34 interface ArrayBufferView {
35 };
36
37 interface URL {
38 };
39
40 interface EventTarget {
41 };
42
43 interface Event {
44 };
45
46 [TreatNonCallableAsNull]
47 callback EventHandlerNonNull = any (Event event);
48 typedef EventHandlerNonNull? EventHandler;
49 </pre>
50
51 <pre id="idl" style="display: none">
plehegar4e53aeb2014-08-26 19:01:4352[Constructor,
53 Constructor(sequence<(ArrayBuffer or ArrayBufferView or Blob or DOMString)> blobParts, optional BlobPropertyBag options), Exposed=Window,Worker]
54interface Blob {
Ms2gerd12f7992014-02-01 12:01:2655
plehegar4e53aeb2014-08-26 19:01:4356 readonly attribute unsigned long long size;
57 readonly attribute DOMString type;
58 readonly attribute boolean isClosed;
Ms2gerd12f7992014-02-01 12:01:2659
plehegar4e53aeb2014-08-26 19:01:4360 //slice Blob into byte-ranged chunks
Ms2gerd12f7992014-02-01 12:01:2661
plehegar4e53aeb2014-08-26 19:01:4362 Blob slice([Clamp] optional long long start,
63 [Clamp] optional long long end,
64 optional DOMString contentType);
65 void close();
Ms2gerd12f7992014-02-01 12:01:2666
plehegar4e53aeb2014-08-26 19:01:4367};
Ms2gerd12f7992014-02-01 12:01:2668
plehegar4e53aeb2014-08-26 19:01:4369dictionary BlobPropertyBag {
70 DOMString type = "";
71};
Ms2gerd12f7992014-02-01 12:01:2672
plehegar4e53aeb2014-08-26 19:01:4373[Constructor(sequence<(Blob or DOMString or ArrayBufferView or ArrayBuffer)> fileBits,
74[EnsureUTF16] DOMString fileName, optional FilePropertyBag options), Exposed=Window,Worker]
75interface File : Blob {
Ms2gerd12f7992014-02-01 12:01:2676
plehegar4e53aeb2014-08-26 19:01:4377 readonly attribute DOMString name;
78 readonly attribute long long lastModified;
Ms2gerd12f7992014-02-01 12:01:2679
plehegar4e53aeb2014-08-26 19:01:4380};
Ms2gerd12f7992014-02-01 12:01:2681
plehegar4e53aeb2014-08-26 19:01:4382dictionary FilePropertyBag {
Ms2gerd12f7992014-02-01 12:01:2683
plehegar4e53aeb2014-08-26 19:01:4384 DOMString type = "";
85 long long lastModified;
Ms2gerd12f7992014-02-01 12:01:2686
plehegar4e53aeb2014-08-26 19:01:4387};
Ms2gerd12f7992014-02-01 12:01:2688
plehegar4e53aeb2014-08-26 19:01:4389[Exposed=Window,Worker] interface FileList {
90 getter File? item(unsigned long index);
91 readonly attribute unsigned long length;
92};
Ms2gerd12f7992014-02-01 12:01:2693
plehegar4e53aeb2014-08-26 19:01:4394[Constructor, Exposed=Window,Worker]
95interface FileReader: EventTarget {
96
97 // async read methods
98 void readAsArrayBuffer(Blob blob);
99 void readAsText(Blob blob, optional DOMString label);
100 void readAsDataURL(Blob blob);
101
102 void abort();
103
104 // states
105 const unsigned short EMPTY = 0;
106 const unsigned short LOADING = 1;
107 const unsigned short DONE = 2;
108
109 readonly attribute unsigned short readyState;
110
111 // File or Blob data
112 readonly attribute (DOMString or ArrayBuffer)? result;
113
114 readonly attribute DOMError? error;
115
116 // event handler attributes
117 attribute EventHandler onloadstart;
118 attribute EventHandler onprogress;
119 attribute EventHandler onload;
120 attribute EventHandler onabort;
121 attribute EventHandler onerror;
122 attribute EventHandler onloadend;
123
124};
125
126[Constructor, Exposed=Worker]
127interface FileReaderSync {
128
129 // Synchronously return strings
130
131 ArrayBuffer readAsArrayBuffer(Blob blob);
132 DOMString readAsText(Blob blob, optional DOMString label);
133 DOMString readAsDataURL(Blob blob);
134};
135
136partial interface URL {
137
138 static DOMString createObjectURL(Blob blob);
139 static DOMString createFor(Blob blob);
140 static void revokeObjectURL(DOMString url);
141
142};
Ms2gerd12f7992014-02-01 12:01:26143 </pre>
144
145 <script>
146 var fileInput;
147
148 setup(function() {
149 fileInput = document.querySelector("#fileChooser")
150 }, {explicit_done: true, explicit_timeout: true});
151
152 on_event(fileInput, "change", function(evt) {
153 var idl_array = new IdlArray();
154 idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
155 idl_array.add_idls(document.getElementById("idl").textContent);
156
157 idl_array.add_objects({
158 FileList: [fileInput.files],
159 File: [fileInput.files[0]],
160 });
161 idl_array.test();
162
163 done();
164 });
165 </script>
166 </body>
167</html>