blob: 14d9af4130715db9d4e648ba79ed0623ff7c1bc1 [file] [log] [blame]
<!DOCTYPE html>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script src='resources/streams-utils.js'></script>
<script>
// This is updated till https://github.com/whatwg/streams/commit/4ba861e6f60c248060811830e11271c84b439cc3
var test1 = async_test('Closing a writable stream with in-flight writes below the high water mark delays the close call properly');
test1.step(function() {
var isDone = false;
var ws = new WritableStream(
{
write: function(chunk) {
return new Promise(test1.step_func(function(resolve) {
setTimeout(test1.step_func(function() {
isDone = true;
resolve();
}), 500);
}));
},
close: function() {
assert_true(isDone, 'close is only called once the promise has been resolved');
test1.done();
}
},
new ByteLengthQueuingStrategy({ highWaterMark: 1024 * 16 })
);
ws.write({ byteLength: 1024 });
ws.close();
});
</script>