Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -1563,10 +1563,14 @@
}
};
const queueWriterCommand = (stream, command) => {
if (!writerStates.has(stream)) {
const state = writerStates.get(stream);
if (!state) {
)JS",
R"JS( return Promise.reject(new TypeError('Illegal invocation'));
}
if (!state.transaction) {
return Promise.reject(new TypeError('Writer is closed'));
}
let writer;
try { writer = WritableStream.prototype.getWriter.call(stream); }
catch (error) { return Promise.reject(error); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1683,11 +1683,23 @@ void test_native_file_system_access_picker_and_handle_contract()
&& write_state.find("\"instance\":true") != std::string::npos
&& write_state.find("\"closed\":true") != std::string::npos,
"createWritable stream identity or close changed: " + write_state);
require(evaluate(engine.get(), R"JS((async()=>{
try { await __writeStream.write('late'); return 'unexpected'; }
catch (error) { return error.name; }
})())JS", "file-handle-write-after-close.js") == "\"TypeError\"",
"write after close did not reject TypeError");
execute(engine.get(), R"JS(globalThis.__closedCommandState = 'pending'; (async()=>{
const errors = [];
for (const command of [
() => __writeStream.write('late'),
() => __writeStream.seek(0),
() => __writeStream.truncate(0)]) {
try { await command(); errors.push('resolved'); }
catch (error) { errors.push(error.name); }
}
globalThis.__closedCommandState = errors.join(',');
})())JS", "file-handle-command-after-close.js");
const auto closed_command_state = evaluate_until_equals(engine.get(),
"__closedCommandState", "file-handle-command-after-close-result.js",
"\"TypeError,TypeError,TypeError\"");
require(closed_command_state == "\"TypeError,TypeError,TypeError\"",
"write/seek/truncate after close did not reject TypeError: "
+ closed_command_state);

activate_file_picker(engine.get(), 50005U);
execute(engine.get(), R"JS(
Expand Down Expand Up @@ -1770,6 +1782,7 @@ void test_native_file_system_access_picker_and_handle_contract()
execute(engine.get(), R"JS(
globalThis.__abortedWrite='pending';
__saveHandle.createWritable().then(async stream => {
globalThis.__abortedStream = stream;
await stream.abort('discard');
__abortedWrite='aborted';
}, error => { __abortedWrite=error.name; });
Expand All @@ -1795,6 +1808,23 @@ void test_native_file_system_access_picker_and_handle_contract()
require(evaluate(engine.get(), "__abortedWrite",
"file-handle-create-writable-abort-result.js") == "\"aborted\"",
"stream abort did not preserve terminal state");
execute(engine.get(), R"JS(globalThis.__abortedCommandState = 'pending'; (async()=>{
const errors = [];
for (const command of [
() => __abortedStream.write('late'),
() => __abortedStream.seek(0),
() => __abortedStream.truncate(0)]) {
try { await command(); errors.push('resolved'); }
catch (error) { errors.push(error.name); }
}
globalThis.__abortedCommandState = errors.join(',');
})())JS", "file-handle-command-after-abort.js");
const auto aborted_command_state = evaluate_until_equals(engine.get(),
"__abortedCommandState", "file-handle-command-after-abort-result.js",
"\"TypeError,TypeError,TypeError\"");
require(aborted_command_state == "\"TypeError,TypeError,TypeError\"",
"write/seek/truncate after abort did not reject TypeError: "
+ aborted_command_state);

execute(engine.get(), R"JS(
globalThis.__writeFailure='pending';
Expand Down
Loading