summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/entries-api/idlharness-manual.window.js
blob: 9f2731bf1d02576ea5a597fe94b0e2277f3f8fbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: script=support.js

'use strict';

let resolve;
let globalItem;
let globalEntry;

let entriesPromise = new Promise(r => {
  resolve = r;
});

entry_test((t, entry, item) => {
  assert_true(entry.isDirectory);
  resolve(getEntriesAsPromise(entry));
  globalItem = item;
  globalEntry = entry;
  t.done();
});

idl_test(
  ['entries-api'],
  ['FileAPI', 'html', 'dom'],
  async idl_array => {
    const entries = await entriesPromise;
    window.samples = {
      item: globalItem,
      dirEntry: entries.filter(entry => entry.isDirectory)[0],
      fileEntry: entries.filter(entry => entry.isFile)[0],
      fileSystem: globalEntry.filesystem,
    };

    idl_array.add_objects({
      File: ['new File([], "example.txt")'],
      HTMLInputElement: ['document.createElement("input")'],
      DataTransferItem: ['samples.item'],
      FileSystemEntry: [],
      FileSystemDirectoryEntry: ['samples.dirEntry'],
      FileSystemDirectoryReader: ['samples.dirEntry.createReader()'],
      FileSystemFileEntry: ['samples.fileEntry'],
      FileSystem: ['samples.fileSystem'],
    });
  }
);