Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileAPI interface test #583

Merged
merged 5 commits into from
Feb 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions FileAPI/idlharness-manual.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>File API manual IDL tests</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#conformance">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>File API manual IDL tests</h1>

<div>
<p>Test steps:</p>
<ol>
<li>Download <a href="support/upload.txt">upload.txt</a> to local.</li>
<li>Select the local upload.txt file to run the test.</li>
</ol>
</div>

<form name="uploadData">
<input type="file" id="fileChooser">
</form>

<div id="log"></div>

<pre id="untested_idl" style="display: none">
interface ArrayBuffer {
};

interface ArrayBufferView {
};

interface URL {
};

interface EventTarget {
};

interface Event {
};

[TreatNonCallableAsNull]
callback EventHandlerNonNull = any (Event event);
typedef EventHandlerNonNull? EventHandler;
</pre>

<pre id="idl" style="display: none">
interface FileList {
getter File? item(unsigned long index);
readonly attribute unsigned long length;
};

[Constructor,
Constructor(sequence<(ArrayBuffer or ArrayBufferView or Blob or DOMString)> blobParts, optional BlobPropertyBag options)]
interface Blob {
readonly attribute unsigned long long size;
readonly attribute DOMString type;

//slice Blob into byte-ranged chunks

Blob slice(optional long long start,
optional long long end,
optional DOMString contentType);
void close();
};

dictionary BlobPropertyBag {
DOMString type = "";
};

[Constructor(Blob fileBits, DOMString fileName)]
interface File : Blob {
readonly attribute DOMString name;
readonly attribute Date lastModifiedDate;
};

[Constructor]
interface FileReader: EventTarget {
// async read methods
void readAsArrayBuffer(Blob blob);
void readAsText(Blob blob, optional DOMString label);
void readAsDataURL(Blob blob);

void abort();

// states
const unsigned short EMPTY = 0;
const unsigned short LOADING = 1;
const unsigned short DONE = 2;

readonly attribute unsigned short readyState;

// File or Blob data
readonly attribute (DOMString or ArrayBuffer)? result;

readonly attribute DOMError? error;

// event handler attributes
attribute EventHandler onloadstart;
attribute EventHandler onprogress;
attribute EventHandler onload;
attribute EventHandler onabort;
attribute EventHandler onerror;
attribute EventHandler onloadend;
};

partial interface URL {
static DOMString? createObjectURL(Blob blob);
static DOMString? createFor(Blob blob); // static DOMString? createFor()Blob blob);
static void revokeObjectURL(DOMString url);
};
</pre>

<script>
var fileInput;

setup(function() {
fileInput = document.querySelector("#fileChooser")
}, {explicit_done: true, explicit_timeout: true});

on_event(fileInput, "change", function(evt) {
var idl_array = new IdlArray();
idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
idl_array.add_idls(document.getElementById("idl").textContent);

idl_array.add_objects({
FileList: [fileInput.files],
File: [fileInput.files[0]],
});
idl_array.test();

done();
});
</script>
</body>
</html>
123 changes: 123 additions & 0 deletions FileAPI/idlharness.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>File API automated IDL tests</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#conformance">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>File API automated IDL tests</h1>

<div id="log"></div>

<pre id="untested_idl" style="display: none">
interface ArrayBuffer {
};

interface ArrayBufferView {
};

interface URL {
};

interface EventTarget {
};

interface Event {
};

[TreatNonCallableAsNull]
callback EventHandlerNonNull = any (Event event);
typedef EventHandlerNonNull? EventHandler;
</pre>

<pre id="idl" style="display: none">
interface FileList {
getter File? item(unsigned long index);
readonly attribute unsigned long length;
};

[Constructor,
Constructor(sequence<(ArrayBuffer or ArrayBufferView or Blob or DOMString)> blobParts, optional BlobPropertyBag options)]
interface Blob {
readonly attribute unsigned long long size;
readonly attribute DOMString type;

//slice Blob into byte-ranged chunks

Blob slice(optional long long start,
optional long long end,
optional DOMString contentType);
void close();
};

dictionary BlobPropertyBag {
DOMString type = "";
};

[Constructor(Blob fileBits, DOMString fileName)]
interface File : Blob {
readonly attribute DOMString name;
readonly attribute Date lastModifiedDate;
};

[Constructor]
interface FileReader: EventTarget {
// async read methods
void readAsArrayBuffer(Blob blob);
void readAsText(Blob blob, optional DOMString label);
void readAsDataURL(Blob blob);

void abort();

// states
const unsigned short EMPTY = 0;
const unsigned short LOADING = 1;
const unsigned short DONE = 2;

readonly attribute unsigned short readyState;

// File or Blob data
readonly attribute (DOMString or ArrayBuffer)? result;

readonly attribute DOMError? error;

// event handler attributes
attribute EventHandler onloadstart;
attribute EventHandler onprogress;
attribute EventHandler onload;
attribute EventHandler onabort;
attribute EventHandler onerror;
attribute EventHandler onloadend;
};

partial interface URL {
static DOMString? createObjectURL(Blob blob);
static DOMString? createFor(Blob blob); // static DOMString? createFor()Blob blob);
static void revokeObjectURL(DOMString url);
};
</pre>

<script>
var idl_array;

setup(function() {
idl_array = new IdlArray();
idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
idl_array.add_idls(document.getElementById("idl").textContent);

idl_array.add_objects({
Blob: [new Blob(["TEST"])],
FileReader: [new FileReader()]
});
});

idl_array.test();
</script>
</body>
</html>
1 change: 1 addition & 0 deletions FileAPI/support/upload.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello