<!doctype html>
<title>Entries API IDL tests</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/WebIDLParser.js></script>
<script src=/resources/idlharness.js></script>

<h1>Entries API IDL tests</h1>
<div id=log></div>

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

<script type=text/plain>
partial interface File {
    readonly attribute USVString webkitRelativePath;
};

partial interface HTMLInputElement {
    attribute boolean webkitdirectory;
    readonly attribute FrozenArray<FileSystemEntry> webkitEntries;
};

partial interface DataTransferItem {
    FileSystemEntry? webkitGetAsEntry();
};

callback interface ErrorCallback {
    void handleEvent(DOMException err);
};

interface FileSystemEntry {
    readonly attribute boolean isFile;
    readonly attribute boolean isDirectory;
    readonly attribute USVString name;
    readonly attribute USVString fullPath;
    readonly attribute FileSystem filesystem;

    void getParent(optional FileSystemEntryCallback successCallback,
                   optional ErrorCallback errorCallback);
};

interface FileSystemDirectoryEntry : FileSystemEntry {
    FileSystemDirectoryReader createReader();
    void getFile(optional USVString? path,
                 optional FileSystemFlags options,
                 optional FileSystemEntryCallback successCallback,
                 optional ErrorCallback errorCallback);
    void getDirectory(optional USVString? path,
                      optional FileSystemFlags options,
                      optional FileSystemEntryCallback successCallback,
                      optional ErrorCallback errorCallback);
};

dictionary FileSystemFlags {
    boolean create = false;
    boolean exclusive = false;
};

callback interface FileSystemEntryCallback {
    void handleEvent(FileSystemEntry entry);
};

interface FileSystemDirectoryReader {
    void readEntries(FileSystemEntriesCallback successCallback,
                     optional ErrorCallback errorCallback);
};
callback interface FileSystemEntriesCallback {
    void handleEvent(sequence<FileSystemEntry> entries);
};

interface FileSystemFileEntry : FileSystemEntry {
    void file(FileCallback successCallback,
              optional ErrorCallback errorCallback);
};
callback interface FileCallback {
    void handleEvent(File file);
};

interface FileSystem {
    readonly attribute USVString name;
    readonly attribute FileSystemDirectoryEntry root;
};
</script>
<script>
"use strict";
var idlArray;
var file_input;
setup(function() {
  idlArray = new IdlArray();
  [].forEach.call(document.querySelectorAll("script[type=text\\/plain]"), function(node) {
    if (node.className == "untested") {
      idlArray.add_untested_idls(node.textContent);
    } else {
      idlArray.add_idls(node.textContent);
    }
    idlArray.add_untested_idls("interface File {};");
    idlArray.add_untested_idls("interface HTMLInputElement {};");
    idlArray.add_untested_idls("interface DataTransferItem {};");
    file_input = document.getElementById("fileChooser");
    idlArray.add_objects({
        File: ['new File(["myFileBits"], "myFileName")'],
        HTMLInputElement: ['file_input'],
    });
  });
}, {explicit_done:true});
window.onload = function() {
  idlArray.test();
  done();
};
</script>
