summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/serial/serialPort_readable_closeLocked.https.any.js
blob: 21196f758b9089c87cca83478e39b911cf82fda3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// META: script=/resources/test-only-api.js
// META: script=/serial/resources/common.js
// META: script=resources/automation.js

serial_test(async (t, fake) => {
  const {port, fakePort} = await getFakeSerialPort(fake);

  await port.open({baudRate: 9600});
  assert_true(port.readable instanceof ReadableStream);

  const reader = port.readable.getReader();
  await promise_rejects_js(t, TypeError, port.close());

  reader.releaseLock();
  await port.close();
  assert_equals(port.readable, null);
}, 'Port cannot be closed while readable is locked');