11cb0ef41Sopenharmony_ci// META: global=window,worker 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_cipromise_test(t => { 51cb0ef41Sopenharmony_ci let isDone = false; 61cb0ef41Sopenharmony_ci const ws = new WritableStream( 71cb0ef41Sopenharmony_ci { 81cb0ef41Sopenharmony_ci write() { 91cb0ef41Sopenharmony_ci return new Promise(resolve => { 101cb0ef41Sopenharmony_ci t.step_timeout(() => { 111cb0ef41Sopenharmony_ci isDone = true; 121cb0ef41Sopenharmony_ci resolve(); 131cb0ef41Sopenharmony_ci }, 200); 141cb0ef41Sopenharmony_ci }); 151cb0ef41Sopenharmony_ci }, 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci close() { 181cb0ef41Sopenharmony_ci assert_true(isDone, 'close is only called once the promise has been resolved'); 191cb0ef41Sopenharmony_ci } 201cb0ef41Sopenharmony_ci }, 211cb0ef41Sopenharmony_ci new ByteLengthQueuingStrategy({ highWaterMark: 1024 * 16 }) 221cb0ef41Sopenharmony_ci ); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci const writer = ws.getWriter(); 251cb0ef41Sopenharmony_ci writer.write({ byteLength: 1024 }); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci return writer.close(); 281cb0ef41Sopenharmony_ci}, 'Closing a writable stream with in-flight writes below the high water mark delays the close call properly'); 29