Commit ab4b7009 authored by Olivier Yiptong's avatar Olivier Yiptong Committed by Commit Bot

[Native File System] Aborting a directory iteration succeeds

The return statement of the async iterator was not returning the
expected type. This removes the ability to cancel an iteration
which fixes the bug where an error would be thrown otherwise.

A full implementation of directory iteration will re-implement
this functionality correctly.

BUG=1007509

Change-Id: I77f3b76b117b7df939e73da826f4fc9b82e9441e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1826993
Commit-Queue: Olivier Yiptong <oyiptong@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701356}
parent d9c01c76
...@@ -29,9 +29,6 @@ class NativeFileSystemDirectoryIterator final ...@@ -29,9 +29,6 @@ class NativeFileSystemDirectoryIterator final
ExecutionContext* execution_context); ExecutionContext* execution_context);
ScriptPromise next(ScriptState*); ScriptPromise next(ScriptState*);
// TODO(mek): This return method should cancel the backend directory iteration
// operation, to avoid doing useless work.
void IteratorReturn() {}
void Trace(Visitor*) override; void Trace(Visitor*) override;
......
...@@ -10,5 +10,4 @@ ...@@ -10,5 +10,4 @@
RuntimeEnabled=NativeFileSystem RuntimeEnabled=NativeFileSystem
] interface NativeFileSystemDirectoryIterator { ] interface NativeFileSystemDirectoryIterator {
[CallWith=ScriptState] Promise<any> next(); [CallWith=ScriptState] Promise<any> next();
[ImplementedAs=IteratorReturn] void return();
}; };
...@@ -6137,6 +6137,7 @@ crbug.com/999209 virtual/lazyload-image/http/tests/lazyload/style-dimension.html ...@@ -6137,6 +6137,7 @@ crbug.com/999209 virtual/lazyload-image/http/tests/lazyload/style-dimension.html
# These tests are missing test automation # These tests are missing test automation
crbug.com/998917 external/wpt/native-file-system/native_FileSystemDirectoryHandle-getDirectory.tentative.https.manual.window.html [ Skip ] crbug.com/998917 external/wpt/native-file-system/native_FileSystemDirectoryHandle-getDirectory.tentative.https.manual.window.html [ Skip ]
crbug.com/998917 external/wpt/native-file-system/native_FileSystemDirectoryHandle-getEntries.tentative.https.manual.window.html [ Skip ]
crbug.com/998917 external/wpt/native-file-system/native_FileSystemDirectoryHandle-getFile.tentative.https.manual.window.html [ Skip ] crbug.com/998917 external/wpt/native-file-system/native_FileSystemDirectoryHandle-getFile.tentative.https.manual.window.html [ Skip ]
crbug.com/998917 external/wpt/native-file-system/native_FileSystemDirectoryHandle-removeEntry.tentative.https.manual.window.html [ Skip ] crbug.com/998917 external/wpt/native-file-system/native_FileSystemDirectoryHandle-removeEntry.tentative.https.manual.window.html [ Skip ]
crbug.com/998917 external/wpt/native-file-system/native_FileSystemWriter.tentative.https.manual.window.html [ Skip ] crbug.com/998917 external/wpt/native-file-system/native_FileSystemWriter.tentative.https.manual.window.html [ Skip ]
......
// META: script=/resources/testdriver.js
// META: script=resources/test-helpers.js
// META: script=resources/native-fs-test-helpers.js
// META: script=script-tests/FileSystemDirectoryHandle-getEntries.js
// META: script=resources/test-helpers.js
// META: script=resources/sandboxed-fs-test-helpers.js
// META: script=script-tests/FileSystemDirectoryHandle-getEntries.js
directory_test(async (t, root) => {
const file_name1 = 'foo1.txt';
const file_name2 = 'foo2.txt';
await createFileWithContents(t, file_name1, 'contents', /*parent=*/ root);
await createFileWithContents(t, file_name2, 'contents', /*parent=*/ root);
let abortIter = async (dir) => {
for await (let entry of dir.getEntries()) {
return entry.name;
}
};
try {
await abortIter(root);
} catch(e) {
assert_unreached('Error thrown on iteration abort.');
}
}, 'getEntries(): returning early from an iteration works');
directory_test(async (t, root) => {
const file_name1 = 'foo1.txt';
const file_name2 = 'foo2.txt';
await createFileWithContents(t, file_name1, 'contents', /*parent=*/ root);
await createFileWithContents(t, file_name2, 'contents', /*parent=*/ root);
let fullIter = async (dir) => {
let name;
for await (let entry of dir.getEntries()) {
name = entry.name;
}
return name;
};
try {
await fullIter(root);
} catch(e) {
assert_unreached('Error thrown on iteration.');
}
}, 'getEntries(): full iteration works');
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment