Re: [whatwg/streams] Port close() tests to web-platform-tests (#529)

tyoshino commented on this pull request.

lgtm

> +  return closePromise.then(value => assert_equals(value, undefined, 'fulfillment value must be undefined'));
+}, 'fulfillment value of ws.close() call must be undefined even if the underlying sink returns a non-undefined ' +
+    'value');
+
+async_test(t => {
+  const thrownError = new Error('throw me');
+  const ws = new WritableStream({
+    close() {
+      throw thrownError;
+    }
+  });
+
+  const writer = ws.getWriter();
+
+  promise_rejects(
+      t, thrownError, writer.close(), 'close promise', 'close promise should be rejected with the thrown error');

remove the 3rd argument as testharness.js's promise_rejects doesn't take it.

> +
+async_test(t => {
+  const thrownError = new Error('throw me');
+  const ws = new WritableStream({
+    close() {
+      throw thrownError;
+    }
+  });
+
+  const writer = ws.getWriter();
+
+  promise_rejects(
+      t, thrownError, writer.close(), 'close promise', 'close promise should be rejected with the thrown error');
+
+  setTimeout(() => {
+    promise_rejects(t, thrownError, writer.closed, 'closed', 'closed should stay rejected');

ditto

> +  const ws = new WritableStream({
+    start(c) {
+      controller = c;
+    },
+    close() {
+      return new Promise(resolve => setTimeout(resolve, 50));
+    }
+  });
+
+  const writer = ws.getWriter();
+
+  writer.close();
+  setTimeout(() => controller.error(passedError), 10);
+
+  promise_rejects(
+      t, passedError, writer.closed, 'closed promise', 'closed promise should be rejected with the passed error');

ditto

> +    },
+    close() {
+      return new Promise(resolve => setTimeout(resolve, 50));
+    }
+  });
+
+  const writer = ws.getWriter();
+
+  writer.close();
+  setTimeout(() => controller.error(passedError), 10);
+
+  promise_rejects(
+      t, passedError, writer.closed, 'closed promise', 'closed promise should be rejected with the passed error');
+
+  setTimeout(() => {
+    promise_rejects(t, passedError, writer.closed, 'closed', 'closed should stay rejected');

ditto

> +async_test(t => {
+  const passedError = new Error('error me');
+  let controller;
+  const ws = new WritableStream({
+    start(c) {
+      controller = c;
+    },
+    close() {
+      controller.error(passedError);
+    }
+  });
+
+  const writer = ws.getWriter();
+
+  promise_rejects(
+      t, passedError, writer.close(), 'close promise', 'close promise should be rejected with the passed error');

ditto

> +  const ws = new WritableStream({
+    start(c) {
+      controller = c;
+    },
+    close() {
+      controller.error(passedError);
+    }
+  });
+
+  const writer = ws.getWriter();
+
+  promise_rejects(
+      t, passedError, writer.close(), 'close promise', 'close promise should be rejected with the passed error');
+
+  setTimeout(() => {
+    promise_rejects(t, passedError, writer.closed, 'closed', 'closed should stay rejected');

ditto

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/529#pullrequestreview-3621598

Received on Tuesday, 11 October 2016 07:24:56 UTC