| Zhiqiang Zhang | a57fb45 | 2013-08-18 07:58:52 | [diff] [blame^] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| 5 | <title>FileAPI Test: idlharness</title> |
| 6 | <link rel="author" title="Intel" href="http://www.intel.com"> |
| 7 | <link rel="help" href="http://www.w3.org/TR/FileAPI/"> |
| 8 | <link rel="help" href="http://www.w3.org/TR/FileAPI/#conformance"> |
| 9 | <script src="/resources/testharness.js"></script> |
| 10 | <script src="/resources/testharnessreport.js"></script> |
| 11 | <script src="/resources/webidl2/lib/webidl2.js"></script> |
| 12 | <script src="/resources/idlharness.js"></script> |
| 13 | </head> |
| 14 | <body> |
| 15 | <h1>idlharness test</h1> |
| 16 | <p>This test validates the WebIDL included in the FileAPI specification.</p> |
| 17 | |
| 18 | <pre id="untested_idl" style="display: none"> |
| 19 | interface ArrayBuffer { |
| 20 | }; |
| 21 | |
| 22 | interface ArrayBufferView { |
| 23 | }; |
| 24 | |
| 25 | dictionary BlobPropertyBag { |
| 26 | }; |
| 27 | |
| 28 | interface EventTarget { |
| 29 | }; |
| 30 | |
| 31 | interface Window { |
| 32 | }; |
| 33 | |
| 34 | interface WorkerGlobalScope { |
| 35 | }; |
| 36 | </pre> |
| 37 | |
| 38 | <pre id="idl" style="display: none"> |
| 39 | [Constructor, |
| 40 | Constructor(sequence<(ArrayBuffer or ArrayBufferView or Blob or DOMString)> blobParts, optional BlobPropertyBag options)] |
| 41 | interface Blob { |
| 42 | |
| 43 | readonly attribute unsigned long long size; |
| 44 | readonly attribute DOMString type; |
| 45 | |
| 46 | //slice Blob into byte-ranged chunks |
| 47 | |
| 48 | Blob slice(optional long long start, |
| 49 | optional long long end, |
| 50 | optional DOMString contentType); |
| 51 | void close(); |
| 52 | }; |
| 53 | |
| 54 | interface File : Blob { |
| 55 | readonly attribute DOMString name; |
| 56 | readonly attribute Date lastModifiedDate; |
| 57 | }; |
| 58 | |
| 59 | interface FileList { |
| 60 | getter File? item(unsigned long index); |
| 61 | readonly attribute unsigned long length; |
| 62 | }; |
| 63 | |
| 64 | [Constructor] |
| 65 | interface FileReader: EventTarget { |
| 66 | |
| 67 | // async read methods |
| 68 | void readAsArrayBuffer(Blob blob); |
| 69 | void readAsText(Blob blob, optional DOMString encoding); |
| 70 | void readAsDataURL(Blob blob); |
| 71 | |
| 72 | void abort(); |
| 73 | |
| 74 | // states |
| 75 | const unsigned short EMPTY = 0; |
| 76 | const unsigned short LOADING = 1; |
| 77 | const unsigned short DONE = 2; |
| 78 | |
| 79 | |
| 80 | readonly attribute unsigned short readyState; |
| 81 | |
| 82 | // File or Blob data |
| 83 | readonly attribute (DOMString or ArrayBuffer)? result; |
| 84 | |
| 85 | readonly attribute DOMError error; |
| 86 | |
| 87 | // event handler attributes |
| 88 | [TreatNonCallableAsNull] attribute Function? onloadstart; |
| 89 | [TreatNonCallableAsNull] attribute Function? onprogress; |
| 90 | [TreatNonCallableAsNull] attribute Function? onload; |
| 91 | [TreatNonCallableAsNull] attribute Function? onabort; |
| 92 | [TreatNonCallableAsNull] attribute Function? onerror; |
| 93 | [TreatNonCallableAsNull] attribute Function? onloadend; |
| 94 | }; |
| 95 | |
| 96 | // This interface is removed by http://dev.w3.org/2006/webapi/FileAPI/ |
| 97 | // [NoInterfaceObject] interface LineEndings { |
| 98 | // DOMString toNativeLineEndings(DOMString string); |
| 99 | // }; |
| 100 | // Window implements LineEndings; |
| 101 | // WorkerGlobalScope implements LineEndings; |
| 102 | </pre> |
| 103 | |
| 104 | <form name='uploadData'> |
| 105 | <input type='file' id='fileChooser'> |
| 106 | </form> |
| 107 | |
| 108 | <div> |
| 109 | <p>Test steps:</p> |
| 110 | <ol> |
| 111 | <li>Download <a href='support/upload.txt'>upload.txt</a> to local.</li> |
| 112 | <li>Select the local upload.txt file to run the test.</li> |
| 113 | </ol> |
| 114 | </div> |
| 115 | |
| 116 | <div id="log"></div> |
| 117 | |
| 118 | <script> |
| 119 | var button = document.querySelector("input"); |
| 120 | |
| 121 | setup({explicit_done: true}); |
| 122 | setup({explicit_timeout: true}); |
| 123 | |
| 124 | on_event(button, "change", function(evt) { |
| 125 | var idl_array = new IdlArray(); |
| 126 | idl_array.add_untested_idls(document.getElementById("untested_idl").textContent); |
| 127 | idl_array.add_idls(document.getElementById("idl").textContent); |
| 128 | |
| 129 | var testFileList = button.files; |
| 130 | var testFile = button.files[0]; |
| 131 | |
| 132 | idl_array.add_objects({Blob : [new Blob(["TEST"])], |
| 133 | FileList: [testFileList], |
| 134 | File: [testFile], |
| 135 | FileReader: [new FileReader()], |
| 136 | LineEndings: ["window"]}); |
| 137 | idl_array.test(); |
| 138 | |
| 139 | done(); |
| 140 | }); |
| 141 | </script> |
| 142 | </body> |
| 143 | </html> |