https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 593dea5f1b8e9d90bbcc20adcafe370e8f0b0564 authored by James Graham on 12 April 2018, 12:48:29 UTC
Use version-specific prefs files when running Firefox
Tip revision: 593dea5
byte-length-queuing-strategy.js
'use strict';

if (self.importScripts) {
  self.importScripts('/resources/testharness.js');
}

promise_test(() => {
  let isDone = false;
  const ws = new WritableStream(
    {
      write() {
        return new Promise(resolve => {
          setTimeout(() => {
            isDone = true;
            resolve();
          }, 200);
        });
      },

      close() {
        assert_true(isDone, 'close is only called once the promise has been resolved');
      }
    },
    new ByteLengthQueuingStrategy({ highWaterMark: 1024 * 16 })
  );

  const writer = ws.getWriter();
  writer.write({ byteLength: 1024 });

  return writer.close();
}, 'Closing a writable stream with in-flight writes below the high water mark delays the close call properly');

done();
back to top